Commit ab0bc76f authored by Pavlo Beylin's avatar Pavlo Beylin
Browse files

Fix obfuscation position.

parent 9282a3ad
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment