【发布时间】:2020-05-01 14:30:47
【问题描述】:
我的模型输入形状是 (50,50,1) 我通过以下方式获取框架:
cv2.VideoCapture(0).read()
当我使用 np.reshape() 函数时,它不会将其重塑为所需的形状。
sized_frame = (cv2.resize(frame, (50,50)))
cv2.waitKey(0)
img_data = np.array(photo)
data = tf.reshape(img_data, (1,50,50,3))
model_out = model.predict([img_data])[0]
print(model_out)
if np.argmax(model_out) == 1:
str_label = 'Dog'
else:
str_label = 'Cat'
return str_label
这是我得到的错误:
ValueError: Cannot feed value of shape (1, 50, 50, 3) for Tensor 'input/X:0', which has shape '(?, 50, 50, 1)'
【问题讨论】:
-
看起来模型是在灰度图像上训练的。
-
您好,能否请您提供神经网络的定义。如果是 Keras,只需 model_out.summary()
标签: python numpy tensorflow machine-learning cv2