spacewalk01 / yolov11-tensorrt

C++ implementation of YOLOv11 using TensorRT API
https://github.com/ultralytics/ultralytics
GNU Affero General Public License v3.0
176 stars 34 forks source link

Engine Serialisation Error #3

Closed Addoxx closed 1 month ago

Addoxx commented 1 month ago

Hello spacewalk01,

Thanks for sharing your Yolo11 TensorRT implementation!

I am facing this issue where I am not able to convert the weights from PyTorch to an engine file for me to use in this module. Can you please guide me on how to convert the PyTorch file?

Thanks in advance,

spacewalk01 commented 1 month ago

First use the following code to convert pytorch model into onnx format. Then you can input your onnx model into the program to generate an engine

from ultralytics import YOLO

# Load the YOLO model
model = YOLO("yolo11s.pt")

# Export the model to ONNX format
export_path = model.export(format="onnx")

print(f"Model exported to {export_path}")