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