Official Implementation of Holistic Unlearning Benchmark: A Multi-Faceted Evaluation for Text-to-Image Diffusion Model Unlearning (ICCV 2025)
- A comprehensive benchmark for evaluating unlearning methods in text-to-image diffusion models across multiple tasks and metrics
- ๐ก Feel free to explore the code, open issues, or reach out for discussions and collaborations!
To set up the environment, follow these steps:
- Clone the repository:
git clone https://github.com/ml-postech/HUB.git cd HUB - Create and activate the conda environment:
conda create -n HUBG python=3.10 conda activate HUBG conda install -y pytorch torchvision pytorch-cuda=11.8 -c pytorch -c nvidia pip install -r requirements.txt --no-deps
-
- To evaluate target proportion, reference images for each concept are required. We provide these reference images as part of a Hugging Face dataset.
- Once downloaded, place the dataset under the
images/directory. - Alternative download link: images
-
- For aesthetic score, we use the
sac+logos+ava1-l14-linearMSE.pthmodel. - Place it in the
/models/aesthetic_predictordirectory. - Alternative download link: aesthetic_predictor
- For aesthetic score, we use the
-
- Download giphy_celeb_detector.zip from this link or alternatively from [this Link] () and extract it to
/models/directory. - Alternative download link: celeb-detection-oss
- Download giphy_celeb_detector.zip from this link or alternatively from [this Link] () and extract it to
To perform evaluation using HUB, you must first generate images for each concept and task with your unlearned model. Use the prompts described below to generate images.
python source/image_generation.py \
--method YOUR_METHOD \
--target TARGET \
--task TASK
YOUR_METHOD can be one of the following already configured: sd, esd, uce, salun, ac, sa, receler, sld, mace.
TARGET can be one of the following:
Celebrities: Angelina Jolie, Ariana Grande, Brad Pitt, David Beckham, Elon Musk, Emma Watson, Lady Gaga, Leonardo DiCaprio, Taylor Swift, Tom Cruise;
Styles: Andy Warhol, Auguste Renoir, Claude Monet, รdouard Manet, Frida Kahlo, Paul Cรฉzanne, Picasso, Piet Mondrian, Van Gogh, Roy Lichtenstein;
IP characters: Buzz Lightyear, Homer Simpson, Luigi, Mario, Mickey Mouse, Pikachu, Snoopy, Sonic, SpongeBob, Stitch;
NSFW concepts: Nudity, Violent, Disturbing.
TASK must be one of the following: target_image, general_image, selective_alignment, pinpoint_ness, multilingual_robustness, attack_robustness, incontext_ref_image.
Examples:
- Running
sd:
python source/image_generation.py --method sd --target "Nudity" --task pinpoint_ness --device cuda
- Running unlearning based on UCE:
First download the weights from NSFW.pt and place it in
models/ucefolder. Then run:
python source/image_generation.py --method uce --target "Nudity" --task pinpoint_ness --device cuda
All prompts used in our experiments are provided in the prompts/ directory.
You can also generate prompts for your own target using the following scripts.
python source/prompt_generation/prompt.py \
--target YOUR_TARGET \
[--style] [--nsfw]
- Use
--stylefor style-related targets - Use
--nsfwfor NSFW-related targets
After generating the base prompts, create multilingual versions:
python source/prompt_generation/translate_prompt.py \
--target YOUR_TARGET
python source/prompt_generation/pinpoint_ness.py \
--target YOUR_TARGET
python source/prompt_generation/selective_alignment.py \
--target YOUR_TARGET \
[--style] # Add only if this is a style-related target
For now, we support the following seven unlearning methods: SLD, AC, ESD, UCE, SA, Receler, MACE. To evaluate your own model, you need to modify model.__init__.py to include the loading of your custom model. We recommend that you place your model in models/sd/YOUR_METHOD/.
To run the all tasks at once, execute the following command:
python main.py --method YOUR_METHOD --target TARGETExample a smoke test:
set NUM_TARGET_IMGS and NUM_GENERAL_IMGS in envs.py to low number e.g. 30
NUM_TARGET_IMGS = 30
NUM_GENERAL_IMGS = 30000
and try the following.
python main.py --method sd --target "Nudity" --device cuda
Running evaluation using main.py takes a long time, as it evaluates all tasks at once. To evaluate each task separately, follow these commands. In the following examples, replace the variables according to the settings you want to evaluate. Make sure to execute below command before evaluating each task.
export PYTHONPATH=$PYTHONPATH:YOUR_PROJECT_DIRThe evaluation code is configured to run separately for each concept type, because different classifiers are used. For the target_proportion, multilingual_robustness, and attack_robustness tasks, run the following code.
- Celebrity
python source/eval/eval_gcd.py \
--task TASK \
--method YOUR_METHOD \
--target TARGET
- Style, IP (VLM)
python source/eval/eval_vlm.py \
--task TASK \
--method YOUR_METHOD \
--target TARGET
- NSFW
python source/eval/eval_nsfw.py \
--task TASK \
--method YOUR_METHOD \
--target TARGET
- TASK:
general_image,target_image. - METRIC:
aesthetic,ImageReward,PickScore,FID,FID_SD.
python source/quality/evaluation.py \
--method YOUR_METHOD \
--target TARGET \
--task TASK \
--metric METRIC
python source/eval/eval_selective_alignment.py \
--method YOUR_METHOD \
--target TARGET
python source/eval/eval_vlm.py \
--task "pinpoint_ness" \
--method YOUR_METHOD \
--target TARGET
- Add two attacks.
- Add a leaderboard for each task.
- Add new unlearning methods.
@article{moon2024holistic,
title={Holistic Unlearning Benchmark: A Multi-Faceted Evaluation for Text-to-Image Diffusion Model Unlearning},
author={Moon, Saemi and Lee, Minjong and Park, Sangdon and Kim, Dongwoo},
journal={arXiv preprint arXiv:2410.05664},
year={2024}
}