在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博客_mmdetection2mmdetection ValueError: need at least one array to concatenate解决方案https://hpg123.blog.csdn.net/article/details/124617894

 只要配置文件中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解决方案

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。