{"record":{"id":"5430c2b97d9a3a1c","repo":"tensorflow/models","slug":"bad-image-rank","errorCode":null,"errorMessage":"Bad image rank: {}","messagePattern":"Bad image rank: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/ops/augment.py","lineNumber":599,"sourceCode":"  \"\"\"Apply cutout (https://arxiv.org/abs/1708.04552) to image.\n\n  This operation applies a (2*pad_size x 2*pad_size) mask of zeros to\n  a random location within `image`. The pixel values filled in will be of the\n  value `replace`. The location where the mask will be applied is randomly\n  chosen uniformly over the whole image.\n\n  Args:\n    image: An image Tensor of type uint8.\n    pad_size: Specifies how big the zero mask that will be generated is that is\n      applied to the image. The mask will be of size (2*pad_size x 2*pad_size).\n    replace: What pixel value to fill in the image in the area that has the\n      cutout mask applied to it.\n\n  Returns:\n    An image Tensor that is of type uint8.\n  \"\"\"\n  if image.shape.rank not in [3, 4]:\n    raise ValueError('Bad image rank: {}'.format(image.shape.rank))\n\n  if image.shape.rank == 4:\n    return cutout_video(image, replace=replace)\n\n  image_height = tf.shape(image)[0]\n  image_width = tf.shape(image)[1]\n\n  # Sample the center location in the image where the zero mask will be applied.\n  cutout_center_height = tf.random.uniform(\n      shape=[], minval=0, maxval=image_height, dtype=tf.int32)\n\n  cutout_center_width = tf.random.uniform(\n      shape=[], minval=0, maxval=image_width, dtype=tf.int32)\n\n  image = _fill_rectangle(image, cutout_center_width, cutout_center_height,\n                          pad_size, pad_size, replace)\n\n  return image","sourceCodeStart":581,"sourceCodeEnd":617,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/ops/augment.py#L581-L617","documentation":"Error \"Bad image rank: {}\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/ops/augment.py:599 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass an image tensor of the supported rank (3 for HWC or 4 for NHWC as the op requires).","Add or remove the batch/channel dimension to reach the expected image rank."],"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"}