Skip to content

Commit 6f96a43

Browse files
authored
Merge branch 'dev_1.15.1' into update_trades
2 parents 2338a08 + 509e223 commit 6f96a43

20 files changed

+1517
-606
lines changed

.github/workflows/dockerhub.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
with:
3636
images: adversarialrobustnesstoolbox/releases
3737
tags: |
38-
type=raw,value={{branch}}-1.14.1-{{sha}}
38+
type=raw,value={{branch}}-1.15.0-{{sha}}
3939
type=semver,pattern={{version}}
4040
4141
- name: Build and push Docker image

README-cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Adversarial Robustness Toolbox (ART) v1.14
1+
# Adversarial Robustness Toolbox (ART) v1.15
22
<p align="center">
33
<img src="docs/images/art_lfai.png?raw=true" width="467" title="ART logo">
44
</p>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Adversarial Robustness Toolbox (ART) v1.14
1+
# Adversarial Robustness Toolbox (ART) v1.15
22
<p align="center">
33
<img src="docs/images/art_lfai.png?raw=true" width="467" title="ART logo">
44
</p>

art/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from art import preprocessing
1313

1414
# Semantic Version
15-
__version__ = "1.14.1"
15+
__version__ = "1.15.0"
1616

1717
# pylint: disable=C0103
1818

art/attacks/evasion/auto_conjugate_gradient.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,9 @@ def generate(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> n
463463

464464
# self.eta = np.full((self.batch_size, 1, 1, 1), 2 * self.eps_step).astype(ART_NUMPY_DTYPE)
465465
_batch_size = x_k.shape[0]
466-
eta = np.full((_batch_size, 1, 1, 1), self.eps_step).astype(ART_NUMPY_DTYPE)
466+
eta = np.full((_batch_size,) + (1,) * len(self.estimator.input_shape), self.eps_step).astype(
467+
ART_NUMPY_DTYPE
468+
)
467469
self.count_condition_1 = np.zeros(shape=(_batch_size,))
468470
gradk_1 = np.zeros_like(x_k)
469471
cgradk_1 = np.zeros_like(x_k)
@@ -650,4 +652,4 @@ def get_beta(gradk, gradk_1, cgradk_1):
650652
betak = -(_gradk * delta_gradk).sum(axis=1) / (
651653
(_cgradk_1 * delta_gradk).sum(axis=1) + np.finfo(ART_NUMPY_DTYPE).eps
652654
)
653-
return betak.reshape((_batch_size, 1, 1, 1))
655+
return betak.reshape((_batch_size,) + (1,) * (len(gradk.shape) - 1))

art/attacks/evasion/auto_projected_gradient_descent.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,9 @@ def generate(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> n
458458

459459
# modification for image-wise stepsize update
460460
_batch_size = x_k.shape[0]
461-
eta = np.full((_batch_size, 1, 1, 1), self.eps_step).astype(ART_NUMPY_DTYPE)
461+
eta = np.full((_batch_size,) + (1,) * len(self.estimator.input_shape), self.eps_step).astype(
462+
ART_NUMPY_DTYPE
463+
)
462464
self.count_condition_1 = np.zeros(shape=(_batch_size,))
463465

464466
for k_iter in trange(self.max_iter, desc="AutoPGD - iteration", leave=False, disable=not self.verbose):

art/attacks/poisoning/perturbations/image_perturbations.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from typing import Optional, Tuple
2222

2323
import numpy as np
24-
from PIL import Image
2524

2625

2726
def add_single_bd(x: np.ndarray, distance: int = 2, pixel_value: int = 1) -> np.ndarray:
@@ -112,6 +111,8 @@ def insert_image(
112111
:param blend: The blending factor
113112
:return: Backdoored image.
114113
"""
114+
from PIL import Image
115+
115116
n_dim = len(x.shape)
116117
if n_dim == 4:
117118
return np.array(

art/defences/detector/poison/clustering_analyzer.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,9 @@ def analyze_by_size(self, separated_clusters: List[np.ndarray]) -> Tuple[np.ndar
6868
all_assigned_clean = []
6969
nb_classes = len(separated_clusters)
7070
nb_clusters = len(np.unique(separated_clusters[0]))
71-
summary_poison_clusters: np.ndarray = np.zeros((nb_classes, nb_clusters))
71+
summary_poison_clusters: np.ndarray = np.zeros((nb_classes, nb_clusters), dtype=object)
7272

7373
for i, clusters in enumerate(separated_clusters):
74-
7574
# assume that smallest cluster is poisonous and all others are clean
7675
sizes = np.bincount(clusters)
7776
total_dp_in_class = np.sum(sizes)
@@ -98,8 +97,8 @@ def analyze_by_size(self, separated_clusters: List[np.ndarray]) -> Tuple[np.ndar
9897

9998
report["Class_" + str(i)] = report_class
10099

101-
report["suspicious_clusters"] = report["suspicious_clusters"] + np.sum(summary_poison_clusters).item()
102-
return np.asarray(all_assigned_clean), summary_poison_clusters, report
100+
report["suspicious_clusters"] = report["suspicious_clusters"] + np.sum(summary_poison_clusters)
101+
return np.asarray(all_assigned_clean, dtype=object), summary_poison_clusters, report
103102

104103
def analyze_by_distance(
105104
self,
@@ -187,7 +186,7 @@ def analyze_by_distance(
187186
assigned_clean = self.assign_class(clusters, clean_clusters, np.array(poison_clusters))
188187
all_assigned_clean.append(assigned_clean)
189188

190-
all_assigned_clean_array = np.asarray(all_assigned_clean)
189+
all_assigned_clean_array = np.asarray(all_assigned_clean, dtype=object)
191190
return all_assigned_clean_array, summary_poison_clusters, report
192191

193192
def analyze_by_relative_size(

art/defences/preprocessor/spatial_smoothing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from typing import Optional, Tuple
3131

3232
import numpy as np
33-
from scipy.ndimage.filters import median_filter
33+
from scipy.ndimage import median_filter
3434

3535
from art.utils import CLIP_VALUES_TYPE
3636
from art.defences.preprocessor.preprocessor import Preprocessor

art/estimators/object_detection/pytorch_object_detector.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,10 @@ def _preprocess_and_convert_inputs(
219219

220220
# Set gradients
221221
if not no_grad:
222-
x_tensor.requires_grad = True
222+
if x_tensor.is_leaf:
223+
x_tensor.requires_grad = True
224+
else:
225+
x_tensor.retain_grad()
223226

224227
# Apply framework-specific preprocessing
225228
x_preprocessed, y_preprocessed = self._apply_preprocessing(x=x_tensor, y=y_tensor, fit=fit, no_grad=no_grad)

0 commit comments

Comments
 (0)