lllyasviel/Fooocus · error · RuntimeError
ERROR: Could not detect model type of: {}
Error message
ERROR: Could not detect model type of: {} What it means
In load_checkpoint_guess_config, model_detection.model_config_from_unet inspects the 'model.diffusion_model.' keys to fingerprint the architecture (SD1.x/SD2.x/SDXL etc.). If no known UNet signature matches, the returned config is None and this RuntimeError is raised: the checkpoint's UNet layout is not recognized by this version of ldm_patched. (Note the code calls model_config.set_manual_cast before the None check, so in practice a None config usually surfaces as an AttributeError first in this vendored copy — the RuntimeError is the intended signal.)
Source
Thrown at ldm_patched/modules/sd.py:453
vae = None
vae_filename = None
model = None
model_patcher = None
clip_target = None
parameters = ldm_patched.modules.utils.calculate_parameters(sd, "model.diffusion_model.")
unet_dtype = model_management.unet_dtype(model_params=parameters)
load_device = model_management.get_torch_device()
manual_cast_dtype = model_management.unet_manual_cast(unet_dtype, load_device)
class WeightsLoader(torch.nn.Module):
pass
model_config = model_detection.model_config_from_unet(sd, "model.diffusion_model.", unet_dtype)
model_config.set_manual_cast(manual_cast_dtype)
if model_config is None:
raise RuntimeError("ERROR: Could not detect model type of: {}".format(ckpt_path))
if model_config.clip_vision_prefix is not None:
if output_clipvision:
clipvision = clip_vision.load_clipvision_from_sd(sd, model_config.clip_vision_prefix, True)
if output_model:
inital_load_device = model_management.unet_inital_load_device(parameters, unet_dtype)
offload_device = model_management.unet_offload_device()
model = model_config.get_model(sd, "model.diffusion_model.", device=inital_load_device)
model.load_model_weights(sd, "model.diffusion_model.")
if output_vae:
if vae_filename_param is None:
vae_sd = ldm_patched.modules.utils.state_dict_prefix_replace(sd, {"first_stage_model.": ""}, filter_keys=True)
vae_sd = model_config.process_vae_state_dict(vae_sd)
else:
vae_sd = ldm_patched.modules.utils.load_torch_file(vae_filename_param)
vae_filename = vae_filename_paramView on GitHub (pinned to ae05379cc9)
Solutions
- Confirm the file is a full diffusion checkpoint containing 'model.diffusion_model.*' keys, and put VAEs/LoRAs in their own slots
- Update Fooocus / ldm_patched to a version that supports the model architecture
- Re-download the checkpoint in case of corruption, and re-merge with standard key names if you produced it yourself
Example fix
from safetensors import safe_open
with safe_open(path, framework='pt') as f:
has_unet = any(k.startswith('model.diffusion_model.') for k in f.keys())
# before: loading a bare VAE -> RuntimeError: Could not detect model type
# after:
if not has_unet:
raise SystemExit(f'{path} has no model.diffusion_model.* keys; not a diffusion checkpoint')
model = ldm_patched.modules.sd.load_checkpoint_guess_config(path) Defensive patterns
Strategy: validation
Validate before calling
from safetensors import safe_open
import os
def looks_like_diffusion_checkpoint(path):
if os.path.splitext(path)[1] not in ('.safetensors', '.ckpt', '.pt'):
return False
try:
with safe_open(path, framework='pt') as f:
return any(k.startswith('model.diffusion_model.') for k in f.keys())
except Exception:
return False
if not looks_like_diffusion_checkpoint(path):
reject_file(path, 'not a diffusion checkpoint') Try / catch
try:
out = ldm_patched.modules.sd.load_checkpoint_guess_config(path, output_vae=True, output_clip=True)
except Exception as e:
msg = str(e)
if 'Could not detect model type' in msg or ('NoneType' in msg and 'set_manual_cast' in msg):
raise ModelFormatError(f'{path}: unsupported/unknown UNet architecture - update Fooocus or use a standard checkpoint') from e
raise Prevention
- Validate that model.diffusion_model.* keys exist before loading user files
- Keep Fooocus/ldm_patched updated when adopting newly released architectures
- Use the correct input slot per file type (checkpoint vs VAE vs LoRA)
When it happens
Trigger: Pointing load_checkpoint_guess_config at a non-checkpoint file (a bare VAE, LoRA, or CLIP), or at a checkpoint whose UNet uses an architecture this ldm_patched snapshot does not know (e.g. SD3/Flux-style UNet in an older Fooocus). Also fires for heavily renamed/merged checkpoints whose diffusion_model keys were altered.
Common situations: User selects a VAE file in the checkpoint slot; user tries a brand-new community model with an old Fooocus build; key renaming during a merge breaks the fingerprint regexes.
Related errors
- checkpoint url or path is invalid
- checkpoint url or path is invalid
- CORRUPTED MODEL: one of the q-k-v values for the text encode
- invalid style model {}
- Wrong params!
AI-assisted analysis of lllyasviel/Fooocus@ae05379cc9 (2026-08-15).
Data as JSON: /api/errors/5461dd271fcf36bd.
Report an issue: GitHub.