{"record":{"id":"569041b814829481","repo":"tensorflow/models","slug":"expected-the-last-dimension-of-bbox-has-size","errorCode":null,"errorMessage":"Expected the last dimension of `bbox` has size == 4, but the shape of `bbox` was: %s","messagePattern":"Expected the last dimension of `bbox` has size == 4, but the shape of `bbox` was: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/ops/box_ops.py","lineNumber":899,"sourceCode":"\n  Returns:\n    A tensor in shape (..., height, width) which stores the bitmasks created\n    from the bounding boxes. For example:\n\n    >>> bbox2mask(tf.constant([[1,2,4,4]]),\n                  image_height=5,\n                  image_width=5,\n                  dtype=tf.int32)\n    <tf.Tensor: shape=(1, 5, 5), dtype=int32, numpy=\n    array([[[0, 0, 0, 0, 0],\n            [0, 0, 1, 1, 0],\n            [0, 0, 1, 1, 0],\n            [0, 0, 1, 1, 0],\n            [0, 0, 0, 0, 0]]], dtype=int32)>\n  \"\"\"\n  bbox_shape = bbox.get_shape().as_list()\n  if bbox_shape[-1] != 4:\n    raise ValueError(\n        'Expected the last dimension of `bbox` has size == 4, but the shape '\n        'of `bbox` was: %s' % bbox_shape)\n\n  # (..., 1)\n  ymin = bbox[..., 0:1]\n  xmin = bbox[..., 1:2]\n  ymax = bbox[..., 2:3]\n  xmax = bbox[..., 3:4]\n  # (..., 1, width)\n  ymin = tf.expand_dims(tf.repeat(ymin, repeats=image_width, axis=-1), axis=-2)\n  # (..., height, 1)\n  xmin = tf.expand_dims(tf.repeat(xmin, repeats=image_height, axis=-1), axis=-1)\n  # (..., 1, width)\n  ymax = tf.expand_dims(tf.repeat(ymax, repeats=image_width, axis=-1), axis=-2)\n  # (..., height, 1)\n  xmax = tf.expand_dims(tf.repeat(xmax, repeats=image_height, axis=-1), axis=-1)\n\n  # (height, 1)","sourceCodeStart":881,"sourceCodeEnd":917,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/ops/box_ops.py#L881-L917","documentation":"Error \"Expected the last dimension of `bbox` has size == 4, but the shape of `bbox` was: %s\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/ops/box_ops.py:899 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass bbox with last dimension of size 4 ([y1, x1, y2, x2]).","Fix the bbox tensor shape before calling this op."],"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"}