D:\Project\yolov5prune-6.0\venv\Scripts\python.exe D:\Project\yolov5prune-6.0\detect.py
detect: weights=best.pt, source=dataset\images\val, imgsz=[512, 512], conf_thres=0.25, iou_thres=0.45, max_det=1000, device=cpu, view_img=False, save_txt=False, save_conf=False, save_crop=False, nosave=False, classes=None, agnostic_nms=False, augment=False, visualize=False, update=False, project=runs\detect, name=exp, exist_ok=False, line_thickness=3, hide_labels=False, hide_conf=False, half=False, dnn=False
YOLOv5 2022-1-5 torch 2.1.1+cpu CPU
Traceback (most recent call last):
File "D:\Project\yolov5prune-6.0\detect.py", line 244, in <module>
main(opt)
File "D:\Project\yolov5prune-6.0\detect.py", line 239, in main
run(**vars(opt))
File "D:\Project\yolov5prune-6.0\venv\lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "D:\Project\yolov5prune-6.0\detect.py", line 79, in run
model = DetectMultiBackend(weights, device=device, dnn=dnn)
File "D:\Project\yolov5prune-6.0\models\common.py", line 309, in __init__
model = attempt_load(weights if isinstance(weights, list) else w, map_location=device)
File "D:\Project\yolov5prune-6.0\models\experimental.py", line 96, in attempt_load
ckpt = torch.load(attempt_download(w), map_location=map_location) # load
File "D:\Project\yolov5prune-6.0\venv\lib\site-packages\torch\serialization.py", line 1014, in load
return _load(opened_zipfile,
File "D:\Project\yolov5prune-6.0\venv\lib\site-packages\torch\serialization.py", line 1422, in _load
result = unpickler.load()
File "D:\Project\yolov5prune-6.0\venv\lib\site-packages\torch\serialization.py", line 1415, in find_class
return super().find_class(mod_name, name)
AttributeError: Can't get attribute 'DetectionModel' on <module 'models.yolo' from 'D:\\Project\\yolov5prune-6.0\\models\\yolo.py'>
Process finished with exit code 1
错误源码