Skip to content

Commit b401439

Browse files
Add model detection error hint for lora. (Comfy-Org#8880)
1 parent b43916a commit b401439

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

comfy/sd.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import comfy.ldm.ace.vae.music_dcae_pipeline
1919
import yaml
2020
import math
21+
import os
2122

2223
import comfy.utils
2324

@@ -977,6 +978,12 @@ def load_gligen(ckpt_path):
977978
model = model.half()
978979
return comfy.model_patcher.ModelPatcher(model, load_device=model_management.get_torch_device(), offload_device=model_management.unet_offload_device())
979980

981+
def model_detection_error_hint(path, state_dict):
982+
filename = os.path.basename(path)
983+
if 'lora' in filename.lower():
984+
return "\nHINT: This seems to be a Lora file and Lora files should be put in the lora folder and loaded with a lora loader node.."
985+
return ""
986+
980987
def load_checkpoint(config_path=None, ckpt_path=None, output_vae=True, output_clip=True, embedding_directory=None, state_dict=None, config=None):
981988
logging.warning("Warning: The load checkpoint with config function is deprecated and will eventually be removed, please use the other one.")
982989
model, clip, vae, _ = load_checkpoint_guess_config(ckpt_path, output_vae=output_vae, output_clip=output_clip, output_clipvision=False, embedding_directory=embedding_directory, output_model=True)
@@ -1005,7 +1012,7 @@ def load_checkpoint_guess_config(ckpt_path, output_vae=True, output_clip=True, o
10051012
sd, metadata = comfy.utils.load_torch_file(ckpt_path, return_metadata=True)
10061013
out = load_state_dict_guess_config(sd, output_vae, output_clip, output_clipvision, embedding_directory, output_model, model_options, te_model_options=te_model_options, metadata=metadata)
10071014
if out is None:
1008-
raise RuntimeError("ERROR: Could not detect model type of: {}".format(ckpt_path))
1015+
raise RuntimeError("ERROR: Could not detect model type of: {}\n{}".format(ckpt_path, model_detection_error_hint(ckpt_path, sd)))
10091016
return out
10101017

10111018
def load_state_dict_guess_config(sd, output_vae=True, output_clip=True, output_clipvision=False, embedding_directory=None, output_model=True, model_options={}, te_model_options={}, metadata=None):
@@ -1177,7 +1184,7 @@ def load_diffusion_model(unet_path, model_options={}):
11771184
model = load_diffusion_model_state_dict(sd, model_options=model_options)
11781185
if model is None:
11791186
logging.error("ERROR UNSUPPORTED DIFFUSION MODEL {}".format(unet_path))
1180-
raise RuntimeError("ERROR: Could not detect model type of: {}".format(unet_path))
1187+
raise RuntimeError("ERROR: Could not detect model type of: {}\n{}".format(unet_path, model_detection_error_hint(unet_path, sd)))
11811188
return model
11821189

11831190
def load_unet(unet_path, dtype=None):

0 commit comments

Comments
 (0)