Skip to content

Commit c67cd57

Browse files
authored
Merge branch 'dev_1.15.0' into dev_issue_2148_yolo
2 parents 04cb8aa + 28a3f8c commit c67cd57

File tree

8 files changed

+61
-14
lines changed

8 files changed

+61
-14
lines changed

.github/workflows/dockerhub.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,22 @@ jobs:
2424
uses: actions/checkout@v3
2525

2626
- name: Log in to Docker Hub
27-
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
27+
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
2828
with:
2929
username: ${{ secrets.DOCKER_HUB_USERNAME }}
3030
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
3131

3232
- name: Extract metadata (tags, labels) for Docker
3333
id: meta
34-
uses: docker/metadata-action@c4ee3adeed93b1fa6a762f209fb01608c1a22f1e
34+
uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175
3535
with:
3636
images: adversarialrobustnesstoolbox/releases
3737
tags: |
3838
type=raw,value={{branch}}-1.14.1-{{sha}}
3939
type=semver,pattern={{version}}
4040
4141
- name: Build and push Docker image
42-
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
42+
uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825
4343
with:
4444
context: .
4545
push: true

art/attacks/evasion/adversarial_patch/adversarial_patch_pytorch.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ def __init__(
123123

124124
torch_version = list(map(int, torch.__version__.lower().split("+", maxsplit=1)[0].split(".")))
125125
torchvision_version = list(map(int, torchvision.__version__.lower().split("+", maxsplit=1)[0].split(".")))
126-
assert torch_version[0] >= 1 and torch_version[1] >= 7, "AdversarialPatchPyTorch requires torch>=1.7.0"
126+
assert (
127+
torch_version[0] >= 1 and torch_version[1] >= 7 or (torch_version[0] >= 2)
128+
), "AdversarialPatchPyTorch requires torch>=1.7.0"
127129
assert (
128130
torchvision_version[0] >= 0 and torchvision_version[1] >= 8
129131
), "AdversarialPatchPyTorch requires torchvision>=0.8.0"

examples/adversarial_training_cifar10.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
import logging
99

10+
import tensorflow as tf
11+
12+
tf.compat.v1.disable_eager_execution()
13+
1014
from keras.models import Sequential
1115
from keras.layers import Dense, Flatten, Conv2D, MaxPooling2D, Activation, Dropout
1216
import numpy as np

examples/application_object_detection.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,24 @@ def plot_image_with_boxes(img, boxes, pred_cls):
129129

130130
for i in range(len(boxes)):
131131
# Draw Rectangle with the coordinates
132-
cv2.rectangle(img, boxes[i][0], boxes[i][1], color=(0, 255, 0), thickness=rect_th)
133132

133+
cv2.rectangle(
134+
img,
135+
(int(boxes[i][0][0]), int(boxes[i][0][1])),
136+
(int(boxes[i][1][0]), int(boxes[i][1][1])),
137+
color=(0, 255, 0),
138+
thickness=rect_th,
139+
)
134140
# Write the prediction class
135-
cv2.putText(img, pred_cls[i], boxes[i][0], cv2.FONT_HERSHEY_SIMPLEX, text_size, (0, 255, 0), thickness=text_th)
136-
141+
cv2.putText(
142+
img,
143+
pred_cls[i],
144+
(int(boxes[i][0][0]), int(boxes[i][0][1])),
145+
cv2.FONT_HERSHEY_SIMPLEX,
146+
text_size,
147+
(0, 255, 0),
148+
thickness=text_th,
149+
)
137150
plt.axis("off")
138151
plt.imshow(img.astype(np.uint8), interpolation="nearest")
139152
plt.show()

examples/get_started_fasterrcnn.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,24 @@ def plot_image_with_boxes(img, boxes, pred_cls):
158158

159159
for i in range(len(boxes)):
160160
# Draw Rectangle with the coordinates
161-
cv2.rectangle(img, boxes[i][0], boxes[i][1], color=(0, 255, 0), thickness=rect_th)
162161

162+
cv2.rectangle(
163+
img,
164+
(int(boxes[i][0][0]), int(boxes[i][0][1])),
165+
(int(boxes[i][1][0]), int(boxes[i][1][1])),
166+
color=(0, 255, 0),
167+
thickness=rect_th,
168+
)
163169
# Write the prediction class
164-
cv2.putText(img, pred_cls[i], boxes[i][0], cv2.FONT_HERSHEY_SIMPLEX, text_size, (0, 255, 0), thickness=text_th)
165-
170+
cv2.putText(
171+
img,
172+
pred_cls[i],
173+
(int(boxes[i][0][0]), int(boxes[i][0][1])),
174+
cv2.FONT_HERSHEY_SIMPLEX,
175+
text_size,
176+
(0, 255, 0),
177+
thickness=text_th,
178+
)
166179
plt.axis("off")
167180
plt.imshow(img.astype(np.uint8), interpolation="nearest")
168181
plt.show()
@@ -215,7 +228,7 @@ def append_loss_history(loss_history, output):
215228
"batch_size": 1,
216229
"image_file": "banner-diverse-group-of-people-2.jpg",
217230
"resume": False,
218-
"path": "xp/",
231+
"path": "",
219232
}
220233

221234
pp = pprint.PrettyPrinter(indent=4)
@@ -280,3 +293,14 @@ def append_loss_history(loss_history, output):
280293
file.write(json.dumps(loss_history))
281294

282295
np.save(os.path.join(config["path"], "patch"), attack._patch)
296+
297+
predictions_adv = frcnn.predict(x=x_patch)
298+
299+
for i in range(image.shape[0]):
300+
print("\nPredictions adversarial image {}:".format(i))
301+
302+
# Process predictions
303+
predictions_adv_class, predictions_adv_boxes, predictions_adv_class = extract_predictions(predictions_adv[i])
304+
305+
# Plot predictions
306+
plot_image_with_boxes(img=x_patch[i].copy(), boxes=predictions_adv_boxes, pred_cls=predictions_adv_class)

examples/get_started_keras.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from tensorflow.keras.models import Sequential
1111
from tensorflow.keras.layers import Dense, Flatten, Conv2D, MaxPooling2D
1212
from tensorflow.keras.losses import categorical_crossentropy
13-
from tensorflow.keras.optimizers import Adam
13+
from tensorflow.keras.optimizers.legacy import Adam
1414
import numpy as np
1515

1616
from art.attacks.evasion import FastGradientMethod

notebooks/poisoning_defense_neural_cleanse.ipynb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@
5555
"from art.utils import load_mnist, preprocess\n",
5656
"from art.defences.detector.poison import ActivationDefence\n",
5757
"from art.defences.transformer.poisoning import NeuralCleanse\n",
58-
"from art.estimators.certification.neural_cleanse import KerasNeuralCleanse\n"
58+
"from art.estimators.poison_mitigation import KerasNeuralCleanse\n",
59+
"\n",
60+
"import tensorflow as tf\n",
61+
"if tf.executing_eagerly():\n",
62+
" tf.compat.v1.disable_eager_execution()"
5963
]
6064
},
6165
{

requirements_test.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ GPy==1.10.0
3939
lightgbm==3.3.5
4040
xgboost==1.7.5
4141

42-
kornia~=0.6.10
42+
kornia~=0.6.12
4343
tensorboardX==2.6
4444
lief==0.12.3
4545
jax[cpu]==0.4.8

0 commit comments

Comments
 (0)