python - ValueError: 层dense_2的输入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 中使用了相同的图像和模型,它在那里工作,但是在我的本地计算机上运行它时,它的工作方式不一样,我该如何解决这个问题?
解决方案
推荐阅读
- python - 多类分割 UNet 给出了意想不到的输出
- r - 我可以使用 lm 的多个子集创建一个带有 geom_smooth 的 lm 吗?
- c - 我没有得到此代码的输出(反转字符串)。谁能告诉我为什么?
- android - 如何防止 gms.Task 的内存泄漏?
- python - 创建范围内缺失的指数列表
- javascript - Chart.js 图例填充-左
- ansible - ansible:任务命名风格
- angular - Angular8 使用 HttpClient GET 方法从 Scala Play 端点检索连续数据
- sql - 如何根据标准提取值并创建新列
- javascript - JavaScript net.connect() - 显式设置本地端点 IP 地址