github ultralytics的yolov5 v6.0版本代码导出torchscript导出成功了但是detect.py推理的时候报RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same
这里有两种解决思路
1. 将输入input和weight统一在一个设备上(我采用的这个,比较简单粗暴)
排查代码可以发现,在detect.py中有个DetectMultiBanckend这是用于载入不同类型的模型的类,该类定义在 根目录/models/common.py中,查看该函数对应的 jit(即torchscript) 处代码
可见这里少了一个参数,map_location=device,加上即可