vishnun commited on
Commit
be4d1b3
1 Parent(s): 1f972f6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
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, 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
 
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', 2],['example2.jpg', 2]]
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
 
 
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