roboflow/supervision · error · ValueError
`{name}` has shape {arr.shape}; expected (N, 5) or (N, 6).
Error message
`{name}` has shape {arr.shape}; expected (N, 5) or (N, 6). What it means
`oriented_box_nms` requires `predictions` as a 2-D array of shape (N, 5) — [x_min, y_min, x_max, y_max, confidence] — or (N, 6) with a class-id column appended for class-aware suppression. This error fires when the array is 1-D/3-D or has a different column count (e.g. (N, 4) bare coordinates, (N, 7)). The columns drive sorting by confidence and per-class separation, so a wrong layout corrupts suppression semantics.
Source
Thrown at src/supervision/detection/utils/iou_and_nms.py:1643
>>> predictions = np.array([
... [10, 10, 50, 30, 0.9, 0],
... [11, 11, 51, 31, 0.8, 0],
... ], dtype=np.float32)
>>> keep = sv.oriented_box_non_max_suppression(
... predictions=predictions,
... oriented_boxes=oriented_boxes,
... iou_threshold=0.5,
... )
>>> keep
array([ True, False])
```
"""
_validate_iou_threshold(iou_threshold)
for name, arr in (("predictions", predictions), ("oriented_boxes", oriented_boxes)):
if name == "predictions":
if arr.ndim != 2 or arr.shape[1] not in (5, 6):
raise ValueError(
f"`{name}` has shape {arr.shape}; expected (N, 5) or (N, 6)."
)
continue
if arr.ndim == 3 and arr.shape[1:] != (4, 2):
raise ValueError(
f"`{name}` has shape {arr.shape}; expected (N, 4, 2) "
f"— each box must have exactly 4 corners with (x, y) coordinates."
)
elif arr.ndim == 2 and arr.shape[1] != 8:
raise ValueError(
f"`{name}` has shape {arr.shape}; expected (N, 8) for flat "
f"YOLO format or (N, 4, 2) for corner format."
)
elif arr.ndim not in (2, 3):
raise ValueError(
f"`{name}` must be 2-D (N, 8) or 3-D (N, 4, 2), got shape {arr.shape}."
)
if len(predictions) != len(oriented_boxes):View on GitHub (pinned to 7f254d9784)
Solutions
- Build (N, 6) with numpy: `np.hstack((xyxy, confidence.reshape(-1, 1), class_id.reshape(-1, 1)))`.
- Drop extra columns: slice to the first 5 or 6 columns, e.g. `predictions[:, :6]`.
- Ensure the result of `np.column_stack` is 2-D — a list of lists with inconsistent lengths collapses to 1-D and also trips this check.
Example fix
# before keep = sv.oriented_box_nms(dets.xyxy, obb, 0.5) # (N, 4) # after preds = np.hstack((dets.xyxy, dets.confidence.reshape(-1, 1), dets.class_id.reshape(-1, 1))) keep = sv.oriented_box_nms(preds, obb, 0.5)
Defensive patterns
Strategy: validation
Validate before calling
predictions = np.column_stack((xyxy, conf, class_id)).astype(float) assert predictions.shape[1] in (5, 6) and predictions.ndim == 2
Type guard
def is_nms_predictions(arr) -> bool:
a = np.asarray(arr)
return a.ndim == 2 and a.shape[1] in (5, 6) Prevention
- Build predictions with np.column_stack/hstack in one helper shared by all call sites.
- Never pass detections.xyxy alone — confidence (and usually class_id) is required.
When it happens
Trigger: Calling `sv.oriented_box_nms(predictions, oriented_boxes, ...)` with `predictions = detections.xyxy` (N, 4), forgetting to hstack confidence, or including extra columns like objectness/track-id making (N, 7).
Common situations: Hand-assembling the predictions array from model output instead of using a connector; upgrading code that previously passed (N, 5) when class ids were implied.
Related errors
- `{name}` has shape {arr.shape}; expected (N, 4, 2) — each bo
- `{name}` has shape {arr.shape}; expected (N, 8) for flat YOL
- `{name}` must be 2-D (N, 8) or 3-D (N, 4, 2), got shape {arr
- Empty group detected when non-max-merging detections: {merge
- Invalid value: {value}. Must be one of {cls.list()}
AI-assisted analysis of roboflow/supervision@7f254d9784 (2026-08-15).
Data as JSON: /api/errors/0fc44c4edf2e03fa.
Report an issue: GitHub.