2017-09-07 97 views
0

嘗試將數據提供給模型時出現outOfRange錯誤。我猜測數據永遠不會到達隊列,因此錯誤。爲了測試,我用一個元組(圖像,ground_truth)爲它提供tfrecord。 我也嘗試tensorflow調試器(tfdbg),但它也只是拋出同樣的錯誤,我看不到任何tensoeflow值。OutOfRangeError:RandomShuffleQueue'_2_shuffle_batch/random_shuffle_queue'已關閉且元素不足(請求1,當前大小爲0)

Tensorflow版本:1.3

Python版本:3.5.3

鋨: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) 

堆棧跟蹤:

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)]] 

我嘗試了多種不同的解決方案計算器上張貼同樣的錯誤。不幸的是沒有爲我工作。請讓我知道我是否應該提供任何其他信息。 任何建議表示讚賞。 在此先感謝。

+0

'tfrecord_filename'的內容是什麼? – GPhilo

+0

刪除tf.train.string_input_producer中的num_epochs? –

+0

@GPh tfrecord有4對(image,ground_truth_image)。 – supgodge

回答

0

請使用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]. 

所以,如果你[0,0,1]用我的python腳本與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) 

轉換爲同一值[1,1,1]請參考: https://github.com/tkuanlun350/Tensorflow-SegNet/issues/6

+0

謝謝你的信息,這絕對有用。 – supgodge

0

我正在爲我的機器學習項目創建一個數據集,事實證明,每當我從python以png格式保存圖像文件時,都會出現上述錯誤。 我使用mat-lab生成了數據集,錯誤消失了。我仍在調查此問題,並儘快發佈最新的答案。同時我希望這對別人有幫助。

+0

您是否使用上述方法解決了錯誤?我仍然遇到問題。 – Moondra

+0

嗨Moondra, 是的,我能夠通過使用matlab保存PNG文件來解決這個錯誤。 – supgodge

+0

謝謝。我實際上刪除了.png文件,但我仍然遇到問題。我想我會對此做一個新的線索。 – Moondra

0

If the Annotation image is wrong, this error will be shown. Please see the annotation image matrix value. It should be differ. For example the annotation image matrix value have gray color(matrix value[1 1 1]) but your image not gray(matix value[1 3 6]). So check the matrix value of your annotation image

If the annotation image is not gray, then queue is not fill. This is the error.

嘗試在Inputs.py線68在代碼裏CamVid_reader_seq高清

label_bytes = tf.image.decode_png(labelValue,1) 

注:1種手段轉換彩色圖像爲灰度

+0

請在發佈答案https:// stackoverflow前仔細閱讀。com/help /如何回答 – sissy

相關問題