wtf741 commited on
Commit
bf71338
1 Parent(s): b66505e

add extra tools

Browse files
Files changed (1) hide show
  1. app.py +68 -8
app.py CHANGED
@@ -32,13 +32,19 @@ def clean_adverse(
32
 
33
  def clean(
34
  image: Image.Image,
35
- use_adverse_clean: bool = True,
36
- use_scunet_clean: bool = True,
 
 
 
 
 
 
37
  use_nafnet_clean: bool = False
38
  ) -> Image.Image:
39
  image = load_image(image)
40
- if use_adverse_clean:
41
- image = clean_adverse(image)
42
  if use_scunet_clean:
43
  image = restore_with_scunet(image)
44
  if use_nafnet_clean:
@@ -52,16 +58,70 @@ if __name__ == '__main__':
52
  with gr.Column():
53
  gr_input_image = gr.Image(label='Input Image', type="pil")
54
  gr_submit = gr.Button(value='FUCK YOU MIST!')
55
- gr_adverse = gr.Checkbox(label='Use Adverse Clean', value=True)
56
- gr_scunet = gr.Checkbox(label='Use SCUNET', value=True)
57
- gr_nafnet = gr.Checkbox(label='Use NafNET', value=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
  with gr.Column():
60
  gr_output_image = gr.Image(label='Output Image', type="pil")
61
 
62
  gr_submit.click(
63
  fn=clean,
64
- inputs=[gr_input_image, gr_adverse, gr_scunet, gr_nafnet],
 
 
 
 
 
 
 
 
 
 
 
65
  outputs=[gr_output_image],
66
  )
67
 
 
32
 
33
  def clean(
34
  image: Image.Image,
35
+
36
+ diameter: float = 5,
37
+ sigma_color: float = 8,
38
+ sigma_space: float = 8,
39
+ radius: float = 4,
40
+ eps: float = 16,
41
+
42
+ use_scunet_clean: bool = False,
43
  use_nafnet_clean: bool = False
44
  ) -> Image.Image:
45
  image = load_image(image)
46
+
47
+ image = clean_adverse(image, diameter, sigma_color, sigma_space, radius, eps)
48
  if use_scunet_clean:
49
  image = restore_with_scunet(image)
50
  if use_nafnet_clean:
 
58
  with gr.Column():
59
  gr_input_image = gr.Image(label='Input Image', type="pil")
60
  gr_submit = gr.Button(value='FUCK YOU MIST!')
61
+ with gr.Accordion("Advanced Config", open=False):
62
+ diameter_slider = gr.Slider(
63
+ minimum=1,
64
+ maximum=30,
65
+ step=1,
66
+ value=5,
67
+ label="Diameter (default = 5)",
68
+ interactive=True,
69
+ )
70
+ sigma_color_slider = gr.Slider(
71
+ minimum=1,
72
+ maximum=30,
73
+ step=1,
74
+ value=8,
75
+ label="SigmaColor (default = 8)",
76
+ interactive=True,
77
+ )
78
+ sigma_space_slider = gr.Slider(
79
+ minimum=1,
80
+ maximum=30,
81
+ step=1,
82
+ value=8,
83
+ label="SigmaSpace (default = 8)",
84
+ interactive=True,
85
+ )
86
+
87
+ radius_slider = gr.Slider(
88
+ minimum=1,
89
+ maximum=30,
90
+ step=1,
91
+ value=4,
92
+ label="Radius (default = 4)",
93
+ interactive=True,
94
+ )
95
+ eps_slider = gr.Slider(
96
+ minimum=1,
97
+ maximum=30,
98
+ step=1,
99
+ value=16,
100
+ label="Accuracy (default = 16)",
101
+ interactive=True,
102
+ )
103
+
104
+ with gr.Accordion("Extra Restoration", open=False):
105
+ gr_scunet = gr.Checkbox(label='Use SCUNET', value=False)
106
+ gr_nafnet = gr.Checkbox(label='Use NafNET', value=False)
107
 
108
  with gr.Column():
109
  gr_output_image = gr.Image(label='Output Image', type="pil")
110
 
111
  gr_submit.click(
112
  fn=clean,
113
+ inputs=[
114
+ gr_input_image,
115
+
116
+ diameter_slider,
117
+ sigma_color_slider,
118
+ sigma_space_slider,
119
+ radius_slider,
120
+ eps_slider,
121
+
122
+ gr_scunet,
123
+ gr_nafnet,
124
+ ],
125
  outputs=[gr_output_image],
126
  )
127