{"record":{"id":"46f82535180fa9b8","repo":"roboflow/supervision","slug":"precision-with-metrictarget-masks-requires-detec","errorCode":null,"errorMessage":"Precision with `MetricTarget.MASKS` requires detections to include masks.","messagePattern":"Precision with `MetricTarget\\.MASKS` requires detections to include masks\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/metrics/precision.py","lineNumber":522,"sourceCode":"        precision = np.divide(\n            true_positives,\n            denominator,\n            out=np.zeros_like(true_positives),\n            where=denominator != 0,\n        )\n\n        result_precision: npt.NDArray[np.float64] = precision\n        return result_precision\n\n    def _detections_content(self, detections: Detections) -> npt.NDArray[Any]:\n        \"\"\"Return boxes, masks or oriented bounding boxes from detections.\"\"\"\n        if self._metric_target == MetricTarget.BOXES:\n            return cast(npt.NDArray[Any], detections.xyxy)\n        if self._metric_target == MetricTarget.MASKS:\n            if detections.mask is not None:\n                return cast(npt.NDArray[Any], detections.mask)\n            if len(detections) > 0:\n                raise ValueError(\n                    \"Precision with `MetricTarget.MASKS` requires detections to \"\n                    \"include masks.\"\n                )\n            return self._make_empty_content()\n        if self._metric_target == MetricTarget.ORIENTED_BOUNDING_BOXES:\n            obb = detections.data.get(ORIENTED_BOX_COORDINATES)\n            if obb is not None and len(obb) > 0:\n                result_obb: npt.NDArray[np.float32] = np.array(obb, dtype=np.float32)\n                return result_obb\n            return self._make_empty_content()\n        raise ValueError(f\"Invalid metric target: {self._metric_target}\")\n\n    def _make_empty_content(self) -> npt.NDArray[Any]:\n        if self._metric_target == MetricTarget.BOXES:\n            empty_boxes: npt.NDArray[np.float32] = np.empty((0, 4), dtype=np.float32)\n            return empty_boxes\n\n        if self._metric_target == MetricTarget.MASKS:","sourceCodeStart":504,"sourceCodeEnd":540,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/metrics/precision.py#L504-L540","documentation":"Error \"Precision with `MetricTarget.MASKS` requires detections to include masks.\" thrown in roboflow/supervision.","triggerScenarios":"Thrown at src/supervision/metrics/precision.py:522 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Include masks in the Detections when using MetricTarget.MASKS with Precision.","If masks are unavailable, use MetricTarget.BOXES instead."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}