简体   繁体   English

ValueError:无法为张量“输入/X:0”提供形状(1、50、50、3)的值,其形状为“(?、50、50、1)”

[英]ValueError: Cannot feed value of shape (1, 50, 50, 3) for Tensor 'input/X:0', which has shape '(?, 50, 50, 1)'

my model input shape is (50,50,1) I am getting the frame by:我的 model 输入形状是 (50,50,1) 我通过以下方式获取框架:

 cv2.VideoCapture(0).read()

When I'm using np.reshape() function it does not reshape it the desired shape.当我使用 np.reshape() function 时,它不会将其重塑为所需的形状。

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

This is the error I'm getting:这是我得到的错误:

ValueError: Cannot feed value of shape (1, 50, 50, 3) for Tensor 'input/X:0', which has shape '(?, 50, 50, 1)'

The following code should solve your error以下代码应该可以解决您的错误

gray = cv2.cvtColor(photo, cv2.COLOR_BGR2GRAY)
img_data = np.array(gray)
data = tf.reshape(img_data, (1,50,50,1))
model_out = model.predict(img_data)[0]

Under the assumption that you trained on Grayscale images假设您在灰度图像上进行过训练

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Tensorflow 值错误:无法为 Tensor u'InputData/X:0' 提供形状 (96, 50, 50) 的值,其形状为 '(?, 50, 50, 1)' - Tensorflow value error: Cannot feed value of shape (96, 50, 50) for Tensor u'InputData/X:0', which has shape '(?, 50, 50, 1)' ValueError:无法为形状为“(1, 50)”的张量“Placeholder_22:0”提供形状 (0, 31399, 50) 的值 - ValueError: Cannot feed value of shape (0, 31399, 50) for Tensor 'Placeholder_22:0', which has shape '(1, 50)' ValueError:无法为形状为“(?, 621)”的张量 u'Placeholder_1:0' 提供形状 (50, 807) 的值 - ValueError: Cannot feed value of shape (50, 807) for Tensor u'Placeholder_1:0', which has shape '(?, 621)' ValueError:无法为形状为((?,10)'的张量'Placeholder_1:0'提供形状(50,)的值 - ValueError: Cannot feed value of shape (50,) for Tensor 'Placeholder_1:0', which has shape '(?, 10)' ValueError:无法为张量为'(?,12)'的张量'Placeholder_1:0'输入形状(50,10)的值 - ValueError: Cannot feed value of shape (50, 10) for Tensor 'Placeholder_1:0', which has shape '(?, 12)' 无法为形状为((?,5)''的张量'upper / input / y:0'输入形状(50,)的值 - Cannot feed value of shape (50,) for Tensor 'upper/input/y:0', which has shape '(?, 5)' TensorFlow:如何修复 ValueError:具有形状 (50,1) 的形状 (50,2) 的馈送值 - TensorFlow: How to fix ValueError: feed value of shape (50,2) which has shape (50,1) Tflearn/Tensorflow 值错误:“无法为具有形状 '(?, 1)' 的张量 'TargetsData/Y:0' 提供形状 (50, 11, 11) 的值” - Tflearn/Tensorflow value error: “Cannot feed value of shape (50, 11, 11) for Tensor 'TargetsData/Y:0', which has shape '(?, 1)'” sess.run错误失败“无法为形状为((?,784)”的Tensor'占位符:0'输入形状(50,2352)的值” - failed sess.run error “Cannot feed value of shape (50, 2352) for Tensor 'Placeholder:0', which has shape '(?, 784)'” tflearn 3d张量-ValueError:无法输入形状值(50,15,15) - tflearn 3d tensor - ValueError: Cannot feed value of shape (50, 15, 15)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM