Skip to content

Commit 38bdcbe

Browse files
committed
Merge remote-tracking branch 'origin/main' into dev_1.19.2
2 parents d037f0e + 4022735 commit 38bdcbe

37 files changed

+403
-265
lines changed

.github/actions/yolo/run.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,11 @@ if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed estimators/object_detection/te
88
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/estimators/object_detection/test_object_seeker_yolo.py --framework=pytorch --durations=0
99
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed estimators/object_detection/test_object_seeker_yolo tests"; fi
1010

11+
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/attacks/test_overload_attack.py --framework=pytorch --durations=0
12+
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed attacks/test_overload_attack tests"; fi
13+
14+
pytest --cov-report=xml --cov=art --cov-append -q -vv tests/attacks/test_steal_now_attack_later.py --framework=pytorch --durations=0
15+
if [[ $? -ne 0 ]]; then exit_code=1; echo "Failed attacks/teest_steal_now_attack_later tests"; fi
16+
17+
1118
exit ${exit_code}

.github/workflows/ci-deepspeech-v3.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Run Test Action
3333
uses: ./.github/actions/deepspeech-v3
3434
- name: Upload coverage to Codecov
35-
uses: codecov/codecov-action@v4
35+
uses: codecov/codecov-action@v5
3636
with:
3737
token: ${{ secrets.CODECOV_TOKEN }}
3838
fail_ci_if_error: true

.github/workflows/ci-espresso.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Run Test Action
3333
uses: ./.github/actions/espresso
3434
- name: Upload coverage to Codecov
35-
uses: codecov/codecov-action@v4
35+
uses: codecov/codecov-action@v5
3636
with:
3737
token: ${{ secrets.CODECOV_TOKEN }}
3838
fail_ci_if_error: true

.github/workflows/ci-goturn.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Run Test Action
3333
uses: ./.github/actions/goturn
3434
- name: Upload coverage to Codecov
35-
uses: codecov/codecov-action@v4
35+
uses: codecov/codecov-action@v5
3636
env:
3737
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
3838
with:

.github/workflows/ci-huggingface.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ jobs:
5252
pip3 install -r requirements_test.txt
5353
pip install tensorflow==2.14.0
5454
pip install keras==2.14.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
55+
pip install torch==${{ matrix.torch }} --index-url https://download.pytorch.org/whl/cpu
56+
pip install torchvision==${{ matrix.torchvision }} --index-url https://download.pytorch.org/whl/cpu
57+
pip install torchaudio==${{ matrix.torchaudio }} --index-url https://download.pytorch.org/whl/cpu
5858
pip install transformers==${{ matrix.transformers }}
5959
pip list
6060
- name: Run Tests
6161
run: ./run_tests.sh ${{ matrix.framework }}
6262
- name: Upload coverage to Codecov
63-
uses: codecov/codecov-action@v4
63+
uses: codecov/codecov-action@v5
6464
with:
6565
token: ${{ secrets.CODECOV_TOKEN }}
6666
fail_ci_if_error: true

.github/workflows/ci-keras.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
- name: Run Tests
6969
run: ./run_tests.sh ${{ matrix.framework }}
7070
- name: Upload coverage to Codecov
71-
uses: codecov/codecov-action@v4
71+
uses: codecov/codecov-action@v5
7272
with:
7373
token: ${{ secrets.CODECOV_TOKEN }}
7474
fail_ci_if_error: true

.github/workflows/ci-legacy.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ jobs:
5656
pip install tensorflow==${{ matrix.tensorflow }}
5757
pip install keras==${{ matrix.keras }}
5858
pip install scikit-learn==${{ matrix.scikit-learn }}
59-
pip install torch==${{ matrix.torch }} -f https://download.pytorch.org/whl/cpu/torch_stable.html
60-
pip install torchvision==${{ matrix.torchvision }} -f https://download.pytorch.org/whl/cpu/torch_stable.html
61-
pip install torchaudio==${{ matrix.torchaudio }} -f https://download.pytorch.org/whl/cpu/torch_stable.html
59+
pip install torch==${{ matrix.torch }} --index-url https://download.pytorch.org/whl/cpu
60+
pip install torchvision==${{ matrix.torchvision }} --index-url https://download.pytorch.org/whl/cpu
61+
pip install torchaudio==${{ matrix.torchaudio }} --index-url https://download.pytorch.org/whl/cpu
6262
pip list
6363
- name: Run ${{ matrix.name }} ${{ matrix.module }} Tests
6464
run: ./run_tests.sh ${{ matrix.framework }} ${{ matrix.module }}
6565
- name: Upload coverage to Codecov
66-
uses: codecov/codecov-action@v4
66+
uses: codecov/codecov-action@v5
6767
with:
6868
token: ${{ secrets.CODECOV_TOKEN }}
6969
fail_ci_if_error: true

