yolov7训练自己的数据集out of memory_一道leetcode编一天的博客-CSDN博客
复现visdrone数据集,精度比yolov5提高了不少,AP50提高了10.7,AP95提高了6.1,但还是比不上师姐的数据。
速度上,相较于yolov5提升五倍左右。但是对小目标的检测达不到预期,于是增加了一个检测头,但是出现报错。
Traceback (most recent call last):
File "train.py", line 613, in <module>
train(hyp, opt, device, tb_writer)
File "train.py", line 95, in train
model = Model(opt.cfg, ch=4, nc=nc, anchors=hyp.get('anchors')).to(device) # create
File "/home/dio/VSST/lyt/yolov7-main/models/yolo.py", line 528, in __init__
self.model, self.save = parse_model(deepcopy(self.yaml), ch=[ch]) # model, savelist
File "/home/dio/VSST/lyt/yolov7-main/models/yolo.py", line 791, in parse_model
args.append([ch[x] for x in f])
File "/home/dio/VSST/lyt/yolov7-main/models/yolo.py", line 791, in <listcomp>
args.append([ch[x] for x in f])
TypeError: list indices must be integers or slices, not str
感觉应该是个比较简单的报错,增加anchor以后报错变为
Traceback (most recent call last):
File "train.py", line 613, in <module>
train(hyp, opt, device, tb_writer)
File "train.py", line 95, in train
model = Model(opt.cfg, ch=4, nc=nc, anchors=hyp.get('anchors')).to(device) # create
File "/home/dio/VSST/lyt/yolov7-main/models/yolo.py", line 544, in __init__
m.stride = torch.tensor([s / x.shape[-2] for x in self.forward(torch.zeros(1, ch, s, s))]) # forward
File "/home/dio/VSST/lyt/yolov7-main/models/yolo.py", line 599, in forward
return self.forward_once(x, profile) # single-scale inference, train
File "/home/dio/VSST/lyt/yolov7-main/models/yolo.py", line 625, in forward_once
x = m(x) # run
File "/home/dio/VSST/anaconda3/envs/pytorch1.7/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/dio/VSST/lyt/yolov7-main/models/common.py", line 172, in forward
return torch.cat(x, self.d)
RuntimeError: Sizes of tensors must match except in dimension 1. Got 32 and 64 in dimension 2 (The offending index is 2)
维度不匹配嘛,今天不想改了,emo了。