From 37860174244e2980cec1fee801a614fb605132dc Mon Sep 17 00:00:00 2001 From: soumik12345 <19soumik.rakshit96@gmail.com> Date: Fri, 4 Jul 2025 17:01:05 +0530 Subject: [PATCH 1/4] fix: Track Objects on Video example not retrieving class name correctly --- docs/how_to/track_objects.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/how_to/track_objects.md b/docs/how_to/track_objects.md index c6f128c3..c2be3cef 100644 --- a/docs/how_to/track_objects.md +++ b/docs/how_to/track_objects.md @@ -177,9 +177,9 @@ offering a clear visual representation of each object's class and unique identif detections = tracker.update_with_detections(detections) labels = [ - f"#{tracker_id} {results.names[class_id]}" - for class_id, tracker_id - in zip(detections.class_id, detections.tracker_id) + f"#{tracker_id} {class_name}" + for class_name, tracker_id + in zip(detections.data["class_name"], detections.tracker_id) ] annotated_frame = box_annotator.annotate( @@ -212,9 +212,9 @@ offering a clear visual representation of each object's class and unique identif detections = tracker.update_with_detections(detections) labels = [ - f"#{tracker_id} {results.names[class_id]}" - for class_id, tracker_id - in zip(detections.class_id, detections.tracker_id) + f"#{tracker_id} {class_name}" + for class_name, tracker_id + in zip(detections.data["class_name"], detections.tracker_id) ] annotated_frame = box_annotator.annotate( @@ -260,9 +260,9 @@ movement patterns and interactions between objects in the video. detections = tracker.update_with_detections(detections) labels = [ - f"#{tracker_id} {results.names[class_id]}" - for class_id, tracker_id - in zip(detections.class_id, detections.tracker_id) + f"#{tracker_id} {class_name}" + for class_name, tracker_id + in zip(detections.data["class_name"], detections.tracker_id) ] annotated_frame = box_annotator.annotate( @@ -298,9 +298,9 @@ movement patterns and interactions between objects in the video. detections = tracker.update_with_detections(detections) labels = [ - f"#{tracker_id} {results.names[class_id]}" - for class_id, tracker_id - in zip(detections.class_id, detections.tracker_id) + f"#{tracker_id} {class_name}" + for class_name, tracker_id + in zip(detections.data["class_name"], detections.tracker_id) ] annotated_frame = box_annotator.annotate( From 2ef9d69e0117618a1c82139c0136e58cbed83e67 Mon Sep 17 00:00:00 2001 From: soumik12345 <19soumik.rakshit96@gmail.com> Date: Fri, 4 Jul 2025 17:07:53 +0530 Subject: [PATCH 2/4] chore: make pre-commit happy --- supervision/utils/image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supervision/utils/image.py b/supervision/utils/image.py index 0bd2dbaa..9bc9c68b 100644 --- a/supervision/utils/image.py +++ b/supervision/utils/image.py @@ -785,4 +785,4 @@ def _merge_tiles_elements( def _generate_color_image( shape: Tuple[int, int], color: Tuple[int, int, int] ) -> np.ndarray: - return np.ones(shape[::-1] + (3,), dtype=np.uint8) * color + return np.ones(shape[::-1] + (3,), dtype=np.uint8) * color # noqa RUF005 From ccf84d5653c172b94d66619ceca5b8b8b196d731 Mon Sep 17 00:00:00 2001 From: Soumik Rakshit <19soumik.rakshit96@gmail.com> Date: Tue, 8 Jul 2025 16:21:08 +0530 Subject: [PATCH 3/4] update: image.py --- supervision/utils/image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supervision/utils/image.py b/supervision/utils/image.py index 9bc9c68b..0bd2dbaa 100644 --- a/supervision/utils/image.py +++ b/supervision/utils/image.py @@ -785,4 +785,4 @@ def _merge_tiles_elements( def _generate_color_image( shape: Tuple[int, int], color: Tuple[int, int, int] ) -> np.ndarray: - return np.ones(shape[::-1] + (3,), dtype=np.uint8) * color # noqa RUF005 + return np.ones(shape[::-1] + (3,), dtype=np.uint8) * color From 1190ed2931c78bbee0a6914c850583cf6f83fca6 Mon Sep 17 00:00:00 2001 From: Soumik Rakshit <19soumik.rakshit96@gmail.com> Date: Tue, 8 Jul 2025 16:35:59 +0530 Subject: [PATCH 4/4] update: image.py --- supervision/utils/image.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/supervision/utils/image.py b/supervision/utils/image.py index 0bd2dbaa..37025656 100644 --- a/supervision/utils/image.py +++ b/supervision/utils/image.py @@ -785,4 +785,4 @@ def _merge_tiles_elements( def _generate_color_image( shape: Tuple[int, int], color: Tuple[int, int, int] ) -> np.ndarray: - return np.ones(shape[::-1] + (3,), dtype=np.uint8) * color + return np.ones((*shape[::-1], 3), dtype=np.uint8) * color