test1.py 614 B

12345678910111213141516171819202122
  1. #!/usr/bin/env python
  2. # -*- coding:utf-8 -*-
  3. from ultralytics import YOLO
  4. # Create a new YOLO model from scratch
  5. model = YOLO('yolov8n.yaml')
  6. # Load a pretrained YOLO model (recommended for training)
  7. model = YOLO('yolov8n.pt')
  8. # Train the model using the 'coco128.yaml' dataset for 3 epochs
  9. results = model.train(data='coco128.yaml', epochs=3)
  10. # Evaluate the model's performance on the validation set
  11. results = model.val()
  12. # Perform object detection on an image using the model
  13. results = model('https://ultralytics.com/images/bus.jpg')
  14. # Export the model to ONNX format
  15. success = model.export(format='onnx')