{"record":{"id":"0fc44c4edf2e03fa","repo":"roboflow/supervision","slug":"name-has-shape-arr-shape-expected-n-5-or","errorCode":null,"errorMessage":"`{name}` has shape {arr.shape}; expected (N, 5) or (N, 6).","messagePattern":"`(.+?)` has shape (.+?); expected \\(N, 5\\) or \\(N, 6\\)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/detection/utils/iou_and_nms.py","lineNumber":1643,"sourceCode":"        >>> predictions = np.array([\n        ...     [10, 10, 50, 30, 0.9, 0],\n        ...     [11, 11, 51, 31, 0.8, 0],\n        ... ], dtype=np.float32)\n        >>> keep = sv.oriented_box_non_max_suppression(\n        ...     predictions=predictions,\n        ...     oriented_boxes=oriented_boxes,\n        ...     iou_threshold=0.5,\n        ... )\n        >>> keep\n        array([ True, False])\n\n        ```\n    \"\"\"\n    _validate_iou_threshold(iou_threshold)\n    for name, arr in ((\"predictions\", predictions), (\"oriented_boxes\", oriented_boxes)):\n        if name == \"predictions\":\n            if arr.ndim != 2 or arr.shape[1] not in (5, 6):\n                raise ValueError(\n                    f\"`{name}` has shape {arr.shape}; expected (N, 5) or (N, 6).\"\n                )\n            continue\n        if arr.ndim == 3 and arr.shape[1:] != (4, 2):\n            raise ValueError(\n                f\"`{name}` has shape {arr.shape}; expected (N, 4, 2) \"\n                f\"— each box must have exactly 4 corners with (x, y) coordinates.\"\n            )\n        elif arr.ndim == 2 and arr.shape[1] != 8:\n            raise ValueError(\n                f\"`{name}` has shape {arr.shape}; expected (N, 8) for flat \"\n                f\"YOLO format or (N, 4, 2) for corner format.\"\n            )\n        elif arr.ndim not in (2, 3):\n            raise ValueError(\n                f\"`{name}` must be 2-D (N, 8) or 3-D (N, 4, 2), got shape {arr.shape}.\"\n            )\n    if len(predictions) != len(oriented_boxes):","sourceCodeStart":1625,"sourceCodeEnd":1661,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/detection/utils/iou_and_nms.py#L1625-L1661","documentation":"`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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"# before\nkeep = sv.oriented_box_nms(dets.xyxy, obb, 0.5)  # (N, 4)\n\n# after\npreds = np.hstack((dets.xyxy, dets.confidence.reshape(-1, 1), dets.class_id.reshape(-1, 1)))\nkeep = sv.oriented_box_nms(preds, obb, 0.5)","handlingStrategy":"validation","validationCode":"predictions = np.column_stack((xyxy, conf, class_id)).astype(float)\nassert predictions.shape[1] in (5, 6) and predictions.ndim == 2","typeGuard":"def is_nms_predictions(arr) -> bool:\n    a = np.asarray(arr)\n    return a.ndim == 2 and a.shape[1] in (5, 6)","tryCatchPattern":null,"preventionTips":["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."],"tags":["shape-validation","oriented-boxes","nms","numpy","detection"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}