Skip to content

Fix positive / negative prompts #1002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Fix positive / negative prompts #1002

wants to merge 1 commit into from

Conversation

pcuenca
Copy link
Member

@pcuenca pcuenca commented Oct 26, 2022

I tested a few different combinations:

  • Lists are supplied for both.
  • Lists + num_images_per_prompt.
  • Single positive, single negative, num_images_per_prompt > 1
  • Same without negative prompts.

It seems to work, but it'd be nice to come up with a unit test somehow. Not easy to do because the code to be tested is inside the pipeline function.

Fixes #779.

I tested a few different combinations:
- Lists are supplied for both.
- Lists + num_images_per_prompt.
- Single positive, single negative, num_images_per_prompt > 1
- Same without negative prompts.

It works, but it'd be nice to come up with a unit test.
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Oct 26, 2022

The documentation is not available anymore as the PR was closed or merged.

Copy link
Contributor

@patil-suraj patil-suraj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, just posted one question in the comments. Also for tests ,maybe we could test each combination with dummy model

  • single prompt
  • list of prompts
  • single prompt with num_images_per_prompt
  • list of prompts with num_images_per_prompt

and the same including the negative prompt. This will add a lot of tests but I think it should be fine.

@@ -283,7 +283,7 @@ def __call__(

# duplicate unconditional embeddings for each generation per prompt, using mps friendly method
seq_len = uncond_embeddings.shape[1]
uncond_embeddings = uncond_embeddings.repeat(batch_size, num_images_per_prompt, 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good to me, but I'm surprised that this doesn't work, what was the issue with it ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have three prompts and three negative prompts, batch_size would be three and we would be creating uncond_embeddings with shape (9, 77, 768) in this step. But text_embeddings is still (3, 77, 768), and latents_shape in line 299 would be wrong.

@pcuenca
Copy link
Member Author

pcuenca commented Oct 28, 2022

I think we should merge this soon as more people are finding the problem (it used to be a silent error, but it now fails). See for example #1035. @patrickvonplaten @anton-l can one of you please review on Monday? Meanwhile I'll prepare a couple of tests.

@pcuenca
Copy link
Member Author

pcuenca commented Nov 2, 2022

Superseded by #1035.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stable Diffusion: providing a list of positive prompts and a list of negative prompts does not work as expected
4 participants