Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import sys
|
3 |
+
import gradio as gr
|
4 |
+
from PIL import Image
|
5 |
+
|
6 |
+
## environment settup
|
7 |
+
os.system("git clone https://github.com/codeslake/RefVSR.git")
|
8 |
+
os.chdir("RefVSR")
|
9 |
+
os.system("./install/install_cudnn113.sh")
|
10 |
+
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")
|
11 |
+
os.mkdir("RefVSR")
|
12 |
+
os.system("wget --no-check-certificate 'https://docs.google.com/uc?export=download&id=1TFgihdn8Ml_536F2VXbmkXuGEHcEHOYz' -O ckpt/RefVSR_small_MFID_8K.pytorch")
|
13 |
+
sys.path.append("RefVSR")
|
14 |
+
|
15 |
+
## RefVSR
|
16 |
+
LR_path = "test/test/HR/UW/0000"
|
17 |
+
Ref_path = "test/test/HR/W/0000"
|
18 |
+
Ref_path_T = "test/test/HR/W/0000"
|
19 |
+
os.mkdirs(LR_path)
|
20 |
+
os.mkdirs(Ref_path)
|
21 |
+
|
22 |
+
def resize(width,img):
|
23 |
+
basewidth = width
|
24 |
+
wpercent = (basewidth/float(img.size[0]))
|
25 |
+
hsize = int((float(img.size[1])*float(wpercent)))
|
26 |
+
img = img.resize((basewidth,hsize), Image.ANTIALIAS)
|
27 |
+
return img
|
28 |
+
|
29 |
+
def inference(LR, Ref):
|
30 |
+
LR = resize(256, LR)
|
31 |
+
Ref = resize(256, Ref)
|
32 |
+
LR.save(os.path.join(LR_path, '0000.png'))
|
33 |
+
Ref.save(os.path.join(Ref_path, '0000.png'))
|
34 |
+
Ref.save(os.path.join(Ref_path_T, '0000.png'))
|
35 |
+
|
36 |
+
# os.system("python inference_realbasicvsr.py configs/realbasicvsr_x4.py RealBasicVSR_x4.pth test/ results/demo_000")
|
37 |
+
os.system("python -B run.py \
|
38 |
+
--mode amp_RefVSR_small_MFID_8K \
|
39 |
+
--config config_RefVSR_small_MFID_8K \
|
40 |
+
--data RealMCVSR \
|
41 |
+
--ckpt_abs_name ckpt/RefVSR_small_MFID_8K.pytorch \
|
42 |
+
--data_offset ./test \
|
43 |
+
--output_offset ./result \
|
44 |
+
--qualitative_only \
|
45 |
+
--cpu \
|
46 |
+
--is_gradio")
|
47 |
+
|
48 |
+
return "results/0000.png"
|
49 |
+
|
50 |
+
title="RefVSR"
|
51 |
+
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."
|
52 |
+
|
53 |
+
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>"
|
54 |
+
|
55 |
+
examples=[['mona.jpg']]
|
56 |
+
|
57 |
+
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)
|