Repository navigation
fix(dataset): reject or order a reversed box in the remaining loaders - #2683
Merged
Borda merged 8 commits intoOct 8, 2026
Merged
Conversation
roboflow#2663 stopped the YOLO loader building a box with x_min past x_max, but coco, createml and pascal_voc still did. Such a box makes Detections.area negative, scores two boxes covering the identical region at 0.0 under box_iou_batch, and stops with_nms suppressing, so a corrupt label skews evaluation silently. The format decides the remedy, following what roboflow#2663 established: - coco and createml name an extent, so a negative width or height is not representable and is now rejected, as the YOLO loader does. - pascal_voc names two corners explicitly, so a reversed pair describes the same rectangle and is now ordered, as labelme already does. All three exporters measured the extent from raw corner values, so a reversed Detections exported as a file the loader refuses to read. Each now orders the corners first, and the COCO exporter writes the ordered origin rather than the raw one. The exported box describes the same rectangle and normal boxes are unchanged.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2683 +/- ##
=======================================
Coverage 93% 93%
=======================================
Files 78 78
Lines 11930 11980 +50
=======================================
+ Hits 11049 11101 +52
+ Misses 881 879 -2 🚀 New features to boost your workflow:
|
… export mypy rejected rebinding the ndarray parameter to a list. Order the corners into locals instead, which also leaves the caller's array untouched.
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The changelog is future-dated, and API documentation, type annotations, and zero-boundary tests need correction.
Review effort: Balanced
Findings: 4
Open (4)
What changed in this PR
Normalizes reversed boxes across remaining dataset formats, preventing invalid geometry during import/export.
Changes:
- Rejects negative COCO/CreateML extents.
- Orders Pascal VOC corners and all three exporters.
- Adds regression tests and changelog documentation.
Assessment: Code quality 4/5 · Testing 4/5 · Documentation 3/5
| File | Description |
|---|---|
src/supervision/dataset/formats/coco.py |
Validates extents and orders exports. |
src/supervision/dataset/formats/createml.py |
Rejects negative extents and orders exports. |
src/supervision/dataset/formats/pascal_voc.py |
Orders corners during loading and export. |
tests/dataset/formats/test_coco.py |
Tests rejection and normalized export. |
tests/dataset/formats/test_createml.py |
Tests rejection and normalized export. |
tests/dataset/formats/test_pascal_voc.py |
Tests corner ordering. |
docs/changelog.md |
Documents the fix. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…aining-loaders # Conflicts: # docs/changelog.md
Review notes on roboflow#2683. The COCO loader gained a ValueError with no Raises entry at all, and the CreateML loader's existing Raises section documented only missing keys and conversion failures. Both now state that a negative width or height is rejected and that a zero extent is accepted. Both guards use `< 0`, so a degenerate zero-extent box still loads, but nothing pinned that. Added the zero and negative-zero cases for each loader, mirroring test_yolo.py's test_loads_a_zero_box_extent. All eight fail if the guard is tightened to `<= 0`.
Changes: - Assert exact Pascal VOC coordinates for reversed-box export and clarify the test contract. - Annotate integer extent parameters in COCO and CreateML rejection tests. Impact: - Detect shifted or resized rectangles that ordering-only checks accepted. - Make test parameter contracts explicit without changing production code. Verification: - Targeted dataset tests: 198 passed. - Full suite: 4770 passed, 61 skipped, 39 warnings; 92% coverage. - Pre-commit, formatting, configured mypy, and git diff --check passed. - Exact-coordinate regression rejects shifted and resized exporter mutations. Residual limits: - Independent five-axis review and isolated blueprint remain unresolved. - Local tests used NumPy fallback; native CI covers unchanged production. - Finite geometry coverage is not exhaustive; configured mypy excludes tests. --- Co-authored-by: Codex <[email protected]>
Borda
approved these changes
Oct 8, 2026
Borda
added a commit
that referenced
this pull request
Oct 8, 2026
…#2683) #2663 stopped the YOLO loader building a box with x_min past x_max, but coco, createml and pascal_voc still did. Such a box makes Detections.area negative, scores two boxes covering the identical region at 0.0 under box_iou_batch, and stops with_nms suppressing, so a corrupt label skews evaluation silently. The format decides the remedy, following what #2663 established: - coco and createml name an extent, so a negative width or height is not representable and is now rejected, as the YOLO loader does. - pascal_voc names two corners explicitly, so a reversed pair describes the same rectangle and is now ordered, as labelme already does. All three exporters measured the extent from raw corner values, so a reversed Detections exported as a file the loader refuses to read. Each now orders the corners first, and the COCO exporter writes the ordered origin rather than the raw one. The exported box describes the same rectangle and normal boxes are unchanged. --------- Co-authored-by: jirka <[email protected]> Co-authored-by: Codex <[email protected]>
Merged
Borda
added a commit
that referenced
this pull request
Oct 8, 2026
…#2683) #2663 stopped the YOLO loader building a box with x_min past x_max, but coco, createml and pascal_voc still did. Such a box makes Detections.area negative, scores two boxes covering the identical region at 0.0 under box_iou_batch, and stops with_nms suppressing, so a corrupt label skews evaluation silently. The format decides the remedy, following what #2663 established: - coco and createml name an extent, so a negative width or height is not representable and is now rejected, as the YOLO loader does. - pascal_voc names two corners explicitly, so a reversed pair describes the same rectangle and is now ordered, as labelme already does. All three exporters measured the extent from raw corner values, so a reversed Detections exported as a file the loader refuses to read. Each now orders the corners first, and the COCO exporter writes the ordered origin rather than the raw one. The exported box describes the same rectangle and normal boxes are unchanged. --------- Co-authored-by: jirka <[email protected]> Co-authored-by: Codex <[email protected]>
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.

Closes #2682. Follow-up to #2663, which covered
yoloonly.What changed
The format decides the remedy, following what #2663 established:
cocoandcreatemlname an extent, so a negative width or height is not representable. Both now reject it, with the same message shape the YOLO loader uses:Invalid box extent (-40, 40) in COCO annotation 7; expected a non-negative width and height.pascal_vocnames two corners explicitly, so a reversed pair describes the same rectangle rather than being malformed input. It now orders them, aslabelme._rectangle_to_xyxyalready does.All three exporters measured the extent from raw corner values, so a reversed
Detectionsexported as a file the loader refuses to read — the asymmetry that review caught on #2663. Each now orders the corners first, and the COCO exporter writes the ordered origin rather than the rawxyxy[0], xyxy[1].Verification
Import side:
cocobbox: [50,50,-40,40]area = -1600createmlwidth: -40area = -1600pascal_vocxmin 70, xmax 30area = -1600xyxy = [29, 29, 69, 69],area = 1600Export side, from
Detections(xyxy=[[70, 70, 30, 30]]):cocobbox: [70, 70, -40, -40]bbox: [30, 30, 40, 40]createmlwidth: -40, height: -40width: 40, height: 40, centre unchanged at(50, 50)pascal_vocxmin 71 > xmax 31xmin 31 < xmax 71The exported box describes the same rectangle in each case, and normal boxes are unchanged.
10 new tests across the three format test files, mirroring
TestYoloAnnotationsToDetectionsBoxExtent. All 10 fail without thesrc/change and pass with it. The fulltests/dataset/suite is 554 passing;ruff checkandruff formatare clean.Note
labelmeneeded no change — it already normalises on load, and I left its export alone since it writes a rectangle's corner list rather than an extent.