近日,在使用Cascade R-CNN完成目标检测任务时,我在使用这个模型训练自己的数据集时出现了如下错误:

具体如以下截图所示:

  

  

详细错误如下所示:

Traceback (most recent call last):
File "train.py", line 195, in <module>
train()
File "train.py", line 175, in train
_, global_stepnp, summary_str = sess.run([train_op, global_step, summary_op])
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 929, in run
run_metadata_ptr)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1152, in _run
feed_dict_tensor, options, run_metadata)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1328, in _do_run
run_metadata)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/client/session.py", line 1348, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: ValueError: attempt to get argmax of an empty sequence
Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/script_ops.py", line 206, in __call__
ret = func(*args) File "../libs/detection_oprations/anchor_target_layer_without_boxweight.py", line 49, in anchor_target_layer
argmax_overlaps = overlaps.argmax(axis=1) ValueError: attempt to get argmax of an empty sequence [[node sample_anchors_minibatch/PyFunc (defined at ../libs/networks/build_whole_network.py:433) = PyFunc[Tin=[DT_FLOAT, DT_INT32, DT_FLOAT], Tout=[DT_FLOAT, DT_FLOAT], token="pyfunc_2", _device="/job:localhost/replica:0/task:0/device:CPU:0"](Cast/_1175, postprocess_RPN/Shape_2, make_anchors_forRPN/concat/_1177)]]
[[{{node sample_RCNN_minibatch_stage2/Shape_1/_1383}} = _HostRecv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_3164_sample_RCNN_minibatch_stage2/Shape_1", tensor_type=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]] Caused by op 'sample_anchors_minibatch/PyFunc', defined at:
File "train.py", line 195, in <module>
train()
File "train.py", line 46, in train
gtboxes_batch=gtboxes_and_label)
File "../libs/networks/build_whole_network.py", line 433, in build_whole_detection_network
[tf.float32, tf.float32])
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/script_ops.py", line 457, in py_func
func=func, inp=inp, Tout=Tout, stateful=stateful, eager=False, name=name)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/script_ops.py", line 281, in _internal_py_func
input=inp, token=token, Tout=Tout, name=name)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_script_ops.py", line 129, in py_func
"PyFunc", input=input, token=token, Tout=Tout, name=name)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/deprecation.py", line 488, in new_func
return func(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 3274, in create_op
op_def=op_def)
File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py", line 1770, in __init__
self._traceback = tf_stack.extract_stack() InvalidArgumentError (see above for traceback): ValueError: attempt to get argmax of an empty sequence
Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/script_ops.py", line 206, in __call__
ret = func(*args) File "../libs/detection_oprations/anchor_target_layer_without_boxweight.py", line 49, in anchor_target_layer
argmax_overlaps = overlaps.argmax(axis=1) ValueError: attempt to get argmax of an empty sequence [[node sample_anchors_minibatch/PyFunc (defined at ../libs/networks/build_whole_network.py:433) = PyFunc[Tin=[DT_FLOAT, DT_INT32, DT_FLOAT], Tout=[DT_FLOAT, DT_FLOAT], token="pyfunc_2", _device="/job:localhost/replica:0/task:0/device:CPU:0"](Cast/_1175, postprocess_RPN/Shape_2, make_anchors_forRPN/concat/_1177)]]
[[{{node sample_RCNN_minibatch_stage2/Shape_1/_1383}} = _HostRecv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device_incarnation=1, tensor_name="edge_3164_sample_RCNN_minibatch_stage2/Shape_1", tensor_type=DT_INT32, _device="/job:localhost/replica:0/task:0/device:GPU:0"]()]]

我使用的教程是这个链接:cascade r-cnn训练和测试(tensorflow框架)

这个错误在以前也遇到过,当时的解决方案是通过try except 把发生错误的数据给pass掉。

然后在这次训练的过程中,又遇到了这个错误,这次的错误已经没有办法给pass掉了,因为这个错误会直接导致程序运行中断。

错误原因:空标注文件导致出现这个错误,在检查自己的标注文件过程中,偶然发现竟然存在如下所示的标注文件

<annotation>
<folder>********</folder>
<filename>**********</filename>
<path>******************</path>
<source>
<database>Unknown</database>
</source>
<size>
<width>219</width>
<height>167</height>
<depth>3</depth>
</size>
<segmented>0</segmented>
</annotation>

   

在这个标注的xml文件里面是没有目标检测框的坐标的,而这也是导致出现这个错误的主要原因。

错误解决:

有可能在制作数据集的过程中,某些地方导致xml文件里面的坐标丢失,解决办法有两种,一种是删除掉空坐标的xml文件如果这种类型的xml文件数量较少的情况下,第二种就是检查xml文件然后把丢失的坐标点给添加到xml文件中去。

总结:

这个错误的解决方案也不一定和我一样,这里的提出只是当作一种参考,可能导致错误的原因多种多样,但是如果后面还是出现了这种错误,一定要仔细检查一下数据集。如果后面出现了新的解决方案,我会更新这篇博客的。

