{"record":{"id":"6da5d9006e65a409","repo":"tensorflow/models","slug":"last-dimension-of-boxes-must-be-4-but-is-d","errorCode":null,"errorMessage":"Last dimension of boxes must be 4 but is {:d}","messagePattern":"Last dimension of boxes must be 4 but is (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/ops/box_ops.py","lineNumber":67,"sourceCode":"  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.\n\n  Returns:\n    boxes: a `Tensor` with the same shape as the inputted boxes, in the format\n      of cy, cx, height, width.\n\n  Raises:\n    ValueError: if the last dimension of boxes is not 4.\n  \"\"\"\n  if boxes.shape[-1] != 4:\n    raise ValueError('Last dimension of boxes must be 4 but is {:d}'.format(\n        boxes.shape[-1]))\n\n  boxes_ycenter = (boxes[..., 0] + boxes[..., 2]) / 2\n  boxes_xcenter = (boxes[..., 1] + boxes[..., 3]) / 2\n  boxes_height = boxes[..., 2] - boxes[..., 0]\n  boxes_width = boxes[..., 3] - boxes[..., 1]\n\n  new_boxes = tf.stack(\n      [boxes_ycenter, boxes_xcenter, boxes_height, boxes_width], axis=-1)\n  return new_boxes\n\n\ndef cycxhw_to_yxyx(boxes):\n  \"\"\"Converts box center coordinates plus height and width terms to corner.\n\n  Args:\n    boxes: a numpy array whose last dimension is 4 representing the coordinates\n      of boxes in cy, cx, height, width order.","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/ops/box_ops.py#L49-L85","documentation":"Error \"Last dimension of boxes must be 4 but is {:d}\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/ops/box_ops.py:67 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass boxes whose last dimension is 4.","Decode or trim the box tensor to 4 coordinates per box."],"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"}