Merge pull request #368 from neon-aiart/fix/token-counter-nonetype
FIX: Token Counter TypeError (v2: Handle cond_stage_model is None)pull/369/head
commit
1b2cce5433
|
|
@ -4,8 +4,10 @@ from functools import partial, reduce
|
||||||
|
|
||||||
|
|
||||||
def get_token_counter(text, steps):
|
def get_token_counter(text, steps):
|
||||||
# Check if the model is fully loaded to prevent TypeError during model switching
|
# Check if the model is fully loaded to prevent TypeError during model switching.
|
||||||
if sd_models.model_data.sd_model is None:
|
# Checks both sd_model and its subcomponent (cond_stage_model).
|
||||||
|
if sd_models.model_data.sd_model is None or \
|
||||||
|
sd_models.model_data.sd_model.cond_stage_model is None:
|
||||||
return {"token_count": 0, "max_length": 0}
|
return {"token_count": 0, "max_length": 0}
|
||||||
|
|
||||||
# copy from modules.ui.py
|
# copy from modules.ui.py
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue