问题遇到的现象和发生背景
下载官方代码对yolov5s.pt进行测试,出现如下报错:IndexError: index 57 is out of bounds for axis 0 with size 21
运行结果及报错内容
Traceback (most recent call last):
File "D:\1-syf\yolov5\val.py", line 359, in <module>
main(opt)
File "D:\1-syf\yolov5\val.py", line 333, in main
run(**vars(opt))
File "C:\ProgramData\Anaconda3\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "D:\1-syf\yolov5\val.py", line 213, in run
confusion_matrix.process_batch(predn, labelsn)
File "D:\1-syf\yolov5\utils\metrics.py", line 156, in process_batch
self.matrix[detection_classes[m1[j]], gc] += 1 # correct
IndexError: index 57 is out of bounds for axis 0 with size 21
我的解答思路和尝试过的方法
该错误是由于索引超出了列表的长度引起的,尝试输出predn和labelsn,但是发现也不会改。