Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -26,8 +26,8 @@ HR_Ref_path_T = "test/RealMCVSR/test/HR/T/0000"
|
|
26 |
os.makedirs(HR_LR_path)
|
27 |
os.makedirs(HR_Ref_path)
|
28 |
os.makedirs(HR_Ref_path_T)
|
29 |
-
os.system("wget https://www.dropbox.com/s/
|
30 |
-
os.system("wget https://www.dropbox.com/s/
|
31 |
|
32 |
# 4x downsampled input
|
33 |
LR_path = "test/RealMCVSR/test/LRx4/UW/0000"
|
@@ -54,12 +54,13 @@ def resize(img):
|
|
54 |
img = img.resize((wsize,hsize), Image.ANTIALIAS)
|
55 |
return img
|
56 |
|
57 |
-
|
|
|
58 |
## inference
|
59 |
-
def
|
60 |
-
## resize for user selected input
|
61 |
-
LR = resize(LR)
|
62 |
-
Ref = resize(Ref)
|
63 |
|
64 |
## Input setup (creates folders and places inputs corresponding to the original RefVSR code)
|
65 |
LR.save(os.path.join(LR_path, '0000.png'))
|
@@ -71,38 +72,38 @@ def inference(LR, Ref):
|
|
71 |
|
72 |
## Run RefVSR model
|
73 |
os.system("python -B run.py \
|
74 |
-
--mode
|
75 |
-
--config
|
76 |
--data RealMCVSR \
|
77 |
-
--ckpt_abs_name ckpt/
|
78 |
--data_offset ./test \
|
79 |
--output_offset ./result \
|
80 |
--qualitative_only \
|
81 |
--cpu \
|
82 |
-
--is_gradio")
|
83 |
return "result/0000.png"
|
|
|
|
|
|
|
84 |
|
85 |
-
|
86 |
-
description="The demo applies 4xVSR on a video frame. It runs on CPUs and takes about 150s. For the demo, upload a low-resolution frame and a reference frame to 'LR' and 'Ref' input windows, respectively. It is recommended for the reference frame to have a 2x larger zoom factor than that of the low-resolution frame."
|
87 |
-
|
88 |
-
article = "<p style='text-align: center'><b>To check the full capability of the module, we recommend to clone Github repository and run RefVSR models on videos using GPUs.</b></p><p style='text-align: center'>This demo runs on CPUs and only supports RefVSR for a single LR and Ref frames due to computational complexity.<br>Hence, the model <b>will not take advantage</b> of temporal LR and Ref frames.</p><p style='text-align: center'>Moreover, the model is trained <b>only with the proposed pre-training strategy</b> to cope with downsampled sample frames, which are in the 480x270 resolution.</p><p style='text-align: center'>For user given frames, the size will be adjusted for the longer side of the frames to have 480 pixels.</p><p style='text-align: center'><a href='https://junyonglee.me/projects/RefVSR' target='_blank'>Project</a> | <a href='https://arxiv.org/abs/2203.14537' target='_blank'>arXiv</a> | <a href='https://github.com/codeslake/RefVSR' target='_blank'>Github</a></p>"
|
89 |
|
90 |
-
## resize for sample
|
91 |
-
LR = resize(Image.open('LR.png')).save('LR.png')
|
92 |
-
Ref = resize(Image.open('Ref.png')).save('Ref.png')
|
93 |
|
94 |
## input
|
95 |
-
examples=[['
|
96 |
|
97 |
## interface
|
98 |
-
gr.Interface(
|
99 |
|
100 |
-
####################
|
101 |
## inference
|
102 |
-
def
|
103 |
-
## resize for user selected input
|
104 |
-
|
105 |
-
|
106 |
|
107 |
## Input setup (creates folders and places inputs corresponding to the original RefVSR code)
|
108 |
LR.save(os.path.join(LR_path, '0000.png'))
|
@@ -114,28 +115,28 @@ def inference_8K(LR, Ref):
|
|
114 |
|
115 |
## Run RefVSR model
|
116 |
os.system("python -B run.py \
|
117 |
-
--mode
|
118 |
-
--config
|
119 |
--data RealMCVSR \
|
120 |
-
--ckpt_abs_name ckpt/
|
121 |
--data_offset ./test \
|
122 |
--output_offset ./result \
|
123 |
--qualitative_only \
|
124 |
--cpu \
|
125 |
-
--is_gradio")
|
126 |
return "result/0000.png"
|
127 |
-
|
128 |
-
title="RefVSR"
|
129 |
-
description="Demo application for Reference-based Video Super-Resolution (RefVSR). Upload a low-resolution frame and a reference frame to 'LR' and 'Ref' input windows, respectively. The demo runs on CPUs and takes about 120s."
|
130 |
|
131 |
-
|
|
|
132 |
|
133 |
-
|
134 |
-
|
135 |
-
|
|
|
|
|
136 |
|
137 |
## input
|
138 |
-
examples=[['
|
139 |
|
140 |
## interface
|
141 |
-
gr.Interface(
|
|
|
26 |
os.makedirs(HR_LR_path)
|
27 |
os.makedirs(HR_Ref_path)
|
28 |
os.makedirs(HR_Ref_path_T)
|
29 |
+
os.system("wget https://www.dropbox.com/s/x33ka2jlzwsde7r/LR.png -O HR_LR.png")
|
30 |
+
os.system("wget https://www.dropbox.com/s/pp903wlz3syf68w/Ref.png -O HR_Ref.png")
|
31 |
|
32 |
# 4x downsampled input
|
33 |
LR_path = "test/RealMCVSR/test/LRx4/UW/0000"
|
|
|
54 |
img = img.resize((wsize,hsize), Image.ANTIALIAS)
|
55 |
return img
|
56 |
|
57 |
+
|
58 |
+
#################### 8K ##################
|
59 |
## inference
|
60 |
+
def inference_8K(LR, Ref):
|
61 |
+
## resize for user selected input (not used)
|
62 |
+
#LR = resize(LR)
|
63 |
+
#Ref = resize(Ref)
|
64 |
|
65 |
## Input setup (creates folders and places inputs corresponding to the original RefVSR code)
|
66 |
LR.save(os.path.join(LR_path, '0000.png'))
|
|
|
72 |
|
73 |
## Run RefVSR model
|
74 |
os.system("python -B run.py \
|
75 |
+
--mode RefVSR_MFID_8K \
|
76 |
+
--config config_RefVSR_MFID_8K \
|
77 |
--data RealMCVSR \
|
78 |
+
--ckpt_abs_name ckpt/RefVSR_MFID_8K.pytorch \
|
79 |
--data_offset ./test \
|
80 |
--output_offset ./result \
|
81 |
--qualitative_only \
|
82 |
--cpu \
|
83 |
+
--is_gradio")
|
84 |
return "result/0000.png"
|
85 |
+
|
86 |
+
title="RefVSR"
|
87 |
+
description="Demo application for Reference-based Video Super-Resolution (RefVSR). Upload a low-resolution frame and a reference frame to 'LR' and 'Ref' input windows, respectively. The demo runs on CPUs and takes about 120s."
|
88 |
|
89 |
+
article = "<p style='text-align: center'><b>To check the full capability of the module, we recommend to clone Github repository and run RefVSR models on videos using GPUs.</b></p><p style='text-align: center'><div>This demo runs on CPUs and only supports RefVSR for a single LR and Ref frame due to computational complexity.</div><div>Hence, the model will not take advantage of temporal LR and Ref frames.</div></p><p style='text-align: center'>The model is trained by the proposed two-stage training strategy. The sample frames are in HD resolution (1920x1080) and saved in the PNG format. </p><p style='text-align: center'><a href='https://junyonglee.me/projects/RefVSR' target='_blank'>Project</a> | <a href='https://arxiv.org/abs/2203.14537' target='_blank'>arXiv</a> | <a href='https://github.com/codeslake/RefVSR' target='_blank'>Github</a></p>"
|
|
|
|
|
|
|
90 |
|
91 |
+
## resize for sample (not used)
|
92 |
+
#LR = resize(Image.open('LR.png')).save('LR.png')
|
93 |
+
#Ref = resize(Image.open('Ref.png')).save('Ref.png')
|
94 |
|
95 |
## input
|
96 |
+
examples=[['HR_LR.png', 'HR_Ref.png']]
|
97 |
|
98 |
## interface
|
99 |
+
gr.Interface(inference_8K,[gr.inputs.Image(type="pil"), gr.inputs.Image(type="pil")],gr.outputs.Image(type="file"),title=title,description=description,article=article,theme ="peach",examples=examples).launch(enable_queue=True)
|
100 |
|
101 |
+
#################### low res ##################
|
102 |
## inference
|
103 |
+
def inference(LR, Ref):
|
104 |
+
## resize for user selected input
|
105 |
+
LR = resize(LR)
|
106 |
+
Ref = resize(Ref)
|
107 |
|
108 |
## Input setup (creates folders and places inputs corresponding to the original RefVSR code)
|
109 |
LR.save(os.path.join(LR_path, '0000.png'))
|
|
|
115 |
|
116 |
## Run RefVSR model
|
117 |
os.system("python -B run.py \
|
118 |
+
--mode RefVSR_MFID \
|
119 |
+
--config config_RefVSR_MFID \
|
120 |
--data RealMCVSR \
|
121 |
+
--ckpt_abs_name ckpt/RefVSR_MFID.pytorch \
|
122 |
--data_offset ./test \
|
123 |
--output_offset ./result \
|
124 |
--qualitative_only \
|
125 |
--cpu \
|
126 |
+
--is_gradio")
|
127 |
return "result/0000.png"
|
|
|
|
|
|
|
128 |
|
129 |
+
title="Demo for RefVSR (CVPR 2022)"
|
130 |
+
description="The demo applies 4xVSR on a video frame. It runs on CPUs and takes about 150s. For the demo, upload a low-resolution frame and a reference frame to 'LR' and 'Ref' input windows, respectively. It is recommended for the reference frame to have a 2x larger zoom factor than that of the low-resolution frame."
|
131 |
|
132 |
+
article = "<p style='text-align: center'><b>To check the full capability of the module, we recommend to clone Github repository and run RefVSR models on videos using GPUs.</b></p><p style='text-align: center'>This demo runs on CPUs and only supports RefVSR for a single LR and Ref frames due to computational complexity.<br>Hence, the model <b>will not take advantage</b> of temporal LR and Ref frames.</p><p style='text-align: center'>Moreover, the model is trained <b>only with the proposed pre-training strategy</b> to cope with downsampled sample frames, which are in the 480x270 resolution.</p><p style='text-align: center'>For user given frames, the size will be adjusted for the longer side of the frames to have 480 pixels.</p><p style='text-align: center'><a href='https://junyonglee.me/projects/RefVSR' target='_blank'>Project</a> | <a href='https://arxiv.org/abs/2203.14537' target='_blank'>arXiv</a> | <a href='https://github.com/codeslake/RefVSR' target='_blank'>Github</a></p>"
|
133 |
+
|
134 |
+
## resize for sample
|
135 |
+
LR = resize(Image.open('LR.png')).save('LR.png')
|
136 |
+
Ref = resize(Image.open('Ref.png')).save('Ref.png')
|
137 |
|
138 |
## input
|
139 |
+
examples=[['LR.png','Ref.png']]
|
140 |
|
141 |
## interface
|
142 |
+
gr.Interface(inference, [gr.inputs.Image(type="pil"), gr.inputs.Image(type="pil")], gr.outputs.Image(type="file"),title=title,description=description,article=article,theme ="peach",examples=examples).launch(enable_queue=True)
|