fix(qwen-image dreambooth): correct prompt embed repeats when using --with_prior_preservation#13396
fix(qwen-image dreambooth): correct prompt embed repeats when using --with_prior_preservation#13396chenyangzhu1 wants to merge 2 commits intohuggingface:mainfrom
--with_prior_preservation#13396Conversation
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
|
@sayakpaul I think the same prior-preservation repeat bug also exists in the
I reproduced this in the The same fix pattern from this PR seems applicable there too: If preferred, I can open a separate small PR for the |
|
Sure |
|
Done |
What does this PR do?
I found that the same problem in #13292 also appears in Qwen-Image's dreambooth lora script.
diffusers/examples/dreambooth/train_dreambooth_lora_qwen_image.py
Line 1468 in 8070f6e
The root cause and fixing are the same as #13307 and #13292.
Root cause:
collate_fnappends class prompts to the instance prompts list (doublinglen(prompts)), butprompt_embedsis already doubled earlier viatorch.cat([instance_embeds, class_embeds]). Using the fulllen(prompts)as the repeat count produces4embeddings for2latents atbatch_size=1.Fix: Use
len(prompts) // 2whenargs.with_prior_preservationis active, so the repeat count matches the number of unique prompt groups rather than the doubled collated list.Applied to the Qwen-Image related script:
examples/dreambooth/train_dreambooth_lora_qwen_image.pyFixes #13292
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@sayakpaul
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.