Add ColorPalette and ColorLookup support to keypoint annotators#2343
Open
SkalskiP wants to merge 4 commits into
Open
Add ColorPalette and ColorLookup support to keypoint annotators#2343SkalskiP wants to merge 4 commits into
ColorPalette and ColorLookup support to keypoint annotators#2343SkalskiP wants to merge 4 commits into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #2343 +/- ##
=======================================
- Coverage 81% 81% -0%
=======================================
Files 66 66
Lines 9077 9108 +31
=======================================
+ Hits 7377 7398 +21
- Misses 1700 1710 +10 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the ColorPalette + ColorLookup color-mapping approach (used by detection annotators) to keypoint annotators, enabling palette-driven coloring and introducing a new ColorLookup.KEYPOINT strategy for per-keypoint-index coloring.
Changes:
- Added shared color-resolution helpers to support
ColorLookup.KEYPOINTand reuse logic between detection and keypoint annotators. - Updated
VertexAnnotator,EdgeAnnotator, andVertexLabelAnnotatorto acceptColorPaletteand useColorLookupto resolve per-annotation colors. - Refactored detection annotators to use newly introduced internal helpers, and updated keypoint annotator tests to match the new internal API.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| tests/key_points/test_annotators.py | Updates unit tests for VertexLabelAnnotator color resolution to align with the new single-color resolution logic. |
| src/supervision/key_points/annotators.py | Adds palette/lookup support to keypoint annotators and introduces shared keypoint color resolution. |
| src/supervision/annotators/utils.py | Adds ColorLookup.KEYPOINT and refactors/extends internal color index + color resolution helpers (with deprecation wrappers). |
| src/supervision/annotators/core.py | Switches detection annotators to use the new internal _resolve_detection_color helper. |
Comment on lines
+83
to
+88
| if tracker_id is None: | ||
| raise ValueError( | ||
| "Could not resolve color by track because " | ||
| "tracker_id is not available. Make sure that the " | ||
| "Detections object contains tracker_id data." | ||
| ) |
Comment on lines
+78
to
82
| color_lookup: Strategy for mapping colors to annotations. | ||
| Options are `INDEX` (per-skeleton index), `CLASS` | ||
| (per class_id), and `KEYPOINT` (per keypoint index within | ||
| each skeleton). | ||
| """ |
Comment on lines
+30
to
+36
| def _resolve_keypoint_color( | ||
| color: Color | ColorPalette, | ||
| color_lookup: ColorLookup, | ||
| key_points: KeyPoints, | ||
| instance_idx: int, | ||
| keypoint_idx: int = 0, | ||
| ) -> Color: |
Collaborator
Author
|
@Borda this is ready for review. I believe this makes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Brings the same color-mapping system used by detection annotators (
ColorPalette+ColorLookup) toVertexAnnotator,EdgeAnnotator, andVertexLabelAnnotator. This lets users color keypoints by detection index, class, or track — and introduces a newColorLookup.KEYPOINTstrategy for per-keypoint-index coloring.EdgeAnnotator(sv.ColorLookup.CLASS,sv.ColorLookup.INDEX,sv.ColorLookup.KEYPOINT)VertexAnnotator(sv.ColorLookup.CLASS,sv.ColorLookup.INDEX,sv.ColorLookup.KEYPOINT)VertexLabelAnnotator(sv.ColorLookup.CLASS,sv.ColorLookup.INDEX,sv.ColorLookup.KEYPOINT)