Python/ Expected axis -1 of input shape to have value 3 but received input with shape (None, 32, 32, 1)
Go to solution
Solved by igormp,
On 1/7/2021 at 7:36 AM, Zuccers said:
Hello, I made an image recognition model in python using keras, this is the input shape:
input_shape=(3, 32, 32)The model itself works fine, but when I try to pass any other image that is not from the dataset I get this error:
ValueError: Input 0 of layer sequential is incompatible with the layer: expected axis -1 of input shape to have value 3 but received input with shape (None, 32, 32, 1)I do reshape the image, but can not figure out why I am getting that error and failing every pass
image = load_img("image.jpeg", grayscale="false", color_mode="rgb", target_size=(32, 32)) image = img_to_array(image) image = image.reshape(3, 32, 32, 1) image = image.astype('float32') image = image / 255.0How do I go about solving this issue and reshaping the image correctly?
Thanks in advance!
image = image.reshape(3, 32, 32, 1) Should be:
image = image.reshape(3, 32, 32)
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now