From ab0bc76f30c2efd2474363d477eacb14aa1305cc Mon Sep 17 00:00:00 2001 From: lu60ruhy <pavlo.beylin@fau.de> Date: Wed, 22 Sep 2021 15:45:38 +0200 Subject: [PATCH] Fix obfuscation position. --- patch_transformer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/patch_transformer.py b/patch_transformer.py index 9105bd15..ddb3390f 100644 --- a/patch_transformer.py +++ b/patch_transformer.py @@ -109,9 +109,10 @@ class PatchTransformer(nn.Module): if obfuscate: max_x = adv_patch.shape[1] max_y = adv_patch.shape[2] - obfuscation_root = [int(random.random() * max_x), int(random.random() * max_y)] obfuscation_shape = [int(random.random() * max_obs_part * max_x), int(random.random() * max_obs_part * max_y)] + obfuscation_root = [int(random.random() * (max_x-obfuscation_shape[0])), + int(random.random() * (max_y-obfuscation_shape[1]))] adv_patch[:, obfuscation_root[0]:obfuscation_root[0] + obfuscation_shape[0], obfuscation_root[1]:obfuscation_root[1] + obfuscation_shape[1]] = 0.001 -- GitLab