Improve error message when UNet model is missing

This commit is contained in:
RAJ-VARUN13 2026-05-15 12:12:12 +05:30
parent 77e2ed5e01
commit e6fae69d89

View File

@ -950,7 +950,20 @@ class UNETLoader:
elif weight_dtype == "fp8_e5m2":
model_options["dtype"] = torch.float8_e5m2
unet_path = folder_paths.get_full_path_or_raise("diffusion_models", unet_name)
try:
unet_path = folder_paths.get_full_path_or_raise("diffusion_models", unet_name)
except FileNotFoundError:
available = folder_paths.get_filename_list("diffusion_models")
available_models = "\n".join(f"- {name}" for name in available[:10])
raise FileNotFoundError(
f"UNet model '{unet_name}' was not found.\n\n"
f"Expected location:\n"
f"ComfyUI/models/unet/\n\n"
f"Available UNet models:\n"
f"{available_models if available_models else '(none found)'}"
)
model = comfy.sd.load_diffusion_model(unet_path, model_options=model_options)
return (model,)