.github/workflows/ci-lingvo.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,20 @@ jobs:
5151
sudo apt-get -y -q install ffmpeg libavcodec-extra
5252
python -m pip install --upgrade pip setuptools wheel
5353
pip install -q -r requirements_test.txt
54-
pip install -q -r <(sed '/^tensorflow/d;/^keras/d;/^tensorflow-addons/d;/^lingvo/d;/^Pillow/d' requirements_test.txt)
54+
pip install -q -r <(sed '/^tensorflow/d;/^keras/d;/^tensorflow-addons/d;/^lingvo/d;/^Pillow/d;/^torch/d;/^torchaudio/d;/^torchvision/d' requirements_test.txt)
5555
pip install tensorflow==${{ matrix.tensorflow }}
5656
pip install keras==${{ matrix.keras }}
5757
pip install tensorflow-addons==${{ matrix.tf_addons }}
5858
pip install lingvo==0.13.1
5959
pip install Pillow==10.0.0
60+
pip install torch==2.5.0 --index-url https://download.pytorch.org/whl/cpu
61+
pip install torchaudio==2.5.0 --index-url https://download.pytorch.org/whl/cpu
62+
pip install torchvision==0.20.0 --index-url https://download.pytorch.org/whl/cpu
6063
pip list
6164
- name: Run ${{ matrix.name }} Tests
6265
run: pytest --cov-report=xml --cov=art --cov-append -q -vv tests/estimators/speech_recognition/test_tensorflow_lingvo.py --framework=${{ matrix.framework }} --durations=0
6366
- name: Upload coverage to Codecov
64-
uses: codecov/codecov-action@v4
67+
uses: codecov/codecov-action@v5
6568
with:
6669
token: ${{ secrets.CODECOV_TOKEN }}
6770
fail_ci_if_error: true

.github/workflows/ci-mxnet.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
- name: Run ${{ matrix.name }} ${{ matrix.module }} Tests
5151
run: ./run_tests.sh ${{ matrix.framework }} ${{ matrix.module }}
5252
- name: Upload coverage to Codecov
53-
uses: codecov/codecov-action@v4
53+
uses: codecov/codecov-action@v5
5454
with:
5555
token: ${{ secrets.CODECOV_TOKEN }}
5656
fail_ci_if_error: true

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
- name: Run Test Action - test_pytorch_object_seeker_faster_rcnn
5151
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
5252
- name: Upload coverage to Codecov
53-
uses: codecov/codecov-action@v4
53+
uses: codecov/codecov-action@v5
5454
with:
5555
token: ${{ secrets.CODECOV_TOKEN }}
5656
fail_ci_if_error: true

.github/workflows/ci-pytorch.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,18 @@ jobs:
2828
fail-fast: false
2929
matrix:
3030
include:
31-
- name: PyTorch 1.13.1 (Python 3.10)
31+
- name: PyTorch 2.6.0 (Python 3.10)
3232
framework: pytorch
3333
python: '3.10'
34-
torch: 1.13.1+cpu
35-
torchvision: 0.14.1+cpu
36-
torchaudio: 0.13.1
37-
- name: PyTorch 2.2.1 (Python 3.10)
34+
torch: 2.6.0
35+
torchvision: 0.21.0
36+
torchaudio: 2.6.0
37+
- name: PyTorch 2.7.0 (Python 3.10)
3838
framework: pytorch
3939
python: '3.10'
40-
torch: 2.2.1
41-
torchvision: 0.17.1+cpu
42-
torchaudio: 2.2.1
40+
torch: 2.7.0
41+
torchvision: 0.22.0
42+
torchaudio: 2.7.0
4343

