Spaces:
Running
Running
narugo1992
commited on
Commit
·
4426230
1
Parent(s):
65abdbf
dev(narugo): add step size option
Browse files
app.py
CHANGED
@@ -8,7 +8,8 @@ from PIL import Image
|
|
8 |
from attack import Attacker, make_args
|
9 |
|
10 |
|
11 |
-
def attack_given_image(image: Image.Image, target: str, steps: int, eps: float,
|
|
|
12 |
if image.mode != 'RGB':
|
13 |
image = image.convert('RGB')
|
14 |
|
@@ -24,7 +25,7 @@ def attack_given_image(image: Image.Image, target: str, steps: int, eps: float,
|
|
24 |
'--out_dir', str(td_output),
|
25 |
'--target', target,
|
26 |
'--eps', str(eps),
|
27 |
-
'--step_size',
|
28 |
'--steps', str(steps),
|
29 |
])
|
30 |
attacker = Attacker(args)
|
@@ -45,7 +46,8 @@ if __name__ == '__main__':
|
|
45 |
gr.Image(type='pil', label='Original Image'),
|
46 |
gr.Radio(['auto', 'ai', 'human'], value='auto', label='Attack Target'),
|
47 |
gr.Slider(minimum=1, maximum=50, value=20, step=1, label='Steps'),
|
48 |
-
gr.Slider(minimum=1
|
|
|
49 |
],
|
50 |
outputs=[
|
51 |
gr.Label(label='Before Prediction'),
|
|
|
8 |
from attack import Attacker, make_args
|
9 |
|
10 |
|
11 |
+
def attack_given_image(image: Image.Image, target: str, steps: int, eps: float, step_size: float,
|
12 |
+
progress=gr.Progress()):
|
13 |
if image.mode != 'RGB':
|
14 |
image = image.convert('RGB')
|
15 |
|
|
|
25 |
'--out_dir', str(td_output),
|
26 |
'--target', target,
|
27 |
'--eps', str(eps),
|
28 |
+
'--step_size', str(step_size),
|
29 |
'--steps', str(steps),
|
30 |
])
|
31 |
attacker = Attacker(args)
|
|
|
46 |
gr.Image(type='pil', label='Original Image'),
|
47 |
gr.Radio(['auto', 'ai', 'human'], value='auto', label='Attack Target'),
|
48 |
gr.Slider(minimum=1, maximum=50, value=20, step=1, label='Steps'),
|
49 |
+
gr.Slider(label="eps (Noise intensity)", minimum=1, maximum=16, step=1, value=1),
|
50 |
+
gr.Slider(label="Noise step size", minimum=0.001, maximum=16, step=0.001, value=0.136),
|
51 |
],
|
52 |
outputs=[
|
53 |
gr.Label(label='Before Prediction'),
|