Why does neural network input shape not match image shape?

  Kiến thức lập trình

I have developed a neural network using TensorFlow, and am trying to use it to predict new images. I have loaded a JPEG image as a test example and reformatted it using OpenCV:

formatted_image = cv.resize(image, dsize = (128,128))

Using image.shape returns (128, 128, 3) which is my target.

However, putting this image through model.predict() gives me the following error:

ValueError: Input 0 of layer "model_1" is incompatible with the layer: expected shape=(None, 128, 128, 3), found shape=(32, 128, 3)

I’m not sure where this value is coming from; I’ve tried a couple of ways of converting it to a tensor, such as tf_formatted_image = tf.convert_to_tensor(formatted_image, dtype=tf.int8), but this has been unsuccessful.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT