Commit Graph

10 Commits (d4b37aa4187b40466772b6282d8b28acd5ad77c9)

Author SHA1 Message Date
hirorohi 2aa33fd12a Fix ModuleNotFoundError for sd_hijack
by KidouEita
2026-04-20 16:34:50 +09:00
ねおん 88be6531e8
Fix: Use try-except to stabilize token counter during model access
This fixes a server crash (TypeError NoneType in torch/nn/modules/module.py) when the token counter API is triggered during model load/switch.

Standard sequential null checks failed because the crash occurred inside PyTorch's internal attribute lookup process. The whole function is wrapped in try-except as a robust defense against this race condition.
2025-11-26 16:22:35 +09:00
ねおん 077daf3f6e
FIX: Prevent critical TypeError in token counter with robust null check (v4)
The token counter was crashing during model loading/unloading (race condition) because it was attempting to access attributes on an object that was momentarily None.

This fix introduces a sequential and robust null check (sd_models.model_data is None or sd_models.model_data.sd_model is None) at the start of the function to safely return 0 tokens during unstable states.
2025-11-26 02:07:14 +09:00
ねおん b49e275eb0
FIX: Prevent TypeError in token counter during model switching (v2)
The previous fix (v1) was incomplete, as sd_model.cond_stage_model could still be None during model loading/unloading sequences (observed with XYZ Plot model swapping).
This v2 fix adds a specific check for cond_stage_model to ensure stability in dynamic environments.
2025-11-15 23:52:24 +09:00
ねおん fea3070a40
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).
2025-11-10 02:49:34 +09:00
ねおん 0aa3c04de4
Update get_token_counter.py 2025-11-10 02:44:22 +09:00
ねおん d7865901ec
Update get_token_counter.py 2025-11-10 02:28:05 +09:00
ねおん 9e1ced6438
Fix: Prevent TypeError: 'NoneType' is not iterable on model switching (Forge/reForge)
This fixes the TypeError that occurs during model switching in sd-webui-reforge and possibly other optimized environments.

The error happens because 'get_token_counter' tries to access 'sd_models.model_data.sd_model.cond_stage_model' before the model is fully loaded (when 'sd_model' is None).

The fix adds a check for the 'None' value to safely return 0 tokens instead of throwing an error.
2025-11-04 03:14:14 +09:00
Serick 8a41850bff Add cond_stage_model to get_prompt_lengths argument only when using forge 2024-02-14 13:42:13 +09:00
Physton 510fa649c6 Optimize Python code
Former-commit-id: 8d08367816ff84a2a2f62470b06421c0340f5fdb
2023-06-15 17:21:56 +08:00