2

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

thangaraj1980
  • 141
  • 2
  • 11

2 Answers2

2

Open runs/train/Model/opt.yaml file and change epochs no. try again

!python train.py  --weights /content/drive/MyDrive/yolov5/runs/train/Model/weights/last.pt  --resume
David Arenburg
  • 91,361
  • 17
  • 137
  • 196
Ashish1KD
  • 21
  • 4
  • 1
    The provided solution is not clear for readers. Please, clarify it. – Hamed Baziyad Jul 10 '22 at 13:09
  • 2
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 11 '22 at 13:28
  • 1
    This works for YOLOv7 too – David Arenburg Dec 26 '22 at 09:15
1

Try this: In the runs folder(where your previous weights are stored), find a file with name "args.yaml" inside the file, augment the epochs count by the no. of epochs you want to train your model now. For example: If previously your model was trained for 100 epochs then, the args.yaml file would have an attribute: "epochs: 100" Lets say you was to continue training for 50 more epochs then change epochs to 150 i.e. "epochs: 150" save the file and then execute training command.