UpscaleAI / app.py
MxeGlm's picture
upscale like notebook
e916c39
raw
history blame
742 Bytes
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()