roboflow/supervision · error · ValueError
Predictions and targets must be lists of numpy arrays. Got {
Error message
Predictions and targets must be lists of numpy arrays. Got {type(predictions[0])} and {type(targets[0])} instead. What it means
Error "Predictions and targets must be lists of numpy arrays. Got {type(predictions[0])} and {type(targets[0])} instead." thrown in roboflow/supervision.
Source
Thrown at src/supervision/metrics/detection.py:198
def _validate_input_tensors(
predictions: list[npt.NDArray[np.float32]],
targets: list[npt.NDArray[np.float32]],
metric_target: MetricTarget = MetricTarget.BOXES,
) -> None:
"""
Checks for shape consistency of input tensors.
"""
if len(predictions) != len(targets):
raise ValueError(
f"Number of predictions ({len(predictions)}) and"
f"targets ({len(targets)}) must be equal."
)
if len(predictions) > 0:
if not isinstance(predictions[0], np.ndarray) or not isinstance(
targets[0], np.ndarray
):
raise ValueError(
"Predictions and targets must be lists of numpy arrays. "
f"Got {type(predictions[0])} and {type(targets[0])} instead."
)
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[0].shape[1] != expected_pred_cols:
raise ValueError(
f"Predictions must have shape (N, {expected_pred_cols}). "
f"Got {predictions[0].shape} instead."
)
if targets[0].shape[1] != expected_target_cols:
raise ValueError(View on GitHub (pinned to 7f254d9784)
Solutions
- Pass predictions and targets as lists of numpy arrays (one array per image).
- Convert Detections to arrays with the appropriate helper, or convert your data to np.ndarray lists first.
When it happens
Trigger: Thrown at src/supervision/metrics/detection.py:198 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/927429e2b54ec82e.
Report an issue: GitHub.