Skip to content
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

Why can I only have 75 characters after updating the latest version? #1471

Closed
kidps2 opened this issue Oct 1, 2022 · 3 comments
Closed

Why can I only have 75 characters after updating the latest version? #1471

kidps2 opened this issue Oct 1, 2022 · 3 comments
Labels
not-an-issue This issue is not with the repo itself.

Comments

@kidps2
Copy link

kidps2 commented Oct 1, 2022

Only 75 characters can't be used normally. Some keywords have more than 20 characters, some artists have more than 20 characters, and some keywords have a series of 50 characters. The limit of 75 characters can't be used normally

@kidps2 kidps2 added the bug-report Report of a bug, yet to be confirmed label Oct 1, 2022
@kidps2
Copy link
Author

kidps2 commented Oct 1, 2022

Did I use up any ghostwriting? Or is the old version also limited to 75, but the new version is displayed?

@dovezp
Copy link

dovezp commented Oct 1, 2022

It has to do with the tokenize limit for input characters. Long story short, Stable Diffusion has a limit for input text length.

In general, a prompt must be 75 tokens or less, anything above will result in "prompt truncated after tokenization". Your prompt is case insensitive. There's about 30,000 tokens understood by the AI, this means it won't know about some weird word unused since the 1600s. A token is roughly a word, a punctuation, or a Unicode character.

You can preview some common prompts here: https://promptomania.com/stable-diffusion-prompt-builder/

This is where Textual Inversion and saving existing tokenizer parameters as Styles come into play.

Styles Example:

  1. Enter a positive prompt: cute kitten
  2. Generate
    index
cute kitten
Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 3270996573, Size: 512x512, Model hash: 9453d3e5
  1. Create Style, name it cute_kitten
  2. Enter new positive prompt: Giovanni Fattori
  3. Apply new cute_kitten Style
    image
  4. Generate
    index
Giovanni Fattori, cute kitten
Steps: 20, Sampler: Euler a, CFG scale: 27.5, Seed: 1676737396, Size: 512x512, Model hash: 9453d3e5

Textual Inversion Example:

  1. Find a concept-image model / embed model. Personally I look at https://huggingface.co/sd-concepts-library

  2. Download your model of choice, for example https://huggingface.co/sd-concepts-library/852style-girl

  3. Rename {learned_embeds}.bin to the class name that is inside token_identifier.txt. For example, I copy <852style-girl> and name the bin file, 852style-girl.bin

  4. Move the newly named bin file to the \embeddings\ directory

  5. Now boot up webui and lets call this in the prompt. For our example: <852style-girl>, photorealistic, oil painting, vintage

  6. Click generate. You should notice a prompt in your log window Loaded a total of {{x}} textual inversion embeddings.. Give it some time to process.

  7. Profit
    index

<852style-girl>, photorealistic, oil painting, vintage
Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 3895043234, Size: 512x768, Model hash: 9453d3e5

@dovezp
Copy link

dovezp commented Oct 1, 2022

You can manually tweak the ui.py if you would like to mess with the tokenizer functions, and navigate backwards from there to see what is happening but I personally don't recommend it.

https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/master/modules/ui.py#L348

@C43H66N12O12S2 C43H66N12O12S2 added not-an-issue This issue is not with the repo itself. and removed bug-report Report of a bug, yet to be confirmed labels Oct 2, 2022
nne998 pushed a commit to fjteam/stable-diffusion-webui that referenced this issue Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not-an-issue This issue is not with the repo itself.
Projects
None yet
Development

No branches or pull requests

3 participants