[GH-ISSUE #47] Have issue working with weight syntanx and editing prompt #36

Closed
opened 2026-10-30 21:17:37 +00:00 by bsakaguchi · 8 comments
Owner

Originally created by @byzod on GitHub (Oct 29, 2022).
Original GitHub issue: https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/issues/47

  1. Interfere vanilla hotkey to chagne weight, i.e. select a word and press ctrl+↑ or ctrl+↓ to quick change weight of it. With tagcomplete runnig, this hotkey no longer works

    For example double click to select word dog in prompt girl, (sad:1.5), dog and press ctrl+↑, the prompt changes to girl, (sad:1.5), (dog:1.1) automatically, when tagcomplete is not installed

  2. Have problem showing complete drop list inside weight parenthesis when edit existed tag

    For example select dog in girl, (sad:1.5), dog and type runn to overwrite it, the tagcomplete list shows and I can tab to select running
    But select sad and type runn to overwrite it, no list shows.
    Select sad and type runn still no list show.
    Select sad and type runn the list shows but tab or click running nothing happens.

    demo
    An1

Originally created by @byzod on GitHub (Oct 29, 2022). Original GitHub issue: https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/issues/47 1. Interfere vanilla hotkey to chagne weight, i.e. select a word and press `ctrl+↑` or `ctrl+↓` to quick change weight of it. With tagcomplete runnig, this hotkey no longer works For example double click to select word `dog` in prompt `girl, (sad:1.5), dog` and press `ctrl+↑`, the prompt changes to `girl, (sad:1.5), (dog:1.1)` automatically, when tagcomplete is not installed 3. Have problem showing complete drop list inside weight parenthesis when edit existed tag For example select `dog` in `girl, (sad:1.5), dog` and type `runn` to overwrite it, the tagcomplete list shows and I can `tab` to select `running` But select `sad` and type `runn` to overwrite it, no list shows. Select `sad` and type ` runn` still no list show. Select `sad` and type ` runn ` the list shows but `tab` or click `running` nothing happens. demo ![An1](https://user-images.githubusercontent.com/848607/198823277-a2b55d5c-f259-43ff-bdb9-4e175465e86c.gif)
Author
Owner

@DominikDoom commented on GitHub (Oct 29, 2022):

  1. was fixed in 9fc9f1ab7d (v1.6.0), so if you're on a version newer than that it should work (it does for me on the current version).
  2. This is a known issue currently. Since some tags can have parentheses or colons, a word inside them is not seen as a single tag without brackets, but tries to match the text including the parentheses and : separator. I could probably add a special check for that though. The reason it doesn't autocomplete after you clicked on it is because it looks for the word based on the cursor position, so since the cursor is not at the end of the word but after the space, it fails. But that it shows the list in that case after you typed a space seems to be a bug, I'll look into it.
<!-- gh-comment-id:1295796106 --> @DominikDoom commented on GitHub (Oct 29, 2022): 1. was fixed in 9fc9f1ab7dcaa3cee9e226061df6a320f8626aad (v1.6.0), so if you're on a version newer than that it should work (it does for me on the current version). 2. This is a known issue currently. Since some tags can have parentheses or colons, a word inside them is not seen as a single tag without brackets, but tries to match the text including the parentheses and : separator. I could probably add a special check for that though. The reason it doesn't autocomplete after you clicked on it is because it looks for the word based on the cursor position, so since the cursor is not at the end of the word but after the space, it fails. But that it shows the list in that case after you typed a space seems to be a bug, I'll look into it.
Author
Owner

@byzod commented on GitHub (Oct 29, 2022):

  1. was fixed in 9fc9f1a (v1.6.0), so if you're on a version newer than that it should work (it does for me on the current version).

Thanks for the confirm, after few test I found that it's a hardcode bug of webui's localization... this feature is not working at all with chinese localization ..I didn't realized that until now :/

github.com/AUTOMATIC1111/stable-diffusion-webui@35c45df28b/javascript/edit-attention.js (L4)

It check if the placeholder has prompt, but in chinese it's 提示词, so always return false

  1. This is a known issue currently. Since some tags can have parentheses or colons, a word inside them is not seen as a single tag without brackets, but tries to match the text including the parentheses and : separator. I could probably add a special check for that though.

Parenthesis of correctly written tags are always escaped like Nero \(fate\), just ignore unescaped (wrong) parenthesis would make things easier

<!-- gh-comment-id:1295809203 --> @byzod commented on GitHub (Oct 29, 2022): > 1. was fixed in [9fc9f1a](https://github.com/DominikDoom/a1111-sd-webui-tagcomplete/commit/9fc9f1ab7dcaa3cee9e226061df6a320f8626aad) (v1.6.0), so if you're on a version newer than that it should work (it does for me on the current version). Thanks for the confirm, after few test I found that it's a hardcode bug of webui's localization... this feature is not working at all with chinese localization ..I didn't realized that until now :/ https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/35c45df28b303a05d56a13cb56d4046f08cf8c25/javascript/edit-attention.js#L4 It check if the placeholder has `prompt`, but in chinese it's `提示词`, so always return false > 2. This is a known issue currently. Since some tags can have parentheses or colons, a word inside them is not seen as a single tag without brackets, but tries to match the text including the parentheses and : separator. I could probably add a special check for that though. Parenthesis of **correctly written** tags are always escaped like `Nero \(fate\)`, just ignore unescaped (wrong) parenthesis would make things easier
Author
Owner

@DominikDoom commented on GitHub (Oct 29, 2022):

Good to know, you should probably open an issue there for that bug if there isn't one already
Ah I see you already did that.

For 2 simply ignoring it sadly isn't an option because () aren't escaped yet if the user is still typing them, but I am currently working on the proper solution with a separate check for the (<tag>:<num>) weighting format. With that in place you should then be able to edit & complete tags in the weighting brackets like any other.

<!-- gh-comment-id:1295811524 --> @DominikDoom commented on GitHub (Oct 29, 2022): ~Good to know, you should probably open an issue there for that bug if there isn't one already~ Ah I see you already did that. For 2 simply ignoring it sadly isn't an option because () aren't escaped yet if the user is still typing them, but I am currently working on the proper solution with a separate check for the (\<tag\>:\<num\>) weighting format. With that in place you should then be able to edit & complete tags in the weighting brackets like any other.
Author
Owner

@byzod commented on GitHub (Oct 29, 2022):

Got it: https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/3904

I don't know much about the parser thing so no more suggestions I could give :)

Don't forget that webui support complex syntax like this: (part of a real prompt from a friend)

(closeup:0.6) sweat [(loli:1):0.75] small breasts, wet (cumdrip pussy:1.2), 
[sketch | line art|charcoal ] [(watercolor:1.2):0.7] spot color by [(Jeremy Mann:1.4)::0.6] [(Akihiko Yoshida:1.4):0.4]
<!-- gh-comment-id:1295812620 --> @byzod commented on GitHub (Oct 29, 2022): Got it: https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/3904 I don't know much about the parser thing so no more suggestions I could give :) Don't forget that webui support complex syntax like this: (part of a real prompt from a friend) ``` (closeup:0.6) sweat [(loli:1):0.75] small breasts, wet (cumdrip pussy:1.2), [sketch | line art|charcoal ] [(watercolor:1.2):0.7] spot color by [(Jeremy Mann:1.4)::0.6] [(Akihiko Yoshida:1.4):0.4] ```
Author
Owner

@DominikDoom commented on GitHub (Oct 29, 2022):

Yeah I'm aware, I do some complex prompts from time to time myself.
With my current WIP regex it would look like this:
image
Everything that is green was matched as a weighted tag, while brown tries to match "normal" tags. As you can see, it already works pretty well, even for nested tags - as long as they have no spaces, which is a limitation of all tags currently.

So when editing a tag that was already inserted, you'd have use underscores:
image
to still get a proper match. Maybe I'll automate or work around that in the future somehow, but for now it's out of scope.

With spaces ignored, it matches all of them as expected though, so I know the regex will also work for the future.
image
I just can't ignore them for now because I have no mechanism in place to search & insert tags with underscores or spaces seen as the same.

<!-- gh-comment-id:1295818593 --> @DominikDoom commented on GitHub (Oct 29, 2022): Yeah I'm aware, I do some complex prompts from time to time myself. With my current WIP regex it would look like this: ![image](https://user-images.githubusercontent.com/34448969/198830444-73072a7d-c2de-4420-a715-ef54dd22fdcf.png) Everything that is green was matched as a weighted tag, while brown tries to match "normal" tags. As you can see, it already works pretty well, even for nested tags - as long as they have no spaces, which is a limitation of all tags currently. So when editing a tag that was already inserted, you'd have use underscores: ![image](https://user-images.githubusercontent.com/34448969/198830154-7560a14a-af37-46c3-909f-ceed8ede61fd.png) to still get a proper match. Maybe I'll automate or work around that in the future somehow, but for now it's out of scope. With spaces ignored, it matches all of them as expected though, so I know the regex will also work for the future. ![image](https://user-images.githubusercontent.com/34448969/198830568-d6d689ef-f196-4848-a5fe-cd1dcdd42002.png) I just can't ignore them for now because I have no mechanism in place to search & insert tags with underscores or spaces seen as the same.
Author
Owner

@byzod commented on GitHub (Oct 29, 2022):

With spaces ignored, it matches all of them as expected though, so I know the regex will also work for the future. I just can't ignore them for now because I have no mechanism in place to search & insert tags with underscores or spaces seen as the same.

It's worth noting that (cat ears:1.5) is (cat_ears:1.5), but (girl with cat ears:1.5) is not (girl_with_cat_ears:1.5), there's no way to tell the difference unless you search the tag in database all the time (will that be a performance hit?), nor you can tell user want to edit cat ears or girl with cat ears when they double click on cat

<!-- gh-comment-id:1295824599 --> @byzod commented on GitHub (Oct 29, 2022): > With spaces ignored, it matches all of them as expected though, so I know the regex will also work for the future. I just can't ignore them for now because I have no mechanism in place to search & insert tags with underscores or spaces seen as the same. It's worth noting that `(cat ears:1.5)` is `(cat_ears:1.5)`, but `(girl with cat ears:1.5)` is not `(girl_with_cat_ears:1.5)`, there's no way to tell the difference unless you search the tag in database all the time (will that be a performance hit?), nor you can tell user want to edit `cat ears` or `girl with cat ears` when they double click on `cat`
Author
Owner

@DominikDoom commented on GitHub (Oct 29, 2022):

Yeah, that is the big problem. I can't know where multi-word tags start or end, and searching for multiple pair combinations would be impossible due to performance reasons - trying out every combination would be:

  1. Matching every single tag
  2. Matching every combination of adjacent words
    a. For all groups size 2 to size n, where n is our total tag count.

That would put us at a complexity of O(cn) or worse, which gets out of hand really fast.

That's why I'm choosing to ignore it for now 😅
Finding a proper solution for that would only work in very restrictive circumstances, so I think it's fair game to require manual underscore replacement by the user on that part (or leaving replaceUnderscores off in the config, but that might lead to worse results for some models.

<!-- gh-comment-id:1295827112 --> @DominikDoom commented on GitHub (Oct 29, 2022): Yeah, that is the big problem. I can't know where multi-word tags start or end, and searching for multiple pair combinations would be impossible due to performance reasons - trying out every combination would be: 1. Matching every single tag 2. Matching every combination of adjacent words a. For all groups size 2 to size n, where n is our total tag count. That would put us at a complexity of O(c<sup>n</sup>) or worse, which gets out of hand really fast. That's why I'm choosing to ignore it for now 😅 Finding a proper solution for that would only work in very restrictive circumstances, so I think it's fair game to require manual underscore replacement by the user on that part (or leaving `replaceUnderscores` off in the config, but that might lead to worse results for some models.
Author
Owner

@DominikDoom commented on GitHub (Oct 29, 2022):

Editing inside brackets should work now, as long as the hard-coding bug is fixed for you on the webui side.

https://user-images.githubusercontent.com/34448969/198831834-6d31418c-1ad9-41d0-b928-808587ec6059.mp4

<!-- gh-comment-id:1295827356 --> @DominikDoom commented on GitHub (Oct 29, 2022): Editing inside brackets should work now, as long as the hard-coding bug is fixed for you on the webui side. https://user-images.githubusercontent.com/34448969/198831834-6d31418c-1ad9-41d0-b928-808587ec6059.mp4
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DominikDoom/a1111-sd-webui-tagcomplete#36
No description provided.