mmdetection训练出现:IndexError: list index out of range 错误
文章目录:
- 1 问题分析
- 1.1 尝试解决错误:第一次
- 1.2 尝试解决错误:第二次
- 2 我的问题解决方式
我的环境:
Ubuntu18.04 TorchVision: 0.6.0 OpenCV: 4.2.0 MMCV: 0.5.5 MMDetection: 2.0.0+d9c8f14 MMDetection Compiler: GCC 7.5 MMDetection CUDA Compiler: 10.2
训练的模型是:
1 问题分析
在使用

1.1 尝试解决错误:第一次
根据这个错误,很容易想到是否是类别写的不正确,于是去检查如下三个文件:
mmdetection/mmdet/datasets/voc.py :中的CLASSED变量对应的类别是否正确mmdetection/mmdet/core/evaluation/class_names.py :voc_classes()函数返回的类别是否正确mmdetection/configs/_base_/models/retinanet_r50_fpn.py :中num_classes对应的类别数是否正确
结果反复检查了好几遍,还是没有解决这个问题,当然如果你遇到这个问题,很可能就是因为类别写的不对,你一定要
1.2 尝试解决错误:第二次
自己解决不了,于是就去逛github mmdetection的官网,然后乖乖查看
ONE YEARS LATER
一顿尝试,最终还是不行,错误重现!!!
2 我的问题解决方式
我最开始编译的mmdetection环境路径为:
/home/shl/shl/mmdetection
但是我后面训练自己的另外一个数据集的时候,是直接把这个编译好的mmdetection拷贝一份出来,会出一定的问题,比如:
cp -r mmdetection mmdetection_clothes
然后在
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | (mmdetection) shl@zfcv:~/shl/mmdetection$ pip list Package Version Location ---------------------- ------------------- ------------------------- absl-py 0.9.0 addict 2.2.1 cachetools 4.1.0 certifi 2020.4.5.1 chardet 3.0.4 click 7.1.2 cycler 0.10.0 Cython 0.29.19 Flask 1.1.2 future 0.18.2 google-auth 1.17.2 google-auth-oauthlib 0.4.1 grpcio 1.29.0 idna 2.9 importlib-metadata 1.6.1 itsdangerous 1.1.0 Jinja2 2.11.2 kiwisolver 1.2.0 Markdown 3.2.2 MarkupSafe 1.1.1 matplotlib 3.2.1 mmcv 0.5.5 mmdet 2.0.0+d9c8f14 /home/shl/shl/mmdetection # 这里可以看到,mmdetection_clothes训练时还是在这里调用mmdet下的类别相关信息 numpy 1.18.4 oauthlib 3.1.0 opencv-python 4.2.0.34 pandas 1.0.4 Pillow 7.1.2 pip 20.0.2 protobuf 3.12.2 pyasn1 0.4.8 pyasn1-modules 0.2.8 pycocotools 2.0 pyparsing 2.4.7 python-dateutil 2.8.1 pytz 2020.1 PyYAML 5.3.1 requests 2.23.0 requests-oauthlib 1.3.0 rsa 4.6 scipy 1.4.1 seaborn 0.10.1 setuptools 46.4.0.post20200518 six 1.15.0 tensorboard 2.2.2 tensorboard-plugin-wit 1.6.0.post3 terminaltables 3.1.0 torch 1.5.0 torchvision 0.6.0 tqdm 4.46.1 urllib3 1.25.9 Werkzeug 1.0.1 wheel 0.34.2 yapf 0.30.0 zipp 3.1.0 (mmdetection) shl@zfcv:~/shl/mmdetection$ |
所以最后的解决方式,在