{"record":{"id":"4a9a01359e084562","repo":"roboflow/supervision","slug":"f1score-with-metrictarget-masks-requires-detecti","errorCode":null,"errorMessage":"F1Score with `MetricTarget.MASKS` requires detections to include masks.","messagePattern":"F1Score with `MetricTarget\\.MASKS` requires detections to include masks\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/metrics/f1_score.py","lineNumber":535,"sourceCode":"        return result_f1_score\n\n    def _detections_content(\n        self, detections: Detections\n    ) -> npt.NDArray[Any] | CompactMask:\n        \"\"\"Return boxes, masks or oriented bounding boxes from detections.\n\n        For the mask target this may return a\n        :class:`~supervision.detection.compact_mask.CompactMask` rather than a\n        dense boolean array when the detections carry compact masks.\n        \"\"\"\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                # detections.mask is NDArray[bool] | CompactMask; return as-is.\n                return detections.mask\n            if len(detections) > 0:\n                raise ValueError(\n                    \"F1Score 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        if self._metric_target == MetricTarget.MASKS:\n            empty_masks: npt.NDArray[np.bool_] = np.empty((0, 0, 0), dtype=bool)","sourceCodeStart":517,"sourceCodeEnd":553,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/metrics/f1_score.py#L517-L553","documentation":"Error \"F1Score with `MetricTarget.MASKS` requires detections to include masks.\" thrown in roboflow/supervision.","triggerScenarios":"Thrown at src/supervision/metrics/f1_score.py:535 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Include masks in the Detections when using MetricTarget.MASKS with F1Score.","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"}