roboflow/supervision · error · ValueError
The number of predictions ({len(predictions)}) and targets (
Error message
The number of predictions ({len(predictions)}) and targets ({len(targets)}) during the update must be the same. What it means
Error "The number of predictions ({len(predictions)}) and targets ({len(targets)}) during the update must be the same." thrown in roboflow/supervision.
Source
Thrown at src/supervision/metrics/f1_score.py:116
targets: Detections | list[Detections],
) -> F1Score:
"""
Add new predictions and targets to the metric, but do not compute the result.
Args:
predictions: The predicted detections.
targets: The target detections.
Returns:
The updated metric instance.
"""
if not isinstance(predictions, list):
predictions = [predictions]
if not isinstance(targets, list):
targets = [targets]
if len(predictions) != len(targets):
raise ValueError(
f"The number of predictions ({len(predictions)}) and"
f" targets ({len(targets)}) during the update must be the same."
)
self._predictions_list.extend(predictions)
self._targets_list.extend(targets)
return self
def compute(self) -> F1ScoreResult:
"""
Calculate the F1 score metric based on the stored predictions and ground-truth
data, at different IoU thresholds.
Returns:
The F1 score metric result.
"""
result = self._compute(self._predictions_list, self._targets_list)View on GitHub (pinned to 7f254d9784)
Solutions
- Pass the same number of prediction and target Detections (one per image) to update().
- Align predictions and targets by image before calling update.
When it happens
Trigger: Thrown at src/supervision/metrics/f1_score.py:116 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/3729c287cd0374a7.
Report an issue: GitHub.