mmdetection ValueError: need at least one array to concatenate解决方案

在mmdetection中有时候训练模型会出现ValueError: need at least one array to concatenate的错误,详情如下图所示。

mmdetection ValueError: need at least one array to concatenate解决方案

很多人都说是mmdet/dataset下coco.py或voc.py中CLASSES设置与数据集对应不上,博主不以为然。因为在mmdetection2中,不需要到mmdet/dataset中修改CLASSES,只需要在训练配置文件中中设置一下就行了。config解释器会通过继承自动修改CLASSES的值,具体可见下图,或参考mmdetection2的使用教程从数据处理、配置文件到训练与测试(支持coco数据和pascal_voc数据)_万里鹏程转瞬至的博客-CSDN博客_mmdetection2icon-default.png?t=M5H6https://hpg123.blog.csdn.net/article/details/124617894

mmdetection ValueError: need at least one array to concatenate解决方案

 只要配置文件中classes设置正确了,voc数据就不会出现上述的报错。

但是,coco数据集会因此数据转化时设置有误,而导致出现上述错误。博主的数据集只有shoot一个类别,在数据集转换时,通过下列方式在tools\dataset_converters\pascal_voc.py文件设置类别。【错误方式】mmdetection ValueError: need at least one array to concatenate解决方案

 然后生成的coco数据存在问题,本来只有一个shoot类别的coco数据,结果出现了 20余个supercategory项目。这就是导致报错的根源。

mmdetection ValueError: need at least one array to concatenate解决方案

在转换数据集时,需要通过在tools\dataset_converters\pascal_voc.py文件按照以下标准以下设置修改自定义类别

mmdetection ValueError: need at least one array to concatenate解决方案 通过该方式生成的coco数据集才是严格正确的,其categories的格式如下图所示。如果是通过第三方项目生成的coco数据,则请检查categories内的数据与数据集的类别是否正常。mmdetection ValueError: need at least one array to concatenate解决方案

 在修改coco数据集的错误后,现在mmdetection可以正常训练数据了。

mmdetection ValueError: need at least one array to concatenate解决方案

 

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
xiaoxingxing的头像xiaoxingxing管理团队
上一篇 2023年2月25日 下午9:41
下一篇 2023年2月25日 下午9:42

相关推荐