{"record":{"id":"50ca0ba510fd211e","repo":"tensorflow/models","slug":"invalid-dimensions-for-box-data-50ca0b","errorCode":null,"errorMessage":"Invalid dimensions for box data.","messagePattern":"Invalid dimensions for box data\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/utils/object_detection/box_list.py","lineNumber":53,"sourceCode":"\nimport tensorflow as tf, tf_keras\n\n\nclass BoxList(object):\n  \"\"\"Box collection.\"\"\"\n\n  def __init__(self, boxes):\n    \"\"\"Constructs box collection.\n\n    Args:\n      boxes: a tensor of shape [N, 4] representing box corners\n\n    Raises:\n      ValueError: if invalid dimensions for bbox data or if bbox data is not in\n          float32 format.\n    \"\"\"\n    if len(boxes.get_shape()) != 2 or boxes.get_shape()[-1] != 4:\n      raise ValueError('Invalid dimensions for box data.')\n    if boxes.dtype != tf.float32:\n      raise ValueError('Invalid tensor type: should be tf.float32')\n    self.data = {'boxes': boxes}\n\n  def num_boxes(self):\n    \"\"\"Returns number of boxes held in collection.\n\n    Returns:\n      a tensor representing the number of boxes held in the collection.\n    \"\"\"\n    return tf.shape(input=self.data['boxes'])[0]\n\n  def num_boxes_static(self):\n    \"\"\"Returns number of boxes held in collection.\n\n    This number is inferred at graph construction time rather than run-time.\n\n    Returns:","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/utils/object_detection/box_list.py#L35-L71","documentation":"Shape guard in BoxList.__init__: a BoxList is fundamentally an [N, 4] collection of (ymin, xmin, ymax, xmax) corners; a `boxes` tensor that is not rank 2 with last dim 4 (scalar, 1D, or wrong width) cannot represent that layout and is rejected at construction.","triggerScenarios":"Thrown at official/vision/utils/object_detection/box_list.py:53 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass box data with shape [N, 4].","Reshape the box tensor to 2-D with 4 coordinates per box."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}