keras-team/keras · error · ValueError
Invalid images rank: expected rank 3 (single image) or rank
Error message
Invalid images rank: expected rank 3 (single image) or rank 4 (batch of images). Received input with shape: images.shape={images.get_partial_shape()} What it means
Error "Invalid images rank: expected rank 3 (single image) or rank 4 (batch of images). Received input with shape: images.shape={images.get_partial_shape()}" thrown in keras-team/keras.
Source
Thrown at keras/src/backend/openvino/image.py:294
"Invalid value for argument `fill_mode`. Only `'constant'` "
f"is supported. Received: fill_mode={fill_mode}"
)
if pad_to_aspect_ratio and crop_to_aspect_ratio:
raise ValueError(
"Only one of `pad_to_aspect_ratio` & `crop_to_aspect_ratio` "
"can be `True`."
)
if not len(size) == 2:
raise ValueError(
"Argument `size` must be a tuple of two elements "
f"(height, width). Received: size={size}"
)
target_height, target_width = tuple(size)
images = get_ov_output(images)
rank = len(images.get_partial_shape())
if rank not in (3, 4):
raise ValueError(
"Invalid images rank: expected rank 3 (single image) "
"or rank 4 (batch of images). Received input with shape: "
f"images.shape={images.get_partial_shape()}"
)
if data_format == "channels_last":
height_axis, width_axis = (-3, -2)
else:
height_axis, width_axis = (-2, -1)
def _gather_dim(shape_tensor, axis):
axis_node = ov_opset.constant([axis], Type.i32).output(0)
axis0 = ov_opset.constant(0, Type.i32).output(0)
return ov_opset.gather(shape_tensor, axis_node, axis0).output(0)
def _floor_div_int(numerator, denominator):
numerator_f = ov_opset.convert(numerator, Type.f32).output(0)
denominator_f = ov_opset.convert(denominator, Type.f32).output(0)View on GitHub (pinned to 7a34a03db6)
When it happens
Trigger: Thrown at keras/src/backend/openvino/image.py:294 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of keras-team/keras@7a34a03db6 (2026-08-25).
Data as JSON: /api/errors/1cbe95cb54d7c131.
Report an issue: GitHub.