tensorflow/models · error · ValueError
boxes.shape[-1] is {:d}, but must be 4.
Error message
boxes.shape[-1] is {:d}, but must be 4. What it means
Error "boxes.shape[-1] is {:d}, but must be 4." thrown in tensorflow/models.
Source
Thrown at official/vision/ops/box_ops.py:39
EPSILON = 1e-8
BBOX_XFORM_CLIP = np.log(1000. / 16.)
def yxyx_to_xywh(boxes):
"""Converts boxes from ymin, xmin, ymax, xmax to xmin, ymin, width, height.
Args:
boxes: a numpy array whose last dimension is 4 representing the coordinates
of boxes in ymin, xmin, ymax, xmax order.
Returns:
boxes: a numpy array whose shape is the same as `boxes` in new format.
Raises:
ValueError: If the last dimension of boxes is not 4.
"""
if boxes.shape[-1] != 4:
raise ValueError(
'boxes.shape[-1] is {:d}, but must be 4.'.format(boxes.shape[-1]))
boxes_ymin = boxes[..., 0]
boxes_xmin = boxes[..., 1]
boxes_width = boxes[..., 3] - boxes[..., 1]
boxes_height = boxes[..., 2] - boxes[..., 0]
new_boxes = np.stack(
[boxes_xmin, boxes_ymin, boxes_width, boxes_height], axis=-1)
return new_boxes
def yxyx_to_cycxhw(boxes):
"""Converts box corner coordinates to center plus height and width terms.
Args:
boxes: a `Tensor` with last dimension of 4, representing the coordinates of
boxes in ymin, xmin, ymax, xmax order.View on GitHub (pinned to e006f5f0d5)
Solutions
- Pass boxes whose last dimension is 4 ([y1, x1, y2, x2]).
- Slice or re-encode the boxes so the last dimension equals 4.
When it happens
Trigger: Thrown at official/vision/ops/box_ops.py:39 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24).
Data as JSON: /api/errors/482efa4a202d0d6b.
Report an issue: GitHub.