I created a model in google Collaboratory using the cifar10 dataset and I used it to predict images and their labels. This worked perfectly and I was very happy with the result. I then wanted to predict my own images because this is what I would be using this for. I want to upload images into google colab which I'm currently doing by mounting my drive. I then want to take that folder of images and turn it into an array of shape (number of images, 32,32,3) I am currently reshaping them and using keras.preprocessing.image.dataGenerator and then using .flow_from_directory to get the images. It seems to work when I put it into the model but I want to see the images using matplotlib.imshow. When I try this, it throws an error that it could not broadcast input array of shape (8,32,32,3) to array size (8). Why is it trying to reshape the array. Sorry I'm pretty new to all this. Here's my code. It is very messy and there are lots of dumb things that I tried.
import tensorflow as tf
from keras.preprocessing.image import img_to_array
from keras.preprocessing.image import array_to_img
from keras.preprocessing.image import load_img
from keras.preprocessing.image import ImageDataGenerator
from keras.preprocessing.image import DirectoryIterator
from google.colab import files
test=ImageDataGenerator(rescale=1./255)
test_ims=DirectoryIterator('/content/drive/MyDrive/test/',test,target_size=(32,32),batch_size=32,class_mode='sparse')
test_set=test.flow_from_directory('/content/drive/MyDrive/test/',target_size=(32,32),batch_size=32,class_mode='sparse')
#print(test_set[0])
print(test_ims)
#imarray=np.array([img_to_array(img)])
!ls saved_model
modelll=tf.keras.models.load_model('/content/saved_model/mymode3')
#history=modelll(test_set)
#print(history)
#print(np.argmax(history[0]))
probability_model1 = tf.keras.Sequential([modelll,
tf.keras.layers.Softmax()])
prediction1=probability_model1.predict(test_set)
#print(prediction1)
#print('10')
history1=np.argmax(prediction1[6])
print(test_set.__getitem__(0))
plt.imshow(test_set.__getitem__(0))
#print(history1)
#print(test_set)
#print(cifclassnems[history[0]])
#print('the rock')```
But yeah I just want to import images and run them through the model. The model is named modelll(don't ask). Anything is helpful! Thank you!