Repository navigation
fix(dataset): round Pascal VOC bndbox corners instead of truncating them - #2748
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2748 +/- ##
=======================================
- Coverage 94% 94% -0%
=======================================
Files 83 83
Lines 13675 13674 -1
=======================================
- Hits 12883 12882 -1
Misses 792 792 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟢 Approval recommended
The focused correction has regression coverage; the only remaining feedback is a minor missing changelog entry.
1 open finding
What changed in this PR
Corrects Pascal VOC bounding-box exports by rounding fractional corners rather than truncating them, addressing YOLO conversion precision loss.
Changes:
- Rounds all four bounding-box corners and documents the behavior.
- Adds regression cases for rounding up, rounding down, and YOLO floating-point noise.
| File | Description |
|---|---|
| tests/dataset/formats/test_pascal_voc.py | Adds fractional-coordinate regression tests. |
| src/supervision/dataset/formats/pascal_voc.py | Rounds exported corners and updates the docstring. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Changes: - Merge the fetched develop target into the Pascal VOC rounding branch, including the Unreleased notes for PRs roboflow#2740, roboflow#2741, and roboflow#2743. - Integrate OpenCV-compatible ellipse rasterization and its regression coverage. - Integrate mask ROI handling that excludes all-False masks and its tests. - Integrate overflow-safe mean-average-precision box extents and dtype regression tests. Impact: - Keeps the PR branch current so the roboflow#2748 changelog note can be added beside the target's Unreleased entries. - Brings the target's drawing, mask annotation, and metric fixes into the local PR branch. Verification: - The three-tree merge completed automatically without conflicts. - The staged merge diff check passed; all eight staged paths were reviewed. Residual limits: - None known. --- Co-authored-by: Codex <[email protected]>
|
Related: #2756. This PR fixes the truncation, but the +1 is still applied to xmax and ymax. Under the VOC devkit convention (1-based, inclusive), only xmin and ymin need it: the box [0, 0, 37, 29] from #2747 should be written as 1 1 37 29, not 1 1 38 30. It might be easiest to handle both in this PR. |
|
Thanks, @t7spotter. You're right about the devkit convention: with 1-based inclusive indices, a box covering 0-based pixels Fixing it isn't writer-only, though. @Borda, if you agree with the devkit convention, I'm happy to open a follow-up that changes the reader and writer together, with a changelog note about files written by earlier versions. |
Changes: - Add a PR roboflow#2748 Unreleased note describing nearest-integer rounding of all four Pascal VOC bndbox corners during YOLO-to-VOC export. Impact: - Readers can see that fractional box coordinates are rounded to preserve intended box extent. Verification: - Pinned mdformat hook passed; full suite passed: 5726 passed, 123 skipped, 39 warnings. - git diff --check and parent self-review passed; lint and type checks are not applicable because only Markdown changed. Residual limits: - Independent multi-role review coverage remains unvalidated; no fresh review was authorized. --- Co-authored-by: Codex <[email protected]>
|
@Lingikaushikreddy, as this seems to be quite connected and better not accidentally release one without the other one, so let's do it within this PR 🦝 |
Changes: - Add a PR roboflow#2748 Unreleased note describing nearest-integer rounding of all four Pascal VOC bndbox corners during YOLO-to-VOC export. Impact: - Readers can see that fractional box coordinates are rounded to preserve intended box extent. Verification: - Pinned mdformat hook passed; full suite passed: 5726 passed, 123 skipped, 39 warnings. - git diff --check and parent self-review passed; lint and type checks are not applicable because only Markdown changed. Residual limits: - Independent multi-role review coverage remains unvalidated; no fresh review was authorized. --- Co-authored-by: Codex <[email protected]>
356e40a to
44451e9
Compare
|
@Borda, done: #2756 is folded in here, and the branch is rebased on
Full suite and pre-commit pass locally. |
Changes: - Add a PR roboflow#2748 Unreleased note describing nearest-integer rounding of all four Pascal VOC bndbox corners during YOLO-to-VOC export. Impact: - Readers can see that fractional box coordinates are rounded to preserve intended box extent. Verification: - Pinned mdformat hook passed; full suite passed: 5726 passed, 123 skipped, 39 warnings. - git diff --check and parent self-review passed; lint and type checks are not applicable because only Markdown changed. Residual limits: - Independent multi-role review coverage remains unvalidated; no fresh review was authorized. --- Co-authored-by: Codex <[email protected]>
44451e9 to
74c7c29
Compare
Changes: - Add a PR roboflow#2748 Unreleased note describing nearest-integer rounding of all four Pascal VOC bndbox corners during YOLO-to-VOC export. Impact: - Readers can see that fractional box coordinates are rounded to preserve intended box extent. Verification: - Pinned mdformat hook passed; full suite passed: 5726 passed, 123 skipped, 39 warnings. - git diff --check and parent self-review passed; lint and type checks are not applicable because only Markdown changed. Residual limits: - Independent multi-role review coverage remains unvalidated; no fresh review was authorized. --- Co-authored-by: Codex <[email protected]>
The Pascal VOC devkit uses 1-based, inclusive pixel indices, so a box covering zero-indexed pixels x1 .. x2 - 1 is written xmin = x1 + 1, xmax = x2. The writer added 1 to all four corners and the reader subtracted 1 from all four, so a supervision round trip looked exact while every exported box was one pixel too wide and tall for devkit readers such as Detectron2. Write and read the offset on xmin and ymin only. Mask-derived boxes come from contour vertices on the outermost mask pixels, so their far edge is now taken one past the largest vertex; their written bndbox is unchanged. Update the tests and fixtures that encoded the old offset.
74c7c29 to
c9cac51
Compare
Changes: - Merge fetched develop commit 18dbc49 into the PR branch and resolve the changelog, Pascal VOC conversion, and format-test overlaps. - Preserve the target VOC far-edge convention, the PR fractional rounding behavior, and both changelog entries while retaining all other fetched develop changes. Impact: - Brings the PR branch up to the verified develop target, including recent dataset, metrics, detection, utility, documentation, CI, and dependency-lock updates. - Keeps target max-corner serialization intact for boxes and mask-derived polygons. Verification: - tests/dataset/formats/test_pascal_voc.py: 77 passed. - git diff --cached --check: passed; no unmerged paths remain. - The staged index differs from fetched develop only in the three resolved conflict paths. Residual limits: - The half-pixel minimum offset ordering still needs the selected remediation finding fix. - The subpixel collapse behavior needs its exact reviewer case and round-trip regression after scope selection. --- Co-authored-by: Codex <[email protected]>
…hem (#2748) * fix(dataset): round Pascal VOC bndbox corners instead of truncating them * docs(changelog): document Pascal VOC rounding * fix(dataset): offset only xmin and ymin in Pascal VOC bndbox --------- Co-authored-by: Lingikaushikreddy <[email protected]> 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
object_to_pascal_vocwrote<bndbox>corners withint(), which truncates. A fractional box lost up to a pixel per corner, and a box read from 6-decimal YOLO labels could be written withxmin=0, outside 1-indexed VOC. The corners are now rounded to the nearest integer pixel.Motivation and Context
Closes #2747
YOLO → VOC conversion is where this bites.
from_yoloreturns corners a hair off the integer pixel, so the integer box[0, 0, 37, 29]from an Ultralytics label came back from VOC as[-1, -1, 37, 28]. It now round-trips to[0, 0, 37, 29].Changes Made
src/supervision/dataset/formats/pascal_voc.py:str(round(x))instead ofstr(int(x))for the four<bndbox>corners, and a docstring note.tests/dataset/formats/test_pascal_voc.py: parametrized test for rounding up, rounding down, and the YOLO float-noise box.docs/changelog.md: entry under Unreleased.<polygon>points are already written unrounded, as before.Testing
New test on
develop: 2 of 3 cases fail (('11', '11', '21', '21') != ('12', '12', '22', '22')and('0', '0', '38', '29') != ('1', '1', '38', '30')). The rounds-down case passes on both and guards against a ceil-based fix.With this change:
uv run pytest tests/dataset/formats/test_pascal_voc.py, 58 passed.Full suite:
uv run pytest, 5697 passed, 105 skipped (develop: 5694 passed, 105 skipped).uv run pre-commit run --all-filespasses.Added/updated tests, and the full suite passes locally
Updated docs (docstrings / mkdocs entry) for new or changed public API
Added a changelog entry in
docs/changelog.mdunderUnreleasedAdditional Notes
Python's
roundrounds halves to even (10.5→10), the same asnp.round. An exact half-pixel corner has no better answer either way, so I kept the standard behaviour rather than adding a half-up rule.