我在尝试将数据馈送到模型时会遇到Outofrange错误。我猜想数据永远不会达到队列,因此错误。仅用于测试,我将其添加给Tfrecord,并用一个元组(图像,地面_truth)。我还尝试了TensorFlow调试器(TFDBG),但它也只会抛出相同的错误,我看不到任何TensoeFlow值。
TensorFlow版本:1.3
Python版本:3.5.3
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:
Traceback (most recent call last):
File "C:Program FilesPython35libsite-packagestensorflowpythonclientsession.py", line 1327, in _do_call
return fn(*args)
File "C:Program FilesPython35libsite-packagestensorflowpythonclientsession.py", line 1306, in _run_fn
status, run_metadata)
File "C:Program FilesPython35libcontextlib.py", line 66, in __exit__
next(self.gen)
File "C:Program FilesPython35libsite-packagestensorflowpythonframeworkerrors_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 FilesPython35libsite-packagestensorflowpythonclientsession.py", line 895, in run
run_metadata_ptr)
File "C:Program FilesPython35libsite-packagestensorflowpythonclientsession.py", line 1124, in _run
feed_dict_tensor, options, run_metadata)
File "C:Program FilesPython35libsite-packagestensorflowpythonclientsession.py", line 1321, in _do_run
options, run_metadata)
File "C:Program FilesPython35libsite-packagestensorflowpythonclientsession.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 FilesPython35libsite-packagestensorflowpythontraininginput.py", line 1220, in shuffle_batch
name=name)
File "C:Program FilesPython35libsite-packagestensorflowpythontraininginput.py", line 791, in _shuffle_batch
dequeued = queue.dequeue_many(batch_size, name=name)
File "C:Program FilesPython35libsite-packagestensorflowpythonopsdata_flow_ops.py", line 457, in dequeue_many
self._queue_ref, n=n, component_types=self._dtypes, name=name)
File "C:Program FilesPython35libsite-packagestensorflowpythonopsgen_data_flow_ops.py", line 1342, in _queue_dequeue_many_v2
timeout_ms=timeout_ms, name=name)
File "C:Program FilesPython35libsite-packagestensorflowpythonframeworkop_def_library.py", line 767, in apply_op
op_def=op_def)
File "C:Program FilesPython35libsite-packagestensorflowpythonframeworkops.py", line 2630, in create_op
original_op=self._default_original_op, op_def=op_def)
File "C:Program FilesPython35libsite-packagestensorflowpythonframeworkops.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上发布的不同解决方案,但出于相同的错误。不幸的是,对我没有任何帮助。请让我知道我是否应该提供任何其他信息。任何建议将被赞赏。预先感谢。
请使用此URL创建注释映像。完成注释图像后,请参阅注释图像的矩阵值。
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脚本从[0,0,1]转换为相同的值[1,1,1]
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
我正在为我的机器学习项目创建一个数据集,事实证明,每当我从python中以png格式保存图像文件时,我都会出现错误。我使用MAT-LAB生成了数据集,并且错误消失了。我仍在调查此问题,并尽快发布更新的答案。同时,我希望这对某人有帮助。
如果注释映像是错误的,则将显示此错误。请参见 注释图像矩阵值。应该有所不同。例如 注释图像矩阵值具有灰色(矩阵值[1 1 1]) 但是您的图像不是灰色(Matix值[1 3 6])。因此,请检查矩阵值 您的注释图像
如果注释图像不是灰色,则队列不会填充。这是 错误。
在camvid_reader_seq def
中尝试此代码。label_bytes = tf.image.decode_png(labelValue,1)
注意:1表示将颜色图像转换为灰度
对于任何可能会有所帮助的人,我都会遇到相同的错误,这显然是第一个链接,在不同上下文中谈论错误。
感谢 TensorFlow的差错误消息,由于以下内容,此错误可能是可能的:
- TF记录文件的不良路径
- 图像形状不匹配
- 图像文件格式错误匹配