Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
doc
 
 
 
 
 
 
 
 
 
 
 
 

README.md

PatchGuard: Provable Defense against Adversarial Patches Using Masks on Small Receptive Fields

By Chong Xiang, Arjun Nitin Bhagoji, Vikash Sehwag, Prattek Mittal

Code for paper "PatchGuard: Provable Defense against Adversarial Patches Using Masks on Small Receptive Fields" arXiv

defense overview pipeline

Requirements

The code is tested with Python 3.6 and PyTorch 1.3.0. The complete list of required packages are available in requirement.txt, and can be installed with pip install -r requirement.txt. The code should be compatible with other versions of packages.

Files

├── README.md                        #this file 
├── requirement.txt                  #required package
├── example_cmd.sh                   #example command to run the code
├── mask_bn_imagenet.py              #mask-bn for imagenet(te)
├── mask_bn_cifar.py                 #mask-bn for cifar
├── mask_ds_imagenet.py              #mask-ds for imagenet(te)
├── mask_ds_cifar.py                 #mask-ds for cifar
├── nets
|   ├── bagnet.py                    #modified bagnet model for mask-bn
|   ├── resnet.py                    #modified resnet model for mask-bn
|   ├── dsresnet_imgnt.py            #ds-resnet-50 for imagenet(te)
|   └── dsresnet_cifar.py            #ds-resnet-18 for cifar
├── utils
|   ├── defense_utils.py             #utils for different defenses
|   ├── normalize_utils.py           #utils for nomrlize images stored in numpy array (unused in the paper)
|   ├── cutout.py                    #utils for CUTOUT training (unused)
|   └── progress_bar.py              #progress bar (used in train_cifar.py)
| 
├── misc                             #useful scripts; move them to the main directory for execution
|   ├── test_acc_imagenet.py         #test clean accuracy of resnet/bagnet on imagenet(te); support clipping, median operations
|   ├── test_acc_cifar.py            #test clean accuracy of resnet/bagnet on cifar; support clipping, median operations
|   ├── train_imagenet.py            #train resnet/bagnet for imagenet
|   ├── train_imagenette.py          #train resnet/bagnet for imagenette
|   ├── train_cifar.py               #train resnet/bagnet for cifar
|   ├── patch_attack_imagenet.py     #empirically attack resnet/bagnet trained on imagenet(te)
|   ├── patch_attack_cifar.py        #empirically attack resnet/bagnet trained on cifar
|   ├── PatchAttacker.py             #untargeted adversarial patch attack 
|
└── checkpoints                      #directory for checkpoints
    ├── README.md                    #details of each checkpoint
    └── ...                          #model checkpoints

Datasets

Usage

  • See Files for details of each file.

  • Download data in Datasets and specify the data directory to the code.

  • (optional) Download checkpoints from Google Drive link and move them to checkpoints.

  • See example_cmd.sh for example commands for running the code.

If anything is unclear, please open an issue or contact Chong Xiang (cxiang@princeton.edu).

Notes

  • 10/17/2020 - Updated old checkpoints. Please download the new checkpoints from Google Drive link for better model performance. Note that checkpoints for 1000-class ImageNet are also available now. Also a few minor updates to the source code.
  • 08/01/2020 - A major update to defense_utils.py. Please check the latest version of paper on arXiv and use the new provable analysis in defense_utils.py.

Related Repositories

About

Code for paper "PatchGuard: Provable Defense against Adversarial Patches Using Masks on Small Receptive Fields"

Resources

License

Releases

No releases published

Packages

No packages published
You can’t perform that action at this time.