diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2023-09-09 07:24:07 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-09 07:24:07 +0000 |
commit | 73c2a03d493abeaea78d3b3e78e7beab7e8b5915 (patch) | |
tree | 46e9112f789b639efe34499c7abb5ec14502c98c | |
parent | 06af73bd1d17b417f234746c9a2f8e8e92cf6149 (diff) | |
parent | 349f89302445e094394685c13c1ce95cd14975b8 (diff) | |
download | stable-diffusion-webui-gfx803-73c2a03d493abeaea78d3b3e78e7beab7e8b5915.tar.gz stable-diffusion-webui-gfx803-73c2a03d493abeaea78d3b3e78e7beab7e8b5915.tar.bz2 stable-diffusion-webui-gfx803-73c2a03d493abeaea78d3b3e78e7beab7e8b5915.zip |
Merge pull request #13118 from ljleb/fix-counter
Don't use multicond parser for negative prompt counter
-rw-r--r-- | modules/ui.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/modules/ui.py b/modules/ui.py index 06aa509b..5f0f1cd1 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -1,4 +1,5 @@ import datetime
+import functools
import mimetypes
import os
import sys
@@ -151,11 +152,14 @@ def connect_clear_prompt(button): )
-def update_token_counter(text, steps):
+def update_token_counter(text, steps, is_positive=True):
try:
text, _ = extra_networks.parse_prompt(text)
- _, prompt_flat_list, _ = prompt_parser.get_multicond_prompt_list([text])
+ if is_positive:
+ _, prompt_flat_list, _ = prompt_parser.get_multicond_prompt_list([text])
+ else:
+ prompt_flat_list = [text]
prompt_schedules = prompt_parser.get_learned_conditioning_prompt_schedules(prompt_flat_list, steps)
except Exception:
@@ -535,7 +539,7 @@ def create_ui(): ]
toprow.token_button.click(fn=wrap_queued_call(update_token_counter), inputs=[toprow.prompt, steps], outputs=[toprow.token_counter])
- toprow.negative_token_button.click(fn=wrap_queued_call(update_token_counter), inputs=[toprow.negative_prompt, steps], outputs=[toprow.negative_token_counter])
+ toprow.negative_token_button.click(fn=wrap_queued_call(functools.partial(update_token_counter, is_positive=False)), inputs=[toprow.negative_prompt, steps], outputs=[toprow.negative_token_counter])
extra_networks_ui = ui_extra_networks.create_ui(txt2img_interface, [txt2img_generation_tab], 'txt2img')
ui_extra_networks.setup_ui(extra_networks_ui, txt2img_gallery)
|