Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to retain original image size? #2

Open
artyres1 opened this issue Oct 30, 2024 · 5 comments
Open

How to retain original image size? #2

artyres1 opened this issue Oct 30, 2024 · 5 comments

Comments

@artyres1
Copy link

@LukasStruppek is there any option to retain the original image size because when I run the attacks, the result is seems to be a resized image?!?

@LukasStruppek
Copy link
Collaborator

Hey,

yes, there should be an option included in the code by calling a script using the option --optimize_original. This should optimize the image before resizing.

Best,
Lukas

@artyres1
Copy link
Author

@LukasStruppek That option is not included in adv1_collision_attack.py file

@LukasStruppek
Copy link
Collaborator

Oh, I see. We only implemented this option for adv2_evasion_attack.py. However, it should be easy to add, just remove the resizing option from the preprocessing step and instead add it before feeding the image to the model. Since resizing operations are differentiable in PyTorch, the optimization should still run as usual. Best way is have a look at the adv2_evasion_attack.py script and how it is implemented there.

Best,
Lukas

@artyres1
Copy link
Author

artyres1 commented Nov 3, 2024

I added it like exactly you said but the resulting image kinda gives an opacity over top of image

https://gist.github.com/artyres1/6d0516d2ebc916c8ad84a742679f7534

This is the code..I use Mac M1 MPS engine..instead cuda..

@LukasStruppek
Copy link
Collaborator

What exactly do you mean by "an opacity over top of image"? You should make sure that the image is correctly saved in the end + that the updates are also correctly applied to the correct image tensor. Maybe check which tensor is optimized by the optimizer and use a debugger for localizing the problem. I currently do not have the capacity to implement this functionality into our code, I am sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants