resize的时候报错:InvalidArgumentError
来源:5-8 图像增强api使用
卷积包心菜
2021-03-05
name = './gugong.jpg'
img_string = tf.read_file(name)
img_decoded = tf.image.decode_image(img_string)
img_decoded = tf.reshape(img_decoded, [1, 365, 600, 3])
resize_img = tf.image.resize_bicubic(img_decoded, [730, 1200])
print('resize_img shape: ', resize_img.shape)
sess = tf.Session()
img_decoded_val = sess.run(resize_img)
img_decoded_val = img_decoded_val.reshape((730, 1200, 3))
img_decoded_val = np.asarray(img_decoded_val, np.uint8)
print(img_decoded_val.shape)
%matplotlib inline
imshow(img_decoded_val)
报错如下:
InvalidArgumentError Traceback (most recent call last)
<ipython-input-11-dc13c12d0cb2> in <module>()
12 print('resize_img shape: ', resize_img.shape)
13 sess = tf.Session()
---> 14 img_decoded_val = sess.run(resize_img)
15 img_decoded_val = img_decoded_val.reshape((730, 1200, 3))
16 img_decoded_val = np.asarray(img_decoded_val, np.uint8)
...
InvalidArgumentError: Input to reshape is a tensor with 2128680 values, but the requested shape has 657000
[[node Reshape_7 (defined at <ipython-input-11-dc13c12d0cb2>:9) ]]
跟你的代码一样,为啥会报这个错
写回答
1回答
-
正十七
2021-03-22
错误发生在reshape这一行,可能是因为输入的图片大小不一样了,不是600 x 365的,你再check一下输入的图片大小?
00
相似问题