Transferred 349/349 items from yolov5s.pt
Scaled weight_decay = 0.0005
optimizer: SGD with parameter groups 57 weight, 60 weight (no decay), 60 bias
train: Scanning '../datasets/coco128/labels/train2017.cache' images and labels... 126 found, 2 missing, 0 empty, 0 corrupted: 100%|████████████████████████| 128/128 [00:00<?, ?it/s]
val: Scanning '../datasets/coco128/labels/train2017.cache' images and labels... 126 found, 2 missing, 0 empty, 0 corrupted: 100%|██████████████████████████| 128/128 [00:00<?, ?it/s]
Plotting labels...
autoanchor: Analyzing anchors... anchors/target = 4.27, Best Possible Recall (BPR) = 0.9935
Image sizes 640 train, 640 val
Using 2 dataloader workers
Logging results to runs/train/exp5
Starting training for 100 epochs...
Epoch gpu_mem box obj cls labels img_size
0%| | 0/32 [00:05<?, ?it/s]
Traceback (most recent call last):
File "train.py", line 620, in <module>
main(opt)
File "train.py", line 517, in main
train(opt.hyp, opt, device, callbacks)
File "train.py", line 316, in train
loss, loss_items = compute_loss(pred, targets.to(device)) # loss scaled by batch_size
File "/home/ubuntu/yolov5Project/yolov5-6.0/utils/loss.py", line 120, in __call__
tcls, tbox, indices, anchors = self.build_targets(p, targets) # targets
File "/home/ubuntu/yolov5Project/yolov5-6.0/utils/loss.py", line 217, in build_targets
indices.append((b, a, gj.clamp_(0, gain[3] - 1), gi.clamp_(0, gain[2] - 1))) # image, anchor, grid indices
RuntimeError: result type Float can't be cast to the desired output type long int
修改utils/loss.py
1.修改下面程序
for i in range(self.nl):
anchors = self.anchors[i]
修改结果:
for i in range(self.nl):
anchors, shape = self.anchors[i], p[i].shape
2.修改下面程序:
indices.append((b, a, gj.clamp_(0, gain[3] - 1), gi.clamp_(0, gain[2] - 1))) # image, anchor, grid indices
修改后:
indices.append((b, a, gj.clamp_(0, shape[2] - 1), gi.clamp_(0, shape[3] - 1))) # image, anchor, grid