mirror of
https://github.com/Physton/sd-webui-prompt-all-in-one.git
synced 2026-01-26 11:19:55 +00:00
FIX: Prevent TypeError: NoneType on model switching in token counter
This fixes the critical `TypeError: argument of type 'NoneType' is not iterable` that frequently occurs in the token counter when the main Stable Diffusion model is being unloaded or reloaded (e.g., during XYZ Plot or manual model switching). The error happens because the `get_token_counter` function tries to access `sd_models.model_data.sd_model.cond_stage_model` when `sd_model` is momentarily `None`. The fix adds a robust check for `sd_models.model_data.sd_model is None` at the start of the function, ensuring the token counter safely returns 0 instead of causing an ASGI application crash across all environments (A1111, Forge/reForge).
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from modules import script_callbacks, extra_networks, prompt_parser, sd_models
|
||||
from modules.sd_hijack import model_hijack
|
||||
from functools import partial, reduce
|
||||
|
||||
|
||||
|
||||
def get_token_counter(text, steps):
|
||||
# Check if the model is fully loaded to prevent TypeError during model switching
|
||||
|
||||
Reference in New Issue
Block a user