import tensorflow as tf model = tf.keras.models.Sequential([ tf.keras.layers.Flatten(input_shape = (28,28)), tf.keras.layers.Dense(128, activation = 'relu'), tf.keras.layers.Dropout(0.2), tf.keras.layers.Dense(10) ]) This is the code for the model, which I have trained using the mnist dataset. What I want to do is to then pass a 28x28 png image to the predict() method, which is not working. The code for the prediction is:
img = imageio.imread('image_0.png') prediction = model.predict(img, batch_size = 1) which produces the error
ValueError: Error when checking input: expected flatten_input to have shape (28, 28) but got array with shape (28, 3) I have been stuck on this problem for a few days, but I can't find the correct way to pass an image into the predict method. Any help?
image_0.pngis an RGB, and not a greyscale one (but still, it should be(28, 28, 3), not(28,3)).