4444
name: ${{ matrix.name }}
4545
steps:
@@ -55,14 +55,15 @@ jobs:
5555
sudo apt-get -y -q install ffmpeg libavcodec-extra
5656
python -m pip install --upgrade pip setuptools wheel
5757
pip3 install -r requirements_test.txt
58-
pip install torch==${{ matrix.torch }} -f https://download.pytorch.org/whl/cpu/torch_stable.html
59-
pip install torchvision==${{ matrix.torchvision }} -f https://download.pytorch.org/whl/cpu/torch_stable.html
60-
pip install torchaudio==${{ matrix.torchaudio }} -f https://download.pytorch.org/whl/cpu/torch_stable.html
58+
pip install -q -r <(sed '/^torch/d;/^torchvision/d;/^torchaudio/d' requirements_test.txt)
59+
pip install torch==${{ matrix.torch }} --index-url https://download.pytorch.org/whl/cpu
60+
pip install torchvision==${{ matrix.torchvision }} --index-url https://download.pytorch.org/whl/cpu
61+
pip install torchaudio==${{ matrix.torchaudio }} --index-url https://download.pytorch.org/whl/cpu
6162
pip list
6263
- name: Run Tests
6364
run: ./run_tests.sh ${{ matrix.framework }}
6465
- name: Upload coverage to Codecov
65-
uses: codecov/codecov-action@v4
66+
uses: codecov/codecov-action@v5
6667
with:
6768
token: ${{ secrets.CODECOV_TOKEN }}
6869
fail_ci_if_error: true

.github/workflows/ci-scikit-learn.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
- name: Run Tests
5757
run: ./run_tests.sh ${{ matrix.framework }}
5858
- name: Upload coverage to Codecov
59-
uses: codecov/codecov-action@v4
59+
uses: codecov/codecov-action@v5
6060
with:
6161
token: ${{ secrets.CODECOV_TOKEN }}
6262
fail_ci_if_error: true

.github/workflows/ci-tensorflow-v1.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ jobs:
4848
sudo apt-get update
4949
sudo apt-get -y -q install ffmpeg libavcodec-extra
5050
python -m pip install --upgrade pip setuptools wheel
51-
pip install -q -r <(sed '/^pandas/d;/^scipy/d;/^matplotlib/d;/^xgboost/d;/^tensorflow/d;/^keras/d;/^jax/d;/^torch/d;/^Pillow/d;/^h5py/d;/^kornia/d;/^scikit-learn/d;/^pytest-mock/d;/^GPy/d;/^lief/d;/^statsmodels/d;/^ultralytics/d;/^ipython/d;/^numba/d;/^pytest/d;/^pylint/d;/^mypy/d;/^pycodestyle/d;/^black/d;/^types-PyYAML/d;/^types-setuptools/d;/^requests/d' requirements_test.txt)
51+
pip install -q -r <(sed '/^pandas/d;/^scipy/d;/^matplotlib/d;/^xgboost/d;/^tensorflow/d;/^keras/d;/^jax/d;/^torch/d;/^Pillow/d;/^h5py/d;/^kornia/d;/^scikit-learn/d;/^pytest-mock/d;/^GPy/d;/^lief/d;/^statsmodels/d;/^ultralytics/d;/^ipython/d;/^numba/d;/^pytest/d;/^pylint/d;/^mypy/d;/^pycodestyle/d;/^black/d;/^types-PyYAML/d;/^types-setuptools/d;/^requests/d;/^timm/d' requirements_test.txt)
5252
pip install pandas==1.3.5
5353
pip install scipy==1.7.2
5454
pip install matplotlib==3.5.3
@@ -57,9 +57,9 @@ jobs:
5757
pip install tensorflow==${{ matrix.tensorflow }}
5858
pip install keras==${{ matrix.keras }}
5959
pip install numpy==1.20
60-
pip install torch==1.13.1
61-
pip install torchaudio==0.13.1
62-
pip install torchvision==0.14.1+cpu
60+
pip install torch==1.13.1 --index-url https://download.pytorch.org/whl/cpu
61+
pip install torchaudio==0.13.1 --index-url https://download.pytorch.org/whl/cpu
62+
pip install torchvision==0.14.1 --index-url https://download.pytorch.org/whl/cpu
6363
pip install Pillow==9.5.0
6464
pip install h5py==3.8.0
6565
pip install kornia==0.6.12
@@ -72,11 +72,12 @@ jobs:
7272
pip install pytest==7.4.4
7373
pip install pytest-cov
7474
pip install requests==2.31.0
75+
pip install timm==0.9.12
7576
pip list
7677
- name: Run Tests
7778
run: ./run_tests.sh ${{ matrix.framework }}
7879
- name: Upload coverage to Codecov
79-
uses: codecov/codecov-action@v4
80+
uses: codecov/codecov-action@v5
8081
with:
8182
token: ${{ secrets.CODECOV_TOKEN }}
8283
fail_ci_if_error: true

