Not able to predict model

im new in Deep Learning ( actually i´m taking some courses ). I tried to do binary classification example with a CNN and i´m not able to predict. I want to check ear corn color images ( 20 x 28 x 3 )

My code:

import tensorflow as tf
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import datetime
from tensorflow.keras.layers import Input, Conv2D, Dense, Flatten, Dropout, GlobalMaxPooling2D,BatchNormalization
from tensorflow.keras.models import Model
from tensorflow.keras.preprocessing.image import ImageDataGenerator
from PIL import Image
import cv2
import glob
from pathlib import Path
import os

image_path = 'sample_data/ears'
images = [cv2.imread(file) for file in glob.glob("sample_data/ears/*.png")]

def append_images(images):
  appendedImages = []
  for image in images:
    img=np.array(image)
    resized_image = cv2.resize(img, (28, 20))
    print(resized_image.shape)
    appendedImages.append(resized_image)
  return appendedImages

x_train = append_images(images)

for i, img in enumerate(x_train):
    img_pil = Image.fromarray(img)
    img_pil.save(os.path.join("sample_data/resized_ears", f'corn_kernel_{i}.png'))

print(f'Se guardaron {len(x_train)} imágenes en {"sample_data/resized_ears"}')

data_dir = 'sample_data/ears/resized_ears'

datagen = ImageDataGenerator(rescale=1./255, validation_split=0.2)

train_generator = datagen.flow_from_directory(
    data_dir,
    batch_size=32,
    target_size=(28, 20),
    class_mode='binary',
    subset='training'
    )

validation_generator = datagen.flow_from_directory(
    data_dir,
    target_size=(28, 20),
    batch_size=32,
    class_mode='binary',
    subset='validation'
  )

print("Classes found:", train_generator.class_indices)
print("Classes found:", validation_generator.class_indices)

from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Conv2D, MaxPooling2D, Flatten, Dense

model = Sequential([
    Conv2D(32, (3, 3), activation='relu', input_shape=(20, 28, 3)),
    MaxPooling2D((2, 2)),
    Conv2D(64, (3, 3), activation='relu'),
    MaxPooling2D((2, 2)),
    Flatten(),
    Dense(64, activation='relu'),
    Dense(1, activation='sigmoid')
])


model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])

model.fit(train_generator, epochs=10)


images = [cv2.imread(file) for file in glob.glob("sample_data/ears/resized_ears/class1/*.png")]

images[0].shape

model.predict(images[0])

The model does the fit

Epoch 1/10
1/1 [==============================] - 1s 1s/step - loss: 0.7027 - accuracy: 0.0000e+00
Epoch 2/10
1/1 [==============================] - 0s 30ms/step - loss: 0.3947 - accuracy: 1.0000
Epoch 3/10
1/1 [==============================] - 0s 30ms/step - loss: 0.2136 - accuracy: 1.0000
Epoch 4/10
1/1 [==============================] - 0s 31ms/step - loss: 0.1110 - accuracy: 1.0000
Epoch 5/10
1/1 [==============================] - 0s 33ms/step - loss: 0.0505 - accuracy: 1.0000
Epoch 6/10
1/1 [==============================] - 0s 32ms/step - loss: 0.0206 - accuracy: 1.0000
Epoch 7/10
1/1 [==============================] - 0s 30ms/step - loss: 0.0078 - accuracy: 1.0000
Epoch 8/10
1/1 [==============================] - 0s 30ms/step - loss: 0.0029 - accuracy: 1.0000
Epoch 9/10
1/1 [==============================] - 0s 32ms/step - loss: 0.0010 - accuracy: 1.0000
Epoch 10/10
1/1 [==============================] - 0s 30ms/step - loss: 3.8640e-04 - accuracy: 1.0000
<keras.src.callbacks.History at 0x7e1b08663b20>

But when I try to do the prediction i got this error message:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-157-0f33f27dad40> in <cell line: 5>()
      3 images[0].shape
      4 
----> 5 model.predict(images[0])
      6 

1 frames
/usr/local/lib/python3.10/dist-packages/keras/src/engine/training.py in tf__predict_function(iterator)
     13                 try:
     14                     do_return = True
---> 15                     retval_ = ag__.converted_call(ag__.ld(step_function), (ag__.ld(self), ag__.ld(iterator)), None, fscope)
     16                 except:
     17                     do_return = False

ValueError: in user code:

    File "/usr/local/lib/python3.10/dist-packages/keras/src/engine/training.py", line 2440, in predict_function  *
        return step_function(self, iterator)
    File "/usr/local/lib/python3.10/dist-packages/keras/src/engine/training.py", line 2425, in step_function  **
        outputs = model.distribute_strategy.run(run_step, args=(data,))
    File "/usr/local/lib/python3.10/dist-packages/keras/src/engine/training.py", line 2413, in run_step  **
        outputs = model.predict_step(data)
    File "/usr/local/lib/python3.10/dist-packages/keras/src/engine/training.py", line 2381, in predict_step
        return self(x, training=False)
    File "/usr/local/lib/python3.10/dist-packages/keras/src/utils/traceback_utils.py", line 70, in error_handler
        raise e.with_traceback(filtered_tb) from None
    File "/usr/local/lib/python3.10/dist-packages/keras/src/engine/input_spec.py", line 298, in assert_input_compatibility
        raise ValueError(

    ValueError: Input 0 of layer "sequential_23" is incompatible with the layer: expected shape=(None, 20, 28, 3), found shape=(None, 28, 3)

Why i´m having this?.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật