yolov8模型转onnx

流逝的轻风 / 2024-09-20 / 原文

1.安装yolov8
# Install the required package for YOLOv8
pip install ultralytics

 

2.模型转换

from ultralytics import YOLO

# Load the YOLOv8 model
model = YOLO("yolov8n.pt")

# Export the model to ONNX format
model.export(format="onnx")  # creates 'yolov8n.onnx'

# Load the exported ONNX model
onnx_model = YOLO("yolov8n.onnx")

# Run inference
result = onnx_model.predict(source='1.png', save=True)
print(result)

 

 

参考: https://blog.csdn.net/qq_29402011/article/details/140937125