当前位置: 首页 > 工具软件 > Location Map > 使用案例 >

attempt_load() got an unexpected keyword argument ‘map_location‘

东门城
2023-12-01

报错信息

D:\Users\wh109\anaconda3\python.exe D:\TrackAndReID\Yolov5-Deepsort-Fastreid-main\person_search_reid.py 
Loading faiss with AVX2 support.
Successfully loaded faiss with AVX2 support.
Traceback (most recent call last):
  File "D:\TrackAndReID\Yolov5-Deepsort-Fastreid-main\person_search_reid.py", line 119, in <module>
    yolo_reid = yolo_reid(cfg, args, path=args.video_path)
  File "D:\TrackAndReID\Yolov5-Deepsort-Fastreid-main\person_search_reid.py", line 32, in __init__
    self.person_detect = Person_detect(self.args, self.video_path)
  File "D:\TrackAndReID\Yolov5-Deepsort-Fastreid-main\person_detect_yolov5.py", line 71, in __init__
    self.model = attempt_load(opt.weights, map_location=self.device)  # load FP32 model
TypeError: attempt_load() got an unexpected keyword argument 'map_location'

报错原因

yolov5的版本做了升级了。attempt_load的参数做了调整。如下代码:

def attempt_load(weights, device=None, inplace=True, fuse=True):
    # Loads an ensemble of models weights=[a,b,c] or a single model weights=[a] or weights=a
    from models.yolo import Detect, Model

解决方法

将map_location改为device

 # Load model
 self.model = attempt_load(opt.weights, device=self.device)  # load FP32 model
 类似资料:

相关阅读

相关文章

相关问答