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

fix prompt-bracket-checker miscounting of literal tokens #16669

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

w-e-w
Copy link
Collaborator

@w-e-w w-e-w commented Nov 20, 2024

Description

Current the prompt-bracket-checker.js treats literal tokens as normal tokens

brackets and parentheses proceeded with a slash \( \) are literal

this is wrong

this can easily be fixed by modifying the regex to so it does not count tokens proceeded by a \

internal prompt parser for reference

def parse_prompt_attention(text):
"""
Parses a string with attention tokens and returns a list of pairs: text and its associated weight.
Accepted tokens are:
(abc) - increases attention to abc by a multiplier of 1.1
(abc:3.12) - increases attention to abc by a multiplier of 3.12
[abc] - decreases attention to abc by a multiplier of 1.1
\( - literal character '('
\[ - literal character '['
\) - literal character ')'
\] - literal character ']'
\\ - literal character '\'
anything else - just text

this is not too big of an issue most of the time as if you have a literal opening token in prompts, you would almost alwase have a literal closing token

the internal prompt parser dose handles miss match (()or strangely ordered )( brackets

Screenshots/videos:

Current
image
image

Fixed
image
image

test sample text

should error

Current prompt-bracket-checker.js treats \( literal brackets and parentheses )
\(parentheses proceeded with a slash\) are treated as normal brackets
this is wrong, this SHOUD error
the literal parentheses on the 1st line shoud NOT be counted
resulting an extra closeing parentheses on 1st line

should not error

while this \( should NOT error
as the parentheses on the first line is literal

Checklist:

@catboxanon catboxanon merged commit cd869bb into dev Nov 20, 2024
6 checks passed
Panchovix added a commit to Panchovix/stable-diffusion-webui-reForge that referenced this pull request Nov 20, 2024
@w-e-w w-e-w mentioned this pull request Nov 21, 2024
4 tasks
bluelovers added a commit to bluelovers/stable-diffusion-webui that referenced this pull request Nov 26, 2024
* dev-a1111:
  fix passing of literal backslash (AUTOMATIC1111#16671)
  fix prompt-bracket-checker miscounting of literal tokens (AUTOMATIC1111#16669)
  Bump safetensors to v0.4.5
  Honor lossless webp compression option in API
  use shared.hf_endpoint (AUTOMATIC1111#16611)
  Warn if WebUI is installed under a dot directory (AUTOMATIC1111#16584)
  sd_xl_v.yaml: use_checkpoint = False
  XYZ option to disable grid (AUTOMATIC1111#16416)
  Fix Default system None filter logic (AUTOMATIC1111#16309)
  Fix weighting config for SDXL v-pred
  InputAccordion duplicate elem_id handling (AUTOMATIC1111#16381)
  addEventListener {passive: false} (AUTOMATIC1111#16575)
  pyenv-win compatibility - another approach (AUTOMATIC1111#16287)
  Disable Hires checkpoint if same as First pass checkpoint (AUTOMATIC1111#16269)
  Fix postprocessing_enable_in_main_ui ScriptPostprocessing elem_id (AUTOMATIC1111#16373)
  extra_only / main_ui_only ScriptPostprocessing (AUTOMATIC1111#16374)
  Allow newline in Extra Network activation text (AUTOMATIC1111#16428)
  image embedding data cache (AUTOMATIC1111#16556)
  Fix typo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants