Below I would like to store the images in my laptop to the variable called X_data by using the function of glob and then split it into training and test set before testing the model.
import cv2
import numpy as np
import tensorflow as tf
from tensorflow.keras import datasets, layers, models
import matplotlib.pyplot as plt
import glob
X_data = []
files = glob.glob ("*.png")
for myFile in files:
image = cv2.imread(myFile)
X_data.append(image)
print('X_data shape:', np.array(X_data).shape)
import numpy
numpy.random.shuffle(X_data)
training, test = X_data[:80,:], X_data[80:,:]
model = models.Sequential()
model.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(32, 32, 3)))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation='relu'))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation='relu'))
model.add(layers.Flatten())
model.add(layers.Dense(64, activation='relu'))
model.add(layers.Dense(10))
model.summary()
model.compile(optimizer='adam',
loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
metrics=['accuracy'])
history = model.fit(training, labels_train, epochs=10,
validation_data=(test, labels_test))
But I'm getting
ValueError: Failed to find data adapter that can handle input: <class 'numpy.ndarray'>, (<class 'list'> containing values of types {"<class 'int'>"})
Any ideas?

shapeanddtypeof the relevant variables. I'm guessing thattesorflowis objecting to an array with object dtype containing lists (and probably 1d). Find that array and check the len of all its list elements. Do any differ?np.arraymakes an object array if it can't make a near multidimensional array from the inputs.validation_data(last line).labels_testreturns a[1].type(labels_test)returns alist.len(labels_test)returns a1.Print(test)returns a[].len(test)returns a0.type(test)returns anumpy.ndarray