Spaces:
Runtime error
Runtime error
Commit
·
2c375b5
1
Parent(s):
1650335
Upload app.py
Browse files
app.py
CHANGED
@@ -122,7 +122,7 @@ def iterative_least_likely_fgsm_cifar10(image, model, epsilon, alpha, niter, nb_
|
|
122 |
return adv_x.numpy()
|
123 |
|
124 |
def fn(dataset, attack):
|
125 |
-
epsilon=
|
126 |
alpha=1
|
127 |
niter = int(min(4 + epsilon*255, 1.25 * epsilon * 255))
|
128 |
nb_classes = 10
|
@@ -148,7 +148,6 @@ def fn(dataset, attack):
|
|
148 |
image1 = X_test_cifar10[idx]
|
149 |
label1 = Y_test_cifar10[idx]
|
150 |
pred1 = classes[np.argmax(label1)]
|
151 |
-
print(pred1)
|
152 |
if attack == "FGSM":
|
153 |
image2 = fgsm_cifar10(image1, label1, model_cifar10, epsilon)
|
154 |
elif attack == "I_FGSM":
|
@@ -157,7 +156,6 @@ def fn(dataset, attack):
|
|
157 |
image2 = iterative_least_likely_fgsm_cifar10(image1, model_cifar10, epsilon, alpha, niter, nb_classes)
|
158 |
|
159 |
pred2 = classes[np.argmax(model_cifar10(image2.reshape((1,32,32,3))))]
|
160 |
-
print(pred2)
|
161 |
image1 = image1.reshape((32,32,3))
|
162 |
image2 = image2.reshape((32,32,3))
|
163 |
|
|
|
122 |
return adv_x.numpy()
|
123 |
|
124 |
def fn(dataset, attack):
|
125 |
+
epsilon=5/255
|
126 |
alpha=1
|
127 |
niter = int(min(4 + epsilon*255, 1.25 * epsilon * 255))
|
128 |
nb_classes = 10
|
|
|
148 |
image1 = X_test_cifar10[idx]
|
149 |
label1 = Y_test_cifar10[idx]
|
150 |
pred1 = classes[np.argmax(label1)]
|
|
|
151 |
if attack == "FGSM":
|
152 |
image2 = fgsm_cifar10(image1, label1, model_cifar10, epsilon)
|
153 |
elif attack == "I_FGSM":
|
|
|
156 |
image2 = iterative_least_likely_fgsm_cifar10(image1, model_cifar10, epsilon, alpha, niter, nb_classes)
|
157 |
|
158 |
pred2 = classes[np.argmax(model_cifar10(image2.reshape((1,32,32,3))))]
|
|
|
159 |
image1 = image1.reshape((32,32,3))
|
160 |
image2 = image2.reshape((32,32,3))
|
161 |
|