dbuscombe commited on
Commit
40982a8
·
1 Parent(s): 6f608dd
Files changed (1) hide show
  1. app.py +23 -23
app.py CHANGED
@@ -11,30 +11,30 @@ model = from_pretrained_keras("keras-io/super-resolution")
11
  model.summary()
12
 
13
  def infer(image):
14
- img = Image.fromarray(image)
15
- # img = img.resize((100,100))
16
  img = img.crop((0,100,0,100))
17
- ycbcr = img.convert("YCbCr")
18
- y, cb, cr = ycbcr.split()
19
- y = img_to_array(y)
20
- y = y.astype("float32") / 255.0
21
-
22
- input = np.expand_dims(y, axis=0)
23
- out = model.predict(input)
24
-
25
- out_img_y = out[0]
26
- out_img_y *= 255.0
27
-
28
- # Restore the image in RGB color space.
29
- out_img_y = out_img_y.clip(0, 255)
30
- out_img_y = out_img_y.reshape((np.shape(out_img_y)[0], np.shape(out_img_y)[1]))
31
- out_img_y = Image.fromarray(np.uint8(out_img_y), mode="L")
32
- out_img_cb = cb.resize(out_img_y.size, Image.BICUBIC)
33
- out_img_cr = cr.resize(out_img_y.size, Image.BICUBIC)
34
- out_img = Image.merge("YCbCr", (out_img_y, out_img_cb, out_img_cr)).convert(
35
- "RGB"
36
- )
37
- return (img,out_img)
38
 
39
  article = "<p style='text-align: center'><a href='https://arxiv.org/abs/1609.05158' target='_blank'>Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network</a></p><center> <a href='https://keras.io/examples/vision/super_resolution_sub_pixel/' target='_blank'>Image Super-Resolution using an Efficient Sub-Pixel CNN</a></p> <center>Contributors: <a href='https://twitter.com/Cr0wley_zz'>Devjyoti Chakraborty</a>|<a href='https://twitter.com/ritwik_raha'>Ritwik Raha</a>|<a href='https://twitter.com/ariG23498'>Aritra Roy Gosthipaty</a></center>"
40
 
 
11
  model.summary()
12
 
13
  def infer(image):
14
+ img = Image.fromarray(image)
15
+ # img = img.resize((100,100))
16
  img = img.crop((0,100,0,100))
17
+ ycbcr = img.convert("YCbCr")
18
+ y, cb, cr = ycbcr.split()
19
+ y = img_to_array(y)
20
+ y = y.astype("float32") / 255.0
21
+
22
+ input = np.expand_dims(y, axis=0)
23
+ out = model.predict(input)
24
+
25
+ out_img_y = out[0]
26
+ out_img_y *= 255.0
27
+
28
+ # Restore the image in RGB color space.
29
+ out_img_y = out_img_y.clip(0, 255)
30
+ out_img_y = out_img_y.reshape((np.shape(out_img_y)[0], np.shape(out_img_y)[1]))
31
+ out_img_y = Image.fromarray(np.uint8(out_img_y), mode="L")
32
+ out_img_cb = cb.resize(out_img_y.size, Image.BICUBIC)
33
+ out_img_cr = cr.resize(out_img_y.size, Image.BICUBIC)
34
+ out_img = Image.merge("YCbCr", (out_img_y, out_img_cb, out_img_cr)).convert(
35
+ "RGB"
36
+ )
37
+ return (img,out_img)
38
 
39
  article = "<p style='text-align: center'><a href='https://arxiv.org/abs/1609.05158' target='_blank'>Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network</a></p><center> <a href='https://keras.io/examples/vision/super_resolution_sub_pixel/' target='_blank'>Image Super-Resolution using an Efficient Sub-Pixel CNN</a></p> <center>Contributors: <a href='https://twitter.com/Cr0wley_zz'>Devjyoti Chakraborty</a>|<a href='https://twitter.com/ritwik_raha'>Ritwik Raha</a>|<a href='https://twitter.com/ariG23498'>Aritra Roy Gosthipaty</a></center>"
40