MxeGlm commited on
Commit
6e9a12b
1 Parent(s): e916c39

better interface

Browse files
Files changed (1) hide show
  1. app.py +22 -21
app.py CHANGED
@@ -4,31 +4,32 @@ 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()
 
 
4
  import sys
5
  from os.path import exists
6
 
7
+ def upscale(image):
8
+ # increase the size of the picture with a factor of 3
9
+ factor = 2
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
+ iface = gr.Interface(
31
+ upscale,
32
+ gr.inputs.Image(shape=(128,128)),
33
+ "text",
34
+ )
35
+ iface.launch()