【发布时间】:2019-11-13 11:43:49
【问题描述】:
我正在尝试从 github 运行一个项目,我正在尝试对图像进行聚类,但是当我运行该项目时出现错误 ValueError: Error when checking input: expected input_1 to have 4 dimensions, but got array with shape (500, 150528)
我尝试调试项目,发现是这两个函数造成的
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.")
和
pred = VGG16.predict(self.images)
我不太确定是否正确使用它或项目需要一些修改 但是如何调整代码来预测数组中的图像?
【问题讨论】:
标签: python keras deep-learning vgg-net