Fix error with ClipVision loader node.

This commit is contained in:
comfyanonymous 2023-06-23 01:08:05 -04:00
parent 3e0686ce94
commit 9e37f4c7d5
2 changed files with 4 additions and 3 deletions

View File

@ -52,8 +52,9 @@ def convert_to_transformers(sd, prefix):
sd = transformers_convert(sd, prefix, "vision_model.", 32) sd = transformers_convert(sd, prefix, "vision_model.", 32)
return sd return sd
def load_clipvision_from_sd(sd, prefix): def load_clipvision_from_sd(sd, prefix="", convert_keys=False):
sd = convert_to_transformers(sd, prefix) if convert_keys:
sd = convert_to_transformers(sd, prefix)
if "vision_model.encoder.layers.30.layer_norm1.weight" in sd: if "vision_model.encoder.layers.30.layer_norm1.weight" in sd:
json_config = os.path.join(os.path.dirname(os.path.realpath(__file__)), "clip_vision_config_h.json") json_config = os.path.join(os.path.dirname(os.path.realpath(__file__)), "clip_vision_config_h.json")
else: else:

View File

@ -1049,7 +1049,7 @@ def load_checkpoint_guess_config(ckpt_path, output_vae=True, output_clip=True, o
if model_config.clip_vision_prefix is not None: if model_config.clip_vision_prefix is not None:
if output_clipvision: if output_clipvision:
clipvision = clip_vision.load_clipvision_from_sd(sd, model_config.clip_vision_prefix) clipvision = clip_vision.load_clipvision_from_sd(sd, model_config.clip_vision_prefix, True)
model = model_config.get_model(sd) model = model_config.get_model(sd)
model.load_model_weights(sd, "model.diffusion_model.") model.load_model_weights(sd, "model.diffusion_model.")