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).pull/366/head
parent
0aa3c04de4
commit
fea3070a40