How predict more than one image in keras
Question:
I Am trying to run a project from github , I am trying to cluster images, but when I run the project I get an error ValueError: Error when checking input: expected input_1 to have 4 dimensions, but got array with shape (500, 150528)
I tried to debug the project and I found that it caused by those two functions
def load_images(self):
self.images = []
for image in self.image_paths:
self.images.append(
cv2.cvtColor(cv2.resize(cv2.imread(self.folder_path + "\" + image), (224, 224)), cv2.COLOR_BGR2RGB))
self.images = np.float32(self.images).reshape(len(self.images), -1)
self.images /= 255
print("n " + str(
self.max_examples) + " images from the "" + self.folder_path + "" folder have been loaded in a random order.")
and
pred = VGG16.predict(self.images)
I am not quite sure if am using it correctly or the project need some modifications
but how can I adapt the code to predict the images in the array?
Answers:
I Am trying to run a project from github , I am trying to cluster images, but when I run the project I get an error ValueError: Error when checking input: expected input_1 to have 4 dimensions, but got array with shape (500, 150528)
I tried to debug the project and I found that it caused by those two functions
def load_images(self):
self.images = []
for image in self.image_paths:
self.images.append(
cv2.cvtColor(cv2.resize(cv2.imread(self.folder_path + "\" + image), (224, 224)), cv2.COLOR_BGR2RGB))
self.images = np.float32(self.images).reshape(len(self.images), -1)
self.images /= 255
print("n " + str(
self.max_examples) + " images from the "" + self.folder_path + "" folder have been loaded in a random order.")
and
pred = VGG16.predict(self.images)
I am not quite sure if am using it correctly or the project need some modifications
but how can I adapt the code to predict the images in the array?