diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

Fix multi-prompt inference

Open nikitabalabin opened this issue 11 months ago • 4 comments

Fix generation of multiple images with multiple prompts, e.g len(prompts)>1, num_images_per_prompt>1

What does this PR do?

Fixes # (issue)

Before submitting

  • [x] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • [x] Did you read the contributor guideline?
  • [x] Did you read our philosophy doc (important for complex PRs)?
  • [ ] Was this discussed/approved via a GitHub issue or the forum? Please add a link to it if that's the case.
  • [x] Did you make sure to update the documentation with your changes? Here are the documentation guidelines, and here are tips on formatting docstrings.
  • [ ] Did you write any new necessary tests?

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.

nikitabalabin avatar Mar 04 '24 12:03 nikitabalabin

Can you show an example of where the current code (without the changes in this PR) fails?

sayakpaul avatar Mar 05 '24 11:03 sayakpaul

from diffusers import PixArtAlphaPipeline, Transformer2DModel
import torch

pipe = PixArtAlphaPipeline.from_pretrained("PixArt-alpha/PixArt-XL-2-1024-MS", 
                                           torch_dtype=torch.float16).to('cuda')
prompts = ["a man", "cat riding a bike in the forest, watercolor style"]   
images = pipe(prompt=prompts, num_images_per_prompt=2).images

images[1] and images[2] will be generated with wrong prompt_attention_mask.

nikitabalabin avatar Mar 06 '24 20:03 nikitabalabin

Thanks! Could we add a fast test for this as well?

sayakpaul avatar Mar 07 '24 03:03 sayakpaul

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.

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

github-actions[bot] avatar Apr 03 '24 15:04 github-actions[bot]