{"record":{"id":"8cca18d871c698eb","repo":"docling-project/docling","slug":"expected-object-detection-model-metadata-to-expose","errorCode":null,"errorMessage":"Expected object-detection model metadata to expose at least 2 inputs (images, orig_target_sizes), got {len(metadata.inputs)}.","messagePattern":"Expected object-detection model metadata to expose at least 2 inputs \\(images, orig_target_sizes\\), got (.+?)\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"docling/models/inference_engines/object_detection/api_kserve_v2_engine.py","lineNumber":80,"sourceCode":"                \"pipeline_options.enable_remote_services=True.\"\n            )\n\n    def _resolve_model_name(self) -> str:\n        if self.options.model_name:\n            return self.options.model_name\n\n        return self._repo_id.replace(\"/\", \"--\")\n\n    def _resolve_model_version(self) -> Optional[str]:\n        return self.options.model_version\n\n    def _resolve_tensor_names(self) -> tuple[str, str, str, str, str]:\n        if self._kserve_client is None:\n            raise RuntimeError(\"KServe v2 client is not initialized.\")\n\n        metadata = self._kserve_client.get_model_metadata()\n        if len(metadata.inputs) < 2:\n            raise RuntimeError(\n                \"Expected object-detection model metadata to expose at least 2 inputs \"\n                f\"(images, orig_target_sizes), got {len(metadata.inputs)}.\"\n            )\n        if len(metadata.outputs) < 3:\n            raise RuntimeError(\n                \"Expected object-detection model metadata to expose at least 3 outputs \"\n                f\"(labels, boxes, scores), got {len(metadata.outputs)}.\"\n            )\n\n        input_images_name = metadata.inputs[0].name\n        input_orig_target_sizes_name = metadata.inputs[1].name\n        output_labels_name = metadata.outputs[0].name\n        output_boxes_name = metadata.outputs[1].name\n        output_scores_name = metadata.outputs[2].name\n\n        return (\n            input_images_name,\n            input_orig_target_sizes_name,","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/models/inference_engines/object_detection/api_kserve_v2_engine.py#L62-L98","documentation":"After querying the KServe v2 server's model metadata, the engine requires at least 2 input tensors (images, orig_target_sizes), matching the RT-DETR-style object detection contract. If the served model exposes fewer than 2 inputs, a RuntimeError is raised because the engine cannot map its preprocessed inputs onto the model graph.","triggerScenarios":"Pointing ApiKserveV2ObjectDetectionEngineOptions.url at a KServe v2 endpoint that serves a model other than an RT-DETR/DETR-family object detector — e.g. a classifier, a segmentation model, or a text model — so get_model_metadata() returns 0 or 1 inputs.","commonSituations":"Reusing a KServe endpoint previously set up for a different task; serving the wrong model revision or a base (non-finetuned) checkpoint; a Triton/KServe model repository with a misconfigured config.pbtxt that renamed or hid inputs.","solutions":["Verify the endpoint actually serves an RT-DETR-style detector with 'images' and 'orig_target_sizes' inputs (inspect with a direct KServe metadata REST/gRPC call).","Fix the model_name / url in ApiKserveV2ObjectDetectionEngineOptions to point at the correct object-detection model.","If you control the server, correct its model repository config so both inputs are exposed."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"# probe the endpoint before wiring it into docling\nfrom docling.clients.kserve_client import KserveV2Client\nc = KserveV2Client(url=opts.url, inference_port=opts.inference_port)\nmeta = c.get_model_metadata()\nassert len(meta.inputs) >= 2, f\"need images+orig_target_sizes inputs, got {[i.name for i in meta.inputs]}\"","typeGuard":null,"tryCatchPattern":"try:\n    engine.initialize()\nexcept RuntimeError as e:\n    if \"at least 2 inputs\" in str(e):\n        raise RuntimeError(f\"Endpoint {opts.url} does not serve a DETR-style detector\") from e\n    raise","preventionTips":["Smoke-test the KServe endpoint's metadata before configuring Docling against it.","Pin model_name/model_version so the served model cannot drift.","Serve RT-DETR exports that keep the standard images/orig_target_sizes inputs."],"tags":["kserve","model-mismatch","metadata","object-detection","remote-services"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}