T2I-Adapters
T2I-Adapters for Stable Diffusion XL (SDXL)
The train_t2i_adapter_sdxl.py
script (as shown below) shows how to implement the T2I-Adapter training procedure for Stable Diffusion XL.
Running locally with PyTorch
Installing the dependencies
Before running the scripts, make sure to install the library’s training dependencies:
Important
To make sure you can successfully run the latest versions of the example scripts, we highly recommend installing from source and keeping the install up to date as we update the example scripts frequently and install some example-specific requirements. To do this, execute the following steps in a new virtual environment:
Copied
Then cd in the examples/t2i_adapter
folder and run
Copied
And initialize an 🌍 Accelerate environment with:
Copied
Or for a default accelerate configuration without answering questions about your environment
Copied
Or if your environment doesn’t support an interactive shell (e.g., a notebook)
Copied
When running accelerate config
, if we specify torch compile mode to True there can be dramatic speedups.
Circle filling dataset
The original dataset is hosted in the ControlNet repo. We re-uploaded it to be compatible with datasets
here. Note that datasets
handles dataloading within the training script.
Training
Our training examples use two test conditioning images. They can be downloaded by running
Copied
Then run boincai-cli login
to log into your BOINC AI account. This is needed to be able to push the trained T2IAdapter parameters to BOINC AI Hub.
Copied
To better track our training experiments, we’re using the following flags in the command above:
report_to="wandb
will ensure the training runs are tracked on Weights and Biases. To use it, be sure to installwandb
withpip install wandb
.validation_image
,validation_prompt
, andvalidation_steps
to allow the script to do a few validation inference runs. This allows us to qualitatively check if the training is progressing as expected.
Our experiments were conducted on a single 40GB A100 GPU.
Inference
Once training is done, we can perform inference like so:
Copied
Notes
Specifying a better VAE
SDXL’s VAE is known to suffer from numerical instability issues. This is why we also expose a CLI argument namely --pretrained_vae_model_name_or_path
that lets you specify the location of a better VAE (such as this one).
Last updated