This repo contains the code for the paper Generating Natural Adversarial Examples with Stable Diffusion.
Authors: Yueqian Lin*, Jingyang Zhang*, Yiran Chen, Hai Li
To set up the environment for using SD-NAE:
conda create -n sdnae python=3.9
conda activate sdnae
python -m pip install torch torchvision torchaudio # Version 2.1.0
python -m pip install xformers diffusers transformers accelerate pandas
Use generate.py
to synthesize natural adversarial examples yourself!
# Example: generate adversarial examples for class 20, which is 'jellyfish'
# All default hyperparameters (encoded in generate.py) are used
python generate.py --class_ids 20 20
If you find this work useful, please consider citing:
@inproceedings{
lin2024sdnae,
title={{SD}-{NAE}: Generating Natural Adversarial Examples with Stable Diffusion},
author={Yueqian Lin and Jingyang Zhang and Yiran Chen and Hai Li},
booktitle={The Second Tiny Papers Track at ICLR 2024},
year={2024},
url={https://openreview.net/forum?id=D87rimdkGd}
}