Navigate the Universe of Diffusion models with Unified workflow.

UniDiffusion is a toolbox that provides state-of-the-art training and inference algorithms, based on diffusers. UniDiffusion is aimed at researchers and users who wish to deeply customize the training of stable diffusion. We hope that this code repository can provide excellent support for future research and application extensions.
If you also want to implement the following things, have fun with UniDiffusion
cross attention (or convolution / feedforward / ...) layer.lr / weight decay / ... for different layers.Note: UniDiffusion is still under development. Some modules are borrowed from other code repositories and have not been tested yet, especially the components that are not enabled by default in the configuration system. We are working hard to improve this project.
In UniDiffusion, all training methods are decomposed into three dimensions
It allows we conduct a unified training pipeline with strong config system.
Here is a simple example. In diffusers, training text-to-image finetune and dreambooth like:
python train_dreambooth.py --arg ......
python train_finetune.py --arg ......and combining or adjusting some of the methods are difficult (e.g., only training cross attention during dreambooth).
In UniDiffusion, we can easily design our own training arguments in config file:
# text-to-image finetune
unet.training_args = {'': {'mode': 'finetune'}}
# text-to-image finetune with lora
unet.training_args = {'': {'mode': 'lora'}}
# update cross attention with lora
unet.training_args = {'attn2': {'mode': 'lora'}}
# dreambooth
unet.training_args = {'': {'mode': 'finetune'}}
text_encoder.training_args = {'text_embedding': {'initial': True}}
# dreambooth with small lr for text-encoder
unet.training_args = {'': {'mode': 'finetune'}}
text_encoder.training_args = {'text_embedding': {'initial': True, 'optim_kwargs': {'lr': 1e-6}}}and then run
accelerate launch scripts/train.py --config-file /path/to/your/configThis facilitates easier customization, combination, and enhancement of methods, and also allows for the comparison of similarities and differences between methods through configuration files.
In UniDiffusion, we provide a regular matching system for module selection. It allows us to select modules by regular matching. See Regular Matching for Module Selection for more details.
We provide a powerful support for PEFT/PETL methods. See PEFT/PETL Methods for more details.
pip install -e requirements.txtaccelerate config
wandb loginSee Train textual inversion / Dreambooth / LoRA / text-to-image Finetune for details.
accelerate launch scrits/common.py --config-file configs/train/text_to_image_finetune.pyNote: Personalization methods are decomposes in trainable parameters, PEFT/PETL methods, and training process in UniDiffusion. See config file for more details.
We are going to add the following features in the future. We also welcome contributions from the community. Feel free to pull requests or open an issue to discuss ideas for new features.
We welcome contributions from the open-source community!
If you use this toolbox in your research or wish to refer to the baseline results published here, please use the following BibTeX entries:
@misc{pu2022diffusion,
author = {Pu Cao, Tianrui Huang, Lu Yang, Qing Song},
title = {UniDiffusion},
howpublished = {url{https://github.com/PRIV-Creation/UniDiffusion}},
year = {2023}
}