roboflow/supervision · error · ValueError

`is_obb=True` requires `'{ORIENTED_BOX_COORDINATES}'` in `de

Error message

`is_obb=True` requires `'{ORIENTED_BOX_COORDINATES}'` in `detections.data` with shape (N, 4, 2). Load OBB datasets via `DetectionDataset.from_yolo(..., is_obb=True)` or set `detections.data['{ORIENTED_BOX_COORDINATES}']` (shape (N, 4, 2)) before exporting.

What it means

Raised by detections_to_yolo_annotations when is_obb=True but detections.data does not contain the ORIENTED_BOX_COORDINATES entry (shape (N, 4, 2) of OBB corner points). OBB export cannot be derived from axis-aligned xyxy boxes, so the oriented corners must already be attached to the Detections — typically by loading an OBB dataset with DetectionDataset.from_yolo(..., is_obb=True).

Source

Thrown at src/supervision/dataset/formats/yolo.py:367

        ```pycon
        >>> import numpy as np
        >>> from supervision.detection.core import Detections
        >>> from supervision.dataset.formats.yolo import detections_to_yolo_annotations
        >>> detections = Detections(
        ...     xyxy=np.array([[10, 10, 90, 90]], dtype=np.float32),
        ...     class_id=np.array([0]),
        ... )
        >>> detections_to_yolo_annotations(detections, image_shape=(100, 100, 3))
        ['0 0.50000 0.50000 0.80000 0.80000']

        ```
    """
    if (
        is_obb
        and len(detections) > 0
        and ORIENTED_BOX_COORDINATES not in detections.data
    ):
        raise ValueError(
            f"`is_obb=True` requires `'{ORIENTED_BOX_COORDINATES}'` in "
            "`detections.data` with shape (N, 4, 2). Load OBB datasets via "
            "`DetectionDataset.from_yolo(..., is_obb=True)` or set "
            f"`detections.data['{ORIENTED_BOX_COORDINATES}']` "
            "(shape (N, 4, 2)) before exporting."
        )

    if is_obb and detections.mask is not None:
        warnings.warn(
            "`detections.mask` is ignored when `is_obb=True`; "
            "OBB annotations use corner coordinates from "
            f"`detections.data['{ORIENTED_BOX_COORDINATES}']`.",
            UserWarning,
            stacklevel=2,
        )

    annotation: list[str] = []
    for xyxy, mask, _, class_id, _, data in detections:

View on GitHub (pinned to 7f254d9784)

Solutions

  1. If the source dataset is OBB, load it with DetectionDataset.from_yolo(..., is_obb=True) so ORIENTED_BOX_COORDINATES is populated, then export with is_obb=True.
  2. If building Detections by hand, set detections.data[sv.ORIENTED_BOX_COORDINATES] to an (N, 4, 2) array of corner points before exporting.
  3. If your detections are actually axis-aligned, drop is_obb=True from the export call.

Example fix

# before
lines = sv.detections_to_yolo_annotations(dets, image_shape=shape, is_obb=True)
# after
import supervision as sv
import numpy as np
dets.data[sv.ORIENTED_BOX_COORDINATES] = corners  # (N, 4, 2)
lines = sv.detections_to_yolo_annotations(dets, image_shape=shape, is_obb=True)
Defensive patterns

Strategy: type-guard

Validate before calling

import supervision as sv

def can_export_obb(detections: sv.Detections) -> bool:
    """OBB export requires oriented corner data on non-empty detections."""
    return (len(detections) == 0
            or sv.ORIENTED_BOX_COORDINATES in detections.data)

Type guard

def has_obb_data(detections) -> bool:
    """True when detections carry (N, 4, 2) oriented box coordinates."""
    corners = detections.data.get(sv.ORIENTED_BOX_COORDINATES)
    return corners is not None and getattr(corners, 'ndim', 0) == 3 and corners.shape[1:] == (4, 2)

Try / catch

try:
    lines = sv.detections_to_yolo_annotations(dets, image_shape=shape, is_obb=True)
except ValueError as e:
    if 'ORIENTED_BOX_COORDINATES' in str(e):
        raise SystemExit('Load dataset with from_yolo(..., is_obb=True) or set '
                         "detections.data[sv.ORIENTED_BOX_COORDINATES]") from e
    raise

Prevention

When it happens

Trigger: Calling sv.detections_to_yolo_annotations(detections, image_shape=..., is_obb=True) on Detections built from a normal detector output (no oriented corners in data), or exporting a from_yolo(..., is_obb=False) dataset with is_obb=True.

Common situations: Copy-pasting an OBB export snippet onto regular HBB detections; loading the dataset without is_obb=True and then trying to round-trip OBB annotations; manually constructing Detections and forgetting the data field.

Related errors


AI-assisted analysis of roboflow/supervision@7f254d9784 (2026-08-15). Data as JSON: /api/errors/9ba5a0f4bb82ffb7. Report an issue: GitHub.