yolov8模型转onnx

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)

 

简化

from ultralytics import YOLO

# Load a YOLOv8 model
model = YOLO("device.pt")

# Export the model
model.export(format="onnx", opset=12, simplify=True, dynamic=False, imgsz=640)

  

 

 

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

 

posted @ 2024-09-19 16:56  流逝的轻风  阅读(512)  评论(0编辑  收藏  举报