tensorflow/models · error · ValueError
Invalid dimensions for box data.
Error message
Invalid dimensions for box data.
What it means
Error "Invalid dimensions for box data." thrown in tensorflow/models.
Source
Thrown at official/vision/utils/object_detection/box_list.py:53
import tensorflow as tf, tf_keras
class BoxList(object):
"""Box collection."""
def __init__(self, boxes):
"""Constructs box collection.
Args:
boxes: a tensor of shape [N, 4] representing box corners
Raises:
ValueError: if invalid dimensions for bbox data or if bbox data is not in
float32 format.
"""
if len(boxes.get_shape()) != 2 or boxes.get_shape()[-1] != 4:
raise ValueError('Invalid dimensions for box data.')
if boxes.dtype != tf.float32:
raise ValueError('Invalid tensor type: should be tf.float32')
self.data = {'boxes': boxes}
def num_boxes(self):
"""Returns number of boxes held in collection.
Returns:
a tensor representing the number of boxes held in the collection.
"""
return tf.shape(input=self.data['boxes'])[0]
def num_boxes_static(self):
"""Returns number of boxes held in collection.
This number is inferred at graph construction time rather than run-time.
Returns:View on GitHub (pinned to e006f5f0d5)
Solutions
- Pass box data with shape [N, 4].
- Reshape the box tensor to 2-D with 4 coordinates per box.
When it happens
Trigger: Thrown at official/vision/utils/object_detection/box_list.py:53 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/50ca0ba510fd211e.
Report an issue: GitHub.