{"record":{"id":"39c8cac2de0e6b03","repo":"roboflow/supervision","slug":"from-inference-operates-on-a-single-result-at-a","errorCode":null,"errorMessage":"from_inference() operates on a single result at a time.You can retrieve it like so:  inference_result = model.infer(image)[0]","messagePattern":"from_inference\\(\\) operates on a single result at a time\\.You can retrieve it like so:  inference_result = model\\.infer\\(image\\)\\[0\\]","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/key_points/core.py","lineNumber":428,"sourceCode":"            ```\n\n            ```python\n            from supervision import _cv2 as cv2\n            import supervision as sv\n            from inference_sdk import InferenceHTTPClient\n\n            image = cv2.imread(\"<SOURCE_IMAGE_PATH>\")\n            client = InferenceHTTPClient(\n                api_url=\"https://detect.roboflow.com\",\n                api_key=\"<ROBOFLOW_API_KEY>\"\n            )\n\n            result = client.infer(image, model_id=\"<POSE_MODEL_ID>\")\n            key_points = sv.KeyPoints.from_inference(result)\n            ```\n        \"\"\"\n        if isinstance(inference_result, list):\n            raise ValueError(\n                \"from_inference() operates on a single result at a time.\"\n                \"You can retrieve it like so:  inference_result = model.infer(image)[0]\"\n            )\n\n        if hasattr(inference_result, \"dict\"):\n            inference_result = inference_result.dict(exclude_none=True, by_alias=True)\n        elif hasattr(inference_result, \"json\"):\n            inference_result = inference_result.json()\n        if not inference_result.get(\"predictions\"):\n            return cls.empty()\n\n        xy = []\n        confidence = []\n        class_id = []\n        class_names = []\n\n        for prediction in inference_result[\"predictions\"]:\n            prediction_xy = []","sourceCodeStart":410,"sourceCodeEnd":446,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/key_points/core.py#L410-L446","documentation":"Inside Precision.compute()'s main matching branch, the code selects the IoU function by metric target: box_iou_batch for BOXES, mask_iou_batch for MASKS, oriented_box_iou_batch for ORIENTED_BOUNDING_BOXES. Any other MetricTarget value reaches the else-raise. With the current enum this is defensive dead code; it fires only on version skew or injected enum values.","triggerScenarios":"Running a supervision version where MetricTarget gained a member (e.g. a future target) that this Precision build does not handle — typically a mixed/partial install or a monkey-patched enum — while evaluating images with both predictions and targets.","commonSituations":"Partial upgrades, vendored/copied metric modules paired with a newer installed package, or custom enum extension experiments.","solutions":["Reinstall/upgrade supervision so the enum and metric modules come from one version (pip install --force-reinstall supervision)","Restrict metric_target to the three supported members","Remove enum monkey-patches before computing metrics"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"SUPPORTED_IOU_TARGETS = {sv.MetricTarget.BOXES, sv.MetricTarget.MASKS, sv.MetricTarget.ORIENTED_BOUNDING_BOXES}\nassert metric_target in SUPPORTED_IOU_TARGETS, f'{metric_target} has no IoU kernel here'","typeGuard":"def has_iou_kernel(target: sv.MetricTarget) -> bool:\n    return target in {sv.MetricTarget.BOXES, sv.MetricTarget.MASKS, sv.MetricTarget.ORIENTED_BOUNDING_BOXES}","tryCatchPattern":null,"preventionTips":["Pin one supervision version per environment to avoid enum/kernel mismatch","Smoke-test metric construction + a tiny update()/compute() before launching full evaluations"],"tags":["metrics","precision","metric-target","defensive-code"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}