mudler/LocalAI · error · ValueError

no insightface pack '{self.model_pack}' found — install via

Error message

no insightface pack '{self.model_pack}' found — install via `local-ai models install insightface-{self.model_pack.replace('_', '-')}`

What it means

Raised by the insightface engine constructor when _locate_insightface_pack cannot find a directory for the requested model pack (default 'buffalo_l'). The error embeds the exact remediation command, translating underscores to hyphens for the installer's naming scheme.

Source

Thrown at backend/python/insightface/engines.py:243

        self.det_size: tuple[int, int] = (640, 640)
        self.det_thresh: float = 0.5
        self._providers: list[str] = ["CPUExecutionProvider"]
        self._antispoofer: Antispoofer | None = None

    def prepare(self, options: dict[str, str]) -> None:
        import glob
        import os

        from insightface.model_zoo import model_zoo

        self.model_pack = options.get("model_pack", "buffalo_l")
        self.det_size = _parse_det_size(options.get("det_size", "640x640"))
        self.det_thresh = float(options.get("det_thresh", "0.5"))
        self._antispoofer = _build_antispoofer(options, options.get("_model_dir"))

        pack_dir = _locate_insightface_pack(options, self.model_pack)
        if pack_dir is None:
            raise ValueError(
                f"no insightface pack '{self.model_pack}' found — install via "
                f"`local-ai models install insightface-{self.model_pack.replace('_', '-')}`"
            )

        onnx_files = sorted(glob.glob(os.path.join(pack_dir, "*.onnx")))
        # When the pack extracts flat into a shared models directory it
        # mixes with ONNX files from other backends (opencv face engine,
        # MiniFASNet antispoof, WeSpeaker voice embedding, other buffalo
        # packs installed earlier). Feeding those into model_zoo.get_model()
        # blows up inside insightface's router — it assumes a 4-D NCHW
        # input and indexes `input_shape[2]` on tensors that aren't shaped
        # like a face model, raising IndexError. For the upstream packs we
        # know the exact ONNX manifest; scoping to it makes the load
        # deterministic (without it, det_10g.onnx from buffalo_l sorts
        # before det_500m.onnx from buffalo_sc and silently wins).
        manifest = _KNOWN_PACK_MANIFESTS.get(self.model_pack)
        if manifest is not None:
            scoped = [f for f in onnx_files if os.path.basename(f) in manifest]

View on GitHub (pinned to 44413a9d06)

Solutions

  1. Run the command from the message: `local-ai models install insightface-<pack-name-with-hyphens>`.
  2. Verify the pack name spelling in options ('buffalo_l' vs 'buffalo-sc' style differences).
  3. Confirm the models base directory LocalAI searches matches where the installer placed the pack.
  4. For offline hosts, manually place the pack's ONNX files in a directory the locator searches.

Example fix

# before (shell)
local-ai run   # pack never installed

# after
local-ai models install insightface-buffalo-l
local-ai run
Defensive patterns

Strategy: validation

Validate before calling

pack = options.get("model_pack", "buffalo_l")
if _locate_insightface_pack(options, pack) is None:
    raise ValueError(f"run first: local-ai models install insightface-{pack.replace('_', '-')}")

Type guard

def pack_available(options, pack: str) -> bool:
    return _locate_insightface_pack(options, pack) is not None

Try / catch

try:
    engine = InsightFaceEngine(options)
except ValueError as e:
    if "install via" in str(e):
        subprocess.run(["local-ai", "models", "install", f"insightface-{pack.replace('_', '-')}"], check=True)
        engine = InsightFaceEngine(options)  # retry after install
    else:
        raise

Prevention

When it happens

Trigger: options['model_pack'] names a pack whose directory is absent from every searched location — pack never installed, installed under a different name, or the models search path misconfigured.

Common situations: Fresh deployment without `local-ai models install insightface-buffalo-l`, custom pack name passed via options that was never downloaded, or the models directory env var pointing elsewhere than where packs were pulled.

Related errors


AI-assisted analysis of mudler/LocalAI@44413a9d06 (2026-08-15). Data as JSON: /api/errors/c36daa10b7577dc1. Report an issue: GitHub.