divamgupta / stable-diffusion-tensorflow

Stable Diffusion in TensorFlow / Keras
Other
1.57k stars 227 forks source link

Prompt is too long (should be < 77 tokens) #18

Closed lawrencecchen closed 1 year ago

lawrencecchen commented 1 year ago

Is there any way to have longer prompts? (I'm a complete ML noob, would love to learn!)

lawrencecchen commented 1 year ago
Screen Shot 2022-09-20 at 10 03 40 PM

Just read stable diffusion's source code and learned that the tokenizer also caps at 77 tokens, so this issue is moot. I would still love to know why this is the case though!

SidJain1412 commented 1 year ago

@lawrencecchen this explains it: https://github.com/divamgupta/stable-diffusion-tensorflow/issues/20#issuecomment-1253779733

The clip-vit-large-patch14 (https://huggingface.co/openai/clip-vit-large-patch14) model used by SD can only handle sequences of 77 tokens. It works like that in the original pytorch implementation as well. Anything longer than that gets silently truncated.