roboflow/supervision · error · ValueError
Invalid metric target: {self._metric_target}
Error message
Invalid metric target: {self._metric_target} What it means
Error "Invalid metric target: {self._metric_target}" thrown in roboflow/supervision.
Source
Thrown at src/supervision/metrics/f1_score.py:546
if self._metric_target == MetricTarget.BOXES:
return cast(npt.NDArray[Any], detections.xyxy)
if self._metric_target == MetricTarget.MASKS:
if detections.mask is not None:
# detections.mask is NDArray[bool] | CompactMask; return as-is.
return detections.mask
if len(detections) > 0:
raise ValueError(
"F1Score with `MetricTarget.MASKS` requires detections to "
"include masks."
)
return self._make_empty_content()
if self._metric_target == MetricTarget.ORIENTED_BOUNDING_BOXES:
obb = detections.data.get(ORIENTED_BOX_COORDINATES)
if obb is not None and len(obb) > 0:
result_obb: npt.NDArray[np.float32] = np.array(obb, dtype=np.float32)
return result_obb
return self._make_empty_content()
raise ValueError(f"Invalid metric target: {self._metric_target}")
def _make_empty_content(self) -> npt.NDArray[Any]:
if self._metric_target == MetricTarget.BOXES:
empty_boxes: npt.NDArray[np.float32] = np.empty((0, 4), dtype=np.float32)
return empty_boxes
if self._metric_target == MetricTarget.MASKS:
empty_masks: npt.NDArray[np.bool_] = np.empty((0, 0, 0), dtype=bool)
return empty_masks
if self._metric_target == MetricTarget.ORIENTED_BOUNDING_BOXES:
empty_obb: npt.NDArray[np.float32] = np.empty((0, 4, 2), dtype=np.float32)
return empty_obb
raise ValueError(f"Invalid metric target: {self._metric_target}")
def _filter_detections_by_size(
self, detections: Detections, size_category: ObjectSizeCategory
) -> Detections:
"""Return a copy of detections with contents filtered by object size."""
new_detections = deepcopy(detections)View on GitHub (pinned to 7f254d9784)
Solutions
- Construct F1Score with a valid MetricTarget value.
- Do not modify the internal metric target after construction.
When it happens
Trigger: Thrown at src/supervision/metrics/f1_score.py:546 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of roboflow/supervision@7f254d9784 (2026-08-15).
Data as JSON: /api/errors/724e865bbe939c7f.
Report an issue: GitHub.