OutOfRangeError (see above for traceback): FIFOQueue '_1_batch/fifo_queue' is closed and has insufficient elements (requested 32, current size 0)

烈酒焚心 提交于 2019-12-10 10:38:52

问题


I m having problem with tensorflow reading images in using queue. Please let me know what mistake i am doing. Below is the code.

import tensorflow as tf
slim = tf.contrib.slim
from tensorflow.python.framework import ops

import glob
filelist = glob.glob("/*.png")
filelist[0]

imagelist = ops.convert_to_tensor(filelist)

#Makes an input queue 
input_queue = tf.train.slice_input_producer([imagelist],num_epochs = 2, shuffle = True, capacity = 64*3072)

I have used different capacity values but none have worked

def read_images_from_disk(input_queue):
    file_contents = tf.read_file(input_queue[0])
    example = tf.image.decode_png(file_contents, channels=3)
    return example

image = read_images_from_disk(input_queue)

image.set_shape([28,28,3])
image_batch = tf.train.batch([image],batch_size = 32)

with tf.Session() as sess:
sess.run(tf.initialize_all_variables())
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)

for i in range(20):
    print (sess.run(image_batch))

coord.request_stop()
coord.join(threads)
sess.close()


OutOfRangeError (see above for traceback): FIFOQueue '_1_batch/fifo_queue'
is closed and has insufficient elements (requested 32, current size 0)       

Please help me


回答1:


You can add a filename queue, e.g., string_input_producer, to run over all files in the folder with replacement. And try to comment out the shuffle_batch and see if the filename queue is getting any data. This method could run through multiple times if you left num_epoch to none.



来源:https://stackoverflow.com/questions/42224327/outofrangeerror-see-above-for-traceback-fifoqueue-1-batch-fifo-queue-is-cl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!