Skip to content

Commit 2d486e5

Browse files
authored
Merge pull request #2296 from Trusted-AI/dev_1.16.0
Update to ART 1.16.0
2 parents 75b38a1 + ad7520c commit 2d486e5

File tree

102 files changed

+12030
-1458
lines changed

Some content is hidden

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

102 files changed

+12030
-1458
lines changed

.github/actions/yolo/run.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
exit_code=0
44

55
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/estimators/object_detection/test_pytorch_yolo.py --framework=pytorch --durations=0
6-
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed estimators/speech_recognition/test_pytorch_yolo tests"; fi
6+
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed estimators/object_detection/test_pytorch_yolo tests"; fi
7+
8+
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/estimators/object_detection/test_object_seeker_yolo.py --framework=pytorch --durations=0
9+
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed estimators/object_detection/test_object_seeker_yolo tests"; fi
710

811
exit ${exit_code}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: CI Huggingface
2+
on:
3+
# Run on manual trigger
4+
workflow_dispatch:
5+
6+
# Run on pull requests
7+
pull_request:
8+
paths-ignore:
9+
- '*.md'
10+
11+
# Run on merge queue
12+
merge_group:
13+
14+
# Run when pushing to main or dev branches
15+
push:
16+
branches:
17+
- main
18+
- dev*
19+
20+
# Run scheduled CI flow daily
21+
schedule:
22+
- cron: '0 8 * * 0'
23+
24+
jobs:
25+
test:
26+
runs-on: ubuntu-20.04
27+
strategy:
28+
fail-fast: false
29+
matrix:
30+
include:
31+
- name: Huggingface 4.30
32+
framework: huggingface
33+
python: 3.9
34+
torch: 1.13.1+cpu
35+
torchvision: 0.14.1+cpu
36+
torchaudio: 0.13.1
37+
transformers: 4.30.2
38+
39+
name: ${{ matrix.name }}
40+
steps:
41+
- name: Checkout Repo
42+
uses: actions/checkout@v3
43+
- name: Setup Python
44+
uses: actions/setup-python@v4
45+
with:
46+
python-version: ${{ matrix.python }}
47+
- name: Install Dependencies
48+
run: |
49+
sudo apt-get update
50+
sudo apt-get -y -q install ffmpeg libavcodec-extra
51+
python -m pip install --upgrade pip setuptools wheel
52+
pip3 install -r requirements_test.txt
53+
pip install tensorflow==2.10.1
54+
pip install keras==2.10.0
55+
pip install torch==${{ matrix.torch }} -f https://download.pytorch.org/whl/cpu/torch_stable.html
56+
pip install torchvision==${{ matrix.torchvision }} -f https://download.pytorch.org/whl/cpu/torch_stable.html
57+
pip install torchaudio==${{ matrix.torchaudio }} -f https://download.pytorch.org/whl/cpu/torch_stable.html
58+
pip install transformers==${{ matrix.transformers }}
59+
pip list
60+
- name: Run Tests
61+
run: ./run_tests.sh ${{ matrix.framework }}
62+
- name: Upload coverage to Codecov
63+
uses: codecov/codecov-action@v3
64+
with:
65+
fail_ci_if_error: true

.github/workflows/ci-lingvo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
sudo apt-get update
5151
sudo apt-get -y -q install ffmpeg libavcodec-extra
5252
python -m pip install --upgrade pip setuptools wheel
53-
pip install -q -r <(sed '/^scipy/d;/^matplotlib/d;/^pandas/d;/^statsmodels/d;/^numba/d;/^jax/d;/^h5py/d;/^Pillow/d;/^pytest/d;/^pytest-mock/d;/^torch/d;/^torchaudio/d;/^torchvision/d;/^xgboost/d;/^requests/d;/^tensorflow/d;/^keras/d;/^kornia/d;/^librosa/d;/^tqdm/d' requirements_test.txt)
53+
pip install -q -r <(sed '/^scipy/d;/^matplotlib/d;/^pandas/d;/^statsmodels/d;/^numba/d;/^jax/d;/^h5py/d;/^Pillow/d;/^pytest/d;/^pytest-mock/d;/^torch/d;/^torchaudio/d;/^torchvision/d;/^xgboost/d;/^requests/d;/^tensorflow/d;/^keras/d;/^kornia/d;/^librosa/d;/^tqdm/d;/^timm/d' requirements_test.txt)
5454
pip install scipy==1.5.4
5555
pip install matplotlib==3.3.4
5656
pip install pandas==1.1.5

