This repository is the official implementation of Adversarial Purification with One-Step Guided Diffusion Model
To install requirements:
pip install -r requirements.txt
If you want to enable mixed-precision computation using the apex
library, please install the apex
library.
git clone https://github.com/NVIDIA/apex
cd apex
pip3 install -v --no-cache-dir ./
(Maybe) Solution for 'IndexError: tuple index out of range': NVIDIA/apex#694 (comment)
You can download pretrained models here:
- DDPM on ImageNet https://github.com/openai/guided-diffusion
- checkpoint 256x256_diffusion_uncond.pt
- DDPM on Cifar10 https://github.com/openai/improved-diffusion
- checkpoint cifar10_uncond_50M_500K.pt
To evaluate my model on Cifar10, run:
python3 -m torch.distributed.launch --nproc_per_node=4 run.py --mode pgd --T 400 --scale 50000
To evaluate my model on ImageNet, run:
python3 -m torch.distributed.launch --nproc_per_node=4 run.py --mode pgd --T 100 --scale 2000 --model resnet152
This implementation is based on / inspired by: