|
import os |
|
import sys |
|
import gradio as gr |
|
from PIL import Image |
|
|
|
|
|
os.system("git clone https://github.com/codeslake/RefVSR.git") |
|
os.chdir("RefVSR") |
|
os.system("./install/install_cudnn113.sh") |
|
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") |
|
os.mkdir("RefVSR") |
|
os.system("wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=1TFgihdn8Ml_536F2VXbmkXuGEHcEHOYz' -O ckpt/RefVSR_small_MFID_8K.pytorch") |
|
sys.path.append("RefVSR") |
|
|
|
|
|
LR_path = "test/test/HR/UW/0000" |
|
Ref_path = "test/test/HR/W/0000" |
|
Ref_path_T = "test/test/HR/W/0000" |
|
os.mkdirs(LR_path) |
|
os.mkdirs(Ref_path) |
|
|
|
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(LR, Ref): |
|
LR = resize(256, LR) |
|
Ref = resize(256, Ref) |
|
LR.save(os.path.join(LR_path, '0000.png')) |
|
Ref.save(os.path.join(Ref_path, '0000.png')) |
|
Ref.save(os.path.join(Ref_path_T, '0000.png')) |
|
|
|
|
|
os.system("python -B run.py \ |
|
--mode amp_RefVSR_small_MFID_8K \ |
|
--config config_RefVSR_small_MFID_8K \ |
|
--data RealMCVSR \ |
|
--ckpt_abs_name ckpt/RefVSR_small_MFID_8K.pytorch \ |
|
--data_offset ./test \ |
|
--output_offset ./result \ |
|
--qualitative_only \ |
|
--cpu \ |
|
--is_gradio") |
|
|
|
return "results/0000.png" |
|
|
|
title="RefVSR" |
|
description="Demo application for Reference-based 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/2203.14537' target='_blank'>Reference-based Video Super-Resolution</a> | <a href='https://github.com/codeslake/RefVSR' 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) |
|
|