mirror of
https://github.com/jags111/efficiency-nodes-comfyui.git
synced 2026-03-26 07:35:45 -03:00
Refactor: Extract VAE error message into helper function
Co-authored-by: jags111 <5968619+jags111@users.noreply.github.com>
This commit is contained in:
@@ -99,6 +99,16 @@ def encode_prompts(positive_prompt, negative_prompt, token_normalization, weight
|
|||||||
elif return_type == "both":
|
elif return_type == "both":
|
||||||
return positive_encoded, negative_encoded, clip, refiner_positive_encoded, refiner_negative_encoded, refiner_clip
|
return positive_encoded, negative_encoded, clip, refiner_positive_encoded, refiner_negative_encoded, refiner_clip
|
||||||
|
|
||||||
|
########################################################################################################################
|
||||||
|
# Helper function for VAE error message
|
||||||
|
def get_missing_vae_error(ckpt_name):
|
||||||
|
"""Generate error message for checkpoints without embedded VAE"""
|
||||||
|
return (
|
||||||
|
f"Checkpoint '{ckpt_name}' does not contain an embedded VAE. "
|
||||||
|
f"This checkpoint (likely an AIO model) requires an external VAE. "
|
||||||
|
f"Please select a VAE file instead of 'Baked VAE'."
|
||||||
|
)
|
||||||
|
|
||||||
########################################################################################################################
|
########################################################################################################################
|
||||||
# TSC Efficient Loader
|
# TSC Efficient Loader
|
||||||
class TSC_EfficientLoader:
|
class TSC_EfficientLoader:
|
||||||
@@ -168,11 +178,7 @@ class TSC_EfficientLoader:
|
|||||||
cache_overwrite=True)
|
cache_overwrite=True)
|
||||||
# Check if VAE extraction was successful
|
# Check if VAE extraction was successful
|
||||||
if vae is None:
|
if vae is None:
|
||||||
raise ValueError(
|
raise ValueError(get_missing_vae_error(ckpt_name))
|
||||||
f"Checkpoint '{ckpt_name}' does not contain an embedded VAE. "
|
|
||||||
f"This checkpoint (likely an AIO model) requires an external VAE. "
|
|
||||||
f"Please select a VAE file instead of 'Baked VAE'."
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
model, clip, vae = load_checkpoint(ckpt_name, my_unique_id, cache=ckpt_cache, cache_overwrite=True)
|
model, clip, vae = load_checkpoint(ckpt_name, my_unique_id, cache=ckpt_cache, cache_overwrite=True)
|
||||||
lora_params = None
|
lora_params = None
|
||||||
@@ -204,11 +210,7 @@ class TSC_EfficientLoader:
|
|||||||
vae = load_vae(vae_name, my_unique_id, cache=vae_cache, cache_overwrite=True)
|
vae = load_vae(vae_name, my_unique_id, cache=vae_cache, cache_overwrite=True)
|
||||||
elif vae is None:
|
elif vae is None:
|
||||||
# If "Baked VAE" was selected but checkpoint has no embedded VAE
|
# If "Baked VAE" was selected but checkpoint has no embedded VAE
|
||||||
raise ValueError(
|
raise ValueError(get_missing_vae_error(ckpt_name))
|
||||||
f"Checkpoint '{ckpt_name}' does not contain an embedded VAE. "
|
|
||||||
f"This checkpoint (likely an AIO model) requires an external VAE. "
|
|
||||||
f"Please select a VAE file instead of 'Baked VAE'."
|
|
||||||
)
|
|
||||||
|
|
||||||
# Data for XY Plot
|
# Data for XY Plot
|
||||||
dependencies = (vae_name, ckpt_name, clip, clip_skip, refiner_name, refiner_clip, refiner_clip_skip,
|
dependencies = (vae_name, ckpt_name, clip, clip_skip, refiner_name, refiner_clip, refiner_clip_skip,
|
||||||
|
|||||||
Reference in New Issue
Block a user