-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel_export.py
More file actions
31 lines (22 loc) · 824 Bytes
/
Copy pathmodel_export.py
File metadata and controls
31 lines (22 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from ultralytics import YOLO
def export_model(model_path: str, output_path: str):
"""
Exports a YOLO model to ONNX format.
Args:
model_path (str): Path to the YOLO model file.
output_path (str): Path where the ONNX model will be saved.
"""
try:
# Load the YOLO model
model = YOLO(model_path)
# Export the model to ONNX format
model.export(format='onnx')
print(f"Model exported successfully to {output_path}")
except Exception as e:
print(f"Error exporting model: {e}")
if __name__ == "__main__":
# Example usage
model_path = "models_pose/yolo11x-pose.pt" # Path to your YOLO model
# Desired output path for the ONNX model
output_path = "models_pose/yolo11x-pose.onnx"
export_model(model_path, output_path)