.github/workflows/ci-pytorch-object-detectors.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ jobs:
5252
run: pytest --cov-report=xml --cov=art --cov-append -q -vv tests/estimators/object_detection/test_pytorch_faster_rcnn.py --framework=pytorch --durations=0
5353
- name: Run Test Action - test_pytorch_detection_transformer
5454
run: pytest --cov-report=xml --cov=art --cov-append -q -vv tests/estimators/object_detection/test_pytorch_detection_transformer.py --framework=pytorch --durations=0
55+
- name: Run Test Action - test_pytorch_object_seeker_faster_rcnn
56+
run: pytest --cov-report=xml --cov=art --cov-append -q -vv tests/estimators/object_detection/test_object_seeker_faster_rcnn.py --framework=pytorch --durations=0
5557
- name: Upload coverage to Codecov
5658
uses: codecov/codecov-action@v3
5759
with:

art/attacks/attack.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ def set_params(self, **kwargs) -> None:
159159
for key, value in kwargs.items():
160160
if key in self.attack_params:
161161
setattr(self, key, value)
162+
else:
163+
raise ValueError(f'The attribute "{key}" cannot be set for this attack.')
162164
self._check_params()
163165

164166
def _check_params(self) -> None:
@@ -186,6 +188,19 @@ def is_estimator_valid(estimator, estimator_requirements) -> bool:
186188
return False
187189
return True
188190

191+
def __repr__(self):
192+
"""
193+
Returns a string describing the attack class and attack_params
194+
"""
195+
param_str = ""
196+
for param in self.attack_params:
197+
if hasattr(self, param):
198+
param_str += f"{param}={getattr(self, param)}, "
199+
elif hasattr(self, "_attack"):
200+
if hasattr(self._attack, param):
201+
param_str += f"{param}={getattr(self._attack, param)}, "
202+
return f"{type(self).__name__}({param_str})"
203+
189204

190205
class EvasionAttack(Attack):
191206
"""

art/attacks/evasion/adversarial_patch/adversarial_patch_tensorflow.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,10 @@ def _random_overlay(
274274
name=None,
275275
)
276276

277-
pad_h_before = int((self.image_shape[self.i_h] - image_mask.shape[self.i_h_patch + 1]) / 2)
277+
pad_h_before = int((self.image_shape[self.i_h] - image_mask.shape.as_list()[self.i_h_patch + 1]) / 2)
278278
pad_h_after = int(self.image_shape[self.i_h] - pad_h_before - image_mask.shape[self.i_h_patch + 1])
279279

280-
pad_w_before = int((self.image_shape[self.i_w] - image_mask.shape[self.i_w_patch + 1]) / 2)
280+
pad_w_before = int((self.image_shape[self.i_w] - image_mask.shape.as_list()[self.i_w_patch + 1]) / 2)
281281
pad_w_after = int(self.image_shape[self.i_w] - pad_w_before - image_mask.shape[self.i_w_patch + 1])
282282

283283
image_mask = tf.pad( # pylint: disable=E1123
@@ -323,10 +323,10 @@ def _random_overlay(
323323

324324
if mask is None:
325325
padding_after_scaling_h = (
326-
self.image_shape[self.i_h] - im_scale * padded_patch.shape[self.i_h + 1]
326+
self.image_shape[self.i_h] - im_scale * padded_patch.shape.as_list()[self.i_h + 1]
327327
) / 2.0
328328
padding_after_scaling_w = (
329-
self.image_shape[self.i_w] - im_scale * padded_patch.shape[self.i_w + 1]
329+
self.image_shape[self.i_w] - im_scale * padded_patch.shape.as_list()[self.i_w + 1]
330330
) / 2.0
331331
x_shift = np.random.uniform(-padding_after_scaling_w, padding_after_scaling_w)
332332
y_shift = np.random.uniform(-padding_after_scaling_h, padding_after_scaling_h)

0 commit comments

Comments
 (0)