AlexZou commited on
Commit
bf3b4b7
·
1 Parent(s): 1695590

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -14
app.py CHANGED
@@ -6,23 +6,23 @@ def inference(image, task):
6
  os.system('mkdir tmp')
7
  image.save("tmp/lq_image.png", "PNG")
8
 
9
- if task == 'Dehazing':
10
- os.system("python Dehazing.py --test_path ./tmp/lq_image.png --save_path ./tmp/ --pk_path model_zoo/Haze4k.tjm")
11
 
12
  if task == 'LLIE':
13
  os.system("python Lowlight.py --test_path ./tmp/lq_image.png --save_path ./tmp/ --pk_path model_zoo/Low.onnx")
14
 
15
- if task == 'SuperResolutionx2':
16
- os.system("python SuperResolution.py --test_path ./tmp/lq_image.png --save_path ./tmp/ --pk_path model_zoo/SRx2.pth --scale 2")
17
 
18
- if task == 'SuperResolutionx3':
19
- os.system("python SuperResolution.py --test_path ./tmp/lq_image.png --save_path ./tmp/ --pk_path model_zoo/SRx3.pth --scale 3")
20
 
21
- if task == 'SuperResolutionx4':
22
- os.system("python SuperResolution.py --test_path ./tmp/lq_image.png --save_path ./tmp/ --pk_path model_zoo/SRx4.pth --scale 4")
23
 
24
- if task == 'Underwater':
25
- os.system("python Underwater.py --test_path ./tmp/lq_image.png --save_path ./tmp/ --pk_path model_zoo/underwater.pth")
26
 
27
  return 'tmp/output.png'
28
 
@@ -32,13 +32,28 @@ article = ""
32
  #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."
33
  #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>"
34
 
35
-
36
  examples = [['demo/underwater.jpg', 'Underwater'],
37
  ['demo/low.jpg', 'LLIE'],
38
  ['demo/dehaze.jpg', 'Dehazing'],
39
  ['demo/sr.png', 'SuperResolutionx2']]
40
-
41
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  iface = gr.Interface(
43
  inference,
44
  [gr.inputs.Image(type="pil", label="Input"),
@@ -50,4 +65,5 @@ iface = gr.Interface(
50
  enable_queue=True,
51
  examples=examples
52
  )
53
- iface.launch(debug=True,enable_queue=True)
 
 
6
  os.system('mkdir tmp')
7
  image.save("tmp/lq_image.png", "PNG")
8
 
9
+ # if task == 'Dehazing':
10
+ # os.system("python Dehazing.py --test_path ./tmp/lq_image.png --save_path ./tmp/ --pk_path model_zoo/Haze4k.tjm")
11
 
12
  if task == 'LLIE':
13
  os.system("python Lowlight.py --test_path ./tmp/lq_image.png --save_path ./tmp/ --pk_path model_zoo/Low.onnx")
14
 
15
+ # if task == 'SuperResolutionx2':
16
+ # os.system("python SuperResolution.py --test_path ./tmp/lq_image.png --save_path ./tmp/ --pk_path model_zoo/SRx2.pth --scale 2")
17
 
18
+ # if task == 'SuperResolutionx3':
19
+ # os.system("python SuperResolution.py --test_path ./tmp/lq_image.png --save_path ./tmp/ --pk_path model_zoo/SRx3.pth --scale 3")
20
 
21
+ # if task == 'SuperResolutionx4':
22
+ # os.system("python SuperResolution.py --test_path ./tmp/lq_image.png --save_path ./tmp/ --pk_path model_zoo/SRx4.pth --scale 4")
23
 
24
+ # if task == 'Underwater':
25
+ # os.system("python Underwater.py --test_path ./tmp/lq_image.png --save_path ./tmp/ --pk_path model_zoo/underwater.pth")
26
 
27
  return 'tmp/output.png'
28
 
 
32
  #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."
33
  #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>"
34
 
35
+ '''
36
  examples = [['demo/underwater.jpg', 'Underwater'],
37
  ['demo/low.jpg', 'LLIE'],
38
  ['demo/dehaze.jpg', 'Dehazing'],
39
  ['demo/sr.png', 'SuperResolutionx2']]
40
+ '''
41
+
42
+ examples = [['demo/low.jpg', 'LLIE']]
43
+
44
+ iface = gr.Interface(
45
+ inference,
46
+ [gr.inputs.Image(type="pil", label="Input"),
47
+ gr.inputs.Radio(["LLIE"], default="LLIE", label='task'),],
48
+ gr.outputs.Image(type="file", label="Output"),
49
+ title=title,
50
+ description=description,
51
+ article=article,
52
+ enable_queue=True,
53
+ examples=examples
54
+ )
55
+ iface.launch(debug=True,enable_queue=True)
56
+ '''
57
  iface = gr.Interface(
58
  inference,
59
  [gr.inputs.Image(type="pil", label="Input"),
 
65
  enable_queue=True,
66
  examples=examples
67
  )
68
+ iface.launch(debug=True,enable_queue=True)
69
+ '''