.github/workflows/ci-tensorflow-v2.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ jobs:
2828
fail-fast: false
2929
matrix:
3030
include:
31-
- name: TensorFlow 2.13.1 (Keras 2.13.1 Python 3.10)
32-
framework: tensorflow
33-
python: '3.10'
34-
tensorflow: 2.13.1
35-
tf_version: v2
36-
keras: 2.13.1
37-
tf_addons: 0.21.0
3831
- name: TensorFlow 2.14.0v1 (Keras 2.14.0 Python 3.10)
3932
framework: tensorflow2v1
4033
python: '3.10'
@@ -71,7 +64,7 @@ jobs:
7164
- name: Run Tests
7265
run: ./run_tests.sh ${{ matrix.framework }}
7366
- name: Upload coverage to Codecov
74-
uses: codecov/codecov-action@v4
67+
uses: codecov/codecov-action@v5
7568
with:
7669
token: ${{ secrets.CODECOV_TOKEN }}
7770
fail_ci_if_error: true

.github/workflows/ci-tf-faster-rcnn.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Run Test Action
3333
uses: ./.github/actions/tf-faster-rcnn
3434
- name: Upload coverage to Codecov
35-
uses: codecov/codecov-action@v4
35+
uses: codecov/codecov-action@v5
3636
with:
3737
token: ${{ secrets.CODECOV_TOKEN }}
3838
fail_ci_if_error: true

.github/workflows/ci-tfv2-faster-rcnn.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Run Test Action
3333
uses: ./.github/actions/tfv2-faster-rcnn
3434
- name: Upload coverage to Codecov
35-
uses: codecov/codecov-action@v4
35+
uses: codecov/codecov-action@v5
3636
with:
3737
token: ${{ secrets.CODECOV_TOKEN }}
3838
fail_ci_if_error: true

.github/workflows/ci-yolo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Run Test Action
3333
uses: ./.github/actions/yolo
3434
- name: Upload coverage to Codecov
35-
uses: codecov/codecov-action@v4
35+
uses: codecov/codecov-action@v5
3636
with:
3737
token: ${{ secrets.CODECOV_TOKEN }}
3838
fail_ci_if_error: true

.github/workflows/dockerhub.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ jobs:
2323
uses: actions/checkout@v4
2424

2525
- name: Log in to Docker Hub
26-
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
26+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772
2727
with:
2828
username: ${{ secrets.DOCKER_HUB_USERNAME }}
2929
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
3030

3131
- name: Extract metadata (tags, labels) for Docker
3232
id: meta
33-
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96
33+
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804
3434
with:
3535
images: adversarialrobustnesstoolbox/releases
3636
tags: |
3737
type=raw,value={{branch}}-1.19.1-{{sha}}
3838
type=semver,pattern={{version}}
3939
4040
- name: Build and push Docker image
41-
uses: docker/build-push-action@67a2d409c0a876cbe6b11854e3e25193efe4e62d
41+
uses: docker/build-push-action@1dc73863535b631f98b2378be8619f83b136f4a0
4242
with:
4343
context: .
4444
push: true

