roboflow/supervision · error · ValueError
Predictions must have shape (M, {expected_pred_cols}). Got {
Error message
Predictions must have shape (M, {expected_pred_cols}). Got {predictions.shape} instead. What it means
Error "Predictions must have shape (M, {expected_pred_cols}). Got {predictions.shape} instead." thrown in roboflow/supervision.
Source
Thrown at src/supervision/metrics/detection.py:909
Detections with lower iou will be classified as `FP`.
metric_target: The type of detection data to use.
Determines IoU function (`box_iou_batch` vs
`oriented_box_iou_batch`) and coordinate column count.
`MetricTarget.MASKS` is not supported.
Returns:
Confusion matrix based on a single image.
"""
_assert_supported_target(metric_target)
expected_pred_cols = (
10 if metric_target == MetricTarget.ORIENTED_BOUNDING_BOXES else 6
)
expected_target_cols = (
9 if metric_target == MetricTarget.ORIENTED_BOUNDING_BOXES else 5
)
if predictions.ndim != 2 or predictions.shape[1] != expected_pred_cols:
raise ValueError(
f"Predictions must have shape (M, {expected_pred_cols}). "
f"Got {predictions.shape} instead."
)
if targets.ndim != 2 or targets.shape[1] != expected_target_cols:
raise ValueError(
f"Targets must have shape (N, {expected_target_cols}). "
f"Got {targets.shape} instead."
)
result_matrix: npt.NDArray[np.int32] = np.zeros(
(num_classes + 1, num_classes + 1), dtype=np.int32
)
# Filter predictions by confidence threshold
coords_dim = 8 if metric_target == MetricTarget.ORIENTED_BOUNDING_BOXES else 4
class_id_idx = coords_dim
conf_idx = coords_dim + 1
View on GitHub (pinned to 7f254d9784)
Solutions
- Reshape the predictions array to (M, expected_pred_cols) before calling.
- Check for accidental transposition or extra dimensions in the predictions array.
When it happens
Trigger: Thrown at src/supervision/metrics/detection.py:909 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/529f1037c78b7bbb.
Report an issue: GitHub.