Python 训练的DNN模型预测类时的错误

Python 训练的DNN模型预测类时的错误,python,tensorflow,keras,prediction,Python,Tensorflow,Keras,Prediction,我使用下面的程序为我的图像预测类 我用于训练的图像是形状(28,28,1) 在这里,我上传了一个RGB图像,它的形状是(28,28,3),我尝试将该图像转换为灰度,然后预测,但不断得到以下错误 ValueError: Input 0 of layer sequential is incompatible with the layer: expected axis -1 of input shape to have value 1 but received input with shape [No

我使用下面的程序为我的图像预测类

我用于训练的图像是形状(28,28,1)

在这里,我上传了一个RGB图像,它的形状是(28,28,3),我尝试将该图像转换为灰度,然后预测,但不断得到以下错误

ValueError: Input 0 of layer sequential is incompatible with the layer: expected axis -1 of input shape to have value 1 but received input with shape [None, 28, 28, 3]
有谁能告诉我我做错了什么,并帮我解决这个问题。

你需要申请以下类似的申请:

load_img(path, color_mode='grayscale')

到灰度的转换在哪里?实际上我是用Photoshop手动完成的。你的图像在加载后仍然是rgb(3个通道)。尝试加载img(路径,颜色模式为灰度),你可以在这里看到,非常感谢!成功了。
load_img(path, color_mode='grayscale')