Felixogunwale commited on
Commit
7169478
1 Parent(s): ff48d5f

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +43 -0
  2. requirements.txt +15 -0
app.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, task):
12
+ if not os.path.exists('tmp'):
13
+ os.system('mkdir tmp')
14
+ image.save("tmp/lq_image.png", "PNG")
15
+
16
+ if task == 'Denoising':
17
+ os.system("python basicsr/demo.py -opt options/test/SIDD/NAFNet-width64.yml --input_path ./tmp/lq_image.png --output_path ./tmp/image.png")
18
+
19
+ if task == 'Deblurring':
20
+ os.system("python basicsr/demo.py -opt options/test/REDS/NAFNet-width64.yml --input_path ./tmp/lq_image.png --output_path ./tmp/image.png")
21
+
22
+ return 'tmp/image.png'
23
+
24
+ title = "NAFNet"
25
+ 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 for image denoise and deblur. To use it, simply upload your image, or click one of the examples to load them. Inference needs some time since this demo uses CPU."
26
+ 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>"
27
+
28
+
29
+ examples = [['demo/noisy.png', 'Denoising'],
30
+ ['demo/blurry.jpg', 'Deblurring']]
31
+
32
+ iface = gr.Interface(
33
+ inference,
34
+ [gr.inputs.Image(type="pil", label="Input"),
35
+ gr.inputs.Radio(["Denoising", "Deblurring"], default="Denoising", label='task'),],
36
+ gr.outputs.Image(type="file", label="Output"),
37
+ title=title,
38
+ description=description,
39
+ article=article,
40
+ enable_queue=True,
41
+ examples=examples
42
+ )
43
+ iface.launch(debug=True,enable_queue=True)
requirements.txt ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ addict
2
+ future
3
+ lmdb
4
+ numpy
5
+ opencv-python-headless
6
+ Pillow
7
+ pyyaml
8
+ requests
9
+ scikit-image
10
+ scipy
11
+ tb-nightly
12
+ tqdm
13
+ yapf
14
+ torch
15
+ torchvision