Update app.py
Browse files
app.py
CHANGED
@@ -6,24 +6,24 @@ from PIL import Image
|
|
6 |
import matplotlib.pyplot as plt
|
7 |
|
8 |
i1 = gr.inputs.Image(shape=(256, 256))
|
9 |
-
i2 = gr.inputs.Slider(minimum=2, maximum=4, step=0.1, default=None, label="Scale for intensity - the more value the less the intensity in the pixels")
|
10 |
o1 = gr.outputs.Image()
|
11 |
o2 = gr.outputs.Image()
|
12 |
gen_model = load_model('256_model_250ep.h5')
|
13 |
|
14 |
-
def colorify(pixels
|
15 |
|
16 |
pixels = (pixels - 127.5) / 127.5
|
17 |
pixels = np.expand_dims(pixels, 0)
|
18 |
gen_image = gen_model.predict(pixels)
|
19 |
-
gen_image = (gen_image + 1) /
|
20 |
|
21 |
return Image.fromarray((gen_image[0] * 255.0).astype(np.uint8))
|
22 |
|
23 |
title = "Colorify"
|
24 |
description = "Recolor your images using this lite version of PIX2PIX GAN , model is trained on 700 randomly collected images from the internet with 256*256 pixels"
|
25 |
-
examples=[['example1.png'
|
26 |
article = "<p style='text-align: center'>"
|
27 |
|
28 |
-
gr.Interface(fn=colorify, inputs=
|
29 |
|
|
|
6 |
import matplotlib.pyplot as plt
|
7 |
|
8 |
i1 = gr.inputs.Image(shape=(256, 256))
|
9 |
+
#i2 = gr.inputs.Slider(minimum=2, maximum=4, step=0.1, default=None, label="Scale for intensity - the more value the less the intensity in the pixels")
|
10 |
o1 = gr.outputs.Image()
|
11 |
o2 = gr.outputs.Image()
|
12 |
gen_model = load_model('256_model_250ep.h5')
|
13 |
|
14 |
+
def colorify(pixels):
|
15 |
|
16 |
pixels = (pixels - 127.5) / 127.5
|
17 |
pixels = np.expand_dims(pixels, 0)
|
18 |
gen_image = gen_model.predict(pixels)
|
19 |
+
gen_image = (gen_image + 1) / 1.8
|
20 |
|
21 |
return Image.fromarray((gen_image[0] * 255.0).astype(np.uint8))
|
22 |
|
23 |
title = "Colorify"
|
24 |
description = "Recolor your images using this lite version of PIX2PIX GAN , model is trained on 700 randomly collected images from the internet with 256*256 pixels"
|
25 |
+
examples=[['example1.png'],['example2.jpg']]
|
26 |
article = "<p style='text-align: center'>"
|
27 |
|
28 |
+
gr.Interface(fn=colorify, inputs=i1, outputs=o1, title=title, description=description, article=article, examples=examples, enable_queue=True).launch()
|
29 |
|