MxeGlm commited on
Commit
e916c39
·
1 Parent(s): 51c09a3

upscale like notebook

Browse files
Files changed (1) hide show
  1. app.py +31 -4
app.py CHANGED
@@ -1,7 +1,34 @@
1
  import gradio as gr
 
 
 
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- iface.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ import cv2
3
+ from cv2 import dnn_superres
4
+ import sys
5
+ from os.path import exists
6
 
7
+ FILE_PATH = "butterfly.png"
8
+ # increase the size of the picture with a factor of 3
9
+ factor = 3
10
 
11
+ # Create an SR object
12
+ sr = dnn_superres.DnnSuperResImpl_create()
13
+
14
+ # Read image
15
+ image = cv2.imread(FILE_PATH)
16
+
17
+ # Read the desired model
18
+ path = "models/FSRCNN_x" + str(factor) + ".pb"
19
+ sr.readModel(path)
20
+
21
+ # Set the desired model and scale to get correct pre- and post-processing
22
+ sr.setModel("fsrcnn", factor)
23
+
24
+ # Upscale the image
25
+ result = sr.upsample(image)
26
+
27
+ # Save the image
28
+ cv2.imwrite("./upscaled.png", result)
29
+
30
+ # def greet(name):
31
+ # return "Hello " + name + "!!"
32
+
33
+ # iface = gr.Interface(fn=greet, inputs="text", outputs="text")
34
+ # iface.launch()