RealBasicVSR / app.py
akhaliq's picture
akhaliq HF staff
Update app.py
04a5dfa
import os
import sys
os.system("pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cpu/torch1.10/index.html")
os.system("pip install mmedit")
os.system("git clone https://github.com/ckkelvinchan/RealBasicVSR.git")
os.chdir("RealBasicVSR")
os.system("wget https://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/800px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg -O mona.jpg")
import gradio as gr
os.system("wget https://huggingface.co/akhaliq/RealBasicVSR_x4/resolve/main/RealBasicVSR_x4.pth")
sys.path.append("RealBasicVSR")
os.mkdir("test")
from PIL import Image
def resize(width,img):
basewidth = width
wpercent = (basewidth/float(img.size[0]))
hsize = int((float(img.size[1])*float(wpercent)))
img = img.resize((basewidth,hsize), Image.ANTIALIAS)
return img
def inference(img):
img = resize(256,img)
img.save("test/test.png")
os.system("python inference_realbasicvsr.py configs/realbasicvsr_x4.py RealBasicVSR_x4.pth test/ results/demo_000")
return "results/demo_000/test.png"
title="RealBasicVSR"
description="Gradio demo for Investigating Tradeoffs in Real-World Video Super-Resolution. To use it, simply upload your image or click on one of the examples to load them. Read more at the links below."
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2111.12704' target='_blank'>Investigating Tradeoffs in Real-World Video Super-Resolution</a> | <a href='https://github.com/ckkelvinchan/realbasicvsr' target='_blank'>Github Repo</a></p>"
examples=[['mona.jpg']]
gr.Interface(inference,gr.inputs.Image(type="pil"),gr.outputs.Image(type="file"),title=title,description=description,article=article,examples=examples).launch(enable_queue=True)