Update app.py
Browse files
app.py
CHANGED
@@ -50,8 +50,9 @@ def resize(img):
|
|
50 |
img = img.resize((wsize,hsize), Image.ANTIALIAS)
|
51 |
return img
|
52 |
|
|
|
53 |
## inference
|
54 |
-
def
|
55 |
## resize for user selected input (not used)
|
56 |
#LR = resize(LR)
|
57 |
#Ref = resize(Ref)
|
@@ -66,35 +67,35 @@ def inference(LR, Ref):
|
|
66 |
|
67 |
## Run RefVSR model
|
68 |
os.system("python -B run.py \
|
69 |
-
--mode
|
70 |
-
--config
|
71 |
--data RealMCVSR \
|
72 |
-
--ckpt_abs_name ckpt/
|
73 |
--data_offset ./test \
|
74 |
--output_offset ./result \
|
75 |
--qualitative_only \
|
76 |
--cpu \
|
77 |
-
--is_gradio")
|
78 |
return "result/0000.png"
|
79 |
-
|
80 |
title="RefVSR"
|
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
|
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
|
84 |
|
85 |
## resize for sample (not used)
|
86 |
#LR = resize(Image.open('LR.png')).save('LR.png')
|
87 |
#Ref = resize(Image.open('Ref.png')).save('Ref.png')
|
88 |
|
89 |
## input
|
90 |
-
examples=[['
|
91 |
|
92 |
## interface
|
93 |
-
gr.Interface(
|
94 |
-
|
95 |
-
####################
|
96 |
## inference
|
97 |
-
def
|
98 |
## resize for user selected input (not used)
|
99 |
#LR = resize(LR)
|
100 |
#Ref = resize(Ref)
|
@@ -109,28 +110,29 @@ def inference_8K(LR, Ref):
|
|
109 |
|
110 |
## Run RefVSR model
|
111 |
os.system("python -B run.py \
|
112 |
-
--mode
|
113 |
-
--config
|
114 |
--data RealMCVSR \
|
115 |
-
--ckpt_abs_name ckpt/
|
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 |
-
|
|
|
|
|
|
|
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=[['
|
134 |
|
135 |
## interface
|
136 |
-
gr.Interface(
|
|
|
|
50 |
img = img.resize((wsize,hsize), Image.ANTIALIAS)
|
51 |
return img
|
52 |
|
53 |
+
#################### 8K ##################
|
54 |
## inference
|
55 |
+
def inference_8K(LR, Ref):
|
56 |
## resize for user selected input (not used)
|
57 |
#LR = resize(LR)
|
58 |
#Ref = resize(Ref)
|
|
|
67 |
|
68 |
## Run RefVSR model
|
69 |
os.system("python -B run.py \
|
70 |
+
--mode RefVSR_MFID_8K \
|
71 |
+
--config config_RefVSR_MFID_8K \
|
72 |
--data RealMCVSR \
|
73 |
+
--ckpt_abs_name ckpt/RefVSR_MFID_8K.pytorch \
|
74 |
--data_offset ./test \
|
75 |
--output_offset ./result \
|
76 |
--qualitative_only \
|
77 |
--cpu \
|
78 |
+
--is_gradio")
|
79 |
return "result/0000.png"
|
80 |
+
|
81 |
title="RefVSR"
|
82 |
+
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."
|
83 |
|
84 |
+
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>"
|
85 |
|
86 |
## resize for sample (not used)
|
87 |
#LR = resize(Image.open('LR.png')).save('LR.png')
|
88 |
#Ref = resize(Image.open('Ref.png')).save('Ref.png')
|
89 |
|
90 |
## input
|
91 |
+
examples=[['HR_LR.png', 'HR_Ref.png']]
|
92 |
|
93 |
## interface
|
94 |
+
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)
|
95 |
+
|
96 |
+
#################### low res ##################
|
97 |
## inference
|
98 |
+
def inference(LR, Ref):
|
99 |
## resize for user selected input (not used)
|
100 |
#LR = resize(LR)
|
101 |
#Ref = resize(Ref)
|
|
|
110 |
|
111 |
## Run RefVSR model
|
112 |
os.system("python -B run.py \
|
113 |
+
--mode RefVSR_MFID \
|
114 |
+
--config config_RefVSR_MFID \
|
115 |
--data RealMCVSR \
|
116 |
+
--ckpt_abs_name ckpt/RefVSR_MFID.pytorch \
|
117 |
--data_offset ./test \
|
118 |
--output_offset ./result \
|
119 |
--qualitative_only \
|
120 |
--cpu \
|
121 |
+
--is_gradio")
|
122 |
return "result/0000.png"
|
|
|
|
|
|
|
123 |
|
124 |
+
title="RefVSR"
|
125 |
+
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 150s."
|
126 |
+
|
127 |
+
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>"
|
128 |
|
129 |
## resize for sample (not used)
|
130 |
#LR = resize(Image.open('LR.png')).save('LR.png')
|
131 |
#Ref = resize(Image.open('Ref.png')).save('Ref.png')
|
132 |
|
133 |
## input
|
134 |
+
examples=[['LR.png', 'Ref.png']]
|
135 |
|
136 |
## interface
|
137 |
+
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)
|
138 |
+
|