0

我试图使用我训练的模型来检查传递给它的图像,但是,它未能使用我传递的图像。

编码:

path_img = pathlib.Path("D:/Python Projects/Final Year Project/assets/resource/train_images/Acinetobacter.baumanii/edited/img0.png")
image = keras.preprocessing.image.load_img(path_img, target_size=(self.image_height, self.image_width))
image_array = keras.preprocessing.image.img_to_array(image)
image_array = tf.expand_dims(image_array, 0)
prediction = self.imgReg.model.predict(image_array )

我试图运行代码来检测图像的预测,我得到了这个错误:

ValueError: Input 0 of layer dense_2 is incompatible with the layer: expected axis -1 of input shape to have value 50176 but received input with shape [None, 57600]

我在 Google Colabs 中使用了相同的图像和模型,它在那里工作,但是在我的本地计算机上运行它时,它的工作方式不一样,我该如何解决这个问题?

4

0 回答 0