Reputation: 53
I tried using my model to predict/classify, but it said:
ValueError: Input 0 of layer “sequential_2” is incompatible with the layer: expected shape=(None, 45, 45, 3), found shape=(None, 45, 3)
even though when I took the shape of the input, it was (45,45,3) not (None,45,3)
This is my code:
data=list(uploaded.keys())
image=cv2.imread(data[0])
img_reverted=cv2.bitwise_not(image)
print(np.shape(preprocess_input(img_reverted)))
preds = model.predict(preprocess_input(img_reverted))
print(‘Predicted:’, decode_predictions(preds, top=3)[0])
Upvotes: 0
Views: 181
Reputation: 53
I solved the issue. It was expecting a tensor of 4 dimensions, but I only gave one sample, so it was 3 dimensions.
Upvotes: 1