Skip to content

Commit af90a12

Browse files
committed
Make SNAL test robust
Signed-off-by: Beat Buesser <[email protected]>
1 parent b15eba3 commit af90a12

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tests/attacks/test_steal_now_attack_later.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ def collect_patches_from_images(detector, imgs):
6666
pos_matrix[:, 2] = torch.clamp_max(pos_matrix[:, 2], imgs.shape[3])
6767
pos_matrix[:, 3] = torch.clamp_max(pos_matrix[:, 3], imgs.shape[2])
6868
for pos_m in pos_matrix:
69+
if pos_m[3] - pos_m[1] == 0 or pos_m[2] - pos_m[0] == 0:
70+
continue
6971
p = imgs[i, :, pos_m[1] : pos_m[3], pos_m[0] : pos_m[2]]
7072
patch.append(p.to(detector.device))
7173

@@ -165,7 +167,7 @@ def _loader(path):
165167
attack = SNAL(
166168
object_detector,
167169
eps=16.0 / 255.0,
168-
max_iter=10,
170+
max_iter=5,
169171
num_grid=10,
170172
candidates=candidates_list,
171173
collector=collect_patches_from_images,

0 commit comments

Comments
 (0)