{"record":{"id":"ded888f4d2edcf68","repo":"tensorflow/models","slug":"expected-the-last-dimension-of-bbox-has-size-ded888","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/spatial_transform_ops.py","lineNumber":620,"sourceCode":"      numbers of channel dimensions.\n    bbox: A tensor in shape (batch_size, 4), representing the absolute\n      coordinates (ymin, xmin, ymax, xmax) for each bounding box.\n    output_size: The size of the output images in (output_h, output_w).\n\n  Returns:\n    A tensor in shape (batch_size, output_h, output_w, ...). The result has the\n    same dtype as the input if it's float32, float16, bfloat16, otherwise the\n    result is float32.\n  \"\"\"\n  images_shape = images.get_shape().as_list()\n  images_rank = len(images_shape)\n  if images_rank < 3:\n    raise ValueError(\n        'Expected the input images (batch_size, height, width, ...) '\n        'has rank >= 3, was: %s' % images_shape)\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  rank_range = list(range(images_rank))\n  extra_dims = images_shape[3:]\n  extra_dims_perm = rank_range[3:]\n  extra_dims_product = 1\n  for d in extra_dims:\n    extra_dims_product *= d\n\n  input_h = tf.cast(tf.shape(images)[1], tf.float32)\n  input_w = tf.cast(tf.shape(images)[2], tf.float32)\n  output_h = output_size[0]\n  output_w = output_size[1]\n\n  bbox = tf.cast(bbox, tf.float32)\n  # (batch_size, 1)\n  bbox_ymin = bbox[:, 0:1]","sourceCodeStart":602,"sourceCodeEnd":638,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/ops/spatial_transform_ops.py#L602-L638","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/spatial_transform_ops.py:620 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"}