-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[SD-XL] Passing prompt_embeds/negative_prompt_embeds requires also passing pooled_prompt_embeds/negative_pooled_prompt_embeds #4043
Comments
Thanks for reporting. The Also, could you please try to reproduce the issue without introducing an external dependency? That would be helpful. |
Thanks for your reply @sayakpaul. Re the external dependency, I just added it here because it easily generates the prompt embeddings without adding lengthier code (which I thought was beyond the scope of the issue at hand). In fact you can add a dummy Tensor instead of the prompt embedding and the pooled embeds will still get requested. Re the |
I think we would want to raise an error here rather than silently do that. This will allow the user to take complete control of what they want to pass as the embeddings. |
Hi @m-a-r-v-i-n, I prepared a Colab Notebook here to shows how to precompute the embeddings and using them in the pipeline call. This is what I did:
from diffusers import DiffusionPipeline
import torch
ckpt_id = "stabilityai/stable-diffusion-xl-base-0.9"
dtype = torch.float16
device = "cuda"
pipeline = DiffusionPipeline.from_pretrained(
ckpt_id, torch_dtype=dtype, safety_checker=None
).to(device)
prompt = "a lion posing in the style of a cat"
num_images_per_prompt = 1
(
prompt_embeds,
negative_prompt_embeds,
pooled_prompt_embeds,
negative_pooled_prompt_embeds,
) = pipeline.encode_prompt(prompt, device, num_images_per_prompt=num_images_per_prompt)
image = pipeline(
prompt_embeds=prompt_embeds,
pooled_prompt_embeds=pooled_prompt_embeds,
negative_prompt_embeds=negative_prompt_embeds,
negative_pooled_prompt_embeds=negative_pooled_prompt_embeds,
num_inference_steps=20,
).images[0]
image I hope this helps. |
This works, thanks a lot @sayakpaul |
Closing the issue then :-) |
I think this issue has not been resolved.The Compel is to solve 77 token limits. if use the encode_prompt,it's also throw an error: |
It's not an error, it's a warning. |
|
Describe the bug
When calling the
StableDiffusionXLPipeline
and passing the prompts as embeddings using the prompt_embeds/negative_prompt_embeds parameters, an error is generated requiring the pooled_prompt_embeds/negative_pooled_prompt_embeds parameters also to be passed.There seems to be no documentation as to what these parameters should be (how the embeddings should be pooled). The documentation of the
encode_prompt
function states the following:However, the
check_inputs
function is flagging an error when the pooled embeddings are not passed, and I couldn't find any code that automatically generates the pooled embeddings:Reproduction
Logs
No response
System Info
diffusers
version: 0.18.1Who can help?
@patrickvonplaten
@sayakpaul
@williamberman
The text was updated successfully, but these errors were encountered: