数组越界问题
根本原因在于: index越界
- 加载数据集真值的过程中出现了 xywh的值 >= 1 or < 0 的情况!!!
正常情况下数据集应满足 0 <= xywh < 1, 若超过超过此范围,后续加载真值进行loss functin计算时便会导致错误!
错误如下:
- 目标id超过或等于id总和
eg, id_total = 100, 数据集中标签最大应为99, 若出现100, 便会出现CUDA ERROR: device-side assert triggered at xxx
解决方法
在读取数据的同时进行数据检验:
- L 是读取的真值数据, l[:,2:]分别为每个目标的x, y, w, h的数值
- label是真值的文件路径
此处加入数值是否 >= 1 和 < 0 的判断, 并对错误值进行修改即可
最后加入assert报错, 找到错误具体是哪个文件的,方便修改
但这里不建议修改,这里建议应该对label标注同学重拳出击[smirk]
# you can annotation assert line below to make the program runnable
assert not (True in (l[:, 2:] >= 1.0)),\
'\n value of xywh of groundtruth: %s is >= 1.0, WRONG' % label
assert not (True in (l[:, 2:] < 0.0)),\
'\n value of xywh of groundtruth: %s is <= 0.0, IMPOSSIBLE!!' % label
# make the wrong labeled xywh value correct
l[:, 2:][l[:, 2:] >= 1.0] = 0.999999
l[:, 2:][l[:, 2:] < 0.0] = 0.000000
博主在炼丹的过程中发现问题,最后发现问题根源, 解决办法亲测有效!!
祝所有coder 在coding路上不会遇到lable BUG