Spaces:
Build error
Build error
better interface
Browse files
app.py
CHANGED
@@ -4,31 +4,32 @@ from cv2 import dnn_superres
|
|
4 |
import sys
|
5 |
from os.path import exists
|
6 |
|
7 |
-
|
8 |
-
# increase the size of the picture with a factor of 3
|
9 |
-
factor =
|
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 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
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()
|