OutOfRangeError:RandomShuffleQueue'_2_shuffle_batch/random_shuffle_queue'已关闭且元素不足(要求1,当前大小为0) [英] OutOfRangeError: RandomShuffleQueue '_2_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 1, current size 0)
问题描述
尝试将数据输入模型时,出现outOfRange错误.我猜数据永远不会到达队列,因此出现错误.仅出于测试目的,我使用一个元组(image,ground_truth)向tfrecord供电.我也尝试过tensorflow调试器(tfdbg),但它也会抛出相同的错误,我看不到任何tensoeflow值.
I am getting the outOfRange error when trying to feed the data to the model. I am guessing that data never reaches the queue, hence the error. Just for the testing I am feeding it the tfrecord with one tuple (image,ground_truth). I also tried tensorflow debugger(tfdbg) but it would also just throw the same error I couldn't see any tensoeflow value.
Tensorflow版本:1.3
Tensorflow version: 1.3
Python版本:3.5.3
Python version: 3.5.3
操作系统:Windows10
Os: Windows10
filename_queue = tf.train.string_input_producer([tfrecord_filename],num_epochs=1)
image_batch, annotation_batch = tf.train.shuffle_batch([resized_image, resized_annotation],
batch_size=1,
capacity=10,
num_threads=1,
min_after_dequeue=1)
StackTrace:
StackTrace:
Traceback (most recent call last):
File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1327, in _do_call
return fn(*args)
File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1306, in _run_fn
status, run_metadata)
File "C:\Program Files\Python35\lib\contextlib.py", line 66, in __exit__
next(self.gen)
File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\framework\errors_impl.py", line 466, in raise_exception_on_not_ok_status
pywrap_tensorflow.TF_GetCode(status))
tensorflow.python.framework.errors_impl.OutOfRangeError: RandomShuffleQueue '_2_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 1, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_INT32], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/supriya.godge/PycharmProjects/tf-image-segmentation/tf_image_segmentation/recipes/pascal_voc/DeepLab/resnet_v1_101_8s_train.py", line 160, in <module>
train_step])
File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\client\session.py", line 895, in run
run_metadata_ptr)
File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1124, in _run
feed_dict_tensor, options, run_metadata)
File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1321, in _do_run
options, run_metadata)
File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\client\session.py", line 1340, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.OutOfRangeError: RandomShuffleQueue '_2_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 1, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_INT32], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
Caused by op 'shuffle_batch', defined at:
File "C:/Users/supriya.godge/PycharmProjects/tf-image-segmentation/tf_image_segmentation/recipes/pascal_voc/DeepLab/resnet_v1_101_8s_train.py", line 68, in <module>
min_after_dequeue=1)
File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\training\input.py", line 1220, in shuffle_batch
name=name)
File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\training\input.py", line 791, in _shuffle_batch
dequeued = queue.dequeue_many(batch_size, name=name)
File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\ops\data_flow_ops.py", line 457, in dequeue_many
self._queue_ref, n=n, component_types=self._dtypes, name=name)
File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\ops\gen_data_flow_ops.py", line 1342, in _queue_dequeue_many_v2
timeout_ms=timeout_ms, name=name)
File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 767, in apply_op
op_def=op_def)
File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 2630, in create_op
original_op=self._default_original_op, op_def=op_def)
File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 1204, in __init__
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access
OutOfRangeError (see above for traceback): RandomShuffleQueue '_2_shuffle_batch/random_shuffle_queue' is closed and has insufficient elements (requested 1, current size 0)
[[Node: shuffle_batch = QueueDequeueManyV2[component_types=[DT_UINT8, DT_INT32], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]]
我尝试过针对相同错误在stackoverflow上发布的其他解决方案.不幸的是,没有任何事情对我有用.请让我知道是否需要提供其他信息.任何建议表示赞赏.预先感谢.
I have tried different solution posted on stackoverflow for the same error. Unfortunately nothing worked for me. Please let me know if I should provide any additional information. Any suggestion is appreciated. Thanks in advance.
推荐答案
请使用此网址创建注释图像.完成注释图像后,请查看注释图像的矩阵值.
URL: https://github.com/kyamagu/js-segment-annotator
Please use this url to create annotation image. Once you completed the annotation image, please see the matrix value to annotation image.
URL:https://github.com/kyamagu/js-segment-annotator
Example:
Originale Annotation Image Matrix Value [1,1,1] but
Your Annotation image have [0,0,1] or [1,0,0] or [0,1,0].
因此,您可以将我的python脚本与opencv一起从[0,0,1]转换为相同的值[1,1,1]
So you convert to same value[1,1,1] from [0,0,1] using my python script with opencv
def biggest(a, y, z):
Max = a
if y > Max:
Max = y
if z > Max:
Max = z
if y > z:
Max = y
return Max
#Input Image
outdir = "sampleimages/sample2.png"
cnt = 0
image = cv2.imread(outdir)
for i in range(0,360):
for j in range(0,480):
newvalue = biggest(image[i,j,0],image[i,j,1],image[i,j,2])
image[i,j,0] = newvalue
image[i,j,1] = newvalue
image[i,j,2] = newvalue
#if image[i,j] == 8:
# cnt += 1
#Output Image
cv2.imwrite("sampleimages/sample-gray-2.png",image)
请参阅: https://github.com/tkuanlun350/Tensorflow-SegNet/issues/6
这篇关于OutOfRangeError:RandomShuffleQueue'_2_shuffle_batch/random_shuffle_queue'已关闭且元素不足(要求1,当前大小为0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!