Commit
·
ac144eb
0
Parent(s):
Duplicate from chuxiaojie/NAFNet
Browse filesCo-authored-by: Xiaojie Chu <chuxiaojie@users.noreply.huggingface.co>
- .gitattributes +27 -0
- NAFNet-REDS-width64.pth +3 -0
- NAFNet-SIDD-width64.pth +3 -0
- README.md +14 -0
- app.py +43 -0
- requirements.txt +15 -0
.gitattributes
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
6 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
7 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
8 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
9 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
10 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
11 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
12 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
13 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
14 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
15 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
16 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
17 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
18 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
19 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
20 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
21 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
22 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
23 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
24 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
25 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
26 |
+
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
27 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
NAFNet-REDS-width64.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:175fe8b3cdf3abedfbc87769779c3d9f491e05bb2e73ea9d627883f90a4b2df3
|
3 |
+
size 271756689
|
NAFNet-SIDD-width64.pth
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:cd685efaae01f7c4e9951f2deab05780079c8eb1e49ed664b72f6db04dabb445
|
3 |
+
size 464154961
|
README.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: NAFNet
|
3 |
+
emoji: 🌖
|
4 |
+
colorFrom: green
|
5 |
+
colorTo: pink
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 2.9.4
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: mit
|
11 |
+
duplicated_from: chuxiaojie/NAFNet
|
12 |
+
---
|
13 |
+
|
14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
|
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
|