Нейронная сеть по распознаванию изображений.
При использовании готовой, обученной h5 модели возникает такая ошибка:
/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/input_spec.py:239 assert_input_compatibility
str(tuple(shape)))
ValueError: Input 0 of layer sequential_6 is incompatible with the layer: : expected min_ndim=4, found ndim=2. Full shape received: (None, 40000)
Вот информация модели моей сети:
Model: "sequential_6"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv2d_24 (Conv2D) (None, 200, 200, 16) 1216
_________________________________________________________________
max_pooling2d_24 (MaxPooling (None, 100, 100, 16) 0
_________________________________________________________________
conv2d_25 (Conv2D) (None, 100, 100, 32) 12832
_________________________________________________________________
max_pooling2d_25 (MaxPooling (None, 50, 50, 32) 0
_________________________________________________________________
conv2d_26 (Conv2D) (None, 50, 50, 64) 51264
_________________________________________________________________
max_pooling2d_26 (MaxPooling (None, 25, 25, 64) 0
_________________________________________________________________
conv2d_27 (Conv2D) (None, 25, 25, 128) 204928
_________________________________________________________________
max_pooling2d_27 (MaxPooling (None, 12, 12, 128) 0
_________________________________________________________________
flatten_6 (Flatten) (None, 18432) 0
_________________________________________________________________
dense_18 (Dense) (None, 1024) 18875392
_________________________________________________________________
dropout_12 (Dropout) (None, 1024) 0
_________________________________________________________________
dense_19 (Dense) (None, 256) 262400
_________________________________________________________________
dropout_13 (Dropout) (None, 256) 0
_________________________________________________________________
dense_20 (Dense) (None, 3) 771
=================================================================
Total params: 19,408,803
Trainable params: 19,408,803
Non-trainable params: 0
Данные которые должны быть поданы на вход: Изображение 200x200 px
Код подачи изображения:
img_path = '9.jpeg'
Image(img_path, width=200, height=200)
img = image.load_img(img_path, target_size=(200, 200), color_mode = "grayscale")
x = image.img_to_array(img)
x = x.reshape(1, 40000)
x = 255 - x
x /= 255
prediction = model.predict(x)
Заранее спасибо!