Hyperparticle / one-pixel-attack-keras

Keras implementation of "One pixel attack for fooling deep neural networks" using differential evolution on Cifar10 and ImageNet
https://arxiv.org/abs/1710.08864
MIT License
1.22k stars 214 forks source link

Download ImageNet images automatically #3

Open Hyperparticle opened 6 years ago

Hyperparticle commented 6 years ago

Modify 2_one-pixel-attack-imagenet.ipynb to download a sample subset of ImageNet files with appropriate labels. The files should be preprocessed as to be ready for the attack.

CloudFlyCN commented 6 years ago

Hi,I also download a sample subset of ImageNet files by the given file 'imagenet_urls.txt', but some problems to be found:

  1. some pics' urls has been invalid
  2. the model cannot recognize the image correctly even without attack... Thanks for your attention!
Hyperparticle commented 6 years ago

imagenet_urls.txt is just a sample file with some example URLs and is by no means finished or ideal for testing.

  1. About the URLs being invalid: yes, this is a very common occurrence in the ImageNet files, and there should be additional logic that simply ignores images that fail to download.
  2. Make sure you are processing the images similar to what is shown in the existing Python code. Also, note that the current model (keras.applications.MobileNet) is not particularly accurate, so you may get inaccurate results on a small sample image set.

It would also be nice if we had more URLs. This can be accomplished by downloading the URL files from the ImageNet database and sampling them randomly. Something under 5 MB of URLs could suffice. The labels for each of the images would also need to be stored somehow.

Thanks for checking it out. If you have any more questions I'd be happy to answer.

CloudFlyCN commented 6 years ago

I am very glad to get your reply so soon! Coincidently,I have the same idea to refine the valid URLs by adding some logic and it works,but it comes out a new problem that some label(s)(e.g."n09337253") are not within the ImageNet1000.As the result,I finally just download very few images successfully.

Hyperparticle commented 6 years ago

Finding a good set of URLs with valid labels would be necessary. Unfortunately, I have not found any easy automated tools to do this, so it needs some manual work. Send a pull request if you are able.