diff --git a/patch_transformer.py b/patch_transformer.py index 9105bd15283d356a12ed7fed1d35a9c72ba14cf2..ddb3390fcafc9c17967e519295771c3792417688 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