roboflow/supervision · error · ValueError

Detections confidence must be provided for tracking.

Error message

Detections confidence must be provided for tracking.

What it means

ByteTrack (and supervision's `ByteTrack`/`update_with_detections` path) scores detections before associating them to tracks, so every detection row must carry a confidence. `update_with_detections` at src/supervision/tracker/byte_tracker/core.py:135 raises when `detections.confidence is None`. Confidence is baked into the tensors the tracker consumes (`np.hstack((xyxy, confidence[:, np.newaxis]))`).

Source

Thrown at src/supervision/tracker/byte_tracker/core.py:135

                detections = tracker.update_with_detections(detections)

                labels = [f"#{tracker_id}" for tracker_id in detections.tracker_id]

                annotated_frame = box_annotator.annotate(
                    scene=frame.copy(), detections=detections)
                annotated_frame = label_annotator.annotate(
                    scene=annotated_frame, detections=detections, labels=labels)
                return annotated_frame

            sv.process_video(
                source_path="<SOURCE_VIDEO_PATH>",
                target_path="<TARGET_VIDEO_PATH>",
                callback=callback
            )
            ```
        """
        if detections.confidence is None:
            raise ValueError("Detections confidence must be provided for tracking.")

        tensors = np.hstack(
            (
                detections.xyxy,
                detections.confidence[:, np.newaxis],
            )
        )
        tracks = self.update_with_tensors(tensors=tensors)

        if len(tracks) > 0:
            detection_bounding_boxes = np.asarray([det[:4] for det in tensors])
            track_bounding_boxes = np.asarray([track.tlbr for track in tracks])

            ious = box_iou_batch(detection_bounding_boxes, track_bounding_boxes)

            iou_costs: npt.NDArray[np.float32] = 1 - ious

            matches, _, _ = matching.linear_assignment(iou_costs, 0.5)

View on GitHub (pinned to 7f254d9784)

Solutions

  1. Attach confidences when building Detections: `Detections(xyxy=boxes, confidence=np.full(len(boxes), 0.5), class_id=...)`
  2. If the upstream connector supports it, enable confidence output (e.g. YOLO `conf` threshold results already include it)
  3. Skip tracking for confidence-free pipelines and use a geometry-only tool (LineZone/PolygonZone) instead

Example fix

// before
 detections = sv.Detections(xyxy=boxes, class_id=class_ids)
tracks = byte_track.update_with_detections(detections)

// after
 detections = sv.Detections(
     xyxy=boxes,
     confidence=np.full(len(boxes), 0.5, dtype=np.float32),
     class_id=class_ids,
 )
tracks = byte_track.update_with_detections(detections)
Defensive patterns

Strategy: validation

Validate before calling

import numpy as np
import supervision as sv

def with_placeholder_confidence(detections: sv.Detections, value: float = 0.5) -> sv.Detections:
    """Ensure Detections carry confidence so trackers accept them."""
    if detections.confidence is not None:
        return detections
    return detections.copy(confidence=np.full(len(detections), value, dtype=np.float32))

Type guard

def is_trackable(detections) -> bool:
    """ByteTrack requires per-detection confidence scores."""
    return detections.confidence is not None and len(detections.confidence) == len(detections)

Prevention

When it happens

Trigger: Feeding the tracker `Detections` built without the `confidence` argument — e.g. `Detections(xyxy=boxes)` from a deterministic detector, geometry-only sources (`detection.utils` helpers, manually built boxes, polygon zones), or a connector that returns no scores (some segmentation/VLM pipelines).

Common situations: Manual box construction for zone-based counting then passing the same Detections to ByteTrack; VLM or heuristic detectors that yield boxes without probabilities; slicing/copying Detections and dropping the confidence field.

Related errors


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