{"record":{"id":"724e865bbe939c7f","repo":"roboflow/supervision","slug":"invalid-metric-target-self-metric-target-724e86","errorCode":null,"errorMessage":"Invalid metric target: {self._metric_target}","messagePattern":"Invalid metric target: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/metrics/f1_score.py","lineNumber":546,"sourceCode":"        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)\n            return empty_masks\n        if self._metric_target == MetricTarget.ORIENTED_BOUNDING_BOXES:\n            empty_obb: npt.NDArray[np.float32] = np.empty((0, 4, 2), dtype=np.float32)\n            return empty_obb\n        raise ValueError(f\"Invalid metric target: {self._metric_target}\")\n\n    def _filter_detections_by_size(\n        self, detections: Detections, size_category: ObjectSizeCategory\n    ) -> Detections:\n        \"\"\"Return a copy of detections with contents filtered by object size.\"\"\"\n        new_detections = deepcopy(detections)","sourceCodeStart":528,"sourceCodeEnd":564,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/metrics/f1_score.py#L528-L564","documentation":"Error \"Invalid metric target: {self._metric_target}\" thrown in roboflow/supervision.","triggerScenarios":"Thrown at src/supervision/metrics/f1_score.py:546 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Construct F1Score with a valid MetricTarget value.","Do not modify the internal metric target after construction."],"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"}