GithubHelp home page GithubHelp logo

qilong-zhang / pytorch_universal-adversarial-perturbation Goto Github PK

View Code? Open in Web Editor NEW
53.0 2.0 5.0 294 KB

A PyTorch implementation of universal adversarial perturbation (UAP) which is more easy to understand and implement.

Python 100.00%
imagenet-dataset

pytorch_universal-adversarial-perturbation's Introduction

Python

A PyTorch implementation of universal adversarial perturbation which is more easy to understand and implement.
Refer to the original tensorflow code.

Usage

Dataset

training dataset(Choose 10 imgs for each category)
Validation dataset

All you need to do is unzip the downloaded file, and the results are as follows:

Get started

To get started, you should first Change the training data file path (in search.py) to yours. For example

X = ImagetNet('../data/ILSVRC2012_train/pick_image/', 1000, 10, transforms = transform)

If your testing data path (in search.py) is testing_data_path, then you should write

val_loader = torch.utils.data.DataLoader(ImageFolder(testing_data_path, transforms = transform)

It should be noted that I use two different ways to input our data (i.e., X and val_loader), the main reason I didn't make it consistent is because I wanted to show you a variety of ways to write it. Hope it doesn't bother you.

After you modify all the path, then you can run the following demo code

python search.py

Result

I tested my code for googlenet and resnet-152 with \epsilon = 10 (L_inf norm), and after 5 epoch, the result accuracy on validation set was ~78% and ~84% respectively. It is similar with the result report in paper.

Reference

[1] S. Moosavi-Dezfooli*, A. Fawzi*, O. Fawzi, P. Frossard: Universal adversarial perturbations, CVPR 2017

pytorch_universal-adversarial-perturbation's People

Contributors

qilong-zhang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pytorch_universal-adversarial-perturbation's Issues

Attention before using!!!

Firstly, modify the theta to 0.2 in universal_pert.py, otherwise, the algorithm will fall into an endless loop (the default setting set the target fooling to 98%).
Secondly, assign the parameters "epsilon" the 47-th line in search.py to xi, like
v = universal_perturbation(X, val_loader, net, xi=epsilon)

The location of Normalization is confusing

I wonder why put normalization in line 20 instead of simply putting it to the last of transform (the location is shown in the green box)?
The result becomes wrong when I put the normalization into transform. It really confuses me.
Could you please answer the question? Thanks very much!

image

test and npy

I can't get the same result from your code, I think maybe my test method is different from yours.
Can you upload the test code and the npy file (googlenet) of your experiment, especially how to add the npy file to the picture.

dataset

Can you post the Baidu network disk link of the training set (already selected 10 images per category)? The original data training set is too large. Thank you very much

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.