Bugfix for flux2 img2img2 prediction #12855
Open
+9
−2
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.
What does this PR do?
I got the error:
raise ValueError(f"Expected
image_latentsto be a list, got {type(image_latents)}.")(1) cond_model_input_list will go to "_prepare_image_ids" in a list of
[[1, cond_model_input[0], cond_model_input[1], cond_model_input[2]], ...](2) As the "_prepare_image_ids" in pipeline will do the
torch.cat(image_latent_ids, dim=0), this will cause mismatch of shape in the training step in codemodel_input_ids = torch.cat([model_input_ids, cond_model_input_ids], dim=1).cond_model_input_ids .shape[0]is 1, butmodel_input_ids.shape[0]is the batch size. The codecond_model_input_ids.viewis to resize the shape to meet the requirementSo this change will also work if batch size is more than 1.
When I only changed the cond_model_input to list, I got the training abnormal training loss (start with ~1.7, which is too high). So I fix model prediction based on the pipeline part, and loss becomes reasonable (start with ~0.4).
With the code:
With the original code:
The training loss is:
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
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.