How to Use Anti-DreamBooth: A Guide

Jun 13, 2021 | Data Science

Welcome to the world of text-to-image diffusion models! In light of the significant advantages these tools bring, there is a need to safeguard users against potential misuse. The Anti-DreamBooth project offers a solution to protect individuals from unwanted personalized image generation. In this guide, we will walk you through the process of setting up the environment, preparing the dataset, and executing the necessary scripts to harness the power of Anti-DreamBooth. Let’s dive in!

Table of Contents

Environment Setup

To get started with Anti-DreamBooth, follow the steps below to set up your environment.

cd Anti-DreamBooth
conda create -n anti-dreambooth python=3.9
conda activate anti-dreambooth
pip install -r requirements.txt

Next, you’ll need to download pretrained checkpoints for different Stable Diffusion versions and place them in a designated folder (‘.stable-diffusion’). The default version used in experiments is 2.1. You can find the links to various versions below:

Version Link
2.1 Download 2.1
1.5 Download 1.5
1.4 Download 1.4

All experiments are performed on a single NVIDIA 40GB A100 GPU.

Dataset Preparation

For our experiments, we utilize two datasets: VGGFace2 and CelebA-HQ. Here’s a quick rundown:

  • VGGFace2: Contains around 3.31 million images across 9131 identities, with a minimum of 15 images required for each subject having a resolution above 500×500 pixels.
  • CelebA-HQ: Comprising 30,000 images at 1024×1024 resolution, we use an annotated subset that includes 307 subjects, each with at least 15 images.

In our setup, we choose 50 identities from both datasets and split them into three subsets: a reference clean set (set A), a target projecting set (set B), and an extra clean set for uncontrolled experiments (set C). Full split sets can be accessed here.

How to Run

Now that your environment is ready and the datasets are prepared, it’s time to run the scripts!

To defend Stable Diffusion version 2.1 (the default), execute either of the following commands:

bash scripts/attack_with_aspl.sh
bash scripts/attack_with_targeted_aspl.sh

For other supported algorithms, you can execute the similar commands listed in the table below:

Algorithm Bash Script
E-ASPL bash scripts/attack_with_ensemble_aspl.sh
FSMG bash scripts/attack_with_fsmg.sh
T-FSMG bash scripts/attack_with_targeted_fsmg.sh
E-FSMG bash scripts/attack_with_ensemble_fsmg.sh

For those who want to train a DreamBooth model, you can achieve this easily by running:

bash scripts/train_dreambooth_alone.sh

Finally, for inference to generate examples with multiple prompts, execute:

python infer.py --model_path path_to_DREAMBOOTH_model --output_dir .test-infer

Troubleshooting

If you encounter any issues during the setup or execution, consider the following troubleshooting suggestions:

  • Ensure that you have the correct version of Python and conda installed.
  • Check that all necessary dependencies are included in the requirements file.
  • If you encounter errors related to memory, consider running on a machine with a more powerful GPU.
  • Verify that the paths for your datasets and model checkpoints are correct.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

Now you are all set to explore the capabilities of the Anti-DreamBooth framework! This powerful tool not only helps in generating content but also ensures the protection of users from personalized synthesis abuse. At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox