我使用TensorFlow函数tf.image.resize_images来调整我的图像大小,但我在代码中得到了这个错误:ValueError:'images'不包含任何形状.完整代码如下:
# -*- coding: utf-8 -*-
import tensorflow as tf
file = ["./1.jpg"]
f = tf.train.string_input_producer(file)
reader = tf.WholeFileReader()
key, img = reader.read(f)
img = tf.image.decode_image(img)
# img.set_shape([218,178,3])
img = tf.image.resize_images(img, [64,64])
coord = tf.train.Coordinator()
with tf.Session() as sess:
tf.train.start_queue_runners(coord=coord)
image = sess.run(img)
Run Code Online (Sandbox Code Playgroud)
完整的错误信息是
Traceback (most recent call last):
File "image_read_test.py", line 10, in <module>
img = tf.image.resize_images(img, [64,64])
File "C:\Python35\lib\site-packages\tensorflow\python\ops\image_ops_impl.py", line 724, in resize_images
raise ValueError('\'images\' contains no shape.')
ValueError: 'images' contains no shape.
Run Code Online (Sandbox Code Playgroud)
然后我尝试解决这个问题,但只找到了这样的方法
# -*- coding: utf-8 …Run Code Online (Sandbox Code Playgroud)