From 639318832b73ba95c005983731a767cd087f55a4 Mon Sep 17 00:00:00 2001 From: SkalskiP Date: Wed, 23 Apr 2025 23:55:34 +0200 Subject: [PATCH 1/5] ready for tests --- supervision/annotators/core.py | 6 +++++- supervision/annotators/utils.py | 4 +--- supervision/config.py | 7 ++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index d42e46d3..322833b2 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -14,7 +14,8 @@ from supervision.annotators.utils import ( resolve_color, resolve_text_background_xyxy, ) -from supervision.config import CLASS_NAME_DATA_FIELD, ORIENTED_BOX_COORDINATES +from supervision.config import CLASS_NAME_DATA_FIELD, ORIENTED_BOX_COORDINATES, \ + PENDING_TRACK_ID from supervision.detection.core import Detections from supervision.detection.utils import ( clip_boxes, @@ -1743,6 +1744,9 @@ class TraceAnnotator(BaseAnnotator): self.trace.put(detections) for detection_idx in range(len(detections)): tracker_id = int(detections.tracker_id[detection_idx]) + if tracker_id == PENDING_TRACK_ID: + continue + color = resolve_color( color=self.color, detections=detections, diff --git a/supervision/annotators/utils.py b/supervision/annotators/utils.py index 74d25a65..8deef0bf 100644 --- a/supervision/annotators/utils.py +++ b/supervision/annotators/utils.py @@ -3,13 +3,11 @@ from typing import Optional, Tuple, Union import numpy as np +from supervision.config import PENDING_TRACK_COLOR, PENDING_TRACK_ID from supervision.detection.core import Detections from supervision.draw.color import Color, ColorPalette from supervision.geometry.core import Position -PENDING_TRACK_COLOR = Color.GREY -PENDING_TRACK_ID = -1 - class ColorLookup(Enum): """ diff --git a/supervision/config.py b/supervision/config.py index b18d2e20..21d4dfd7 100644 --- a/supervision/config.py +++ b/supervision/config.py @@ -1,2 +1,7 @@ +from supervision import Color + +PENDING_TRACK_COLOR = Color.GREY +PENDING_TRACK_ID = -1 + CLASS_NAME_DATA_FIELD = "class_name" -ORIENTED_BOX_COORDINATES = "xyxyxyxy" +ORIENTED_BOX_COORDINATES = "xyxyxyxy" \ No newline at end of file From 2ea0f443f843811af44122a00aeb49ec05cefc0a Mon Sep 17 00:00:00 2001 From: SkalskiP Date: Thu, 24 Apr 2025 00:08:06 +0200 Subject: [PATCH 2/5] test new approach --- supervision/annotators/core.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index 322833b2..5720b580 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -1740,13 +1740,11 @@ class TraceAnnotator(BaseAnnotator): "The `tracker_id` field is missing in the provided detections." " See more: https://supervision.roboflow.com/latest/how_to/track_objects" ) + detections = detections[detections.tracker_id != PENDING_TRACK_ID] self.trace.put(detections) for detection_idx in range(len(detections)): tracker_id = int(detections.tracker_id[detection_idx]) - if tracker_id == PENDING_TRACK_ID: - continue - color = resolve_color( color=self.color, detections=detections, From da498b091b57e19e9f2271cb3860c96f17167abb Mon Sep 17 00:00:00 2001 From: SkalskiP Date: Thu, 24 Apr 2025 00:13:32 +0200 Subject: [PATCH 3/5] fix circular import --- supervision/annotators/core.py | 5 ++--- supervision/annotators/utils.py | 3 ++- supervision/config.py | 5 ----- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index 5720b580..52b89833 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -12,10 +12,9 @@ from supervision.annotators.utils import ( ColorLookup, Trace, resolve_color, - resolve_text_background_xyxy, + resolve_text_background_xyxy, PENDING_TRACK_ID, ) -from supervision.config import CLASS_NAME_DATA_FIELD, ORIENTED_BOX_COORDINATES, \ - PENDING_TRACK_ID +from supervision.config import CLASS_NAME_DATA_FIELD, ORIENTED_BOX_COORDINATES from supervision.detection.core import Detections from supervision.detection.utils import ( clip_boxes, diff --git a/supervision/annotators/utils.py b/supervision/annotators/utils.py index 8deef0bf..501f6535 100644 --- a/supervision/annotators/utils.py +++ b/supervision/annotators/utils.py @@ -3,11 +3,12 @@ from typing import Optional, Tuple, Union import numpy as np -from supervision.config import PENDING_TRACK_COLOR, PENDING_TRACK_ID from supervision.detection.core import Detections from supervision.draw.color import Color, ColorPalette from supervision.geometry.core import Position +PENDING_TRACK_COLOR = Color.GREY +PENDING_TRACK_ID = -1 class ColorLookup(Enum): """ diff --git a/supervision/config.py b/supervision/config.py index 21d4dfd7..050ad6e6 100644 --- a/supervision/config.py +++ b/supervision/config.py @@ -1,7 +1,2 @@ -from supervision import Color - -PENDING_TRACK_COLOR = Color.GREY -PENDING_TRACK_ID = -1 - CLASS_NAME_DATA_FIELD = "class_name" ORIENTED_BOX_COORDINATES = "xyxyxyxy" \ No newline at end of file From 047489b96ee86e6122befde7e457e4e0868d1240 Mon Sep 17 00:00:00 2001 From: SkalskiP Date: Thu, 24 Apr 2025 00:22:27 +0200 Subject: [PATCH 4/5] bump version from `0.26.0rc5` to `0.26.0rc6` --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1a003593..6f8822f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ name = "supervision" description = "A set of easy-to-use utils that will come in handy in any Computer Vision project" license = { text = "MIT" } -version = "0.26.0rc5" +version = "0.26.0rc6" readme = "README.md" requires-python = ">=3.8" authors = [ From 1cf95972f391bb9f4a8b5f782456815a250fbd1d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 23 Apr 2025 22:26:23 +0000 Subject: [PATCH 5/5] =?UTF-8?q?fix(pre=5Fcommit):=20=F0=9F=8E=A8=20auto=20?= =?UTF-8?q?format=20pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- supervision/annotators/core.py | 3 ++- supervision/annotators/utils.py | 1 + supervision/config.py | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/supervision/annotators/core.py b/supervision/annotators/core.py index 52b89833..b5395737 100644 --- a/supervision/annotators/core.py +++ b/supervision/annotators/core.py @@ -9,10 +9,11 @@ from PIL import Image, ImageDraw, ImageFont from supervision.annotators.base import BaseAnnotator, ImageType from supervision.annotators.utils import ( + PENDING_TRACK_ID, ColorLookup, Trace, resolve_color, - resolve_text_background_xyxy, PENDING_TRACK_ID, + resolve_text_background_xyxy, ) from supervision.config import CLASS_NAME_DATA_FIELD, ORIENTED_BOX_COORDINATES from supervision.detection.core import Detections diff --git a/supervision/annotators/utils.py b/supervision/annotators/utils.py index 501f6535..74d25a65 100644 --- a/supervision/annotators/utils.py +++ b/supervision/annotators/utils.py @@ -10,6 +10,7 @@ from supervision.geometry.core import Position PENDING_TRACK_COLOR = Color.GREY PENDING_TRACK_ID = -1 + class ColorLookup(Enum): """ Enumeration class to define strategies for mapping colors to annotations. diff --git a/supervision/config.py b/supervision/config.py index 050ad6e6..b18d2e20 100644 --- a/supervision/config.py +++ b/supervision/config.py @@ -1,2 +1,2 @@ CLASS_NAME_DATA_FIELD = "class_name" -ORIENTED_BOX_COORDINATES = "xyxyxyxy" \ No newline at end of file +ORIENTED_BOX_COORDINATES = "xyxyxyxy"