{"record":{"id":"ac964f68930d3edd","repo":"mudler/LocalAI","slug":"no-onnx-files-in-pack-directory-pack-dir","errorCode":null,"errorMessage":"no ONNX files in pack directory: {pack_dir}","messagePattern":"no ONNX files in pack directory: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/python/insightface/engines.py","lineNumber":265,"sourceCode":"\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]\n            if scoped:\n                onnx_files = scoped\n        if not onnx_files:\n            raise ValueError(f\"no ONNX files in pack directory: {pack_dir}\")\n\n        # CUDAExecutionProvider is picked automatically by onnxruntime-gpu\n        # when available; falling back to CPU keeps the CPU-only image\n        # working. ctx_id=0 means \"first GPU if any, else CPU\".\n        self._providers = [\"CUDAExecutionProvider\", \"CPUExecutionProvider\"]\n\n        self.models = {}\n        skipped: list[tuple[str, str]] = []\n        for onnx_file in onnx_files:\n            try:\n                m = model_zoo.get_model(onnx_file, providers=self._providers)\n            except Exception as err:\n                # Foreign ONNX (wrong rank/shape, non-insightface model) —\n                # older insightface versions raise IndexError / ValueError\n                # instead of returning None. Keep loading the rest.\n                skipped.append((os.path.basename(onnx_file), str(err)))\n                continue\n            if m is None:","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/mudler/LocalAI/blob/44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26/backend/python/insightface/engines.py#L247-L283","documentation":"Raised by the insightface engine constructor when the pack directory exists but contains zero *.onnx files after globbing (and after optional manifest scoping). The directory was found but is empty or holds only non-ONNX content, so there is nothing to feed model_zoo.get_model.","triggerScenarios":"pack_dir resolves to an existing directory with no .onnx files — an aborted extraction that created the folder but not the files, files with wrong extensions/case, or the manifest scoping step filtering out every file because names don't match the known-pack manifest.","commonSituations":"Partial download/extraction of a pack archive, a pack layout change upstream renaming ONNX files so the _KNOWN_PACK_MANIFESTS filter excludes them all, or manual cleanup that deleted the ONNX weights.","solutions":["List the pack directory to confirm whether files are absent, misnamed, or filtered out by the manifest.","Reinstall the pack (local-ai models install insightface-<pack>) to restore a complete extraction.","If files exist but with unexpected names (upstream layout change), update the backend or file an issue so _KNOWN_PACK_MANIFESTS is extended.","Ensure file extensions are lowercase .onnx and files are not hidden inside a nested subfolder the glob misses."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import glob, os\nonnx = sorted(glob.glob(os.path.join(pack_dir, \"*.onnx\")))\nassert onnx, f\"pack dir {pack_dir} has no ONNX files; reinstall the pack\"","typeGuard":"def pack_has_onnx(pack_dir: str) -> bool:\n    return bool(glob.glob(os.path.join(pack_dir, \"*.onnx\")))","tryCatchPattern":"try:\n    engine = InsightFaceEngine(options)\nexcept ValueError as e:\n    if \"no ONNX files\" in str(e):\n        # empty/filtered pack: reinstall is the deterministic fix\n        reinstall_pack(options.get(\"model_pack\", \"buffalo_l\"))\n        engine = InsightFaceEngine(options)\n    else:\n        raise","preventionTips":["Verify file count and extensions right after pack extraction.","Treat an empty pack directory as a corrupt install and reinstall.","If maintaining pack manifests, update them when upstream renames ONNX files."],"tags":["insightface","model-installation","file-validation","corruption"],"backgroundTag":null,"analyzedSha":"44413a9d06bf5bc52ce088ba8ca74e5a2e8bee26","analyzedAt":"2026-08-15T10:13:50.291Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}