Fix incorrect batch temporal IDs for cond_model_input in dreambooth flux2 img2img#13846
Open
Jefsky wants to merge 1 commit into
Open
Fix incorrect batch temporal IDs for cond_model_input in dreambooth flux2 img2img#13846Jefsky wants to merge 1 commit into
Jefsky wants to merge 1 commit into
Conversation
…lux2 img2img The _prepare_image_ids method assigns different temporal embeddings (T=10, T=20, T=30...) to distinguish multiple reference images within a single sample. However, in the training script, cond_model_input has shape (B, C, H, W) where each batch element is an independent training sample with only one conditional image. The previous implementation split the batch into individual samples, producing incorrect cross-sample temporal offsets (sample 0 -> T=10, sample 1 -> T=20, etc.). Fix: generate temporal IDs for one sample and expand across the batch dimension, so all samples use the same temporal ID (T=10).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In
train_dreambooth_lora_flux2_img2img.py,Flux2Pipeline._prepare_image_idsis designed for multiple reference images within a single sample, assigning different temporal embeddings (T=10, T=20, T=30...) to distinguish them.However,
cond_model_inputhas shape(B, C, H, W)where each batch element is an independent training sample with a single conditional image. The old code split the batch into individual items:This produced incorrect cross-sample temporal offsets:
Fix
Generate temporal IDs for a single sample and expand across the batch dimension:
All batch elements now use the same temporal ID (T=10), which is the correct behavior since each sample only has one conditional image.
Related PRs
Fixes #13811