Skip to content

chore: update YOLO OBB annotation export support - #2302

Merged
Borda merged 5 commits into
roboflow:developfrom
adhavan18:fix-obb-yolo-export
Jun 10, 2026
Merged

Borda merged 5 commits into
roboflow:developfrom
adhavan18:fix-obb-yolo-export

Conversation

@adhavan18

Copy link
Copy Markdown
Contributor

Summary

Adds support for exporting oriented bounding box (OBB) annotations in YOLO format.

Changes

  • Detect OBB coordinates stored under ORIENTED_BOX_COORDINATES.
  • Export OBB annotations as normalized polygon coordinates.
  • Preserve existing behavior for bounding boxes and segmentation masks.
  • Add test coverage for OBB export.

Validation

  • Added test_detections_to_yolo_annotations_exports_obb.
  • All YOLO format tests pass (31 passed).

@adhavan18
adhavan18 requested a review from SkalskiP as a code owner June 8, 2026 07:08
@CLAassistant

CLAassistant commented Jun 8, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codecov

codecov Bot commented Jun 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80%. Comparing base (a549f44) to head (66f7b82).

Additional details and impacted files
@@           Coverage Diff           @@
##           develop   #2302   +/-   ##
=======================================
- Coverage       80%     80%   -0%     
=======================================
  Files           66      66           
  Lines         8785    8787    +2     
=======================================
+ Hits          7045    7046    +1     
- Misses        1740    1741    +1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for exporting oriented bounding box (OBB) annotations from sv.Detections into YOLO polygon-style annotation lines when Detections.data contains ORIENTED_BOX_COORDINATES.

Changes:

  • Extend detections_to_yolo_annotations to emit normalized polygon coordinates for OBB detections.
  • Add a unit test asserting OBB export produces the expected YOLO token layout.

Quality Score (1–5):

  • Code quality: 3/5
  • Testing: 3/5
  • Docs: 3/5

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/supervision/dataset/formats/yolo.py Adds OBB-aware export path in detections_to_yolo_annotations.
tests/dataset/formats/test_yolo.py Adds a new test covering OBB export output.

Comment thread src/supervision/dataset/formats/yolo.py Resolved
Comment thread tests/dataset/formats/test_yolo.py Resolved
Borda and others added 3 commits June 10, 2026 14:31
Resolves merge conflict with origin/develop by accepting the develop-side
implementation of detections_to_yolo_annotations, which supersedes the
presence-based OBB detection in this PR with an explicit is_obb flag approach.

- adopt is_obb: bool = False parameter for explicit OBB export routing
- adopt comprehensive docstring with Args, Returns, Raises, Examples
- adopt object_to_yolo delegation (no DRY duplication, resolves /review H3)
- adopt warnings.warn when is_obb=True and mask is not None (resolves /review M1)
- adopt ValueError guard when is_obb=True but ORIENTED_BOX_COORDINATES absent
- adopt comprehensive test suite: exact-value assertions (resolves /review H1),
  asymmetric 200x100 fixture (resolves /review L2), multiple detections,
  round-trip via DetectionDataset (resolves /review H2), raises-without-corners,
  empty-detections, token-count parametrized, background-image round-trip
- remove contributor's presence-based OBB branch (superseded by is_obb flag)
- add from supervision.dataset.core import DetectionDataset to test imports

---
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
- add shape guard: raise ValueError when per-detection corners.shape != (4,2)
  mirrors the (N,4,2) invariant in metrics/utils/object_size.py; surfaces
  malformed input loudly instead of silently producing corrupt YOLO output
- add test: OBB data in detections.data ignored when is_obb=False; verifies
  bbox 5-token format emitted when ORIENTED_BOX_COORDINATES present but flag
  not set, exercising the flag-based routing added by the merge commit

---
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Replace bare inline comment with #: Sphinx autodoc attribute documentation
describing value layout (shape (N,4,2), float32, pixel coords), corner ordering,
and the two YOLO format functions that consume the key.

---
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
@Borda Borda changed the title feat: add YOLO OBB annotation export support chore: update YOLO OBB annotation export support Jun 10, 2026
@Borda
Borda merged commit 8a40630 into roboflow:develop Jun 10, 2026
26 checks passed
@Borda Borda mentioned this pull request Jun 11, 2026
Borda added a commit that referenced this pull request Jun 16, 2026
- Merge Added [#2312] + Changed [#2312] into single Added entry covering xyxyxyxy_to_xyxy utility and with_nmm OBB merge
- Merge Fixed [#2282] + Fixed [#2317] into single entry [#2282, #2317]; #2317 replaced the rasterization approach from #2282 entirely
- Fold Fixed [#2252] into Added [#2252]; same function, one entry covers both preserve_audio feature and muxing bug fixes
- Fold Fixed [#2289] into Added [#2302, #2289]; same function, one entry covers both is_obb parameter and rotation-loss fix

---
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants