EraseAnything: Enabling Concept Erasure in Rectified Flow Transformers is an open-source project for Concept Erasing in Rectified Flow models: e.g. Flux, SD 3.
- ✅ Supports [diffusers]
- ✅ Easy to extend and integrate
-
Install Rust (if required):
curl https://sh.rustup.rs -sSf | sh export PATH="$HOME/.cargo/bin:$PATH"
-
Install Python dependencies:
pip install transformers sentencepiece einops omegaconf pip install tokenizers==0.20.0 pip install nltk wandb openai
-
Install local packages:
cd peft pip install -e .[torch] or python setup.py install cd ../diffusers pip install -e .[torch] or python setup.py install
-
Set AI Secret Key (Strongly recommend OpenRouter!)
API_KEY='xxx' END_POINT='https://research-01-02.openai.azure.com/' API_VERSION = "2024-08-01-preview"
-
Train the model:
bash train.sh
-
Run inference:
python inference.py
- Training script:
train.sh
- Inference script:
inference.py
- Results will be saved in the
results/
directory (if applicable).
This project is inspired by and builds upon the work of Erasing Concepts from Diffusion Models and other open-source projects. We thank the community for their valuable contributions.
If you use this project in your research, please cite:
@article{gao2024eraseanything,
title={EraseAnything: Enabling Concept Erasure in Rectified Flow Transformers},
author={Gao, Daiheng and Lu, Shilin and Walters, Shaw and Zhou, Wenbo and Chu, Jiaming and Zhang, Jie and Zhang, Bang and Jia, Mengxi and Zhao, Jian and Fan, Zhaoxin and others},
journal={ICML 2025},
year={2024}
}
For technical questions, please contact samuel.gao023@gmail.com.