Stability-AI/generative-models · error · ValueError

Model {model_id} not supported

Error message

Model {model_id} not supported

What it means

sgm.inference.api.SGMWrapper (its __init__) only supports the fixed set of model IDs hard-coded in the module-level `model_specs` dict. Passing any other string raises this ValueError before any file I/O happens, so it is purely a name-validation failure against the supported model registry.

Source

Thrown at sgm/inference/api.py:143

        is_legacy=True,
        config="sd_xl_refiner.yaml",
        ckpt="sd_xl_refiner_1.0.safetensors",
        is_guided=True,
    ),
}


class SamplingPipeline:
    def __init__(
        self,
        model_id: ModelArchitecture,
        model_path="checkpoints",
        config_path="configs/inference",
        device="cuda",
        use_fp16=True,
    ) -> None:
        if model_id not in model_specs:
            raise ValueError(f"Model {model_id} not supported")
        self.model_id = model_id
        self.specs = model_specs[self.model_id]
        self.config = str(pathlib.Path(config_path, self.specs.config))
        self.ckpt = str(pathlib.Path(model_path, self.specs.ckpt))
        self.device = device
        self.model = self._load_model(device=device, use_fp16=use_fp16)

    def _load_model(self, device="cuda", use_fp16=True):
        config = OmegaConf.load(self.config)
        model = load_model_from_config(config, self.ckpt)
        if model is None:
            raise ValueError(f"Model {self.model_id} could not be loaded")
        model.to(device)
        if use_fp16:
            model.conditioner.half()
            model.model.half()
        return model

View on GitHub (pinned to e8cd657656)

Solutions

  1. Inspect `sgm.inference.api.model_specs.keys()` and pass one of the exact registered model_id strings.
  2. Fix the typo so model_id matches a supported key exactly (case and spelling).
  3. If your model genuinely is unsupported, add a ModelSpec entry to model_specs with its config and checkpoint, or use a loader like load_model_from_config directly.

Example fix

// before
model = SGMWrapper(model_id="stable-diffusion-xl")
// after
from sgm.inference.api import model_specs, SGMWrapper
print(model_specs.keys())
model = SGMWrapper(model_id="sd-template-2.2")  # must be a key in model_specs
Defensive patterns

Strategy: validation

Validate before calling

from sgm.inference.api import model_specs
assert model_id in model_specs, f"model_id must be one of {list(model_specs)}"

Type guard

from typing import Literal, get_args
ModelId = Literal[tuple(model_specs.keys())]
def is_valid_model_id(x: str) -> bool:
    return x in model_specs

Try / catch

try:
    model = SGMWrapper(model_id=model_id)
except ValueError as e:
    print(f"Bad model_id: {e}; supported: {list(model_specs.keys())}")

Prevention

When it happens

Trigger: Constructing `SGMWrapper(model_id="sd-2.1")` (or any typo) where model_id is not a key of `model_specs` in sgm/inference/api.py — e.g. misspelled names like "stable-diffusion-2.1" instead of the exact registered ID, or inventing an ID for a checkpoint the wrapper was never configured for.

Common situations: Copying code from blog posts referencing different model naming conventions; upgrading the library where supported IDs changed; assuming arbitrary fine-tuned checkpoints can be loaded by making up an ID.

Related errors


AI-assisted analysis of Stability-AI/generative-models@e8cd657656 (2026-08-29). Data as JSON: /api/errors/67fa0034250cb271. Report an issue: GitHub.