docling-project/docling · error · RuntimeError

ONNX model exposes no inputs

Error message

ONNX model exposes no inputs

What it means

After loading an ONNX InferenceSession, the engine found the model graph declares zero inputs. An input name is required to feed the pixel_values tensor, so a graph with no inputs is unusable — this points to a broken/placeholder .onnx file rather than a docling configuration issue.

Source

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

            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")
        return input_nodes[0].name

    def _resolve_output_name(self, session: ort.InferenceSession) -> str:
        """Resolve ONNX output name from the loaded model graph."""
        output_nodes = session.get_outputs()
        if not output_nodes:
            raise RuntimeError("ONNX model exposes no outputs")
        return output_nodes[0].name

    def initialize(self) -> None:
        """Initialize ONNX session and preprocessor."""
        import onnxruntime as ort

        _log.info("Initializing ONNX Runtime image-classification engine")

        model_folder, self._model_path = self._resolve_model_artifacts()
        _log.debug("Using ONNX model at %s", self._model_path)

View on GitHub (pinned to 61d76f1ff3)

Solutions

  1. Validate the file outside docling: python -c "import onnx; m = onnx.load(path); print(m.graph.input)" — reload/re-export if empty or load fails.
  2. Re-download or re-export the ONNX model from a known-good source and retry initialization.
  3. Check onnxruntime version compatibility with the model's opset/IR version; upgrade onnxruntime if the graph is modern.

Example fix

# before
model_path = possibly_corrupt_onnx_path

# after: validate the graph before handing it to the engine
import onnx
m = onnx.load(str(model_path))
assert m.graph.input, "ONNX graph has no inputs — re-export the model"
Defensive patterns

Strategy: validation

Validate before calling

import onnx

m = onnx.load(str(model_path))
if not m.graph.input:
    raise ValueError(f"{model_path} declares no graph inputs — corrupt or invalid export")

Try / catch

try:
    engine.initialize()
except RuntimeError as e:
    if "exposes no inputs" in str(e):
        # artifact defect: re-download or re-export; retrying the same file is futile
        raise RuntimeError(f"invalid ONNX artifact {engine._model_path}: {e}") from e
    raise

Prevention

When it happens

Trigger: OnnxRuntimeImageClassificationEngine.initialize() -> _resolve_input_name(session) when session.get_inputs() returns an empty list.

Common situations: Loading a corrupt, truncated, or empty ONNX file (interrupted download); a stub/test ONNX graph; an ONNX file that is actually an external-data container whose graph failed to parse inputs; incompatible onnxruntime version misreading the graph.

Related errors


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