我的代码似乎完美地找到了jpeg图像,因为如果我弄乱了路径,它将无法继续,而且我打印了一次match_filenames_的返回,并且有一个正确的图像文件列表。但是,下面的代码似乎没有将图像加载到队列中。文件名队列有什么问题?在
这是我的代码:
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)
输出如下:
^{pr2}$
尝试打印
image_tensor
的形状代码中的},图像从磁盘加载。在
image
是张量,它的大小未知,因为它是从任意jpeg图像生成的图形,而TF无法定义它的大小,当TF创建graph时。但是image_tensor
是{相关问题 更多 >
编程相关推荐