File size: 742 Bytes
51c09a3
e916c39
 
 
 
51c09a3
e916c39
 
 
51c09a3
e916c39
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import gradio as gr
import cv2
from cv2 import dnn_superres
import sys
from os.path import exists

FILE_PATH = "butterfly.png"
# increase the size of the picture with a factor of 3
factor = 3

# Create an SR object
sr = dnn_superres.DnnSuperResImpl_create()

# Read image
image = cv2.imread(FILE_PATH)

# Read the desired model
path = "models/FSRCNN_x" + str(factor) + ".pb"
sr.readModel(path)

# Set the desired model and scale to get correct pre- and post-processing
sr.setModel("fsrcnn", factor)

# Upscale the image
result = sr.upsample(image)

# Save the image
cv2.imwrite("./upscaled.png", result)

# def greet(name):
#     return "Hello " + name + "!!"

# iface = gr.Interface(fn=greet, inputs="text", outputs="text")
# iface.launch()