This repository contains code to reproduce results from some basic transfer attack methods.
- python >= 3.6.5
- torch >= 1.7.0
- torchvision >= 0.8.2
- pretrainedmodels >= 0.7.4
- numpy >= 1.19.5
- scipy > 1.5.4
- I-FGSM
- TIM
- DIM
- MI-FGSM
- NI-SI-FGSM
- VMI-FGSM
- Patch-wise
- SGM
- Admix
- FIA
- ILA
All pretrained models can be found online: pretrainedmodels
Generate adversairal examples and save them into path ./output/. The running log will be saved in ./output_log. This code is to generate adversarial examples using I-FGSM on all source models separately and validate the attack success rate on all target models.
If the prediction of adversarial example is different from clean one, it will be considered as attacking successfully. And the 'y' used during attack process are the predictions of clean imgaes, so the true labels of images are not necessary.
python3 main.py \
--attack-method i_fgsm \
--source-model xxx xxx xxx (optional) \
--target-model xxx xxx xxx xxx xxx (optinal)
- I-FGSM:
--attack-method i_fgsm - MI-FGSM:
--attack-method mi_fgsm - DI-FGSM:
--attack-method di_fgsm - TI-FGSM:
--attack-method ti_fgsm - combine:
--attack-method mi_di_ti_fgsm
- VMI-FGSM:
--attack-method vi_mi_fgsm - combine:
--attack-method vi_mi_xxx_fgsm
- Patch-wise:
--attack-method pi_fgsm - combine :
--attack-method pi_xxx_fgsm
- SGM:
--attack-method sgm - combine:
--attack-method sgm_xxx
- Admix:
--attack-method admix - combine:
--attack-method admix_xxx
- FIA:
--attack-method fia - combine:
--attack-method fia_xxx