如何将图像重塑为特定尺寸

How to reshape image to specific dimentions

我正在尝试将图像发送到我的模型,但图像的形状与模型不同。

ValueError                                Traceback (most recent call 
last)
<ipython-input-5-d3bd0e2a98e0> in <module>()
257 
258 else:
--> 259     model.fit({'input': X_train}, {'targets': y_train}, 
n_epoch=10,snapshot_step=500)
260     model.save('modelvgg.tfl')
261 
ValueError: Cannot feed value of shape (64, 224, 224) for Tensor ' 
input/X:0', which has shape '(?, 224, 224, 3)'

我只想知道如何适应这些尺寸,但我不知道如何。

您缺少输入中的最后一个维度,这是通道数。该模型需要 3 个通道 - 最有可能用于 RGB。您输入的图像只有一个通道,很可能是灰度图像。如果您根本没有 RGB 图像,请尝试使用 np.repeat.

将通道维度复制 3 次