art/attacks/evasion/auto_attack.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ def generate(self, x: np.ndarray, y: np.ndarray | None = None, **kwargs) -> np.n
201201
attack.set_params(targeted=False)
202202

203203
if self.parallel_pool_size > 0:
204+
attack.estimator._optimizer = None
205+
self.estimator._optimizer = None
206+
204207
args.append(
205208
(
206209
deepcopy(x_adv),
@@ -255,6 +258,9 @@ def generate(self, x: np.ndarray, y: np.ndarray | None = None, **kwargs) -> np.n
255258
)
256259

257260
if self.parallel_pool_size > 0:
261+
attack.estimator._optimizer = None
262+
self.estimator._optimizer = None
263+
258264
args.append(
259265
(
260266
deepcopy(x_adv),

art/attacks/evasion/feature_adversaries/feature_adversaries_pytorch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ def loss_fn(source_orig, source_adv, guide):
150150
loss.backward()
151151

152152
# pgd step
153-
if adv.grad is not None:
153+
if adv.grad is not None and self.step_size is not None:
154154
adv.data = adv - adv.grad.detach().sign() * self.step_size
155155
else:
156-
raise ValueError("Gradient tensor in PyTorch model is `None`.")
156+
raise ValueError("Gradient tensor in PyTorch model or step_size is `None`.")
157157
perturbation = torch.clamp(adv.detach() - x.detach(), -self.delta, self.delta)
158158
adv.data = x.detach() + perturbation
159159
if self.estimator.clip_values is not None:

art/attacks/evasion/overload/overload.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def __init__(
6161
max_iter: int,
6262
num_grid: int,
6363
batch_size: int,
64+
threshold: float,
6465
) -> None:
6566
"""
6667
Create an overload attack instance.
@@ -70,12 +71,14 @@ def __init__(
7071
:param max_iter: The maximum number of iterations.
7172
:param num_grid: The number of grids for width and high dimension.
7273
:param batch_size: Size of the batch on which adversarial samples are generated.
74+
:param threshold: IoU threshold.
7375
"""
7476
super().__init__(estimator=estimator)
7577
self.eps = eps
7678
self.max_iter = max_iter
7779
self.num_grid = num_grid
7880
self.batch_size = batch_size
81+
self.threshold = threshold
7982
self._check_params()
8083

8184
def generate(self, x: np.ndarray, y: np.ndarray | None = None, **kwargs) -> np.ndarray:
@@ -157,10 +160,9 @@ def _loss(self, x: "torch.Tensor") -> tuple["torch.Tensor", "torch.Tensor"]:
157160
if isinstance(adv_logits, tuple):
158161
adv_logits = adv_logits[0]
159162

160-
threshold = self.estimator.model.conf
161163
conf = adv_logits[..., 4]
162164
prob = adv_logits[..., 5:]
163-
prob = torch.where(conf[:, :, None] * prob > threshold, torch.ones_like(prob), prob)
165+
prob = torch.where(conf[:, :, None] * prob > self.threshold, torch.ones_like(prob), prob)
164166
prob = torch.sum(prob, dim=2)
165167
conf = conf * prob
166168

@@ -185,7 +187,7 @@ def _loss(self, x: "torch.Tensor") -> tuple["torch.Tensor", "torch.Tensor"]:
185187
for x_i in range(x.shape[0]):
186188
xyhw = adv_logits[x_i, :, :4]
187189
prob = torch.max(adv_logits[x_i, :, 5:], dim=1).values
188-
box_idx = adv_logits[x_i, :, 4] * prob > threshold
190+
box_idx = adv_logits[x_i, :, 4] * prob > self.threshold
189191
xyhw = xyhw[box_idx]
190192
c_xyxy = self.xywh2xyxy(xyhw)
191193
scores = box_iou(grid_box, c_xyxy)
@@ -244,3 +246,6 @@ def _check_params(self) -> None:
244246

245247
if self.batch_size < 1:
246248
raise ValueError("The batch size must be a positive integer.")
249+
250+
if self.threshold < 0.0 or self.threshold > 1.0:
251+
raise ValueError("The threshold must be in the range [0, 1].")

0 commit comments

Comments
 (0)