Repository navigation
fix(annotators): preserve grayscale channel axis in blur and pixelation - #2725
Merged
Borda merged 7 commits intoOct 15, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2725 +/- ##
=======================================
- Coverage 94% 94% -0%
=======================================
Files 83 83
Lines 13127 13127
=======================================
- Hits 12323 12320 -3
- Misses 804 807 +3 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The implementation is correct and well tested; remaining feedback is non-blocking metadata and test-ID cleanup.
2 open findings
What changed in this PR
Fixes grayscale (H, W, 1) handling in privacy annotators while preserving in-place behavior.
Changes:
- Restores singleton channel axes after OpenCV blur/resize operations.
- Adds regression coverage and API documentation.
- Adds an Unreleased changelog entry.
Review scores: Code quality 5/5 · Testing 4/5 · Documentation 4/5
| File | Description |
|---|---|
src/supervision/annotators/core.py |
Preserves grayscale ROI shape after filtering. |
tests/annotators/test_core.py |
Tests grayscale layouts and edge-case regions. |
docs/changelog.md |
Documents the bug fix. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…gle-channel-grayscale # Conflicts: # docs/changelog.md
Changes: - Integrate develop video-reader cancellation, cleanup error handling, and regression tests. - Integrate coincident-label separation and its regression tests. - Retain updated model and annotation examples, typing adjustments, and notebook dependency lock updates. - Reconcile changelog additions, preserving the grayscale fix entry and the newer modification date. Impact: - Preserve the PR's grayscale channel handling atop the current target implementation. - Remove the changelog merge conflict while retaining target behavior and release notes. Verification: - Annotator tests: 211 passed. - Full suite in the existing project environment: 5589 passed, 79 skipped, 94% coverage. - All configured pre-commit hooks passed; staged diff whitespace check passed. Residual limits: - Native OpenCV reproduction and independent reviewer coverage remain open review obligations. - Automatic environment synchronization requires uncached notebook dependencies; checks used the existing environment without synchronization. --- Co-authored-by: Codex <[email protected]>
Borda
approved these changes
Oct 15, 2026
This was referenced Oct 17, 2026
3 tasks done
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.

Description
BlurAnnotatorandPixelateAnnotatorraiseValueErroron grayscale frames shaped(H, W, 1)when native OpenCV is installed:Both calls fail with
could not broadcast input array from shape (16,20) into shape (16,20,1).Motivation and Context
OpenCV's
blurandresizeremove the singleton channel axis. Assigning their two-dimensional result into a three-dimensional region then fails. The NumPy fallback retains that axis, so the same pipeline works without OpenCV and fails when it is installed.Changes Made
Restore each filtered region to its original shape before writing it back to the scene. Document both grayscale layouts and add regressions comparing
(H, W, 1)output with(H, W)output for rectangular, small, single-row and single-column regions, including in-place behavior.Testing
New regression cases on unmodified
develop: 5 failed, 3 passed with OpenCV 5.0.0.Fixed regressions and adjacent blur/pixelation tests with OpenCV 5.0.0: 23 passed.
Complete annotator tests with OpenCV 4.12.0: 211 passed.
uv run pytest --cov=supervisionwith the NumPy fallback: 5,433 passed, 79 skipped, 93% coverage.uv run pre-commit run --all-files: all hooks passed.Added/updated tests, and the full suite passes locally
Updated docs (docstrings / mkdocs entry) for new or changed public API
Added changelog under Unreleased
Additional Notes
No new dependencies or API parameters.