{"record":{"id":"fcb3b301ecb6f3a1","repo":"tensorflow/models","slug":"image-should-be-3d-tensor-fcb3b3","errorCode":null,"errorMessage":"Image should be 3D tensor","messagePattern":"Image should be 3D tensor","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/vision/utils/object_detection/preprocessor.py","lineNumber":398,"sourceCode":"      If masks are included they are padded similarly.\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  with tf.name_scope('ResizeToRange'):\n    if image.get_shape().is_fully_defined():\n      new_size = _compute_new_static_size(image, min_dimension, max_dimension)\n    else:\n      new_size = _compute_new_dynamic_size(image, min_dimension, max_dimension)\n    new_image = tf.image.resize(image, new_size[:-1], method=method)\n\n    if pad_to_max_dimension:\n      new_image = tf.image.pad_to_bounding_box(new_image, 0, 0, max_dimension,\n                                               max_dimension)\n\n    result = [new_image]\n    if masks is not None:\n      new_masks = tf.expand_dims(masks, 3)\n      new_masks = tf.image.resize(\n          new_masks,\n          new_size[:-1],","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/vision/utils/object_detection/preprocessor.py#L380-L416","documentation":"Error \"Image should be 3D tensor\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/vision/utils/object_detection/preprocessor.py:398 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a 3-D image tensor [height, width, channels].","Remove the batch dimension or add the channel dimension as needed."],"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"}