Spaces:
Runtime error
Runtime error
msg
Browse files
.gitattributes
CHANGED
@@ -25,3 +25,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
25 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
25 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
28 |
+
examples/*.* filter=lfs diff=lfs merge=lfs -text
|
app.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import tensorflow as tf
|
2 |
+
import numpy as np
|
3 |
+
from PIL import Image
|
4 |
+
|
5 |
+
from tensorflow.keras.preprocessing.image import img_to_array
|
6 |
+
from huggingface_hub import from_pretrained_keras
|
7 |
+
import gradio as gr
|
8 |
+
|
9 |
+
model = from_pretrained_keras("keras-io/super-resolution")
|
10 |
+
model.summary()
|
11 |
+
|
12 |
+
def infer(image):
|
13 |
+
img = Image.fromarray(image)
|
14 |
+
img = img.resize((100,100))
|
15 |
+
ycbcr = img.convert("YCbCr")
|
16 |
+
y, cb, cr = ycbcr.split()
|
17 |
+
y = img_to_array(y)
|
18 |
+
y = y.astype("float32") / 255.0
|
19 |
+
|
20 |
+
input = np.expand_dims(y, axis=0)
|
21 |
+
out = model.predict(input)
|
22 |
+
|
23 |
+
out_img_y = out[0]
|
24 |
+
out_img_y *= 255.0
|
25 |
+
|
26 |
+
# Restore the image in RGB color space.
|
27 |
+
out_img_y = out_img_y.clip(0, 255)
|
28 |
+
out_img_y = out_img_y.reshape((np.shape(out_img_y)[0], np.shape(out_img_y)[1]))
|
29 |
+
out_img_y = Image.fromarray(np.uint8(out_img_y), mode="L")
|
30 |
+
out_img_cb = cb.resize(out_img_y.size, Image.BICUBIC)
|
31 |
+
out_img_cr = cr.resize(out_img_y.size, Image.BICUBIC)
|
32 |
+
out_img = Image.merge("YCbCr", (out_img_y, out_img_cb, out_img_cr)).convert(
|
33 |
+
"RGB"
|
34 |
+
)
|
35 |
+
return (img,out_img)
|
36 |
+
|
37 |
+
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>"
|
38 |
+
|
39 |
+
examples = [['examples/2000-04-28-18-21-24_L5_rgb.jpg'],['examples/2000-08-02-18-23-18_L5_rgb.jpg'],
|
40 |
+
['examples/2000-08-18-18-23-46_L5_rgb.jpg'],['examples/2000-09-19-18-24-18_L5_rgb.jpg'],['examples/2000-10-21-18-24-43_L5_rgb.jpg']]
|
41 |
+
|
42 |
+
iface = gr.Interface(
|
43 |
+
fn=infer,
|
44 |
+
title = " Satellite Super-resolution",
|
45 |
+
description = "This space is a demo of the keras tutorial 'Image Super-Resolution using an Efficient Sub-Pixel CNN' based on the paper 'Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network' 👀",
|
46 |
+
article = article,
|
47 |
+
inputs=gr.inputs.Image(label="Input Image"),
|
48 |
+
outputs=[gr.outputs.Image(label="Resized 100x100 image"),
|
49 |
+
gr.outputs.Image(label="Super-resolution 300x300 image")
|
50 |
+
],
|
51 |
+
examples=examples,
|
52 |
+
).launch()
|
examples/2000-04-28-18-21-24_L5_rgb.jpg
ADDED
Git LFS Details
|
examples/2000-08-02-18-23-18_L5_rgb.jpg
ADDED
Git LFS Details
|
examples/2000-08-18-18-23-46_L5_rgb.jpg
ADDED
Git LFS Details
|
examples/2000-09-19-18-24-18_L5_rgb.jpg
ADDED
Git LFS Details
|
examples/2000-10-21-18-24-43_L5_rgb.jpg
ADDED
Git LFS Details
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
scikit-image
|
2 |
+
numpy
|
3 |
+
tensorflow
|