{"record":{"id":"14ec8104a115a95a","repo":"keras-team/keras","slug":"invalid-channel-size-expected-3-rgb-or-1-grays-14ec81","errorCode":null,"errorMessage":"Invalid channel size: expected 3 (RGB) or 1 (Grayscale). Received input with shape: images.shape={images.shape}","messagePattern":"Invalid channel size: expected 3 \\(RGB\\) or 1 \\(Grayscale\\)\\. Received input with shape: images\\.shape=(.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/backend/openvino/image.py","lineNumber":64,"sourceCode":"    \"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(\n                0\n            )\n        grayscales = ov_opset.multiply(images, rgb_weights).output(0)\n        grayscales = ov_opset.reduce_sum(\n            grayscales, reduction_axes=[channel_axis]\n        ).output(0)\n        grayscales = ov_opset.unsqueeze(grayscales, axes=[channel_axis]).output(","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/backend/openvino/image.py#L46-L82","documentation":"Error \"Invalid channel size: expected 3 (RGB) or 1 (Grayscale). Received input with shape: images.shape={images.shape}\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/backend/openvino/image.py:64 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"}