Repository navigation
Fix batched prompt/image pairing in the Kandinsky combined pipelines (item 1 of #15465) - #15488
Open
amarjithkumar2007-wq wants to merge 2 commits into
Conversation
Contributor
|
Hi @amarjithkumar2007-wq, thanks for the PR! It does not appear to link an issue it fixes.
See the contribution guide for more details. Please note that PRs without a linked issue are likely to be automatically closed 10 days after this notice. Once the PR links an existing issue, the author box is ticked, or the |
This branch has not been deployed
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.
What
Fixes item 1 of #15465, as agreed with @nyxbyb on the issue.
KandinskyPriorPipelineexpandsimage_embedsper prompt withrepeat_interleave, so a batch of prompts["cat", "dog"]withnum_images_per_prompt=2produces embeddings ordered[cat, cat, dog, dog]. The three combined pipelines (KandinskyCombinedPipeline,KandinskyImg2ImgCombinedPipeline,KandinskyInpaintCombinedPipeline) instead expanded thepromptlist with list multiplication, giving[cat, dog, cat, dog]. With more than one prompt andnum_images_per_prompt > 1, half of the images were therefore generated with another prompt's text. Theimageandmask_imagelists in the Img2Img/Inpaint variants were expanded with the same mismatched pattern and are fixed the same way.The expansion now repeats each entry per prompt, matching the prior's ordering. Nothing changes for a single prompt or
num_images_per_prompt=1(the expansion is a no-op there).Tests
tests/pipelines/kandinsky/test_kandinsky_combined.py: a stub prior returns embeddings that record which prompt produced them (expanded withrepeat_interleave, as the real prior does), and a stub decoder records what the combined pipeline hands it. The tests assert that every prompt, image and mask stays paired with its own embeddings in all three combined pipelines. All three fail on currentmainand pass with this change.pytest tests/pipelines/kandinsky/test_kandinsky_combined.py(whole file, CPU): 45 passed, 60 skipped, 3 xfailed with this change. On unmodifiedmainthe same file gives 42 passed, 60 skipped, 3 xfailed, so the only difference is the 3 new tests. The skips and xfails are pre-existing and were not investigated further.ruff format --check,ruff checkandutils/check_copies.pypass on the changed files.AI contribution disclosure (per this repo's guidelines)
This contribution was prepared with AI assistance (Instinct). I reviewed the final diff and the test results myself before submitting.
Self-review notes:
prompt,imageandmask_imagein the three combined pipelines; no other code paths are touched.repeat_interleaveordering inpipeline_kandinsky_prior.pywas taken as the reference behavior.