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 resolves the model directory (HF cache or artifacts_path plus repo folder) and appends the model filename; if that file does not exist on disk it raises FileNotFoundError with the exact expected path. The filename comes from options.model_filename unless overridden by model_config.extra_config['model_filename'].

Source

Thrown at docling/models/inference_engines/object_detection/onnxruntime_engine.py:84

    def _resolve_model_artifacts(self) -> tuple[Path, Path]:
        """Resolve model artifacts from artifacts_path or HF download.

        Returns:
            Tuple of (model_folder, model_path)
        """
        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 initialize(self) -> None:
        """Initialize ONNX session and preprocessor."""
        import onnxruntime as ort

        _log.info("Initializing ONNX Runtime object-detection engine")

View on GitHub (pinned to 61d76f1ff3)

Solutions

  1. Check the printed model_path and copy/download the missing .onnx file to exactly that location (docling-tools models download is the usual tool).
  2. Verify artifacts_path contains the repo-id-named subfolder with the revision that matches model_config.revision.
  3. If using a custom filename, make sure options.model_filename or extra_config['model_filename'] matches the actual file name on disk.

Example fix

# before
# artifacts dir has model.onnx but spec expects rtdetr_r50vd.onnx

# after
# either rename the file to match, or point the spec at the real file:
extra_config = {"model_filename": "model.onnx"}
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
expected = artifacts_path / repo_id.replace('/', '--') / engine._resolve_model_filename()
if not expected.exists():
    raise FileNotFoundError(f"Pre-check: missing ONNX weights at {expected}")

Try / catch

try:
    engine.initialize()
except FileNotFoundError as e:
    log.error("Model weights missing: %s", e)
    raise  # do not fall back silently in offline deployments

Prevention

When it happens

Trigger: Running with --artifacts-path pointing at a directory that lacks the model repo subfolder or the specific .onnx file; an artifacts snapshot downloaded for a different model revision; a custom model_filename/extra_config filename that does not match the downloaded artifact.

Common situations: Air-gapped/offline deployments with pre-populated artifacts_path missing one file; partial/interrupted downloads; case-sensitivity differences of filenames between the download host and Linux filesystems; wrong model_filename in a custom model spec.

Related errors


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