python-3.xdeep-learningyoloyolov5

How to resume/continue from already trained YOLO5 Training Epoch?


I have started the Yolo5 Training with custom data

The command I have used:

!python train.py --img 640 --batch-size 32 --epochs 5 --data /content/drive/MyDrive/yolov5_dataset/dataset_Trafic/data.yaml --cfg /content/drive/MyDrive/yolov5/models/yolov5s.yaml  --name Model

Training started as below & completed:

enter image description here

For resuming/continue for more epoch I have below command

!python train.py --img 640 --batch-size 32 --epochs 6 --data /content/drive/MyDrive/yolov5_dataset/dataset_Trafic/data.yaml --weights /content/drive/MyDrive/yolov5/runs/train/Model/weights/best.pt --cache --exist-ok

enter image description here

But still the Training start from the scratch. How to continue from previous epoch.

Also I tried with resume command

!python train.py --epochs 10 --resume

but I am getting below error message

enter image description here


Solution

  • I'm not sure if this would work for YOLOv5 but this is how to resume training in YOLOv8 from the documentation:

    Python

    from ultralytics import YOLO
    model = YOLO('path/to/last.pt')  # load a partially trained model
    results = model.train(resume=True)
    

    CLI

    yolo train resume model=path/to/last.pt