how to predict an image using saved model
Having problems with dimensions is very common. As others have mentioned, the method predict expects to get a batch of images. You should run model.summary() to see what the expected dimensions of the input are. The batch size itself might have been designed to be flexible during training, by specifying None in the first dimension on the model input_shape parameter.

Without knowing more of the dimensions, I cannot say exactly where your problems lies. You could include that information by editing your question.



It will likely help to have a look at the documentation for predict function of the model objects.

There is an argument: batch_size, which defaults to 32 if not fixed by the model itself, which you can see from the model.summary(). If you set this equal to 1, perhaps you will get a prediction.

Below is a modified version of your code that I would expect to return a prediction.

from keras.models import load_model
from keras.preprocessing import image
import numpy as np

# dimensions of our images    -----   are these then grayscale (black and white)?
img_width, img_height = 313, 220

# load the model we saved
model = load_model('model.h5')

# Get test image ready
test_image = image.load_img('/Images/1.jpg', target_size=(img_width, img_height))
test_image = image.img_to_array(test_image)
test_image = np.expand_dims(test_image, axis=0)

test_image = test_image.reshape(img_width, img_height*3)    # Ambiguity!
# Should this instead be: test_image.reshape(img_width, img_height, 3) ??

result = model.predict(test_image, batch_size=1)
print result


Note: there is ambiguity in the dimensions where I highlight it. A colour image will have three dimensions: (height, width, 3). Black and white will have only two dimensions: (height, width).