Spaces:
Build error
Build error
File size: 780 Bytes
51c09a3 e916c39 51c09a3 6e9a12b 51c09a3 6e9a12b e916c39 6e9a12b e916c39 6e9a12b e916c39 6e9a12b e916c39 6e9a12b e916c39 6e9a12b d4ddb36 e916c39 6e9a12b f0a6fc5 6e9a12b |
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 36 37 |
import gradio as gr
import cv2
from cv2 import dnn_superres
import sys
from os.path import exists
def upscale(image):
# increase the size of the picture with a factor of 3
factor = 2
# 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)
return result
iface = gr.Interface(
upscale,
gr.inputs.Image(shape=(128,128)),
"text"
)
iface.launch()
|