Skip to content

ShawnXYang/C-GSP

Repository files navigation

Boosting Transferability of Targeted Adversarial Examples via Hierarchical Generative Networks

The code for the paper 'Boosting Transferability of Targeted Adversarial Examples via Hierarchical Generative Networks' in ECCV 2022.

Environment settings and libraries we used in our experiments

This project is tested under the following environment settings:

  • OS: Ubuntu 18.04.4
  • GPU: Geforce 2080 Ti or Tesla P100
  • Python: 3.6
  • PyTorch: >= 1.6.0
  • Torchvision: >= 0.6.0

Running commands

Training

  • Please prepare the ImageNet set, and we adopt the ImageNet training set as our training data.

  • Below we provide running commands for training the conditional generator based on 8 different target classes from a previous same setting.

python train.py --train_dir $DATA_PATH/ImageNet/train --model_type incv3 --eps 16 --batch_size 64 --start-epoch 0 --nz 16 --epochs 10 --label_flag 'N8'
python train.py --train_dir $DATA_PATH/ImageNet/train --model_type res152 --eps 16 --batch_size 64 --start-epoch 0 --nz 16 --epochs 10 --label_flag 'N8'

Download pretrained adversarial generators Generator-Inv3 and Generator-Res152 based on the setting of 8 different classes.

Generating adversarial examples

Below we provide running commands for generating targeted adversarial examples on ImageNet NeurIPS validation set (1k images):

python eval_n8.py --data_dir data/ImageNet1k/ --model_type incv3 --eps 16 --load_path $SAVE_CHECKPOINT

Testing

The above crafted adversarial examples can be directly used for testing different models in torchvision. Besides, you can also adopt Inception ResNet-V2 , ResNet-V2-152 in Tensorflow Slim or Inc-v3ens3, Inc-v3ens4, IncRes-v2ens trained by Ensemble Adversarial Training in Tensorflow.

Below we provide running commands for testing our method against different black-box models:

python inference_n8.py --test_dir $IMAGES_DIR --model_t vgg16

Basic Setting

Besides, we also provide all 20 pretrained adversarial generators Generator-Inv3-1K.zip based on the basic setting of 1K classes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages