0
我的代码似乎完美地找到了jpeg图像,因为如果我搞乱了路径,它将不会继续,我还打印出match_filenames_once的返回,并且存在正确的图像文件列表。但是下面的代码似乎没有将图像加载到队列中。 filename_queue有什么问题?tf.WholeFileReader()not reading
这里是我的代码:
filename_queue = tf.train.string_input_producer(
tf.train.match_filenames_once("./resized2/*.jpg"),shuffle=False)
image_reader = tf.WholeFileReader()
myfilename, image_file = image_reader.read(filename_queue)
image = tf.image.decode_jpeg(image_file)
# Start a new session to show example output.
with tf.Session() as sess:
init_op = tf.global_variables_initializer(), tf.local_variables_initializer()
sess.run(init_op)
# Start populating the filename queue.
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
for i in range(1): #length of your filename list
image_tensor = image.eval() #here is your image Tensor :)
print(myfilename)
print(image.shape)
#Image.fromarray(np.asarray(image_tensor)).show()
coord.request_stop()
coord.join(threads)
这里是输出:
Tensor("ReaderReadV2:0", shape=(), dtype=string)
(?, ?, ?)
你的意思是 - 'print(image_tensor.shape)'? –
是的,打印出(225,300,3),这是图像的尺寸 –