tensorflow/models · error · ValueError
Image should be 3D tensor
Error message
Image should be 3D tensor
What it means
Error "Image should be 3D tensor" thrown in tensorflow/models.
Source
Thrown at official/projects/centernet/ops/preprocess_ops.py:271
padding. By default pads zeros.
Returns:
Note that the position of the resized_image_shape changes based on whether
masks are present.
resized_image: A 3D tensor of shape [new_height, new_width, channels],
where the image has been resized (with bilinear interpolation) so that
min(new_height, new_width) == min_dimension or
max(new_height, new_width) == max_dimension.
resized_masks: If masks is not None, also outputs masks. A 3D tensor of
shape [num_instances, new_height, new_width].
resized_image_shape: A 1D tensor of shape [3] containing shape of the
resized image.
Raises:
ValueError: if the image is not a 3D tensor.
"""
if len(image.get_shape()) != 3:
raise ValueError('Image should be 3D tensor')
def _resize_landscape_image(image):
# resize a landscape image
return tf.image.resize(
image, tf.stack([min_dimension, max_dimension]), method=method,
preserve_aspect_ratio=True)
def _resize_portrait_image(image):
# resize a portrait image
return tf.image.resize(
image, tf.stack([max_dimension, min_dimension]), method=method,
preserve_aspect_ratio=True)
with tf.name_scope('ResizeToRange'):
if image.get_shape().is_fully_defined():
if image.get_shape()[0] < image.get_shape()[1]:
new_image = _resize_landscape_image(image)
else:View on GitHub (pinned to e006f5f0d5)
When it happens
Trigger: Thrown at official/projects/centernet/ops/preprocess_ops.py:271 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24).
Data as JSON: /api/errors/dc4510c87a8de8bd.
Report an issue: GitHub.