From 0d27d9ea090f8300677d4c2571dedf2b62ac4fb5 Mon Sep 17 00:00:00 2001 From: awsr <43862868+awsr@users.noreply.github.com> Date: Fri, 27 Feb 2026 18:06:01 -0800 Subject: [PATCH] Use manual looping - I'm assuming there won't be much of a difference in performance. If it ends up being too slow, this can always be reverted. --- modules/ui_common.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/ui_common.py b/modules/ui_common.py index 99a8a2d22..0231676c6 100644 --- a/modules/ui_common.py +++ b/modules/ui_common.py @@ -458,11 +458,8 @@ def update_token_counter(text: str): max_length = 0 try: - try: - ids = getattr(tokenizer(prompt_list), 'input_ids', []) - except TypeError: - for p in prompt_list: - ids.append(getattr(tokenizer(p), 'input_ids', [])) + for p in prompt_list: + ids.append(getattr(tokenizer(p), 'input_ids', [])) except Exception as e: shared.log.warning("Token counter:", e) return gr.update(value=f"??/{max_length}", visible=True)