Siddhu Neehal
Siddhu Neehal

Reputation: 31

re-training a pre-trained yolo model

i am working on object detection using yolov8 in google colab. i trained a yolov8 model and downloaded the best.pt weights after the training was over. now for better results i wish to train it for more epochs (over the same dataset) but by loading the pre-trained weights i downloaded earlier. is it possible to do this? i found some info about resuming the training for an interruption but this is not the case here i guess.

cli:
%cd {HOME}
!yolo task=detect resume model=barcode_detection.pt data={dataset.location}/data.yaml epochs=100 imgsz=800 plots=True

python:
model = YOLO("barcode_detection.pt")
results = model.train(task=detect, epochs=200, save_period = 10, resume=True, data={dataset.location}/data.yaml, plot=True )

the above is the code i was trying to use based on the documentation from https://docs.ultralytics.com/modes/train/ but it didnot work.

Upvotes: 3

Views: 12025

Answers (2)

adem hamici
adem hamici

Reputation: 11

You just have to change this line :

!yolo task=detect mode=train model=yolov8s.pt data=data.yaml epochs=20 imgsz=640 plots=True

to this line:

!yolo task=detect mode=train model=/content/drive/MyDrive/runs/detect/train/weights/last.pt data=data.yaml epochs=20 imgsz=640 plots=True

Upvotes: 1

AlbertSawZ
AlbertSawZ

Reputation: 133

YOLOv8 models are pretrained on the COCO dataset, so when you trained the model on your dataset you basically re-trained it on your own data.

In summary, what you're doing is correct since you're taking your trained weights.

How to save a YOLOv8 model after some training on a custom dataset to continue the training later?

Upvotes: 4

Related Questions