{"record":{"id":"482efa4a202d0d6b","repo":"tensorflow/models","slug":"boxes-shape-1-is-d-but-must-be-4-482efa","errorCode":null,"errorMessage":"boxes.shape[-1] is {:d}, but must be 4.","messagePattern":"boxes\\.shape\\[-1\\] is (.+?), but must be 4\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/ops/box_ops.py","lineNumber":39,"sourceCode":"EPSILON = 1e-8\nBBOX_XFORM_CLIP = np.log(1000. / 16.)\n\n\ndef yxyx_to_xywh(boxes):\n  \"\"\"Converts boxes from ymin, xmin, ymax, xmax to xmin, ymin, width, height.\n\n  Args:\n    boxes: a numpy array whose last dimension is 4 representing the coordinates\n      of boxes in ymin, xmin, ymax, xmax order.\n\n  Returns:\n    boxes: a numpy array whose shape is the same as `boxes` in new format.\n\n  Raises:\n    ValueError: If the last dimension of boxes is not 4.\n  \"\"\"\n  if boxes.shape[-1] != 4:\n    raise ValueError(\n        'boxes.shape[-1] is {:d}, but must be 4.'.format(boxes.shape[-1]))\n\n  boxes_ymin = boxes[..., 0]\n  boxes_xmin = boxes[..., 1]\n  boxes_width = boxes[..., 3] - boxes[..., 1]\n  boxes_height = boxes[..., 2] - boxes[..., 0]\n  new_boxes = np.stack(\n      [boxes_xmin, boxes_ymin, boxes_width, boxes_height], axis=-1)\n\n  return new_boxes\n\n\ndef yxyx_to_cycxhw(boxes):\n  \"\"\"Converts box corner coordinates to center plus height and width terms.\n\n  Args:\n    boxes: a `Tensor` with last dimension of 4, representing the coordinates of\n      boxes in ymin, xmin, ymax, xmax order.","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/ops/box_ops.py#L21-L57","documentation":"Error \"boxes.shape[-1] is {:d}, but must be 4.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/ops/box_ops.py:39 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass boxes whose last dimension is 4 ([y1, x1, y2, x2]).","Slice or re-encode the boxes so the last dimension equals 4."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}