damian0815 / compel

A prompting enhancement library for transformers-type text embedding systems
MIT License
526 stars 47 forks source link

Token indices sequence length is longer than the specified maximum sequence length for this model #72

Closed mlinmg closed 11 months ago

mlinmg commented 1 year ago

When I try to use this code with he sdxl model I get this: Token indices sequence length is longer than the specified maximum sequence length for this model (176 > 77). Running this sequence through the model will result in indexing errors The code I use is:

def prompt_worker_sdxl(prompt,negative_prompt,pipe_sdxl):
    compel = Compel(tokenizer=[pipe_sdxl.tokenizer, pipe_sdxl.tokenizer_2],
                        text_encoder=[pipe_sdxl.text_encoder, pipe_sdxl.text_encoder_2],
                        returned_embeddings_type=ReturnedEmbeddingsType.PENULTIMATE_HIDDEN_STATES_NON_NORMALIZED,
                        requires_pooled=[False, True],
                    truncate_long_prompts=False)

    with torch.no_grad():
        conditioning, pooled = compel([prompt,negative_prompt])
    return conditioning, pooled

the pipelines I've tested are:

pipe_sdxl_cntrlnt = StableDiffusionXLControlNetPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    controlnet=controlnet_sdxl,
    vae=vae_sdxl,
    torch_dtype=torch.float16,
)
pipe_sdxl = StableDiffusionXLPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    vae=vae_sdxl,
    torch_dtype=torch.float16,

)

with this schedulers:

pipe_sdxl_cntrlnt.scheduler = DPMSolverMultistepScheduler(use_karras_sigmas=True).from_config(pipe_sdxl_cntrlnt.scheduler.config)
pipe_sdxl_cntrlnt.scheduler.algorithm_type = 'sde-dpmsolver++'
pipe_sdxl.scheduler = DPMSolverMultistepScheduler(use_karras_sigmas=True).from_config(pipe_sdxl.scheduler.config)
pipe_sdxl.scheduler.algorithm_type = 'sde-dpmsolver++'

compel is 2.0.2

segalinc commented 1 year ago

I have the same issue, did you find a solution ?

mlinmg commented 1 year ago

No, I decided to not use it and to shorten prompt lenght

segalinc commented 1 year ago

ah, not much an option for me.

damian0815 commented 11 months ago

this isn't an error, the result should be fine..