laugh12321 / TensorRT-YOLO

🚀 你的YOLO部署神器。TensorRT Plugin、CUDA Kernel、CUDA Graphs三管齐下,享受闪电般的推理速度。| Your YOLO Deployment Powerhouse. With the synergy of TensorRT Plugins, CUDA Kernels, and CUDA Graphs, experience lightning-fast inference speeds.
https://github.com/laugh12321/TensorRT-YOLO
GNU General Public License v3.0
540 stars 67 forks source link

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

Closed Tom-Teamo closed 5 months ago

Tom-Teamo commented 5 months ago

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?

laugh12321 commented 5 months ago

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

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

https://github.com/ultralytics/yolov5/issues/10121

Tom-Teamo commented 5 months ago

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

laugh12321 commented 5 months ago

ultralytics没有提供hubconf.py

Tom-Teamo commented 5 months ago

ok 👍