Spaces:
Runtime error
Runtime error
Commit
·
ad12fad
1
Parent(s):
339cc82
Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,41 @@
|
|
1 |
-
from zipfile import ZipFile
|
2 |
-
|
3 |
import gradio as gr
|
|
|
4 |
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
return "tmp.zip", "tmp.zip"
|
11 |
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import os
|
3 |
|
4 |
|
5 |
+
os.system("git clone https://github.com/megvii-research/NAFNet")
|
6 |
+
os.system("mv NAFNet/* ./")
|
7 |
+
os.system("mv *.pth experiments/pretrained_models/")
|
8 |
+
os.system("python3 setup.py develop --no_cuda_ext --user")
|
|
|
9 |
|
10 |
|
11 |
+
def inference(image_l, image_r):
|
12 |
+
if not os.path.exists('tmp'):
|
13 |
+
os.system('mkdir tmp')
|
14 |
+
image_l.save("tmp/lr_l.png", "PNG")
|
15 |
+
image_r.save("tmp/lr_r.png", "PNG")
|
16 |
+
os.system("python basicsr/demo_ssr.py -opt options/test/NAFSSR/NAFSSR-L_4x.yml"
|
17 |
+
+"--input_l_path ./demo/lr_l.png --input_r_path ./demo/lr_r.png"
|
18 |
+
+"--output_l_path ./demo/image_l.png --output_r_path ./demo/image_r.png")
|
19 |
+
|
20 |
+
return 'tmp/image_l.png', 'tmp/image_r.png'
|
21 |
+
|
22 |
+
title = "NAFNet"
|
23 |
+
description = "Gradio demo for <b>NAFNet: Nonlinear Activation Free Network for Image Restoration</b>. NAFNet achieves state-of-the-art performance on three tasks: image denoising, image debluring and stereo image super-resolution (SR). See the paper and project page for detailed results below. Here, we provide a demo forstereo image super-resolution (SR). To use it, simply upload your left and right view images, or click the examples to load them."
|
24 |
+
article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2204.04676' target='_blank'>Simple Baselines for Image Restoration</a> | <a href='https://arxiv.org/abs/2204.08714' target='_blank'>NAFSSR: Stereo Image Super-Resolution Using NAFNet</a> | <a href='https://github.com/megvii-research/NAFNet' target='_blank'> Github Repo</a></p>"
|
25 |
|
26 |
+
|
27 |
+
examples = ['demo/lr_img_l.png', 'demo/lr_img_r.png']
|
28 |
+
|
29 |
+
iface = gr.Interface(
|
30 |
+
inference,
|
31 |
+
[gr.inputs.Image(type="pil", label="Input (Left View)"),
|
32 |
+
gr.inputs.Image(type="pil", label="Input (Right View)")],
|
33 |
+
[gr.outputs.Image(type="file", label="Output (Left View)"),
|
34 |
+
gr.outputs.Image(type="file", label="Output (Right View)")]
|
35 |
+
title=title,
|
36 |
+
description=description,
|
37 |
+
article=article,
|
38 |
+
enable_queue=True,
|
39 |
+
examples=examples
|
40 |
+
)
|
41 |
+
iface.launch(debug=True,enable_queue=True)
|