Coder Social home page Coder Social logo

huangwenjing1027 / nag Goto Github PK

View Code? Open in Web Editor NEW

This project forked from val-iisc/nag

0.0 0.0 0.0 4.7 MB

Tensorflow implementation of NAG : Network for adversary generation [CVPR 2018]

Home Page: http://val.serc.iisc.ernet.in/nag/

Python 99.91% Shell 0.09%

nag's Introduction

NAG - Network for Adversary Generation

Code for the paper NAG - Network for Adversary Generation.

Konda Reddy Mopuri*, Utkarsh Ojha*, Utsav Garg, R. Venkatesh Babu.

CVPR 2018

This work is an attempt to explore the manifold of perturbations that can cause CNN based classifiers to behave absurdly. At present, this repository provides the facility to train the generator that can produce perturbations to fool VGG F, VGG 16, VGG 19, GoogleNet, CaffeNet, ResNet 50, ResNet 152. The generator architecture has been modified from here.

Architecture

Sample perturbations

Generalizability of universal adversarial perturbations

The table below shows the fooling rate achieved for different networks. The rows represent the network for which the perturbation is crafted, and the column indicates the netwrok on which the strength of perturbation is tested. Testing is done on the 50k validation set of ILSVRC.

Dependencies

Python 2.7.1, Tensorflow 1.0.1, h5py

Setting up the dataset

Our major results have been obtained by training our model on a dataset consisting of 10k images, 10 random images from each of the 1000 classes from ILSVRC dataset. Testing has been done on the standard 50k validation images of ILSVRC. To speed up the training and testing of the model, data in .hdf5 format has been used. utilities/ folder provides the relevant scripts to convert a folder of images in a suitable format (.jpg, .png etc.) into a single .hdf5 file.

For example, train_hdf5.py does the necessary pre-processing on a folder of images and creates ilsvrc_train.hdf5 file.

Caution: .hdf5 files created will be of large sizes. ilsvrc_test.hdf5 will be ~30gb.

Training your own generator

Once the .hdf5 files are done, we can begin training the generator for a given classifier. Set the target classifier in classify.py (currently the default network is ResNet 50) from any one of the mentioned networks.

For training the generator, run: python train_generator.py The code saves the evolving perturbations by saving them in running_perturbatin.npy in case one wants to visualize them.

Testing on clean images

Run python uap_generate.py to obtain the perturbations from the saved generator in the form of either .png images or .npy files. Simple add the perturbations to the clean images and test their classification results of clean and corrupted image using classify_image.py . As a word of caution, make sure you set the classifier in classify_image.py according to the loaded checkpoint file in uap_generate.py, unless you want to check the transferability of perturbations.

Sample fooling

Reference

@inproceedings{nag-cvpr-2018,
  title={NAG: Network for Adversary Generation},
  author={Mopuri, Konda Reddy and Ojha, Utkarsh and Garg, Utsav and Babu, R Venkatesh},
 booktitle = {Proceedings of the IEEE Computer Vision and Pattern Recognition ({CVPR})},
 year = {2018}
}

Contact Utkarsh Ojha in case you have any questions.

nag's People

Contributors

utkarshojha avatar

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.