{"record":{"id":"2dde841819b1c78c","repo":"roboflow/supervision","slug":"detections-confidence-must-be-provided-for-trackin","errorCode":null,"errorMessage":"Detections confidence must be provided for tracking.","messagePattern":"Detections confidence must be provided for tracking\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/tracker/byte_tracker/core.py","lineNumber":135,"sourceCode":"                detections = tracker.update_with_detections(detections)\n\n                labels = [f\"#{tracker_id}\" for tracker_id in detections.tracker_id]\n\n                annotated_frame = box_annotator.annotate(\n                    scene=frame.copy(), detections=detections)\n                annotated_frame = label_annotator.annotate(\n                    scene=annotated_frame, detections=detections, labels=labels)\n                return annotated_frame\n\n            sv.process_video(\n                source_path=\"<SOURCE_VIDEO_PATH>\",\n                target_path=\"<TARGET_VIDEO_PATH>\",\n                callback=callback\n            )\n            ```\n        \"\"\"\n        if detections.confidence is None:\n            raise ValueError(\"Detections confidence must be provided for tracking.\")\n\n        tensors = np.hstack(\n            (\n                detections.xyxy,\n                detections.confidence[:, np.newaxis],\n            )\n        )\n        tracks = self.update_with_tensors(tensors=tensors)\n\n        if len(tracks) > 0:\n            detection_bounding_boxes = np.asarray([det[:4] for det in tensors])\n            track_bounding_boxes = np.asarray([track.tlbr for track in tracks])\n\n            ious = box_iou_batch(detection_bounding_boxes, track_bounding_boxes)\n\n            iou_costs: npt.NDArray[np.float32] = 1 - ious\n\n            matches, _, _ = matching.linear_assignment(iou_costs, 0.5)","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/tracker/byte_tracker/core.py#L117-L153","documentation":"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]))`).","triggerScenarios":"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).","commonSituations":"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.","solutions":["Attach confidences when building Detections: `Detections(xyxy=boxes, confidence=np.full(len(boxes), 0.5), class_id=...)`","If the upstream connector supports it, enable confidence output (e.g. YOLO `conf` threshold results already include it)","Skip tracking for confidence-free pipelines and use a geometry-only tool (LineZone/PolygonZone) instead"],"exampleFix":"// before\n detections = sv.Detections(xyxy=boxes, class_id=class_ids)\ntracks = byte_track.update_with_detections(detections)\n\n// after\n detections = sv.Detections(\n     xyxy=boxes,\n     confidence=np.full(len(boxes), 0.5, dtype=np.float32),\n     class_id=class_ids,\n )\ntracks = byte_track.update_with_detections(detections)","handlingStrategy":"validation","validationCode":"import numpy as np\nimport supervision as sv\n\ndef with_placeholder_confidence(detections: sv.Detections, value: float = 0.5) -> sv.Detections:\n    \"\"\"Ensure Detections carry confidence so trackers accept them.\"\"\"\n    if detections.confidence is not None:\n        return detections\n    return detections.copy(confidence=np.full(len(detections), value, dtype=np.float32))","typeGuard":"def is_trackable(detections) -> bool:\n    \"\"\"ByteTrack requires per-detection confidence scores.\"\"\"\n    return detections.confidence is not None and len(detections.confidence) == len(detections)","tryCatchPattern":null,"preventionTips":["Construct Detections with confidence= alongside xyxy= by habit","Before update_with_detections, assert detections.confidence is not None","Remember placeholder confidences (e.g. 0.5) change ByteTrack's activation thresholds — tune them if scores are fake"],"tags":["byte-track","tracking","detections","validation"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}