from ultralytics import YOLO # Load a model model = YOLO('yolov8n-seg.pt') # build a new model from YAML # Train the model results = model.train(data='seg_magnet.yaml', epochs=150, imgsz=640)