Help python and cv2 with using image data to train a model

i have been getting the error
PS D:\CV2> & C:/Users/RM/AppData/Local/Microsoft/WindowsApps/python3.12.exe d:/CV2/mmake.pyTraceback (most recent call last):File "d:\CV2\mmake.py", line 32, in <module>train_data = cv2.ml.TrainData_create(images_array, cv2.ml.ROW_SAMPLE, responses)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^cv2.error: OpenCV(4.9.0) D:\a\opencv-python\opencv-python\opencv\modules\ml\src\data.cpp:257: error: (-215:Assertion failed) samples.type() == CV_32F || samples.type() == CV_32S in function 'cv::ml::TrainDataImpl::setData'

from the code

#======================================#
#                                      #
#                                      #
#        if you get this software      #
#            make it better            #
#                                      #
#                                      #
#                                      #
#======================================#

# Import the necessary libraries
import cv2
import numpy as np
import os

# Define the path to the folder containing enrolled faces
folder_path = "enrolled"

# Initialize lists to store images
images = []

# Iterate through the files in the folder
for filename in os.listdir(folder_path):
    if filename.endswith(".jpg") or filename.endswith(".png"):
        image_path = os.path.join(folder_path, filename)
        image = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)  # Read image in grayscale
        if image is not None:
            # Preprocess the image (resize, normalize)
            preprocessed_image = cv2.resize(image, (224, 224))
            preprocessed_image = preprocessed_image / 255.0

            images.append(preprocessed_image)

# Create an OpenCV model (you can choose a different model type if needed)
model = cv2.ml.SVM_create()

# Convert images to the appropriate data type (32-bit floating-point)
images_array = np.array(images, dtype=np.float32)

# Prepare the training data with labels
responses = np.array([0, 1, 0, 1])  # Example labels, replace with actual labels
train_data = cv2.ml.TrainData_create(images_array, cv2.ml.ROW_SAMPLE, responses)

# Train the model
model.train(train_data)

please help :globe_with_meridians: :globe_with_meridians: :globe_with_meridians: please help I have been trying to debug this for 3 - 7 hours now

look at its dtype and shape

check type and make it S32

images_array = np.array(images, dtype=np.float32)

wrong shape (needs to be 1 row per entry (flatten or sth))