from ultralytics import YOLO

# Load a COCO-pretrained YOLO12n model
model = YOLO("yolo12n.pt")

# Train the model on the COCO8 example dataset for 100 epochs
results = model.train(data="coco8.yaml", epochs=100, imgsz=640)
print(results)

# Evaluate the model's performance on the validation set
results = model.val()
print(results)

# Perform object detection on an image using the model
results = model("https://ultralytics.com/images/bus.jpg")
print(results)

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