Home

Awesome

Revealing Vulnerabilities in Stable Diffusion via Targeted Attacks

<img src=examples/framework.png width="70%" height="40%">

Dependencies

Usage

  1. Download the word2id.pkl and wordvec.pkl for the synonym model, and put download files into the Word2Vec dir.

  2. A script is provided to perform targeted attacks for Stable Diffusion

# Traning for generating the adversarial prompts
python run.py --config_path ./object_config.json  # Object attacks
python run.py --config_path ./style_config.json  # Style attacks
# Testing for evaluating the attack success rate
python test_object_multi.py --config_path ./object_config.json  # Object attack 
python test_style_multi.py --config_path ./style_config.json # Style attack
# Testing for evaluating FID score of generated images
python IQA.py --gen_img_path [the root of generated images] --task [object or style] --attack_goal_path [the path of referenced images] --metric image_quality 

Parameters

Config can be loaded from a JSON file.

Config has the following parameters:

Adversarial Attack Dataset

We public our adversarial attack dataset that is used to achieve object attacks on Stable Diffusion. The dataset is available at [Link].

Citation

If you find the repo useful, please consider citing.

@article{zhang2024revealing,
  title={Revealing Vulnerabilities in Stable Diffusion via Targeted Attacks},
  author={Zhang, Chenyu and Wang, Lanjun and Liu, Anan},
  journal={arXiv preprint arXiv:2401.08725},
  year={2024}
}