{"record":{"id":"c36daa10b7577dc1","repo":"mudler/LocalAI","slug":"no-insightface-pack-self-model-pack-found-in","errorCode":null,"errorMessage":"no insightface pack '{self.model_pack}' found — install via `local-ai models install insightface-{self.model_pack.replace('_', '-')}`","messagePattern":"no insightface pack '(.+?)' found — install via `local-ai models install insightface-(.+?)`","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/python/insightface/engines.py","lineNumber":243,"sourceCode":"        self.det_size: tuple[int, int] = (640, 640)\n        self.det_thresh: float = 0.5\n        self._providers: list[str] = [\"CPUExecutionProvider\"]\n        self._antispoofer: Antispoofer | None = None\n\n    def prepare(self, options: dict[str, str]) -> None:\n        import glob\n        import os\n\n        from insightface.model_zoo import model_zoo\n\n        self.model_pack = options.get(\"model_pack\", \"buffalo_l\")\n        self.det_size = _parse_det_size(options.get(\"det_size\", \"640x640\"))\n        self.det_thresh = float(options.get(\"det_thresh\", \"0.5\"))\n        self._antispoofer = _build_antispoofer(options, options.get(\"_model_dir\"))\n\n        pack_dir = _locate_insightface_pack(options, self.model_pack)\n        if pack_dir is None:\n            raise ValueError(\n                f\"no insightface pack '{self.model_pack}' found — install via \"\n                f\"`local-ai models install insightface-{self.model_pack.replace('_', '-')}`\"\n            )\n\n        onnx_files = sorted(glob.glob(os.path.join(pack_dir, \"*.onnx\")))\n        # When the pack extracts flat into a shared models directory it\n        # mixes with ONNX files from other backends (opencv face engine,\n        # MiniFASNet antispoof, WeSpeaker voice embedding, other buffalo\n        # packs installed earlier). Feeding those into model_zoo.get_model()\n        # blows up inside insightface's router — it assumes a 4-D NCHW\n        # input and indexes `input_shape[2]` on tensors that aren't shaped\n        # like a face model, raising IndexError. For the upstream packs we\n        # know the exact ONNX manifest; scoping to it makes the load\n        # deterministic (without it, det_10g.onnx from buffalo_l sorts\n        # before det_500m.onnx from buffalo_sc and silently wins).\n        manifest = _KNOWN_PACK_MANIFESTS.get(self.model_pack)\n        if manifest is not None:\n            scoped = [f for f in onnx_files if os.path.basename(f) in manifest]","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/backend/python/insightface/engines.py#L225-L261","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run the command from the message: `local-ai models install insightface-<pack-name-with-hyphens>`.","Verify the pack name spelling in options ('buffalo_l' vs 'buffalo-sc' style differences).","Confirm the models base directory LocalAI searches matches where the installer placed the pack.","For offline hosts, manually place the pack's ONNX files in a directory the locator searches."],"exampleFix":"# before (shell)\nlocal-ai run   # pack never installed\n\n# after\nlocal-ai models install insightface-buffalo-l\nlocal-ai run","handlingStrategy":"validation","validationCode":"pack = options.get(\"model_pack\", \"buffalo_l\")\nif _locate_insightface_pack(options, pack) is None:\n    raise ValueError(f\"run first: local-ai models install insightface-{pack.replace('_', '-')}\")","typeGuard":"def pack_available(options, pack: str) -> bool:\n    return _locate_insightface_pack(options, pack) is not None","tryCatchPattern":"try:\n    engine = InsightFaceEngine(options)\nexcept ValueError as e:\n    if \"install via\" in str(e):\n        subprocess.run([\"local-ai\", \"models\", \"install\", f\"insightface-{pack.replace('_', '-')}\"], check=True)\n        engine = InsightFaceEngine(options)  # retry after install\n    else:\n        raise","preventionTips":["Add pack installation to deployment provisioning scripts.","Validate pack presence at backend startup with a clear log line.","Keep pack option names aligned with installer naming (hyphens vs underscores)."],"tags":["insightface","model-installation","configuration","localai"],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}