From afcb77965c07649a812be8fa0e3e72afdd5a1a86 Mon Sep 17 00:00:00 2001 From: Linas Kondrackis Date: Sun, 25 Feb 2024 20:33:24 +0200 Subject: [PATCH 1/2] Fix smoother removing tracking_id from detections * Addresses issue #928 matching implementation in ByteTrack, but sidestepping the underlying cause outlined in #943. --- supervision/detection/tools/smoother.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/supervision/detection/tools/smoother.py b/supervision/detection/tools/smoother.py index 593b2a8fa..1e8f91afd 100644 --- a/supervision/detection/tools/smoother.py +++ b/supervision/detection/tools/smoother.py @@ -115,4 +115,8 @@ def get_smoothed_detections(self) -> Detections: if track is not None: tracked_detections.append(track) - return Detections.merge(tracked_detections) + detections = Detections.merge(tracked_detections) + if len(tracked_detections) == 0: + detections.tracker_id = np.array([], dtype=int) + + return detections From 5e1d9bbd40054938ae8a994b26e7026e321e8743 Mon Sep 17 00:00:00 2001 From: Linas Kondrackis Date: Wed, 28 Feb 2024 15:22:15 +0200 Subject: [PATCH 2/2] smoother: check len of detections - not tracked_detections --- supervision/detection/tools/smoother.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supervision/detection/tools/smoother.py b/supervision/detection/tools/smoother.py index 1e8f91afd..f58f32998 100644 --- a/supervision/detection/tools/smoother.py +++ b/supervision/detection/tools/smoother.py @@ -116,7 +116,7 @@ def get_smoothed_detections(self) -> Detections: tracked_detections.append(track) detections = Detections.merge(tracked_detections) - if len(tracked_detections) == 0: + if len(detections) == 0: detections.tracker_id = np.array([], dtype=int) return detections