Skip to content

Commit e3942cd

Browse files
authored
Merge pull request #965 from Trusted-AI/dev_1.6.0
Update to ART 1.6.0
2 parents fa4fe6a + 5ef6327 commit e3942cd

File tree

202 files changed

+6763
-1727
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

202 files changed

+6763
-1727
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,18 @@ jobs:
3131
tensorflow: 1.15.5
3232
tf_version: v1
3333
keras: 2.2.5
34-
- name: TensorFlow 2.2.2 (Keras 2.3.1 Python 3.7)
35-
framework: tensorflow
36-
python: 3.7
37-
tensorflow: 2.2.2
38-
tf_version: v2
39-
keras: 2.3.1
40-
- name: TensorFlow 2.2.2v1 (Keras 2.3.1 Python 3.7)
41-
framework: tensorflow2v1
42-
python: 3.7
43-
tensorflow: 2.2.2
44-
tf_version: v2
45-
keras: 2.3.1
4634
- name: TensorFlow 2.3.2 (Keras 2.4.3 Python 3.7)
4735
framework: tensorflow
4836
python: 3.7
4937
tensorflow: 2.3.2
5038
tf_version: v2
5139
keras: 2.4.3
40+
- name: TensorFlow 2.4.1v1 (Keras 2.4.3 Python 3.8)
41+
framework: tensorflow2v1
42+
python: 3.8
43+
tensorflow: 2.4.1
44+
tf_version: v2
45+
keras: 2.4.3
5246
- name: TensorFlow 2.4.1 (Keras 2.4.3 Python 3.8)
5347
framework: tensorflow
5448
python: 3.8
@@ -79,6 +73,13 @@ jobs:
7973
- name: mxnet (Python 3.7)
8074
framework: mxnet
8175
python: 3.7
76+
- name: TensorFlow+Lingvo 2.1.0v1 (Keras 2.3.1 Python 3.6)
77+
framework: tensorflow2v1
78+
python: 3.6
79+
tensorflow: 2.1.0
80+
tf_version: v2
81+
keras: 2.3.1
82+
lingvo: 0.6.4
8283
- name: legacy (TensorFlow 2.2.1 Keras 2.3.1 scikit-learn 0.22.2 Python 3.7)
8384
framework: legacy
8485
python: 3.7
@@ -115,7 +116,7 @@ jobs:
115116
pip install scikit-learn==${{ matrix.scikit-learn }}
116117
pip list
117118
- name: Pre-install tensorflow
118-
if: ${{ matrix.framework == 'tensorflow' || matrix.framework == 'keras' || matrix.framework == 'kerastf' }}
119+
if: ${{ matrix.framework == 'tensorflow' || matrix.framework == 'keras' || matrix.framework == 'kerastf' || matrix.framework == 'tensorflow2v1' }}
119120
run: |
120121
pip install tensorflow==${{ matrix.tensorflow }}
121122
pip install keras==${{ matrix.keras }}
@@ -125,6 +126,14 @@ jobs:
125126
run: |
126127
pip install scikit-learn==${{ matrix.scikit-learn }}
127128
pip list
129+
- name: Pre-install Lingvo ASR
130+
if: ${{ matrix.tensorflow == '2.1.0' }}
131+
run: |
132+
pip install tensorflow==${{ matrix.tensorflow }}
133+
pip install lingvo==${{ matrix.lingvo }}
134+
pip install tensorflow-addons==0.9.1
135+
pip install model-pruning-google-research==0.0.3
136+
pip list
128137
- name: Run ${{ matrix.name }} Tests
129138
run: ./run_tests.sh ${{ matrix.framework }}
130139
- name: Upload coverage to Codecov

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
- Kyushu University
1010
- Intel Corporation
1111
- University of Chicago
12+
- The MITRE Corporation

art/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from art import wrappers
1212

1313
# Semantic Version
14-
__version__ = "1.5.3"
14+
__version__ = "1.6.0-dev"
1515

1616
# pylint: disable=C0103
1717

art/attacks/evasion/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from art.attacks.evasion.adversarial_patch.adversarial_patch import AdversarialPatch
55
from art.attacks.evasion.adversarial_patch.adversarial_patch_numpy import AdversarialPatchNumpy
66
from art.attacks.evasion.adversarial_patch.adversarial_patch_tensorflow import AdversarialPatchTensorFlowV2
7+
from art.attacks.evasion.adversarial_patch.adversarial_patch_pytorch import AdversarialPatchPyTorch
78
from art.attacks.evasion.adversarial_asr import CarliniWagnerASR
89
from art.attacks.evasion.auto_attack import AutoAttack
910
from art.attacks.evasion.auto_projected_gradient_descent import AutoProjectedGradientDescent

art/attacks/evasion/adversarial_patch/adversarial_patch.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
from art.attacks.evasion.adversarial_patch.adversarial_patch_tensorflow import AdversarialPatchTensorFlowV2
3333
from art.estimators.estimator import BaseEstimator, NeuralNetworkMixin
3434
from art.estimators.classification.classifier import ClassifierMixin
35-
3635
from art.estimators.classification import TensorFlowV2Classifier
3736
from art.attacks.attack import EvasionAttack
3837

@@ -169,6 +168,19 @@ def reset_patch(self, initial_patch_value: Optional[Union[float, np.ndarray]]) -
169168
"""
170169
self._attack.reset_patch(initial_patch_value=initial_patch_value)
171170

171+
def insert_transformed_patch(self, x: np.ndarray, patch: np.ndarray, image_coords: np.ndarray):
172+
"""
173+
Insert patch to image based on given or selected coordinates.
174+
175+
:param x: The image to insert the patch.
176+
:param patch: The patch to be transformed and inserted.
177+
:param image_coords: The coordinates of the 4 corners of the transformed, inserted patch of shape
178+
[[x1, y1], [x2, y2], [x3, y3], [x4, y4]] in pixel units going in clockwise direction, starting with upper
179+
left corner.
180+
:return: The input `x` with the patch inserted.
181+
"""
182+
return self._attack.insert_transformed_patch(x, patch, image_coords)
183+
172184
def set_params(self, **kwargs) -> None:
173185
super().set_params(**kwargs)
174186
self._attack.set_params(**kwargs)

art/attacks/evasion/adversarial_patch/adversarial_patch_numpy.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from tqdm.auto import trange
3434

3535
from art.attacks.attack import EvasionAttack
36+
from art.attacks.evasion.adversarial_patch.utils import insert_transformed_patch
3637
from art.estimators.estimator import BaseEstimator, NeuralNetworkMixin
3738
from art.estimators.classification.classifier import ClassifierMixin
3839
from art.utils import check_and_transform_label_format
@@ -578,3 +579,17 @@ def reset_patch(self, initial_patch_value: Optional[Union[float, np.ndarray]]) -
578579
self.patch = initial_patch_value
579580
else:
580581
raise ValueError("Unexpected value for initial_patch_value.")
582+
583+
@staticmethod
584+
def insert_transformed_patch(x: np.ndarray, patch: np.ndarray, image_coords: np.ndarray):
585+
"""
586+
Insert patch to image based on given or selected coordinates.
587+
588+
:param x: The image to insert the patch.
589+
:param patch: The patch to be transformed and inserted.
590+
:param image_coords: The coordinates of the 4 corners of the transformed, inserted patch of shape
591+
[[x1, y1], [x2, y2], [x3, y3], [x4, y4]] in pixel units going in clockwise direction, starting with upper
592+
left corner.
593+
:return: The input `x` with the patch inserted.
594+
"""
595+
return insert_transformed_patch(x, patch, image_coords)

0 commit comments

Comments
 (0)