Repository navigation
Conversation
Changes: - New LabelMapAnnotator in annotators/label_map.py colours an (H, W) integer class-id map over a scene through one colour lookup table built from a ColorPalette, with opacity and a background_id left unpainted - Class i takes palette colour i with wrap-around, negative ids are never painted, and a map that is not 2-D integer, not the scene's size, or spans more than 1,048,576 ids raises ValueError - Exported as sv.LabelMapAnnotator and listed in docs/detection/annotators.md - Tests in tests/annotators/test_label_map.py cover palette colours, background and negative ids, opacity, in-place drawing, Pillow scenes, integer widths, validation errors and parity with MaskAnnotator on Detections.from_semantic_segmentation - Changelog entry under Unreleased Impact: - A semantic segmentation map can be drawn from one array the size of the image instead of one mask per class Limitations: - Draws only on 3-channel uint8 scenes and needs a map of the scene's size - The changelog entry has no pull request link yet --- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
LabelMapAnnotator
Changes: - The LabelMapAnnotator changelog entry ends with a link to its pull request Impact: - The entry meets the changelog rule that a functional change links its pull request --- Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Valid label maps with near-limit integer IDs can fail palette indexing or lose precision because absolute-ID range generation may produce floating-point values.
1 open issue
What changed in this PR
Adds sv.LabelMapAnnotator to render semantic segmentation class-ID maps directly, without first creating per-class detection masks.
Changes:
- Implements palette-based coloring with opacity, background exclusion, negative-ID handling, and input validation.
- Exports the annotator publicly and documents it in the API reference and changelog.
- Adds tests for rendering, integer dtypes, Pillow input, in-place updates, validation, and parity with
MaskAnnotator.
| File | Description |
|---|---|
tests/annotators/test_label_map.py |
Tests rendering behavior, validation, and mask-rendering parity. |
src/supervision/annotators/label_map.py |
Implements class-map validation, color lookup, and blending. |
src/supervision/__init__.py |
Exports LabelMapAnnotator as public API. |
docs/detection/annotators.md |
Adds the annotator’s API reference. |
docs/changelog.md |
Announces the feature under Unreleased. |
Review effort: Balanced
Comment on lines
+145
to
+146
| ids = np.arange(lowest, highest + 1) | ||
| table = palette[ids % len(palette)] |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #3047 +/- ##
=======================================
Coverage 95% 95%
=======================================
Files 84 85 +1
Lines 15503 15567 +64
=======================================
+ Hits 14772 14833 +61
- Misses 731 734 +3 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.

Changes:
Impact:
Limitations: