跑yolov7-d6出现的问题:
注意:yolov7-d6要使用train_aux.py代码跑哦!!!!记得修改配置文件!!!!
File “/home/pc/renrong/yolov7-main/utils/loss.py”, line 1563, 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)
找在yolo7/utils/loss.py文件中下面代码:
from_which_layer.append((torch.ones(size=(len(b),)) * i)
修改为
from_which_layer.append((torch.ones(size=(len(b),)) * i).to('cuda'))
第二也是在loss文件里面找到下面的代码:
from_which_layer = from_which_layer[fg_mask_inboxes]
在每一行的上面那个代码后面添加一句代码,把向量放在一个地方,好像是这个意思吧哈哈哈,添加的代码是下面一行,每一个都要添加,代码里面有好几处这个代码
from_which_layer = from_which_layer.to(fg_mask_inboxes.device)[fg_mask_inboxes]