Skip to content

Add sdxl prompt embeddings #3995

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

Merged
merged 4 commits into from
Jul 7, 2023
Merged

Add sdxl prompt embeddings #3995

merged 4 commits into from
Jul 7, 2023

Conversation

patrickvonplaten
Copy link
Contributor

@patrickvonplaten patrickvonplaten commented Jul 7, 2023

What does this PR do?

Make sure prompt embeddings can be passed to SD-XL.

Fixes #3970

Before submitting

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.

@@ -17,13 +16,9 @@ class StableDiffusionXLPipelineOutput(BaseOutput):
images (`List[PIL.Image.Image]` or `np.ndarray`)
List of denoised PIL images of length `batch_size` or numpy array of shape `(batch_size, height, width,
num_channels)`. PIL images or numpy array present the denoised images of the diffusion pipeline.
nsfw_content_detected (`List[bool]`)
Copy link
Member

Choose a reason for hiding this comment

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

Why are removing this?

Copy link
Member

Choose a reason for hiding this comment

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

@sayakpaul There is no safety checker in these pipelines.

Copy link
Member

@sayakpaul sayakpaul left a comment

Choose a reason for hiding this comment

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

I would have expected to see a change in encode_prompt() to accommodate the pooled embeddings. But didn't notice it.

What am I missing out on? We should maybe also include tests for those.

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Jul 7, 2023

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

Copy link
Member

@pcuenca pcuenca left a comment

Choose a reason for hiding this comment

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

I don't fully follow. How would this be used with the compel library?

@@ -17,13 +16,9 @@ class StableDiffusionXLPipelineOutput(BaseOutput):
images (`List[PIL.Image.Image]` or `np.ndarray`)
List of denoised PIL images of length `batch_size` or numpy array of shape `(batch_size, height, width,
num_channels)`. PIL images or numpy array present the denoised images of the diffusion pipeline.
nsfw_content_detected (`List[bool]`)
Copy link
Member

Choose a reason for hiding this comment

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

@sayakpaul There is no safety checker in these pipelines.

@patrickvonplaten
Copy link
Contributor Author

Having chatted offilne with @pcuenca this is the only way really we can do things.

If the user passes prompt_embeds we assume that the text encoder is not needed anymore and that the user does not have to pass prompt. This however means that the user has to pass pooled_prompt_embeds.

@patrickvonplaten
Copy link
Contributor Author

Merging

@patrickvonplaten patrickvonplaten merged commit 78922ed into main Jul 7, 2023
@patrickvonplaten patrickvonplaten deleted the sdxl_prompt_embeddings branch July 7, 2023 14:50
@adhikjoshi
Copy link

So, pooled_prompt_embeds is also needed with prompt_embeds

We have understanding of creating embeds, but pooled embeds will be same or they are different?

Can we pass same prompt embeddings in pooled and prompt_embeds?

If not, how can we create pooled embeds? Can compel work?

@sayakpaul
Copy link
Member

Hi @adhikjoshi.

If you check out

you will notice the code for computing the pooled prompt embeddings.

Let me know if that helps.

@bghira
Copy link
Contributor

bghira commented Jul 7, 2023

                # We are only ALWAYS interested in the pooled output of the final text encoder
                negative_pooled_prompt_embeds = negative_prompt_embeds[0]

seems like it's not needed and we can just pass in the negative prompt embeds etc?

@bghira
Copy link
Contributor

bghira commented Jul 7, 2023

docs for encode_prompt say prompt is optional, but signature has no default value of None

yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
* Add sdxl prompt embeddings

* Fix more

* fix some slow tests
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
* Add sdxl prompt embeddings

* Fix more

* fix some slow tests
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.

SDXL prompt embeddings not working
6 participants