This project is for the paper "New Adversarial Image Detection Based on Sentiment Analysis".Some codes are from Mahalanobis detector.
It is tested under Ubuntu Linux 18.04 and Python 3.7 environment, and requries Pytorch package to be installed:
- Pytorch v1.10: Only GPU version is available.
We use the following two libraries to generate adversarial examples.
we train ResNet-34 and InceptionV3 on CIFAR-10, CIFAR-100 and SVHN.
# model: ResNet-34, dataset: CIFAR-10, gpu: 0
python train.py --dataset cifar10 --net_type resnet --gpu 0
# model: InceptionV3, dataset: CIFAR-10, gpu: 0
python train.py --dataset cifar10 --net_type inception --gpu 0
# model: ResNet, dataset: CIFAR-10, adversarial attack: FGSM, gpu: 0
python adv_generate.py --dataset cifar10 --net_type resnet --adv_type FGSM --gpu 0
# model: ResNet, dataset: CIFAR-10, adversarial attack: FGSM, gpu: 0
python train_detector.py --dataset cifar10 --adv_type FGSM --gpu 0
python tsne.py --dataset cifar10 -adv_type FGSM
# model: ResNet, dataset: CIFAR-10, adversarial attack: PGD-20, gpu: 0
python adv_generate.py --dataset cifar10 --net_type resnet --adv_type PGD-20 --gpu 0
# model: ResNet, dataset: CIFAR-10, adversarial attack: PGD-20, gpu: 0
python train_detector.py --dataset cifar10 --net_type resnet --adv_type PGD-20 --gpu 0
cd white_box
# dataset: CIFAR-10, model: ResNet, original attack: PGD-20, gpu: 0
python adv_train.py --dataset cifar10 --adv_type PGD-20 --gpu 0
# dataset: CIFAR-10, model: ResNet, original attack: PGD-20, gpu: 0
# white box attack: pgd-iter-20, pgd-combine-20, resume_epoch: 2
python test_robust.py --dataset cifar10 --adv_type PGD-20 --gpu 0 --resume 2