{"record":{"id":"dc4510c87a8de8bd","repo":"tensorflow/models","slug":"image-should-be-3d-tensor","errorCode":null,"errorMessage":"Image should be 3D tensor","messagePattern":"Image should be 3D tensor","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/centernet/ops/preprocess_ops.py","lineNumber":271,"sourceCode":"      padding. By default pads zeros.\n\n  Returns:\n    Note that the position of the resized_image_shape changes based on whether\n    masks are present.\n    resized_image: A 3D tensor of shape [new_height, new_width, channels],\n      where the image has been resized (with bilinear interpolation) so that\n      min(new_height, new_width) == min_dimension or\n      max(new_height, new_width) == max_dimension.\n    resized_masks: If masks is not None, also outputs masks. A 3D tensor of\n      shape [num_instances, new_height, new_width].\n    resized_image_shape: A 1D tensor of shape [3] containing shape of the\n      resized image.\n\n  Raises:\n    ValueError: if the image is not a 3D tensor.\n  \"\"\"\n  if len(image.get_shape()) != 3:\n    raise ValueError('Image should be 3D tensor')\n\n  def _resize_landscape_image(image):\n    # resize a landscape image\n    return tf.image.resize(\n        image, tf.stack([min_dimension, max_dimension]), method=method,\n        preserve_aspect_ratio=True)\n\n  def _resize_portrait_image(image):\n    # resize a portrait image\n    return tf.image.resize(\n        image, tf.stack([max_dimension, min_dimension]), method=method,\n        preserve_aspect_ratio=True)\n\n  with tf.name_scope('ResizeToRange'):\n    if image.get_shape().is_fully_defined():\n      if image.get_shape()[0] < image.get_shape()[1]:\n        new_image = _resize_landscape_image(image)\n      else:","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/centernet/ops/preprocess_ops.py#L253-L289","documentation":"Error \"Image should be 3D tensor\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/centernet/ops/preprocess_ops.py:271 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"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"}