From 3ed4aeffffae41164fb5d882280eaaa92818fefe Mon Sep 17 00:00:00 2001 From: Raif Olson Date: Mon, 25 Mar 2024 21:41:38 -0400 Subject: [PATCH] fix bugs in PR #1035 fix tuple unpacking bug in PR #1035 Fix bug with detections with un-initialized tracker_ids --- supervision/tracker/byte_tracker/core.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/supervision/tracker/byte_tracker/core.py b/supervision/tracker/byte_tracker/core.py index 9156fb58..4d6416e8 100644 --- a/supervision/tracker/byte_tracker/core.py +++ b/supervision/tracker/byte_tracker/core.py @@ -286,13 +286,23 @@ class ByteTrack: iou_costs = 1 - ious matches, _, _ = matching.linear_assignment(iou_costs, 0.5) - for i, idet, itrack in enumerate(matches): + for i, (idet, itrack) in enumerate(matches): if i == 0: final_detections = detections[[idet]] - final_detections.tracker_id[0] = int(tracks[itrack].track_id) + if final_detections.tracker_id is None: + final_detections.tracker_id = np.asarray( + [int(tracks[itrack].track_id)] + ) + else: + final_detections.tracker_id[0] = int(tracks[itrack].track_id) else: current_detection = detections[[idet]] - current_detection.tracker_id[0] = int(tracks[itrack].track_id) + if current_detection.tracker_id is None: + current_detection.tracker_id = np.asarray( + [int(tracks[itrack].track_id)] + ) + else: + current_detection.tracker_id[0] = int(tracks[itrack].track_id) final_detections = Detections.merge( [final_detections, current_detection] )