Skip to content

Commit

Permalink
Merge branch 'dev_1.17.0' into composite-adversarial-attack
Browse files Browse the repository at this point in the history
  • Loading branch information
beat-buesser authored Dec 13, 2023
2 parents 55f3c72 + 1b3120b commit c8f5816
Show file tree
Hide file tree
Showing 126 changed files with 7,485 additions and 748 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/ci-huggingface.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: CI Huggingface
on:
# Run on manual trigger
workflow_dispatch:

# Run on pull requests
pull_request:
paths-ignore:
- '*.md'

# Run on merge queue
merge_group:

# Run when pushing to main or dev branches
push:
branches:
- main
- dev*

# Run scheduled CI flow daily
schedule:
- cron: '0 8 * * 0'

jobs:
test:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- name: Huggingface 4.30
framework: huggingface
python: 3.9
torch: 1.13.1+cpu
torchvision: 0.14.1+cpu
torchaudio: 0.13.1
transformers: 4.30.2

name: ${{ matrix.name }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get -y -q install ffmpeg libavcodec-extra
python -m pip install --upgrade pip setuptools wheel
pip3 install -r requirements_test.txt
pip install tensorflow==2.14.0
pip install keras==2.14.0
pip install torch==${{ matrix.torch }} -f https://download.pytorch.org/whl/cpu/torch_stable.html
pip install torchvision==${{ matrix.torchvision }} -f https://download.pytorch.org/whl/cpu/torch_stable.html
pip install torchaudio==${{ matrix.torchaudio }} -f https://download.pytorch.org/whl/cpu/torch_stable.html
pip install transformers==${{ matrix.transformers }}
pip list
- name: Run Tests
run: ./run_tests.sh ${{ matrix.framework }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
38 changes: 16 additions & 22 deletions .github/workflows/ci-keras.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,24 @@ jobs:
fail-fast: false
matrix:
include:
- name: Keras 2.9.0 (TensorFlow 2.9.2 Python 3.9)
- name: Keras 2.13.1 (TensorFlow 2.13.1 Python 3.10)
framework: keras
python: 3.9
tensorflow: 2.9.2
keras: 2.9.0
tf_addons: 0.17.0
- name: TensorFlow-Keras 2.9.2 (Keras 2.9.0 Python 3.9)
framework: kerastf
python: 3.9
tensorflow: 2.9.2
keras: 2.9.0
tf_addons: 0.17.0
- name: Keras 2.10.0 (TensorFlow 2.10.1 Python 3.9)
python: '3.10'
tensorflow: 2.13.1
keras: 2.13.1
tf_addons: 0.19.0
- name: Keras 2.14.0 (TensorFlow 2.14.0 Python 3.10)
framework: keras
python: 3.9
tensorflow: 2.10.1
keras: 2.10.0
tf_addons: 0.18.0
- name: TensorFlow-Keras 2.10.1 (Keras 2.10.0 Python 3.9)
python: '3.10'
tensorflow: 2.14.0
keras: 2.14.0
tf_addons: 0.20.0
- name: TensorFlow-Keras 2.14.0 (Keras 2.14.0 Python 3.10)
framework: kerastf
python: 3.9
tensorflow: 2.10.1
keras: 2.10.0
tf_addons: 0.18.0
python: '3.10'
tensorflow: 2.14.0
keras: 2.14.0
tf_addons: 0.20.0

name: ${{ matrix.name }}
steps:
Expand All @@ -66,7 +60,7 @@ jobs:
sudo apt-get update
sudo apt-get -y -q install ffmpeg libavcodec-extra
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements_test.txt
pip install -q -r <(sed '/^tensorflow/d;/^keras/d;/^tensorflow-addons/d' requirements_test.txt)
pip install tensorflow==${{ matrix.tensorflow }}
pip install keras==${{ matrix.keras }}
pip install tensorflow-addons==${{ matrix.tf_addons }}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci-legacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ jobs:
matrix:
module: [attacks_1, attacks_2, estimators, defences, metrics, art]
include:
- name: legacy (TensorFlow 2.10.1 Keras 2.10.0 PyTorch 1.13.1 scikit-learn 1.1.3 Python 3.9)
- name: legacy (TensorFlow 2.14.0 Keras 2.14.0 PyTorch 1.13.1 scikit-learn 1.1.3 Python 3.9)
framework: legacy
python: 3.9
tensorflow: 2.10.1
keras: 2.10.0
python: '3.10'
tensorflow: 2.14.0
keras: 2.14.0
torch: 1.13.1+cpu
torchvision: 0.14.1+cpu
torchaudio: 0.13.1+cpu
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-lingvo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
sudo apt-get update
sudo apt-get -y -q install ffmpeg libavcodec-extra
python -m pip install --upgrade pip setuptools wheel
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)
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)
pip install scipy==1.5.4
pip install matplotlib==3.3.4
pip install pandas==1.1.5
Expand All @@ -76,7 +76,7 @@ jobs:
pip install tqdm==4.64.1
pip list
- name: Run ${{ matrix.name }} Tests
run: ./run_tests.sh ${{ matrix.framework }}
run: pytest --cov-report=xml --cov=art --cov-append -q -vv tests/estimators/speech_recognition/test_tensorflow_lingvo.py --framework=${{ matrix.framework }} --durations=0
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/ci-mxnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ jobs:
fail-fast: false
matrix:
include:
- name: mxnet (Python 3.8)
- name: mxnet (Python 3.9)
framework: mxnet
python: 3.8
python: 3.9

name: Run ${{ matrix.name }} Tests
steps:
Expand All @@ -45,8 +45,6 @@ jobs:
sudo apt-get update
sudo apt-get -y -q install ffmpeg libavcodec-extra
python -m pip install --upgrade pip setuptools wheel
pip install tensorflow==2.4.1
pip install keras==2.4.3
pip3 install -q -r requirements_test.txt
pip list
- name: Run ${{ matrix.name }} ${{ matrix.module }} Tests
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/ci-pytorch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,9 @@ jobs:
fail-fast: false
matrix:
include:
- name: PyTorch 1.11.0 (Python 3.9)
framework: pytorch
python: 3.8
torch: 1.11.0+cpu
torchvision: 0.12.0+cpu
torchaudio: 0.11.0
- name: PyTorch 1.12.1 (Python 3.9)
framework: pytorch
python: 3.8
python: 3.9
torch: 1.12.1+cpu
torchvision: 0.13.1+cpu
torchaudio: 0.12.1
Expand Down Expand Up @@ -67,8 +61,6 @@ jobs:
sudo apt-get -y -q install ffmpeg libavcodec-extra
python -m pip install --upgrade pip setuptools wheel
pip3 install -r requirements_test.txt
pip install tensorflow==2.10.1
pip install keras==2.10.0
pip install torch==${{ matrix.torch }} -f https://download.pytorch.org/whl/cpu/torch_stable.html
pip install torchvision==${{ matrix.torchvision }} -f https://download.pytorch.org/whl/cpu/torch_stable.html
pip install torchaudio==${{ matrix.torchaudio }} -f https://download.pytorch.org/whl/cpu/torch_stable.html
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/ci-scikit-learn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ jobs:
sudo apt-get -y -q install ffmpeg libavcodec-extra
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements_test.txt
pip install tensorflow==2.10.1
pip install keras==2.10.0
pip install scikit-learn==${{ matrix.scikit-learn }}
pip list
- name: Run Tests
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci-style-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ jobs:
run: |
python -m pip install --upgrade pip setuptools wheel
pip install -q pylint==2.12.2 mypy==0.931 pycodestyle==2.8.0 black==21.12b0
pip install -q -r requirements_test.txt
pip install -q -r <(sed '/^numpy/d;/^pluggy/d;/^tensorflow/d;/^keras/d' requirements_test.txt)
pip install numpy==1.22.4
pip install pluggy==0.13.1
pip install tensorflow==2.7.0
pip install keras==2.7.0
pip install tensorflow==2.13.1
pip install keras==2.13.1
pip install types-six
pip install types-PyYAML
pip install types-setuptools
pip install click==8.0.2
pip install numpy==1.21.6
pip list
- name: pycodestyle
run: pycodestyle --ignore=C0330,C0415,E203,E231,W503 --max-line-length=120 art
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/ci-tensorflow-v1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ jobs:
sudo apt-get update
sudo apt-get -y -q install ffmpeg libavcodec-extra
python -m pip install --upgrade pip setuptools wheel
pip install -q -r <(sed '/^pandas/d;/^scipy/d;/^matplotlib/d;/^xgboost/d;/^jax/d' requirements_test.txt)
pip install -q -r <(sed '/^pandas/d;/^scipy/d;/^matplotlib/d;/^xgboost/d;/^tensorflow/d;/^keras/d;/^jax/d' requirements_test.txt)
pip install pandas==1.3.5
pip install scipy==1.7.2
pip install matplotlib==3.5.3
pip install xgboost==1.6.2
pip install protobuf==3.20.1
pip install tensorflow==${{ matrix.tensorflow }}
pip install keras==${{ matrix.keras }}
pip install jax[cpu]==0.3.25
pip install numpy==1.20
pip list
- name: Run Tests
run: ./run_tests.sh ${{ matrix.framework }}
Expand Down
37 changes: 15 additions & 22 deletions .github/workflows/ci-tensorflow-v2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,34 +28,27 @@ jobs:
fail-fast: false
matrix:
include:
- name: TensorFlow 2.9.2 (Keras 2.9.0 Python 3.9)
- name: TensorFlow 2.13.1 (Keras 2.13.1 Python 3.10)
framework: tensorflow
python: 3.9
tensorflow: 2.9.2
python: '3.10'
tensorflow: 2.13.1
tf_version: v2
keras: 2.9.0
tf_addons: 0.17.1
- name: TensorFlow 2.10.1v1 (Keras 2.10.0 Python 3.9)
keras: 2.13.1
tf_addons: 0.21.0
- name: TensorFlow 2.14.0v1 (Keras 2.14.0 Python 3.10)
framework: tensorflow2v1
python: 3.9
tensorflow: 2.10.1
tf_version: v2
keras: 2.10.0
tf_addons: 0.18.0
- name: TensorFlow 2.10.1 (Keras 2.10.0 Python 3.9)
framework: tensorflow
python: 3.9
tensorflow: 2.10.1
python: '3.10'
tensorflow: 2.14.0
tf_version: v2
keras: 2.10.0
tf_addons: 0.18.0
- name: TensorFlow 2.10.1 (Keras 2.10.0 Python 3.10)
keras: 2.14.0
tf_addons: 0.21.0
- name: TensorFlow 2.14.0 (Keras 2.14.0 Python 3.10)
framework: tensorflow
python: '3.10'
tensorflow: 2.10.1
tensorflow: 2.14.0
tf_version: v2
keras: 2.10.0
tf_addons: 0.18.0
keras: 2.14.0
tf_addons: 0.21.0

