Repository navigation
fix(dataset): export annotations for in-memory grayscale images - #2641
Conversation
@INo-xious ^^ 🙏 |
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused fixes correctly handle grayscale dimensions and are comprehensively covered by format-specific regression tests.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes grayscale in-memory image annotation exports across LabelMe, YOLO, and Pascal VOC.
Changes:
- Reads height/width safely from 2D or 3D arrays.
- Records Pascal VOC grayscale depth as
1. - Adds comprehensive regression tests and changelog documentation.
Assessment: Code quality 5/5 · Testing 5/5 · Documentation 5/5
| File | Description |
|---|---|
src/supervision/dataset/formats/labelme.py |
Supports 2D image dimensions. |
src/supervision/dataset/formats/yolo.py |
Supports and documents 2D shapes. |
src/supervision/dataset/formats/pascal_voc.py |
Records grayscale depth correctly. |
tests/dataset/formats/test_labelme.py |
Tests grayscale and color exports. |
tests/dataset/formats/test_yolo.py |
Tests normalized box and mask geometry. |
tests/dataset/formats/test_pascal_voc.py |
Tests dimensions, depth, and geometry. |
docs/changelog.md |
Documents the export fix. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2641 +/- ##
=======================================
Coverage 92% 92%
=======================================
Files 78 78
Lines 11733 11749 +16
=======================================
+ Hits 10759 10775 +16
Misses 974 974 🚀 New features to boost your workflow:
|
Changes: - Preserve the PR roboflow#2641 grayscale export changelog entry alongside the four newer Unreleased entries from develop. - Integrate the current develop changes for in-place dataset image export, empty-joint keypoint NMS, COCO-compatible mean average precision, and video writer error propagation. Impact: - Keeps PR roboflow#2641 documentation while retaining the newer target changelog and implementations. - Aligns the remediation branch with the fetched develop tip before review findings are handled. Verification: - git merge-tree reported only the docs/changelog.md conflict; resolution retained both sides. - git diff --name-only --diff-filter=U returned no paths. - git diff --cached --check passed. Residual limits: - PR roboflow#2641 review findings remain to be triaged and remediated. --- Co-authored-by: Codex <[email protected]>
* fix(dataset): export annotations for in-memory grayscale images * docs: link grayscale dataset export pull request * test(yolo): add test for grayscale image OBB export with normalized tokens --------- Co-authored-by: jirka <[email protected]> Co-authored-by: Codex <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Description
Exporting a
DetectionDatasetcontaining a two-dimensional grayscale image raises a dimension-unpacking error in LabelMe and YOLO, or anIndexErrorin Pascal VOC. Read height and width independently of channels, and write Pascal VOC depth as1for grayscale images.Minimal reproduction on
developat8c7df2388ce46f16139edc498c2bc3874493b4bc:Motivation and Context
In-memory image dictionaries remain supported until their scheduled removal in 0.33.0. COCO export already accepts these grayscale arrays. The other three exporters should preserve their dimensions and annotations too.
PR #2410 addressed image modes during loading. PR #2637, currently open, addresses copying images into their source folder. Neither fixes grayscale annotation dimensions.
Changes Made
1for two-dimensional images without changing image pixels.Testing
On unmodified production code, the new tests failed for all six grayscale cases with the expected dimension errors; all six color controls passed:
With the fix:
The clean base passed 4316 tests with the same 24 skips and 91% coverage; its pre-commit checks also passed. Validation ran on macOS with Python 3.13.9 using the NumPy fallback backend. Native OpenCV and rasterio were not installed; their existing optional reference tests account for the skips. No test skips were added.
docs/changelog.mdunderUnreleased(skip for lint/type/format-only or pure doc changes)Additional Notes
No public API, dependencies, coordinate conventions, or image pixels are changed.