SSD数据集训练时出现IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed等

如果你已经按(windows)ssd深度学习2: 训练自己的数据集gpu+ windows11+ anaconda+ pycharm+ RTX3050 笔记(内含单通道灰度图像的训练方法)_chao_xy的博客-CSDN博客(linux) ssd-pytorch深度学习2: 训练自己的数据集, gpu+anaconda+pycharm+RTX2080ti 笔记_chao_xy的博客-CSDN博客步骤进行训练

错误包括但不限于

boxes[:, 0::2] = width - boxes[:, 2::-2]
IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed

boxes[:, 0] /= width
IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed

 boxes[:, :2] += (int(left), int(top))
IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed

看一下是否有图像没有目标,导致对应的xml中没有BBOX

在ssd/data/datasets/voc.py中的def __getitem__(self, index):下插入

if len(boxes) == 0:# 检测是否有空白的bbox
    print(image_id)

SSD数据集训练时出现IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed等_第1张图片

 然后就会自动打印出中没有BBOX的xml

SSD数据集训练时出现IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed等_第2张图片

删掉这些xml与对应的图片,注意 \ImageSets\Main中txt文件中相应的id也要删掉

你可能感兴趣的:(SSD,python,深度学习)