damian0815 / compel

A prompting enhancement library for transformers-type text embedding systems

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

mlinmg opened this issue · comments

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

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

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

ah, not much an option for me.

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