Spaces:
Runtime error
Runtime error
Commit
·
1fcc608
1
Parent(s):
a4da7de
Update app.py
Browse files
app.py
CHANGED
@@ -121,7 +121,8 @@ def iterative_least_likely_fgsm_cifar10(image, model, epsilon, alpha, niter, nb_
|
|
121 |
# adv_x = adv_x * 0.5 + 0.5
|
122 |
return adv_x.numpy()
|
123 |
|
124 |
-
def fn(dataset, attack, epsilon
|
|
|
125 |
niter = int(min(4 + epsilon*255, 1.25 * epsilon * 255))
|
126 |
nb_classes = 10
|
127 |
classes = ["airplane", "automobile", "bird", "cat", "deer", "dog", "frog", "horse", "ship", "truck"]
|
@@ -181,12 +182,11 @@ demo = gr.Interface(
|
|
181 |
fn=fn,
|
182 |
allow_flagging="never",
|
183 |
title="Adversarial attack demonstration",
|
184 |
-
description="A random image from the chosen dataset will be perturbated with the chosen attack type and both the original image and the perturbated image will be displayed.",
|
185 |
inputs=[
|
186 |
gr.Radio(choices=["MNIST", "CIFAR10"], label="Pick a dataset"),
|
187 |
gr.Radio(choices=["FGSM", "I-FGSM", "I-LL-FGSM"], label="Pick an attack"),
|
188 |
gr.Number(value=15, label="Epsilon"),
|
189 |
-
gr.Number(value=1, label="Alpha")
|
190 |
],
|
191 |
outputs=[
|
192 |
gr.Image(label="Original Image").style(height=256,width=256),
|
|
|
121 |
# adv_x = adv_x * 0.5 + 0.5
|
122 |
return adv_x.numpy()
|
123 |
|
124 |
+
def fn(dataset, attack, epsilon):
|
125 |
+
epsilon = epsilon/255
|
126 |
niter = int(min(4 + epsilon*255, 1.25 * epsilon * 255))
|
127 |
nb_classes = 10
|
128 |
classes = ["airplane", "automobile", "bird", "cat", "deer", "dog", "frog", "horse", "ship", "truck"]
|
|
|
182 |
fn=fn,
|
183 |
allow_flagging="never",
|
184 |
title="Adversarial attack demonstration",
|
185 |
+
description="A random image from the chosen dataset will be perturbated with the chosen attack type and both the original image and the perturbated image will be displayed.The Epsilon parameter is an integer in the range [0, 255] that controls the aggressiveness of the attack.",
|
186 |
inputs=[
|
187 |
gr.Radio(choices=["MNIST", "CIFAR10"], label="Pick a dataset"),
|
188 |
gr.Radio(choices=["FGSM", "I-FGSM", "I-LL-FGSM"], label="Pick an attack"),
|
189 |
gr.Number(value=15, label="Epsilon"),
|
|
|
190 |
],
|
191 |
outputs=[
|
192 |
gr.Image(label="Original Image").style(height=256,width=256),
|