docling-project/docling · error · FileNotFoundError

ONNX model file '{model_filename}' not found: {model_path}

Error message

ONNX model file '{model_filename}' not found: {model_path}

What it means

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.

Source

Thrown at docling/models/inference_engines/image_classification/onnxruntime_engine.py:70

        self._session: Optional[ort.InferenceSession] = None
        self._model_path: Optional[Path] = None
        self._input_name: Optional[str] = None
        self._output_name: Optional[str] = None

    def _resolve_model_artifacts(self) -> tuple[Path, Path]:
        """Resolve model artifacts from artifacts_path or HF download."""
        repo_id = self._repo_id
        revision = self._model_config.revision or "main"

        model_filename = self._resolve_model_filename()
        model_folder = self._resolve_model_folder(
            repo_id=repo_id,
            revision=str(revision),
        )
        model_path = model_folder / model_filename

        if not model_path.exists():
            raise FileNotFoundError(
                f"ONNX model file '{model_filename}' not found: {model_path}"
            )

        return model_folder, model_path

    def _resolve_model_filename(self) -> str:
        """Determine which ONNX filename to load."""
        filename = self.options.model_filename
        extra_filename = self._model_config.extra_config.get("model_filename")
        if extra_filename and isinstance(extra_filename, str):
            filename = extra_filename
        return filename

    def _resolve_input_name(self, session: ort.InferenceSession) -> str:
        """Resolve ONNX input name from the loaded model graph."""
        input_nodes = session.get_inputs()
        if not input_nodes:
            raise RuntimeError("ONNX model exposes no inputs")

View on GitHub (pinned to 61d76f1ff3)

Solutions

  1. 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.
  2. If using artifacts_path, confirm it contains the ONNX file at the expected location.
  3. Check the pinned model_config.revision includes the ONNX export; update revision or pre-download with the correct filename.
  4. Clear/refresh a corrupted HuggingFace cache entry and re-download.

Example fix

# before
options.model_filename = "model_quantized.onnx"  # not in repo

# after: match the file actually shipped in the model folder/repo
options.model_filename = "model.onnx"
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path

model_path = Path(artifacts_path) / options.model_filename
if not model_path.exists():
    available = sorted(p.name for p in Path(artifacts_path).glob("*.onnx"))
    raise FileNotFoundError(f"{model_path} missing; available: {available}")

Try / catch

try:
    engine.initialize()
except FileNotFoundError as e:
    available = sorted(p.name for p in model_folder.glob("*.onnx"))
    if available:
        options.model_filename = available[0]
        engine = OnnxRuntimeImageClassificationEngine(options=options, ...)
        engine.initialize()
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of docling-project/docling@61d76f1ff3 (2026-08-14). Data as JSON: /api/errors/43b7109d501dfd94. Report an issue: GitHub.