Memories of Forgotten Concepts
Matan Rusanovsky*, Shimon Malnick*, Amir Jevnisek*, Ohad Fried, Shai Avidan
*Equal Contribution
❓ Many studies aim to erase concepts from diffusion models. While these models may no longer generate images tied to the erased concept when prompted, we ask: Is the concept truly erased? Could the model still reproduce it through other means?
↪️Instead of analyzing a model that erased some concept by generating many images and analyzing them, we propose a method that analyzes it using latents that generate the erased concept.
- Download mscoco17.
- Download the ablated models (Links for [Object, Others]).
- Generate the datasets of the erased concepts using the appropriate csv file. For example, to generate the Nudity dataset:
cd Memories_of_Forgotten_Concepts/src
export CONCEPT=nudity
export PROMPT_FILE=../prompts/${CONCEPT}.csv
export SAVE_PATH=../datasets
mkdir -p $SAVE_PATH
python generate_dataset.py --prompts_path ${PROMPT_FILE} --concept ${CONCEPT} --save_path ${SAVE_PATH} --device cuda:0For objects use the generate_object_dataset.py, for example to generate the Parachute object dataset:
cd Memories_of_Forgotten_Concepts/src
export CONCEPT=parachute
export SAVE_PATH=../datasets
mkdir -p $SAVE_PATH
python generate_object_dataset.py --concept ${CONCEPT} --save_path ${SAVE_PATH}- Download the style classifier for detection of the Van Gogh concept. Add an environmen variable for the classifier:
export STYLE_CLASSIFIER_DIR=/path/to/cls/dircreate an environment using the supplied requirements.txt file:
git clone https://github.com/matanr/Memories_of_Forgotten_Concepts
cd Memories_of_Forgotten_Concepts/src
conda create -n mem python=3.10
conda activate mem
pip install -r requirements.txtMake sure the outputs directory contains the concept name in either configuration.
In addition, it is recommended to specify the model name and the experimental configuration.
For example, when running on ESD that erased the concept nudity, in the concept-level configuration, set:
<out directory>=memories_of_ESD_nudity
Similarly, in the "image-level" configuration, set:
<out directory>=many_memories_of_ESD_nudity
For all models except for AdvUnlearn, set:
--ablated_model <path to the ablated model>
Instead, for AdvUnlearn, include:
--ablated_text_encoder OPTML-Group/AdvUnlearn
💡 Only one of these two options (--ablated_model or --ablated_text_encoder) should be used at a time, according to the model that is being analyzed.
Perform a concept-level analysis:
python memory_of_an_ablated_concept.py
--reference_dataset_root <path to mscoco17>
--out_dir <out directory>
--ablated_concept_name <nudity/vangogh/church/garbage_truck/tench/parachute>
--dataset_root <path to the dataset of images of ablated_concept_name>
--diffusion_inversion_method <renoise/nti>
--num_diffusion_inversion_steps 50
[--ablated_model <path to the ablated model> | --ablated_text_encoder OPTML-Group/AdvUnlearn]Perform an image-level analysis:
python many_memories_of_an_ablated_image.py
--reference_dataset_root <path to mscoco17>
--out_dir <out directory>
--ablated_concept_name <nudity/vangogh/church/garbage_truck/tench/parachute>
--dataset_root <path to the dataset of images of ablated_concept_name>
--num_vae_inversion_steps 3000
--diffusion_inversion_method <renoise/nti>
--num_diffusion_inversion_steps 50
[--ablated_model <path to the ablated model> | --ablated_text_encoder OPTML-Group/AdvUnlearn]@InProceedings{Rusanovsky_2025_CVPR,
author = {Rusanovsky, Matan and Malnick, Shimon and Jevnisek, Amir and Fried, Ohad and Avidan, Shai},
title = {Memories of Forgotten Concepts},
booktitle = {Proceedings of the Computer Vision and Pattern Recognition Conference (CVPR)},
month = {June},
year = {2025},
pages = {2966-2975}
}This repository is built upon and incorporates code from Diffusion-MU-Attack, AdvUnlearn and Renoise.
