e-lab / torch-toolbox

A collection of snippets and libraries for Torch from e-Lab
https://engineering.purdue.edu/elab/
199 stars 64 forks source link

Save the adversarial example image and get the difference image #14

Closed newwhitecheng closed 8 years ago

newwhitecheng commented 8 years ago

Hello, I'm recently playing your adversarial example code. Everything works well, but I'm wondering how to save the adversarial example and how to get the difference image. As shown in the following one. I'm very new to torch, any advice will help.

jhjin commented 8 years ago

Now qlua example.lua should do that job for you.

newwhitecheng commented 8 years ago

Sorry for asking again, I use the code you update, but it still can not save the image correctly. I add the following code to save image. image.save('imag_adv.png',img_adv) I get a image which is very different from the original image The first one is the original image. The second image is the one with adversarial. I don't know how to get a adversarial image saving correctly. Do you have any idea? thank you!! car imag_adv

jhjin commented 8 years ago

You need to denormalize the image before saving. Please see https://github.com/e-lab/torch-toolbox/commit/b9a90424984b142614003afcfaaa8efcf0c8b5b6 .