Skip to content

Commit

Permalink
Merge branch 'dev_1.16.0' into huggingface_integration
Browse files Browse the repository at this point in the history
  • Loading branch information
beat-buesser committed Sep 18, 2023
2 parents fe91036 + c048a5c commit 3d4fe0d
Show file tree
Hide file tree
Showing 40 changed files with 35,213 additions and 3,512 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/dockerhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ jobs:
uses: actions/checkout@v3

- name: Log in to Docker Hub
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934
with:
images: adversarialrobustnesstoolbox/releases
tags: |
type=raw,value={{branch}}-1.15.1-{{sha}}
type=raw,value={{branch}}-1.15.2-{{sha}}
type=semver,pattern={{version}}
- name: Build and push Docker image
uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09
with:
context: .
push: true
Expand Down
1 change: 1 addition & 0 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ Please describe the tests that you ran to verify your changes. Consider listing
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] My changes have been tested using both CPU and GPU devices
5 changes: 2 additions & 3 deletions README-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
</p>
<br />

![Continuous Integration](https://github.com/Trusted-AI/adversarial-robustness-toolbox/workflows/Continuous%20Integration/badge.svg)
![CodeQL](https://github.com/Trusted-AI/adversarial-robustness-toolbox/workflows/CodeQL/badge.svg)
[![Documentation Status](https://readthedocs.org/projects/adversarial-robustness-toolbox/badge/?version=latest)](http://adversarial-robustness-toolbox.readthedocs.io/en/latest/?badge=latest)
[![PyPI](https://badge.fury.io/py/adversarial-robustness-toolbox.svg)](https://badge.fury.io/py/adversarial-robustness-toolbox)
Expand All @@ -13,8 +12,8 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/adversarial-robustness-toolbox)](https://pypi.org/project/adversarial-robustness-toolbox/)
[![slack-img](https://img.shields.io/badge/chat-on%20slack-yellow.svg)](https://ibm-art.slack.com/)
[![Downloads](https://pepy.tech/badge/adversarial-robustness-toolbox)](https://pepy.tech/project/adversarial-robustness-toolbox)
[![Downloads](https://pepy.tech/badge/adversarial-robustness-toolbox/month)](https://pepy.tech/project/adversarial-robustness-toolbox)
[![Downloads](https://static.pepy.tech/badge/adversarial-robustness-toolbox)](https://pepy.tech/project/adversarial-robustness-toolbox)
[![Downloads](https://static.pepy.tech/badge/adversarial-robustness-toolbox/month)](https://pepy.tech/project/adversarial-robustness-toolbox)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/5090/badge)](https://bestpractices.coreinfrastructure.org/projects/5090)

<p align="center">
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
</p>
<br />

![Continuous Integration](https://github.com/Trusted-AI/adversarial-robustness-toolbox/workflows/Continuous%20Integration/badge.svg)
![CodeQL](https://github.com/Trusted-AI/adversarial-robustness-toolbox/workflows/CodeQL/badge.svg)
[![Documentation Status](https://readthedocs.org/projects/adversarial-robustness-toolbox/badge/?version=latest)](http://adversarial-robustness-toolbox.readthedocs.io/en/latest/?badge=latest)
[![PyPI](https://badge.fury.io/py/adversarial-robustness-toolbox.svg)](https://badge.fury.io/py/adversarial-robustness-toolbox)
Expand All @@ -13,8 +12,8 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/adversarial-robustness-toolbox)](https://pypi.org/project/adversarial-robustness-toolbox/)
[![slack-img](https://img.shields.io/badge/chat-on%20slack-yellow.svg)](https://ibm-art.slack.com/)
[![Downloads](https://pepy.tech/badge/adversarial-robustness-toolbox)](https://pepy.tech/project/adversarial-robustness-toolbox)
[![Downloads](https://pepy.tech/badge/adversarial-robustness-toolbox/month)](https://pepy.tech/project/adversarial-robustness-toolbox)
[![Downloads](https://static.pepy.tech/badge/adversarial-robustness-toolbox)](https://pepy.tech/project/adversarial-robustness-toolbox)
[![Downloads](https://static.pepy.tech/badge/adversarial-robustness-toolbox/month)](https://pepy.tech/project/adversarial-robustness-toolbox)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/5090/badge)](https://bestpractices.coreinfrastructure.org/projects/5090)

[中文README请按此处](README-cn.md)
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.1"
__version__ = "1.15.2"

# pylint: disable=C0103

Expand Down
15 changes: 15 additions & 0 deletions art/attacks/attack.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ def set_params(self, **kwargs) -> None:
for key, value in kwargs.items():
if key in self.attack_params:
setattr(self, key, value)
else:
raise ValueError(f'The attribute "{key}" cannot be set for this attack.')
self._check_params()

def _check_params(self) -> None:
Expand Down Expand Up @@ -186,6 +188,19 @@ def is_estimator_valid(estimator, estimator_requirements) -> bool:
return False
return True

def __repr__(self):
"""
Returns a string describing the attack class and attack_params
"""
param_str = ""
for param in self.attack_params:
if hasattr(self, param):
param_str += f"{param}={getattr(self, param)}, "
elif hasattr(self, "_attack"):
if hasattr(self._attack, param):
param_str += f"{param}={getattr(self._attack, param)}, "
return f"{type(self).__name__}({param_str})"


class EvasionAttack(Attack):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,10 @@ def _random_overlay(
name=None,
)

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

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

image_mask = tf.pad( # pylint: disable=E1123
Expand Down Expand Up @@ -323,10 +323,10 @@ def _random_overlay(

if mask is None:
padding_after_scaling_h = (
self.image_shape[self.i_h] - im_scale * padded_patch.shape[self.i_h + 1]
self.image_shape[self.i_h] - im_scale * padded_patch.shape.as_list()[self.i_h + 1]
) / 2.0
padding_after_scaling_w = (
self.image_shape[self.i_w] - im_scale * padded_patch.shape[self.i_w + 1]
self.image_shape[self.i_w] - im_scale * padded_patch.shape.as_list()[self.i_w + 1]
) / 2.0
x_shift = np.random.uniform(-padding_after_scaling_w, padding_after_scaling_w)
y_shift = np.random.uniform(-padding_after_scaling_h, padding_after_scaling_h)
Expand Down
Loading

0 comments on commit 3d4fe0d

Please sign in to comment.