52Hz commited on
Commit
0d35acd
1 Parent(s): d2203e3

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -0
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from PIL import Image
4
+
5
+
6
+ os.system('wget https://github.com/FanChiMao/HWMNet/releases/download/v0.0/LOL_enhancement_HWMNet.pth -P experiments/pretrained_models')
7
+ os.system('wget https://github.com/FanChiMao/HWMNet/releases/download/v0.0/MIT5K_enhancement_HWMNet.pth -P experiments/pretrained_models')
8
+
9
+ def inference(img):
10
+ os.system('mkdir test')
11
+ #basewidth = 256
12
+ #wpercent = (basewidth / float(img.size[0]))
13
+ #hsize = int((float(img.size[1]) * float(wpercent)))
14
+ #img = img.resize((basewidth, hsize), Image.ANTIALIAS)
15
+ img.save("test/1.png", "PNG")
16
+ os.system(
17
+ 'python main_test_SRMNet.py --input_dir test --weights experiments/pretrained_models/real_denoising_SRMNet.pth')
18
+ return 'result/1.png'
19
+
20
+
21
+ title = "Selective Residual M-Net for Real-world Image Denoising"
22
+ description = "Gradio demo for SRMNet. SRMNet has competitive performance results on two synthetic and two realworld noisy datasets in terms of quantitative metrics and visual quality. See the paper and project page for detailed results below. Here, we provide a demo for real-world image denoising. To use it, simply upload your image, or click one of the examples to load them. Reference from: https://huggingface.co/akhaliq"
23
+ article = "<p style='text-align: center'><a href='https://' target='_blank'>Selective Residual M-Net</a> | <a href='https://github.com/FanChiMao/SRMNet' target='_blank'>Github Repo</a></p>"
24
+
25
+ examples = [['Noise.png'], ['Noise2.png']]
26
+ gr.Interface(
27
+ inference,
28
+ [gr.inputs.Image(type="pil", label="Input")],
29
+ gr.outputs.Image(type="file", label="Output"),
30
+ title=title,
31
+ description=description,
32
+ article=article,
33
+ allow_flagging=False,
34
+ allow_screenshot=False,
35
+ examples=examples
36
+ ).launch(debug=True)