[WIP][Examples] Support LoRA DreamBooth training with SD XL#3896
[WIP][Examples] Support LoRA DreamBooth training with SD XL#3896
Conversation
Fix embeddings for classic SD models.
| def compute_embeddings(prompt, text_encoders, tokenizers): | ||
| original_size = (args.resolution, args.resolution) | ||
| target_size = (args.resolution, args.resolution) | ||
| crops_coords_top_left = (0, 0) |
There was a problem hiding this comment.
we should pass in crop coords as an optional value, because forcing this to 0,0 while also forcing a square resolution and cropping the input data is kind of going against the results of the SDXL paper, and the purpose of these conditioning inputs.
|
i would like for these examples to begin using a common module for shared functions, the code duplication is pretty high and the maintenance cost of updating all of these scripts just grows over time, now that each new model seems to get its own examples with possibly 4 different scripts. if we use a common module, i would like for it to have the data bucketing implemented that was used in the original technical report, so that we use a conditioning method to scale the smaller side to a fixed value and then use a two-decimal rounded aspect ratio (eg. 1.78 for 16:9) to put these images into buckets. it gets tricky, because the original model was trained on 256x256, 512x512, and 1024 based multi-aspect. if we had multiple dataloaders for SDXL (1 for each base resolution) and a common module to handle this, then general finetune, LoRA and TI scripts can all benefit from that. i implemented aspect bucketing into the diffusers finetuning script for SD2.1 and can share whatever lessons from that. |
|
Hey @bghira, thanks for sharing your insights!
Please note that we purposefully don't do it as stated in our doc. Also, we don't want to maintain too many examples here. If you checked, the DreamBooth example we currently have in For aspect-ratio bucketing, we purposefully don't want to add it because it introduces complexity we want to avoid to respect the goals of having these examples officially maintained, i.e., to provide not just the examples but also achieve readability and simplicity baked inside of them. But more than happy to welcome a PR from you if you want to maybe add that as a community example. Happy for it to be also included from our official docs :) |
|
Closing in favor of #4016. |
What does this PR do?
This PR is for me to gather feedback on the structure and the modifications to accommodate the DreamBooth LoRA training with SD XL.
Keep in mind
This PR adds an example to show how to conduct DreamBooth LoRA training with SDXL. Builds on top of #3859.
While reviewing the PR, please only restrict yourself to the
train_dreambooth_lora_sd_xl.pyscript.Others
make style && make qualityto not mess with the other files.use_auth_token=Truein the script because of obvious reasons.I am currently training with the following command:
The
dogdataset was downloaded using the following code:The training artifacts are available here: https://huggingface.co/diffusers/lora-trained-xl (private, only visible to the diffusers team members for now).