Update app.py
Browse files
app.py
CHANGED
@@ -34,6 +34,9 @@ os.makedirs(HR_Ref_path_T)
|
|
34 |
os.makedirs('result')
|
35 |
os.system("wget https://www.dropbox.com/s/vqekqdz80d85gi4/UW.png -O LR.png")
|
36 |
os.system("wget https://www.dropbox.com/s/lsopmquhpm87v83/W.png -O Ref.png")
|
|
|
|
|
|
|
37 |
|
38 |
## resize if necessary (not used)
|
39 |
def resize(img):
|
@@ -74,10 +77,10 @@ def inference(LR, Ref):
|
|
74 |
--is_gradio")
|
75 |
return "result/0000.png"
|
76 |
|
77 |
-
title="RefVSR (
|
78 |
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."
|
79 |
|
80 |
-
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 frame due to computational complexity. Hence, the model will not take advantage of temporal LR and Ref frames.</p><p style='text-align: center'>The model is trained by the proposed pre-
|
81 |
|
82 |
## resize for sample (not used)
|
83 |
#LR = resize(Image.open('LR.png')).save('LR.png')
|
@@ -87,4 +90,47 @@ article = "<p style='text-align: center'><b>To check the full capability of the
|
|
87 |
examples=[['LR.png', 'Ref.png']]
|
88 |
|
89 |
## interface
|
90 |
-
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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
os.makedirs('result')
|
35 |
os.system("wget https://www.dropbox.com/s/vqekqdz80d85gi4/UW.png -O LR.png")
|
36 |
os.system("wget https://www.dropbox.com/s/lsopmquhpm87v83/W.png -O Ref.png")
|
37 |
+
os.system("wget https://www.dropbox.com/s/xv6inxwy0so4ni0/LR.png -O HR_LR.png")
|
38 |
+
os.system("wget https://www.dropbox.com/s/abydd1oczs1163l/Ref.png -O HR_Ref.png")
|
39 |
+
|
40 |
|
41 |
## resize if necessary (not used)
|
42 |
def resize(img):
|
|
|
77 |
--is_gradio")
|
78 |
return "result/0000.png"
|
79 |
|
80 |
+
title="RefVSR | Fast inference with a low-res (430x270) frame"
|
81 |
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."
|
82 |
|
83 |
+
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 frame due to computational complexity. Hence, the model will not take advantage of temporal LR and Ref frames.</p><p style='text-align: center'>The model is trained by the proposed pre-training strategy only. The sample frames are in 430x270 resolution 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>"
|
84 |
|
85 |
## resize for sample (not used)
|
86 |
#LR = resize(Image.open('LR.png')).save('LR.png')
|
|
|
90 |
examples=[['LR.png', 'Ref.png']]
|
91 |
|
92 |
## interface
|
93 |
+
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)
|
94 |
+
|
95 |
+
#################### 8K ##################
|
96 |
+
## inference
|
97 |
+
def inference_8K(LR, Ref):
|
98 |
+
## resize for user selected input (not used)
|
99 |
+
#LR = resize(LR)
|
100 |
+
#Ref = resize(Ref)
|
101 |
+
|
102 |
+
## Input setup (creates folders and places inputs corresponding to the original RefVSR code)
|
103 |
+
LR.save(os.path.join(LR_path, '0000.png'))
|
104 |
+
Ref.save(os.path.join(Ref_path, '0000.png'))
|
105 |
+
Ref.save(os.path.join(Ref_path_T, '0000.png'))
|
106 |
+
LR.save(os.path.join(HR_LR_path, '0000.png'))
|
107 |
+
Ref.save(os.path.join(HR_Ref_path, '0000.png'))
|
108 |
+
Ref.save(os.path.join(HR_Ref_path_T, '0000.png'))
|
109 |
+
|
110 |
+
## Run RefVSR model
|
111 |
+
os.system("python -B run.py \
|
112 |
+
--mode amp_RefVSR_small_MFID_8K \
|
113 |
+
--config config_RefVSR_small_MFID_8K \
|
114 |
+
--data RealMCVSR \
|
115 |
+
--ckpt_abs_name ckpt/RefVSR_small_MFID_8K.pytorch \
|
116 |
+
--data_offset ./test \
|
117 |
+
--output_offset ./result \
|
118 |
+
--qualitative_only \
|
119 |
+
--cpu \
|
120 |
+
--is_gradio")
|
121 |
+
return "result/0000.png"
|
122 |
+
|
123 |
+
title="RefVSR | Slow inference with a real-world HD (1920x1080) frame"
|
124 |
+
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."
|
125 |
+
|
126 |
+
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 frame due to computational complexity. Hence, the model will not take advantage of temporal LR and Ref frames.</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>"
|
127 |
+
|
128 |
+
## resize for sample (not used)
|
129 |
+
#LR = resize(Image.open('LR.png')).save('LR.png')
|
130 |
+
#Ref = resize(Image.open('Ref.png')).save('Ref.png')
|
131 |
+
|
132 |
+
## input
|
133 |
+
examples=[['HR_LR.png', 'HR_Ref.png']]
|
134 |
+
|
135 |
+
## interface
|
136 |
+
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)
|