laugh12321/TensorRT-YOLO

[Question]: Why are the methods different when loading models?

Closed this issue · 4 comments

Hi, I am a new guy in object detection.

I looked into source code and found that when loading YOLOv8, it uses return YOLO(model=weights, verbose=False).model which is a self-implemented method. However in YOLOv5 and v9, it uses the torch.hub.load. So I wanna know what causes this difference?

由于大多数人使用的是官方仓库来训练YOLOv5YOLOv7YOLOv9模型,而不是通过ultralytics.YOLO进行训练。

当直接使用torch.load加载模型,且脚本不在项目目录下时,会出现ModuleNotFoundError: No module named 'models'的错误。这是YOLOv5的一个历史遗留问题。由于YOLOv7和YOLOv9是在YOLOv5的基础上进行修改的,因此它们也存在这个问题。ultralytics社区建议使用torch.hub.load来加载模型。

ultralytics/yolov5#10121

好的,感谢解答,请问为什么YOLOv8不使用torch.hub.load

ultralytics没有提供hubconf.py

ok 👍