错误:tensorflow.python.framework.errors_impl.InvalidArgumentError: ValueError: attempt to get argmax of an empty sequence的解决方案的更多相关文章

  1. faster-rcnn错误信息 : tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [21] rhs shape= [2]

    faster-rcnn错误信息 : tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shap ...

  2. tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a value for placeholder tensor 'x_1' with dtype float and shape [?,227,227,3]

    记一次超级蠢超级折磨我的bug. 报错内容: tensorflow.python.framework.errors_impl.InvalidArgumentError: You must feed a ...

  3. gt_argmax_overlaps = overlaps.argmax(axis=0) ValueError: attempt to get argmax of an empty sequence错误处理

    在faster rcnn内进行随机裁剪数据增强,训练一段时间后报错: gt_argmax_overlaps = overlaps.argmax(axis=0) ValueError: attempt ...

  4. tensorflow.python.framework.errors_impl.OutOfRangeError: FIFOQueue

    tensorflow.python.framework.errors_impl.OutOfRangeError: FIFOQueue 原创文章,请勿转载哦~!! 觉得有用的话,欢迎一起讨论相互学习~F ...

  5. Tensorflow 报错:tensorflow.python.framework.errors_impl.InternalError: Failed to create session.

    问题描述 IDE:pycharm,环境中安装tensorflow-gpu 1.8.0 ,Cuda9 ,cudnn 7,等,运行代码 报错如下 tensorflow.python.framework.e ...

  6. 【err】tensorflow.python.framework.errors_impl.OutOfRangeError: RandomShuffleQueue

    problem Traceback (most recent call last): File , in _do_call return fn(*args) File , in _run_fn opt ...

  7. ''tensorflow.python.framework.errors_impl.ResourceExhaustedError: OOM when allocating tensor with shape[?]'' 错误分析

    这是tensorflow 一个经常性错误,错误的原因在于:显卡内存不够. 解决方法就是降低显卡的使用内存,途径有以下几种措施: 1 减少Batch 的大小 2 分析错误的位置,在哪一层出现显卡不够,比 ...

  8. tensorflow.python.framework.errors_impl.PermissionDeniedError: /data; Permission denied

    在linux系统中,tensorflow跑mnist数据集出现错误,本应该自动下载的数据集 将mnist自动下载的路径,由/data/mnist之前的/删掉即可.改为data/mnist.

  9. 启动Tensorboard时发生错误:class BeholderHook(tf.estimator.SessionRunHook): AttributeError: module 'tensorflow.python.estimator.estimator_lib' has no attribute 'SessionRunHook'

    报错:class BeholderHook(tf.estimator.SessionRunHook):AttributeError: module 'tensorflow.python.estimat ...

  10. ImportError: /lib64/libm.so.6: version `GLIBC_2.23' not found (required by /usr/local/python37/lib/python3.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so)

    一 问题背景 这个错误的出现往往与我前面的一篇文章 ImportError: /lib64/libm.so.6: version `CXXAB_1.3.8.' not found (required ...

随机推荐

  1. 深度揭秘阿里云 Serverless Kubernetes

    作者 | 陈晓宇(阿里云技术专家) 策划 | 褚杏娟 伴随着云原生的发展,从早先的单机版 Docker 到 Kubernetes 的编排领域的一统江湖,再到云上托管 Kubernetes,技术风雨变化 ...

  2. vue 状态管理 一、状态管理概念和基本结构

    系列导航 vue 状态管理 一.状态管理概念和基本结构 vue 状态管理 二.状态管理的基本使用 vue 状态管理 三.Mutations和Getters用法 vue 状态管理 四.Action用法 ...

  3. 微信小程序从基础入门到项目实战-黑马程序员-pink老师推荐(持续更新)

    https://www.bilibili.com/video/BV1WJ41197sD/?spm_id_from=333.788.recommend_more_video.0

  4. Keep English Level-03

    rule -- 统治,管理,规章,制度 ruling -- 裁决 ruler -- 统治者,尺子 district judge -- 地方法官 sweeping -- 一刀切的 haul --拉 ov ...

  5. SpringBoot03:首页国际化

    页面国际化 有的时候,我们的网站会去涉及中英文甚至多语言的切换,这时候我们就需要学习国际化! 1.配置文件编写 首先在resources资源文件下新建一个i18n目录,存放国际化配置文件 新建一个lo ...

  6. linux-网络状态-netstat

  7. Git-签名-user-email

  8. [粘贴]Introducing Exadata X9M: Dramatically Faster, More Cost Effective, and Easier to Use

    https://blogs.oracle.com/exadata/post/exadata-x9m   The Exadata Product Management and Development t ...

  9. [转帖]Linux系统安装之后,如何调节CPU性能策略

    https://baize.cc/posts/efc.html#:~:text=Linux%E7%B3%BB%E7%BB%9F%E5%AE%89%E8%A3%85%E4%B9%8B%E5%90%8E% ...

  10. bcc工具的简要学习

    摘要 继续补充假期落下的内容. 其实有很多知识需要学习, 自己掌握的还是偏少一些. bcc的全貌 # 注意 bcc 需要较高的内核. 3.10 系列的内核基本不可用. argdist drsnoop ...