{"record":{"id":"b375d9f105bdf151","repo":"keras-team/keras","slug":"invalid-images-rank-expected-rank-3-single-image-b375d9","errorCode":null,"errorMessage":"Invalid images rank: expected rank 3 (single image) or rank 4 (batch of images). Received input with shape: images.shape={images.shape}","messagePattern":"Invalid images rank: expected rank 3 \\(single image\\) or rank 4 \\(batch of images\\)\\. Received input with shape: images\\.shape=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/openvino/image.py","lineNumber":57,"sourceCode":"    \"nearest\": \"nearest\",\n    \"bicubic\": \"cubic\",\n}\n# Lanczos methods are handled via _ov_scale_and_translate\n# instead of ov_opset.interpolate, which does not support them natively.\nLANCZOS_INTERPOLATIONS = {\n    \"lanczos3\": \"lanczos3\",\n    \"lanczos5\": \"lanczos5\",\n}\nALL_RESIZE_INTERPOLATIONS = tuple(RESIZE_INTERPOLATIONS) + tuple(\n    LANCZOS_INTERPOLATIONS\n)\n\n\ndef rgb_to_grayscale(images, data_format=None):\n    images = get_ov_output(images)\n    data_format = backend.standardize_data_format(data_format)\n    if images.get_partial_shape().rank not in (3, 4):\n        raise ValueError(\n            \"Invalid images rank: expected rank 3 (single image) \"\n            \"or rank 4 (batch of images). Received input with shape: \"\n            f\"images.shape={images.shape}\"\n        )\n    channel_axis = -3 if data_format == \"channels_first\" else -1\n    if images.shape[channel_axis] not in (1, 3):\n        raise ValueError(\n            \"Invalid channel size: expected 3 (RGB) or 1 (Grayscale). \"\n            f\"Received input with shape: images.shape={images.shape}\"\n        )\n\n    if images.shape[channel_axis] == 3:\n        original_type = images.get_element_type()\n        rgb_weights = ov_opset.constant(\n            [0.2989, 0.5870, 0.1140], dtype=original_type\n        ).output(0)\n        if data_format == \"channels_first\":\n            rgb_weights = ov_opset.unsqueeze(rgb_weights, axes=[-2, -1]).output(","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/openvino/image.py#L39-L75","documentation":"Error \"Invalid images rank: expected rank 3 (single image) or rank 4 (batch of images). Received input with shape: images.shape={images.shape}\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/backend/openvino/image.py:57 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":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}