| from ultralytics import YOLO | |
| # Load a pretrained YOLO model (recommended for training) | |
| model = YOLO('yolov8l.pt') | |
| results = model.train(data='path_to_data/data.yaml', epochs=3) | |
| # Evaluate the model's performance on the validation set | |
| results = model.val() | |
| # Perform object detection on an image using the model | |
| results = model('path_to_test_image') | |
| # Export the model to ONNX format | |
| success = model.export(format='onnx') |