name: ${{ matrix.name }}
steps:
Expand All @@ -70,7 +63,7 @@ jobs:
sudo apt-get update
sudo apt-get -y -q install ffmpeg libavcodec-extra
python -m pip install --upgrade pip setuptools wheel
pip install -r requirements_test.txt
pip install -q -r <(sed '/^tensorflow/d;/^keras/d;/^tensorflow-addons/d' requirements_test.txt)
pip install tensorflow==${{ matrix.tensorflow }}
pip install keras==${{ matrix.keras }}
pip install tensorflow-addons==${{ matrix.tf_addons }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/dockerhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ jobs:
with:
images: adversarialrobustnesstoolbox/releases
tags: |
type=raw,value={{branch}}-1.15.2-{{sha}}
type=raw,value={{branch}}-1.16.0-{{sha}}
type=semver,pattern={{version}}
- name: Build and push Docker image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56
with:
context: .
push: true
Expand Down
2 changes: 1 addition & 1 deletion README-cn.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Adversarial Robustness Toolbox (ART) v1.15
# Adversarial Robustness Toolbox (ART) v1.16
<p align="center">
<img src="docs/images/art_lfai.png?raw=true" width="467" title="ART logo">
</p>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Adversarial Robustness Toolbox (ART) v1.15
# Adversarial Robustness Toolbox (ART) v1.16
<p align="center">
<img src="docs/images/art_lfai.png?raw=true" width="467" title="ART logo">
</p>
Expand Down
2 changes: 1 addition & 1 deletion art/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from art import preprocessing

# Semantic Version
__version__ = "1.15.2"
__version__ = "1.16.0"

# pylint: disable=C0103

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import logging
import math
from typing import Optional, Tuple, Union, TYPE_CHECKING
from typing import Any, Optional, Tuple, Union, TYPE_CHECKING

import numpy as np
from tqdm.auto import trange
Expand Down Expand Up @@ -270,15 +270,15 @@ def _get_circular_patch_mask(self, nb_samples: int, sharpness: int = 40) -> "tor
y = np.linspace(-1, 1, diameter)
x_grid, y_grid = np.meshgrid(x, y, sparse=True)
z_grid = (x_grid ** 2 + y_grid ** 2) ** sharpness
image_mask = 1 - np.clip(z_grid, -1, 1)
image_mask: Union[int, np.ndarray[Any, np.dtype[Any]]] = 1 - np.clip(z_grid, -1, 1)
elif self.patch_type == "square":
image_mask = np.ones((diameter, diameter))

image_mask = np.expand_dims(image_mask, axis=0)
image_mask = np.broadcast_to(image_mask, self.patch_shape)
image_mask = torch.Tensor(np.array(image_mask)).to(self.estimator.device)
image_mask = torch.stack([image_mask] * nb_samples, dim=0)
return image_mask
image_mask_tensor = torch.Tensor(np.array(image_mask)).to(self.estimator.device)
image_mask_tensor = torch.stack([image_mask_tensor] * nb_samples, dim=0)
return image_mask_tensor

def _random_overlay(
self,
Expand Down
Loading

0 comments on commit c8f5816

Please sign in to comment.