allknowingroger dbuscombe commited on
Commit
936db7e
·
0 Parent(s):

Duplicate from dbuscombe/SatelliteSuperResolution

Browse files

Co-authored-by: Daniel Buscombe <[email protected]>

.gitattributes ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ftz filter=lfs diff=lfs merge=lfs -text
6
+ *.gz filter=lfs diff=lfs merge=lfs -text
7
+ *.h5 filter=lfs diff=lfs merge=lfs -text
8
+ *.joblib filter=lfs diff=lfs merge=lfs -text
9
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
10
+ *.model filter=lfs diff=lfs merge=lfs -text
11
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
12
+ *.onnx filter=lfs diff=lfs merge=lfs -text
13
+ *.ot filter=lfs diff=lfs merge=lfs -text
14
+ *.parquet filter=lfs diff=lfs merge=lfs -text
15
+ *.pb filter=lfs diff=lfs merge=lfs -text
16
+ *.pt filter=lfs diff=lfs merge=lfs -text
17
+ *.pth filter=lfs diff=lfs merge=lfs -text
18
+ *.rar filter=lfs diff=lfs merge=lfs -text
19
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
20
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
21
+ *.tflite filter=lfs diff=lfs merge=lfs -text
22
+ *.tgz filter=lfs diff=lfs merge=lfs -text
23
+ *.wasm 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
28
+ examples/*.* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: SatelliteSuperResolution
3
+ emoji: 🏢
4
+ colorFrom: yellow
5
+ colorTo: gray
6
+ sdk: gradio
7
+ sdk_version: 2.9.4
8
+ app_file: app.py
9
+ pinned: false
10
+ license: mit
11
+ duplicated_from: dbuscombe/SatelliteSuperResolution
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
app.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import tensorflow as tf
2
+ import numpy as np
3
+ from PIL import Image
4
+ from glob import glob
5
+ import pandas as pd
6
+ from tensorflow.keras.preprocessing.image import img_to_array
7
+ from huggingface_hub import from_pretrained_keras
8
+ import gradio as gr
9
+
10
+ model = from_pretrained_keras("keras-io/super-resolution")
11
+ model.summary()
12
+
13
+ def infer(image):
14
+
15
+ nx=image.shape[0]
16
+ ny=image.shape[1]
17
+
18
+ img = Image.fromarray(image)
19
+ # img = img.resize((100,100))
20
+ # img = img.crop((0,100,0,100))
21
+ ycbcr = img.convert("YCbCr")
22
+ y, cb, cr = ycbcr.split()
23
+ y = img_to_array(y)
24
+ y = y.astype("float32") / 255.0
25
+
26
+ input = np.expand_dims(y, axis=0)
27
+ out = model.predict(input)
28
+
29
+ nxo = out.squeeze().shape[0]
30
+ nyo = out.squeeze().shape[1]
31
+
32
+ out_img_y = out[0]
33
+ out_img_y *= 255.0
34
+
35
+ # Restore the image in RGB color space.
36
+ out_img_y = out_img_y.clip(0, 255)
37
+ out_img_y = out_img_y.reshape((np.shape(out_img_y)[0], np.shape(out_img_y)[1]))
38
+ out_img_y = Image.fromarray(np.uint8(out_img_y), mode="L")
39
+ out_img_cb = cb.resize(out_img_y.size, Image.BICUBIC)
40
+ out_img_cr = cr.resize(out_img_y.size, Image.BICUBIC)
41
+ out_img = Image.merge("YCbCr", (out_img_y, out_img_cb, out_img_cr)).convert(
42
+ "RGB"
43
+ )
44
+
45
+ out_img.save('output.png')
46
+
47
+ out = {}
48
+ out.update( {'input image size x': nx } )
49
+ out.update( {'output image size x': nxo } )
50
+ out.update( {'input image size y': ny } )
51
+ out.update( {'output image size y': nyo } )
52
+
53
+ return (pd.DataFrame(data=out.values(), index=out.keys()).transpose(), img,out_img, 'output.png')
54
+
55
+ 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>"
56
+
57
+ examples= [[l] for l in glob('examples/tiles/*.jpg')]
58
+ out1 = gr.outputs.Dataframe(label='Summary', headers=["Input X (px)", "Output X (px)", "Input Y (px)", "Output Y (px)"], type='pandas')
59
+ out2 = gr.outputs.Image(label="Cropped input image", type='pil')
60
+ out3 = gr.outputs.Image(label="Super-resolution x3 image", type='pil')
61
+ out4 = gr.outputs.File(label='Click to download super-resolved image')
62
+
63
+ iface = gr.Interface(
64
+ fn=infer,
65
+ title = " Satellite Super-resolution",
66
+ description = "This space is a demo of Satellite image Super-Resolution using a Sub-Pixel Convolutional Neural Network",
67
+ article = article,
68
+ inputs=gr.inputs.Image(label="Input Image"),
69
+ outputs=[out1,out2,out3,out4],
70
+ examples=examples,
71
+ ).launch()
examples/2000-04-28-18-21-24_L5_rgb.jpg ADDED

Git LFS Details

  • SHA256: 9819ce0b66d6c5926a75f93e6cfa025be0f4b06a4ce09ad1cbfa72b3b108d96d
  • Pointer size: 130 Bytes
  • Size of remote file: 60.7 kB
examples/2000-08-02-18-23-18_L5_rgb.jpg ADDED

Git LFS Details

  • SHA256: c80154e60ba5d6210868fbe1984c5ccdae7d33725e538f5c7442e82f3a17ab48
  • Pointer size: 130 Bytes
  • Size of remote file: 72.5 kB
examples/2000-08-18-18-23-46_L5_rgb.jpg ADDED

Git LFS Details

  • SHA256: 3c888e9e1b4cda58d593d212456072ad1afa1ecefcba036fc9250a3788b18f15
  • Pointer size: 130 Bytes
  • Size of remote file: 72.7 kB
examples/2000-09-19-18-24-18_L5_rgb.jpg ADDED

Git LFS Details

  • SHA256: 67585d15d2db6a8e2d4925ad557996b72e7490bd4aa2bc36c0b171a4b63109ea
  • Pointer size: 130 Bytes
  • Size of remote file: 60 kB
examples/2000-10-21-18-24-43_L5_rgb.jpg ADDED

Git LFS Details

  • SHA256: 45f363db3d4860fbe3b0d93799586980af017f6dbe7bb2b0fd9acad47902cbd6
  • Pointer size: 130 Bytes
  • Size of remote file: 59.6 kB
examples/tiles/2000-04-28-18-21-24_L5_rgb-0.jpg ADDED
examples/tiles/2000-04-28-18-21-24_L5_rgb-1.jpg ADDED
examples/tiles/2000-08-02-18-23-18_L5_rgb-0.jpg ADDED
examples/tiles/2000-08-02-18-23-18_L5_rgb-1.jpg ADDED
examples/tiles/2000-08-18-18-23-46_L5_rgb-0.jpg ADDED
examples/tiles/2000-08-18-18-23-46_L5_rgb-1.jpg ADDED
examples/tiles/2000-09-19-18-24-18_L5_rgb-0.jpg ADDED
examples/tiles/2000-09-19-18-24-18_L5_rgb-1.jpg ADDED
examples/tiles/2000-10-21-18-24-43_L5_rgb-0.jpg ADDED
examples/tiles/2000-10-21-18-24-43_L5_rgb-1.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ scikit-image
2
+ numpy
3
+ tensorflow
4
+ pandas