Home

Awesome

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:

Running commands

Training

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-v3<sub>ens3</sub>, Inc-v3<sub>ens4</sub>, IncRes-v2<sub>ens</sub> 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.