Kev09 julien-c HF Staff commited on
Commit
33b8d22
·
0 Parent(s):

Duplicate from keras-io/super-resolution

Browse files

Co-authored-by: Julien Chaumond <[email protected]>

Files changed (6) hide show
  1. .gitattributes +27 -0
  2. README.md +47 -0
  3. app.py +50 -0
  4. camel.jpg +0 -0
  5. pokemon.jpg +0 -0
  6. requirements.txt +1 -0
.gitattributes ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
5
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.model filter=lfs diff=lfs merge=lfs -text
12
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
13
+ *.onnx filter=lfs diff=lfs merge=lfs -text
14
+ *.ot filter=lfs diff=lfs merge=lfs -text
15
+ *.parquet filter=lfs diff=lfs merge=lfs -text
16
+ *.pb filter=lfs diff=lfs merge=lfs -text
17
+ *.pt filter=lfs diff=lfs merge=lfs -text
18
+ *.pth filter=lfs diff=lfs merge=lfs -text
19
+ *.rar filter=lfs diff=lfs merge=lfs -text
20
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
22
+ *.tflite filter=lfs diff=lfs merge=lfs -text
23
+ *.tgz filter=lfs diff=lfs merge=lfs -text
24
+ *.xz 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
README.md ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Super Resolution
3
+ emoji: 🖼
4
+ colorFrom: red
5
+ colorTo: green
6
+ sdk: gradio
7
+ app_file: app.py
8
+ pinned: false
9
+ license: mit
10
+ duplicated_from: keras-io/super-resolution
11
+ ---
12
+
13
+ # Configuration
14
+
15
+ `Super-resolution using Efficient Sub pixel net`: _string_
16
+ Display title for the Space
17
+
18
+ `emoji`: _string_
19
+ Space emoji (emoji-only character allowed)
20
+
21
+ `colorFrom`: _string_
22
+ Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
23
+
24
+ `colorTo`: _string_
25
+ Color for Thumbnail gradient (red, yellow, green, blue, indigo, purple, pink, gray)
26
+
27
+ `sdk`: _string_
28
+ Can be either `gradio`, `streamlit`, or `static`
29
+
30
+ `sdk_version` : _string_
31
+ Only applicable for `streamlit` SDK.
32
+ See [doc](https://hf.co/docs/hub/spaces) for more info on supported versions.
33
+
34
+ `app_file`: _string_
35
+ Path to your main application file (which contains either `gradio` or `streamlit` Python code, or `static` html code).
36
+ Path is relative to the root of the repository.
37
+
38
+ `models`: _List[string]_
39
+ HF model IDs (like "gpt2" or "deepset/roberta-base-squad2") used in the Space.
40
+ Will be parsed automatically from your code if not specified here.
41
+
42
+ `datasets`: _List[string]_
43
+ HF dataset IDs (like "common_voice" or "oscar-corpus/OSCAR-2109") used in the Space.
44
+ Will be parsed automatically from your code if not specified here.
45
+
46
+ `pinned`: _boolean_
47
+ Whether the Space stays on top of your list.
app.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tensorflow as tf
2
+
3
+ import math
4
+ import numpy as np
5
+ from PIL import Image
6
+
7
+ from tensorflow.keras.preprocessing.image import img_to_array
8
+ from huggingface_hub import from_pretrained_keras
9
+ import gradio as gr
10
+
11
+ model = from_pretrained_keras("keras-io/super-resolution")
12
+
13
+ def infer(image):
14
+ img = Image.fromarray(image)
15
+ img = img.resize((100,100))
16
+ ycbcr = img.convert("YCbCr")
17
+ y, cb, cr = ycbcr.split()
18
+ y = img_to_array(y)
19
+ y = y.astype("float32") / 255.0
20
+
21
+ input = np.expand_dims(y, axis=0)
22
+ out = model.predict(input)
23
+
24
+ out_img_y = out[0]
25
+ out_img_y *= 255.0
26
+
27
+ # Restore the image in RGB color space.
28
+ out_img_y = out_img_y.clip(0, 255)
29
+ out_img_y = out_img_y.reshape((np.shape(out_img_y)[0], np.shape(out_img_y)[1]))
30
+ out_img_y = Image.fromarray(np.uint8(out_img_y), mode="L")
31
+ out_img_cb = cb.resize(out_img_y.size, Image.BICUBIC)
32
+ out_img_cr = cr.resize(out_img_y.size, Image.BICUBIC)
33
+ out_img = Image.merge("YCbCr", (out_img_y, out_img_cb, out_img_cr)).convert(
34
+ "RGB"
35
+ )
36
+ return (img,out_img)
37
+
38
+ 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>"
39
+
40
+ iface = gr.Interface(
41
+ fn=infer,
42
+ title = " Image Super-resolution",
43
+ 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' 👀",
44
+ article = article,
45
+ inputs=gr.inputs.Image(label="Input Image"),
46
+ outputs=[gr.outputs.Image(label="Resized 100x100 image"),
47
+ gr.outputs.Image(label="Super-resolution 300x300 image")
48
+ ],
49
+ examples=[["camel.jpg"], ["pokemon.jpg"]],
50
+ ).launch()
camel.jpg ADDED
pokemon.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ tensorflow>2.6