Add ColorPalette and ColorLookup support to keypoint annotators#2343
Add ColorPalette and ColorLookup support to keypoint annotators#2343SkalskiP wants to merge 9 commits into
ColorPalette and ColorLookup support to keypoint annotators#2343Conversation
Codecov Report❌ Patch coverage is ❌ Your project check has failed because the head coverage (82%) is below the target coverage (95%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## develop #2343 +/- ##
=======================================
- Coverage 82% 82% -0%
=======================================
Files 66 66
Lines 9082 9113 +31
=======================================
+ Hits 7412 7436 +24
- Misses 1670 1677 +7 🚀 New features to boost your workflow:
|
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. |
|
@Borda this is ready for review. I believe this makes |
| calculate_dynamic_pixel_size, | ||
| get_labels_text, | ||
| hex_to_rgba, | ||
| resolve_color, |
There was a problem hiding this comment.
Maybe check this issue and consider also deprecating it?
- Generalize TRACK error msg in _resolve_color_idx to not reference "Detections object" (function now shared with keypoint annotators) - Consolidate multi-line error strings to full line width - Add Raises section to _resolve_color_idx docstring - Add TRACK-not-supported note to VertexAnnotator, EdgeAnnotator, VertexLabelAnnotator color_lookup docs - Add ColorPalette+ColorLookup tests: INDEX/CLASS/KEYPOINT for all three keypoint annotators + CLASS-without-class_id error case - Fix _resolve_color_idx signature: NDArray[np.generic] (linter) [resolve items 1,2,3,5,6] PR #2343 review by @Copilot and @Borda Challenge: evidence=VALID suggestion=VALID resolution=as-suggested --- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
|
There seems to be some timeout for one of the links, but it shall be fine... |
| calculate_dynamic_kernel_size, | ||
| calculate_dynamic_pixel_size, | ||
| get_labels_text, | ||
| hex_to_rgba, |
There was a problem hiding this comment.
| hex_to_rgba, | |
| hex_to_rgba, | |
| resolve_color, |
Co-authored-by: Jirka Borovec <6035284+Borda@users.noreply.github.com>
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)