File size: 4,386 Bytes
ded9852 137fd43 ded9852 5f7f801 ded9852 |
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
import os
import sys
import gradio as gr
from PIL import Image
## environment settup
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")
## RefVSR
LR_path = "test/test/HR/UW/0000"
Ref_path = "test/test/HR/W/0000"
Ref_path_T = "test/test/HR/W/0000"
os.makedirs(LR_path)
os.makedirs(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 inference_realbasicvsr.py configs/realbasicvsr_x4.py RealBasicVSR_x4.pth test/ results/demo_000")
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 = "<link rel="stylesheet" href="./bulma.min.css"><section class="hero is-small is-centered"> <div class="hero-body has-text-centered"> <h4 class="subtitle is-size-4 is-size-5-mobile publication-booktitle"> CVPR 2022</h4> <h1 class="title is-size-1 is-size-3-mobile publication-title">Reference-based Video Super-Resolution<br> Using Multi-Camera Video Triplets</h1> <div class="is-size-5 is-size-6-mobile publication-authors"> <span class="author-block"> <a href="https://junyonglee.me">Junyong Lee</a>,</span> <span class="author-block"> <a href="#" onclick="return false;">Myeonghee Lee</a>,</span> <span class="author-block"> <a href="https://www.scho.pe.kr/">Sunghyun Cho</a>, </span> <span class="author-block"> <a href="http://cg.postech.ac.kr/leesy/">Seungyong Lee</a> </span> </div> <div class="is-size-5 is-size-6-mobile publication-authors"> <span class="author-block">POSTECH</span> </div> <div class="column has-text-centered"> <!-- <span class="link-block"> <a href=""class="external-link button is-normal is-rounded is-dark" title="will be available soon" disabled> <span class="icon"> <i class="far fa-file-pdf"></i> </span> <span>Paper</span> </a> </span> --> <span class="link-block"> <a href="https://arxiv.org/abs/2203.14537"class="external-link button is-normal is-rounded is-dark"> <span class="icon"> <i class="ai ai-arxiv"></i> </span> <span>arXiv</span> </a> </span> <span class="link-block"> <a href="https://www.dropbox.com/s/sbn8iws22lud25c/05956-supp.pdf?raw=1"class="external-link button is-normal is-rounded is-dark"> <span class="icon"> <i class="far fa-file-pdf"></i> </span> <span>Supp</span> </a> </span> <span class="link-block"> <a href="https://github.com/codeslake/RefVSR" title="Github"class="external-link button is-normal is-rounded is-dark"> <span class="icon"> <i class="fab fa-github"></i> </span> <span>Code</span> </a> </span> <span class="link-block"> <a href="https://junyonglee.me/datasets/RealMCVSR/" title="RealMCVSR Dataset"class="external-link button is-normal is-rounded is-dark"> <span class="icon"> <i class="fas fa-photo-video"></i> </span> <span>RealMCVSR Dataset</span> </a> </span> </div> </div> </section>"
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)
|