From 38b7ac6e269e6ecc5bdd6fefdfb2fb1185b09c9d Mon Sep 17 00:00:00 2001 From: comfyanonymous Date: Tue, 13 Feb 2024 00:01:08 -0500 Subject: [PATCH] Don't init the CLIP model when the checkpoint has no CLIP weights. --- comfy/sd.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/comfy/sd.py b/comfy/sd.py index c15d73fed..5b22d1178 100644 --- a/comfy/sd.py +++ b/comfy/sd.py @@ -470,10 +470,13 @@ def load_checkpoint_guess_config(ckpt_path, output_vae=True, output_clip=True, o w = WeightsLoader() clip_target = model_config.clip_target() if clip_target is not None: - clip = CLIP(clip_target, embedding_directory=embedding_directory) - w.cond_stage_model = clip.cond_stage_model sd = model_config.process_clip_state_dict(sd) - load_model_weights(w, sd) + if any(k.startswith('cond_stage_model.') for k in sd): + clip = CLIP(clip_target, embedding_directory=embedding_directory) + w.cond_stage_model = clip.cond_stage_model + load_model_weights(w, sd) + else: + print("no CLIP/text encoder weights in checkpoint, the text encoder model will not be loaded.") left_over = sd.keys() if len(left_over) > 0: