Giter Club home page Giter Club logo

tremba's Introduction

Black-Box Adversarial Attack with Transferable Model-based Embedding

This repository contains the code for reproducing the experimental results of attacking Imagenet dataset, of our submission: Black-Box Adversarial Attack with Transferable Model-based Embedding.

Requirements

Python packages: numpy, pytorch, torchvision.

The code is tested under Ubuntu 18.04, Python 3.7.1, PyTorch 1.1.0, NumPy 1.16.4, torchvision 0.3.0, CUDA 10.0 and cuDNN 7.4.2.

Please download the weight of the generator from https://drive.google.com/file/d/1IvqcYTnIjqPK7oZU-UnVzjfdxdtV63jk/view?usp=sharing and extract it in the root folder;

Please download the test images from https://drive.google.com/file/d/1Gs_Rw-BDwuEn5FcWigYP5ZM9StCufZdP/view?usp=sharing and extract it under dataset/Imagenet

Reproducing the results

Imagenet targeted attack:

For reproducing the result of attacking class 0 (tench), you can run the code using the The results can be reproduced using the following command:

python attack.py --device cuda:0 --config config/attack_target.json --model_name [VGG19|Resnet34| Densenet121|Mobilenet]

If you want to attack another class, please change in target_class and generator_name in the config/attack_target.json. Here is the list of the target_class and its corresponding generator_name

target_class generator_name
20 (Dipper) Imagenet_VGG16_Resnet18_Squeezenet_Googlenet_target_20
40 (American chameleon) Imagenet_VGG16_Resnet18_Squeezenet_Googlenet_target_40
60 (Night snake) Imagenet_VGG16_Resnet18_Squeezenet_Googlenet_target_60
80 (Ruffed grouse) Imagenet_VGG16_Resnet18_Squeezenet_Googlenet_target_80
100 (Black swan) Imagenet_VGG16_Resnet18_Squeezenet_Googlenet_target_100

Imagenet un-targeted attack:

For reproducing the result of un-targeted, you can run the code using the The results can be reproduced using the following command:

python attack.py --device cuda:0 --config config/attack_untarget.json --model_name [VGG19|Resnet34|Densenet121|Mobilenet]

Attack defense model:

Please download the weight of the Imagenet model from https://drive.google.com/file/d/1nNRhzijZnHjHJ6SkFVTaFxDO-YnxiAhZ/view?usp=sharing and extract it in the root folder;

For reproducing the result of attacking defense model, you can run the code using the The results can be reproduced using the following comman d:

python attack.py --device cuda:0 --config [config/attack_defense_untarget.json|config/attack_defense_OSP_untarget.json] 

About the attack algorithm, config/attack_defense_untarget.json corresponds to TREMBA and config/attack_defense_OSP_untarget.json corresponds to TREMBA$_{OSP}$.

The result in store in the output folder with npy format recording the queries need to attack each image. The image with query larger than 50000 means the attack is failed.

Training the Generator

Please download the train images from https://drive.google.com/file/d/1R_aC1onf0Yv77cL0OHjJ2VeXjrIbgKXb/view?usp=sharing and extract it under dataset/Imagenet

We need two gpus to train the generator for un-targeted and targeted attack, four gpus to train the generator for attacking defense model.

For training the generator for un-targeted and targeted attack, the command is

python train_generator.py --config [config/train_untarget.json|config/train_target.json] --device 0 1

config/train_untarget.json corresponds the generator for un-targeted attack and config/train_target.json corresponds the generator for un-targeted attack. You may change to target_class in config/train_target.json to train the generator for attacking different class.

For training the generator for the defened network, the command is

python train_generator.py --config config/train_defense_untarget.json --device 0 1 2 3

The weight for generator will be stored in G_weight

tremba's People

Contributors

transembedba avatar

Watchers

James Cloos avatar  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.