Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
|
5 |
+
|
6 |
+
os.system('wget https://github.com/FanChiMao/SRMNet-thesis/releases/download/v0.0/Deblurring_motionblur.pth -P experiments/pretrained_models')
|
7 |
+
os.system('wget https://github.com/FanChiMao/SRMNet-thesis/releases/download/v0.0/Dehaze_realworld.pth -P experiments/pretrained_models')
|
8 |
+
os.system('wget https://github.com/FanChiMao/SRMNet-thesis/releases/download/v0.0/Denoise_gaussian.pth -P experiments/pretrained_models')
|
9 |
+
os.system('wget https://github.com/FanChiMao/SRMNet-thesis/releases/download/v0.0/Denoise_realworld.pth -P experiments/pretrained_models')
|
10 |
+
os.system('wget https://github.com/FanChiMao/SRMNet-thesis/releases/download/v0.0/Deraining_raindrop.pth -P experiments/pretrained_models')
|
11 |
+
os.system('wget https://github.com/FanChiMao/SRMNet-thesis/releases/download/v0.0/Deraining_rainstreak.pth -P experiments/pretrained_models')
|
12 |
+
os.system('wget https://github.com/FanChiMao/SRMNet-thesis/releases/download/v0.0/LLEnhancement.pth -P experiments/pretrained_models')
|
13 |
+
os.system('wget https://github.com/FanChiMao/SRMNet-thesis/releases/download/v0.0/Retouching.pth -P experiments/pretrained_models')
|
14 |
+
|
15 |
+
def inference(img, model):
|
16 |
+
os.system('mkdir test')
|
17 |
+
img.save("test/1.png", "PNG")
|
18 |
+
if model == 'Denoising (gaussian)':
|
19 |
+
os.system('python main_test_SRMNet.py --input_dir test --weights experiments/pretrained_models/Denoise_gaussian.pth')
|
20 |
+
elif model == 'Denoising (real-world)':
|
21 |
+
os.system('python main_test_SRMNet.py --input_dir test --weights experiments/pretrained_models/Denoise_realworld.pth')
|
22 |
+
elif model == 'Deblurring (motion-blur)':
|
23 |
+
os.system('python main_test_SRMNet.py --input_dir test --weights experiments/pretrained_models/Deblurring_motionblur.pth')
|
24 |
+
elif model == 'Dehazing (dense haze)':
|
25 |
+
os.system('python main_test_SRMNet.py --input_dir test --weights experiments/pretrained_models/Dehaze_realworld.pth')
|
26 |
+
elif model == 'Deraining (rainstreak)':
|
27 |
+
os.system('python main_test_SRMNet.py --input_dir test --weights experiments/pretrained_models/Deraining_rainstreak.pth')
|
28 |
+
elif model == 'Deraining (raindrop)':
|
29 |
+
os.system('python main_test_SRMNet.py --input_dir test --weights experiments/pretrained_models/Deraining_raindrop.pth')
|
30 |
+
elif model == 'Low-light Enhancement':
|
31 |
+
os.system('python main_test_SRMNet.py --input_dir test --weights experiments/pretrained_models/LLEnhancement.pth')
|
32 |
+
elif model == 'Retouching':
|
33 |
+
os.system('python main_test_SRMNet.py --input_dir test --weights experiments/pretrained_models/Retouching.pth')
|
34 |
+
|
35 |
+
return 'result/1.png'
|
36 |
+
|
37 |
+
|
38 |
+
title = "[NCHU thesis] Image Restoration by Selective Residual Block on Improved Hierarchical Encoder-Decoder Networks"
|
39 |
+
description = ""
|
40 |
+
article = "<p style='text-align: center'><a href='https://' target='_blank'>Image Restoration by Selective Residual Block on Improved Hierarchical Encoder-Decoder Networks</a> | <a href='https://github.com/FanChiMao/SRMNet-thesis' target='_blank'>Github Repo</a></p> <center><img src='https://visitor-badge.glitch.me/badge?page_id=52Hz_SRMNet_thesis' alt='visitor badge'></center>"
|
41 |
+
|
42 |
+
examples = [['low-light.png', 'LOL'], ['low-light_2.png', 'MIT-5K']]
|
43 |
+
gr.Interface(
|
44 |
+
inference,
|
45 |
+
[gr.inputs.Image(type="pil", label="Input"), gr.inputs.Dropdown(choices=[
|
46 |
+
'Denoising (gaussian)',
|
47 |
+
'Denoising (real-world)',
|
48 |
+
'Deblurring (motion-blur)',
|
49 |
+
'Dehazing (dense haze)',
|
50 |
+
'Deraining (rainstreak)',
|
51 |
+
'Deraining (raindrop)',
|
52 |
+
'Low-light Enhancement',
|
53 |
+
'Retouching',
|
54 |
+
], type="value", default='Denoising (gaussian)', label="model")],
|
55 |
+
gr.outputs.Image(type="file", label="Output"),
|
56 |
+
title=title,
|
57 |
+
description=description,
|
58 |
+
article=article,
|
59 |
+
allow_flagging=False,
|
60 |
+
allow_screenshot=False,
|
61 |
+
examples=examples
|
62 |
+
).launch(debug=True)
|