Skip to content

wangfrombupt/adversarial_detector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

New Adversarial Image Detection Based on Sentiment Analysis

This project is for the paper "New Adversarial Image Detection Based on Sentiment Analysis".Some codes are from Mahalanobis detector.

Preliminaries

It is tested under Ubuntu Linux 18.04 and Python 3.7 environment, and requries Pytorch package to be installed:

We use the following two libraries to generate adversarial examples.

Training Classifier

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

Detecting Adversarial Samples

0. Generate adversarial samples:

# model: ResNet, dataset: CIFAR-10, adversarial attack: FGSM, gpu: 0
python adv_generate.py --dataset cifar10 --net_type resnet --adv_type FGSM --gpu 0

1. Train detector:

# model: ResNet, dataset: CIFAR-10, adversarial attack: FGSM, gpu: 0
python train_detector.py --dataset cifar10 --adv_type FGSM --gpu 0

2. Visualization

python tsne.py --dataset cifar10 -adv_type FGSM

Evaluating on PGD White Box Attack

0. Generate original adversarial samples:

# 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

1. Train original detector:

# 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

2. Adversarial training on White Box Attack samples:

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

3. Test the robustness

# 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages