roboflow/supervision · error · ValueError
Precision with `MetricTarget.MASKS` requires detections to i
Error message
Precision with `MetricTarget.MASKS` requires detections to include masks.
What it means
Error "Precision with `MetricTarget.MASKS` requires detections to include masks." thrown in roboflow/supervision.
Source
Thrown at src/supervision/metrics/precision.py:522
precision = np.divide(
true_positives,
denominator,
out=np.zeros_like(true_positives),
where=denominator != 0,
)
result_precision: npt.NDArray[np.float64] = precision
return result_precision
def _detections_content(self, detections: Detections) -> npt.NDArray[Any]:
"""Return boxes, masks or oriented bounding boxes from detections."""
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:
return cast(npt.NDArray[Any], detections.mask)
if len(detections) > 0:
raise ValueError(
"Precision 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:View on GitHub (pinned to 7f254d9784)
Solutions
- Include masks in the Detections when using MetricTarget.MASKS with Precision.
- If masks are unavailable, use MetricTarget.BOXES instead.
When it happens
Trigger: Thrown at src/supervision/metrics/precision.py:522 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/46f82535180fa9b8.
Report an issue: GitHub.