stable-diffusion-webui
stable-diffusion-webui copied to clipboard
[Bug]: Typo in re_attention in prompt_parser.py?
Is there an existing issue for this?
- [X] I have searched the existing issues and checked the recent builds/commits
What happened?
prompt_parser.py in line 261 has
re_attention = re.compile(r"""
\\\(|
\\\)|
\\\[|
\\]|
\\\\|
\\|
\(|
\[|
:([+-]?[.\d]+)\)|
\)|
]|
[^\\()\[\]:]+|
:
""", re.X)
The 5th line (\\]|) seems to be missing a backslash.
Steps to reproduce the problem
- Open file
- Stare at file
- ...
- Profit :)
What should have happened?
A correct regular expression should be in that file, with balanced brackets.
Commit where the problem happens
c1c27dad3ba371a5ae344b267c760aa51e77f193
What platforms do you use to access the UI ?
Linux
What browsers do you use to access the UI ?
Brave
Command Line Arguments
`--lowvram --always-batch-cond-uncond --theme dark --xformers`
List of extensions
No
Console logs
No
Additional information
(sorry for not filling out all the boxes, I guess this is not actually important)
While that regex is definitely the stuff nightmares are made of, I'm not detecting any real impact from it. I tried editing the file, restarting the server, and generating an image with a static seed. I ran three passes with a prompt where a word had no brackets, square brackets, and escaped square brackets. Each change to the prompt changes the image, but between the version with two backslashes in the file, versus three, there is absolutely no difference in the result.
You can see on the 9th and 12th line there, there's another pair where the opening square bracket is escaped, but the closing is not. Google absolutely refuses to give up its secrets regarding this, but I hypothesize that you don't need to escape a close bracket if it's not after an open bracket.
I added a print(res) to the code to see what falls out, and "fixing" this regexp does indeed not change the behavior -- at least not with the test cases I was able to come up with.
Even running this manually in ipython
for m in re_attention.finditer('(([(abc\[:2)(def\]:3)]))'):
print(m.group(0), m.group(1))
showed no difference.
So yes, not a bug at all, it just makes the nigthmares worse ;)