import warnings
from path import update_data_yml_path
warnings.filterwarnings('ignore')
from ultralytics import YOLO


if __name__ == '__main__':
    # 加载并设置配置文件数据集绝对路径
    update_data_yml_path()
    # 加载模型配置文件
    model = YOLO(model=r'yolo11.yml')
    # 加载预训练权重
    model.load(r'yolo11n.pt')
    model.train(
        data=r'data.yaml',
        imgsz=640,
        epochs=200,
        batch=16,
        workers=4,
        close_mosaic=30,
        device='0',
        optimizer='SGD',
        resume=False,
        project='runs/train',
        name='result',
        single_cls=False,
        cache=False
    )


