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/precision.py:118

        targets: Detections | list[Detections],
    ) -> Precision:
        """
        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) -> PrecisionResult:
        """
        Calculate the precision metric based on the stored predictions and ground-truth
        data, at different IoU thresholds.

        Returns:
            The precision metric result.
        """
        result = self._compute(self._predictions_list, self._targets_list)

View on GitHub (pinned to 7f254d9784)

Solutions

  1. Pass the same number of prediction and target Detections (one per image) to update().
  2. Align predictions and targets by image before calling update.

When it happens

Trigger: Thrown at src/supervision/metrics/precision.py:118 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/e5a9e2f74cce5786. Report an issue: GitHub.