while training yolov7-e6e.pt i got this error.
Traceback (most recent call last):
File “/content/gdrive/MyDrive/files/yolov7-main/train_aux.py”, line 612, in
train(hyp, opt, device, tb_writer)
File “/content/gdrive/MyDrive/files/yolov7-main/train_aux.py”, line 362, in train
loss, loss_items = compute_loss_ota(pred, targets.to(device), imgs) # loss scaled by batch_size
File “/content/gdrive/MyDrive/files/yolov7-main/utils/loss.py”, line 1206, in call
bs_aux, as_aux_, gjs_aux, gis_aux, targets_aux, anchors_aux = self.build_targets2(p[:self.nl], targets, imgs)
File “/content/gdrive/MyDrive/files/yolov7-main/utils/loss.py”, line 1558, in build_targets2
from_which_layer = from_which_layer[fg_mask_inboxes]
RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)
Try changing line no 759, 1404, 1557 which is:
from_which_layer = from_which_layer[fg_mask_inboxes]
change this to:
from_which_layer = from_which_layer.to(fg_mask_inboxes.device)[fg_mask_inboxes]
in all the three places. Probably it should work. Also use train_aux.py. here is the complete line:
!python3 train_aux.py –img-size 1280 –cfg cfg/training/yolov7-e6e.yaml –hyp data/hyp.scratch.p6.yaml –batch-size 4 –epochs 100 –data data/data_files.yaml –weights yolov7-e6e.pt –device 0
Ronson Danthy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.