This is a repository for storing code for course project. The code was adapted from the official implementation of the paper Diffusion Models for Adversarial Purification.
- 64-bit Python 3.8.
- CUDA=11.0 must be installed first.
ImageNet data should be put in ./dataset/imagenet_lmdb/val/
and categorized into different classes in different subfolders.
convert the ImageNet dataset to LMDB.
There is no need to download CIFAR-10 separately.
For the pre-trained diffusion models, you need to first download them from the following links:
- Score SDE for
CIFAR-10: (
vp/cifar10_ddpmpp_deep_continuous
: download link) - Guided Diffusion for
ImageNet: (
256x256 diffusion unconditional
: download link)
For the pre-trained classifiers, most of them do not need to be downloaded separately, except for
resnet-50
on CIFAR-10: download link
Note that you have to put all the pretrained models in the pretrained
directory.
bash cifar10_L2_rand.sh bash imagenet_L2_rand.sh
bash imagenet_Linf_rand.sh
Please check the LICENSE file. This work may be used non-commercially, meaning for research or evaluation purposes only. For business inquiries, please contact [email protected].