Spaces:
Runtime error
Runtime error
msg
Browse files
app.py
CHANGED
|
@@ -11,30 +11,30 @@ model = from_pretrained_keras("keras-io/super-resolution")
|
|
| 11 |
model.summary()
|
| 12 |
|
| 13 |
def infer(image):
|
| 14 |
-
|
| 15 |
-
|
| 16 |
img = img.crop((0,100,0,100))
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 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 |
|