roboflow/supervision · error · ValueError

The provided detections do not contain confidence values. Pl

Error message

The provided detections do not contain confidence values. Please provide `custom_values` or ensure that the detections contain confidence values (e.g. by using a different model).

What it means

Raised by `PercentageBarAnnotator._validate_custom_values` when `custom_values` is None and the detections lack a `confidence` array. The annotator draws a 0-1 bar per detection, defaulting to confidence scores; with neither custom values nor confidence there is nothing valid to render, so it fails before drawing.

Source

Thrown at src/supervision/annotators/core.py:2976

            )
        elif position == Position.CENTER_RIGHT:
            return (cx, cy - height // 2), (cx + width, cy + height // 2)
        elif position == Position.BOTTOM_LEFT:
            return (cx - width, cy), (cx, cy + height)
        elif position == Position.BOTTOM_CENTER:
            return (cx - width // 2, cy), (cx + width // 2, cy + height)
        elif position == Position.BOTTOM_RIGHT:
            return (cx, cy), (cx + width, cy + height)
        raise ValueError(f"Unsupported position: {position}")

    @staticmethod
    def _validate_custom_values(
        custom_values: npt.NDArray[np.float64] | list[float] | None,
        detections: Detections,
    ) -> None:
        if custom_values is None:
            if detections.confidence is None:
                raise ValueError(
                    "The provided detections do not contain confidence values. "
                    "Please provide `custom_values` or ensure that the detections "
                    "contain confidence values (e.g. by using a different model)."
                )

        else:
            if not isinstance(custom_values, (np.ndarray, list)):
                raise TypeError(
                    "custom_values must be either a numpy array or a list of floats."
                )

            if len(custom_values) != len(detections):
                raise ValueError(
                    "The length of custom_values must match the number of detections."
                )

            if not all(0 <= value <= 1 for value in custom_values):
                raise ValueError("All values in custom_values must be between 0 and 1.")

View on GitHub (pinned to 7f254d9784)

Solutions

  1. Pass `custom_values` explicitly: a NumPy array or list with one 0-1 value per detection, e.g. normalized class scores.
  2. Ensure the model output you build Detections from includes confidence (most `from_*` connectors map it).
  3. If bars should show something other than confidence (e.g. speed), supply it via custom_values.

Example fix

# before
annotator = sv.PercentageBarAnnotator()
detections = sv.Detections(xyxy=boxes, class_id=ids)  # no confidence
annotator.annotate(scene, detections)  # ValueError

# after
annotator = sv.PercentageBarAnnotator()
detections = sv.Detections(xyxy=boxes, class_id=ids, confidence=scores)
# or: annotator.annotate(scene, detections, custom_values=normalized_scores)
Defensive patterns

Strategy: type-guard

Validate before calling

if detections.confidence is None and custom_values is None:
    custom_values = np.ones(len(detections))  # or compute real scores
annotator.annotate(scene, detections, custom_values=custom_values)

Type guard

def can_draw_percentage_bars(detections, custom_values=None) -> bool:
    return custom_values is not None or detections.confidence is not None

Prevention

When it happens

Trigger: Constructing `sv.Detections(xyxy=..., class_id=...)` with no `confidence` and calling `sv.PercentageBarAnnotator().annotate(scene, detections)`; annotating outputs of a model/connector that does not populate confidence; class-agnostic or hand-assembled detections in tests.

Common situations: Prototyping with hand-built Detections fixtures that skip confidence; pipelines using annotators on tracker outputs from a path that strips confidence; models whose connector maps only boxes and class ids.

Related errors


AI-assisted analysis of roboflow/supervision@7f254d9784 (2026-08-15). Data as JSON: /api/errors/d9d45a3702cd4137. Report an issue: GitHub.