Import image into Tensorflow model I trained a simple Handwriting model with Tensorflow and MNIST:
(x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data()
x_train = x_train.astype('float32')/255
x_test =  x_test.astype('float32')/255
model = keras.Sequential([
    keras.layers.Flatten(input_shape=(28,28)),
    keras.layers.Dense(100,activation = 'relu'),
    keras.layers.Dense(100,activation = 'sigmoid'),
    keras.layers.Dense(10,activation = 'sigmoid'),
])

As you can see, I flatted my first layer into 784 px One-dimensional array.
Now on paper I wrote a number :

After changing it's scale into 28*28 with image editor(GIMP), I loaded my image into my code:
img_width, img_height = 28, 28
img = image.load_img('rgb_seven.jpeg', target_size=(img_width, img_height))
x = image.img_to_array(img)

This is x result:
array([[[167., 170., 179.],
        [168., 171., 180.],
        [168., 171., 180.],
        ...,
        [174., 175., 180.],
        [174., 175., 180.],
        [167., 170., 175.]],

       [[173., 176., 185.],
        [172., 175., 184.],
        [166., 169., 178.],

and :
images = np.vstack(x)
images

And it's images result is :
array([[167., 170., 179.],
       [168., 171., 180.],
       [168., 171., 180.],
       ...,
       [166., 173., 179.],
       [166., 173., 179.],
       [166., 173., 179.]], dtype=float32)

Before to predict I have to do flat my images so I do this:
x_images_flattened = images.reshape(len(images),28*28)

But I got error:
ValueError                                Traceback (most recent call last)
&lt;ipython-input-30-db6c299f19c6&gt; in &lt;module&gt;
      3 images = np.vstack(x)
      4 # images
----&gt; 5 x_images_flattened = images.reshape(len(images),28*28)

ValueError: cannot reshape array of size 2352 into shape (784,784)

Why I got cannot reshape array of size 2352 into shape (784,784) my image has 28*28 size.
And how can I predict that?
By default, the image is loaded as a color Image i.e. 784*3 = 2352

Load image as grayscale i.e. use parameter color_mode=&quot;grayscale&quot;
No need to of np.vstack(), simply reshape to (-1,784)