{"record":{"id":"43b7109d501dfd94","repo":"docling-project/docling","slug":"onnx-model-file-model-filename-not-found-mod","errorCode":null,"errorMessage":"ONNX model file '{model_filename}' not found: {model_path}","messagePattern":"ONNX model file '(.+?)' not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"docling/models/inference_engines/image_classification/onnxruntime_engine.py","lineNumber":70,"sourceCode":"        self._session: Optional[ort.InferenceSession] = None\n        self._model_path: Optional[Path] = None\n        self._input_name: Optional[str] = None\n        self._output_name: Optional[str] = None\n\n    def _resolve_model_artifacts(self) -> tuple[Path, Path]:\n        \"\"\"Resolve model artifacts from artifacts_path or HF download.\"\"\"\n        repo_id = self._repo_id\n        revision = self._model_config.revision or \"main\"\n\n        model_filename = self._resolve_model_filename()\n        model_folder = self._resolve_model_folder(\n            repo_id=repo_id,\n            revision=str(revision),\n        )\n        model_path = model_folder / model_filename\n\n        if not model_path.exists():\n            raise FileNotFoundError(\n                f\"ONNX model file '{model_filename}' not found: {model_path}\"\n            )\n\n        return model_folder, model_path\n\n    def _resolve_model_filename(self) -> str:\n        \"\"\"Determine which ONNX filename to load.\"\"\"\n        filename = self.options.model_filename\n        extra_filename = self._model_config.extra_config.get(\"model_filename\")\n        if extra_filename and isinstance(extra_filename, str):\n            filename = extra_filename\n        return filename\n\n    def _resolve_input_name(self, session: ort.InferenceSession) -> str:\n        \"\"\"Resolve ONNX input name from the loaded model graph.\"\"\"\n        input_nodes = session.get_inputs()\n        if not input_nodes:\n            raise RuntimeError(\"ONNX model exposes no inputs\")","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/models/inference_engines/image_classification/onnxruntime_engine.py#L52-L88","documentation":"The ONNX Runtime engine resolved a model folder (from artifacts_path or a HuggingFace download) but the expected .onnx file is not present at the resolved path. The filename comes from options.model_filename or the model spec's extra_config['model_filename']; a mismatch or incomplete download yields this FileNotFoundError.","triggerScenarios":"OnnxRuntimeImageClassificationEngine._resolve_model_artifacts() when model_folder / model_filename does not exist — e.g. artifacts_path lacks the file, the HF repo revision has a different ONNX filename, or extra_config points at a name not in the repo.","commonSituations":"Wrong model_filename (repo ships model.onnx but config asks model_quantized.onnx); offline/partial HF cache; artifacts_path pointing at a directory without the ONNX export; pinned revision that predates the ONNX export being added to the repo.","solutions":["List the resolved model_folder contents and set options.model_filename (or the model spec's extra_config 'model_filename') to the actual .onnx file present.","If using artifacts_path, confirm it contains the ONNX file at the expected location.","Check the pinned model_config.revision includes the ONNX export; update revision or pre-download with the correct filename.","Clear/refresh a corrupted HuggingFace cache entry and re-download."],"exampleFix":"# before\noptions.model_filename = \"model_quantized.onnx\"  # not in repo\n\n# after: match the file actually shipped in the model folder/repo\noptions.model_filename = \"model.onnx\"","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\nmodel_path = Path(artifacts_path) / options.model_filename\nif not model_path.exists():\n    available = sorted(p.name for p in Path(artifacts_path).glob(\"*.onnx\"))\n    raise FileNotFoundError(f\"{model_path} missing; available: {available}\")","typeGuard":null,"tryCatchPattern":"try:\n    engine.initialize()\nexcept FileNotFoundError as e:\n    available = sorted(p.name for p in model_folder.glob(\"*.onnx\"))\n    if available:\n        options.model_filename = available[0]\n        engine = OnnxRuntimeImageClassificationEngine(options=options, ...)\n        engine.initialize()\n    else:\n        raise","preventionTips":["Verify the ONNX filename exists in the model folder/repo before building the engine.","Log available .onnx files when resolution fails to self-heal filename mismatches.","Pin model revisions that are known to ship the expected ONNX export."],"tags":["onnx","model-artifacts","file-not-found","huggingface"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}