I have trained a custom YOLOv8s model on my dataset which has 1 class - "Employee". I want the original YOLOv8s model (with 80 classes) to be my base model and do transfer learning from my custom model. I tried achieving this with the following command:
yolo task=detect mode=train data=data.yaml model=yolov8s.yaml pretrained=yolov8s.pt epochs=25 imgsz=640 plots=True
But this returns me the following error:
RuntimeError: Dataset 'data.yaml' error data.yaml 'names' length 1 and 'nc: 80' must match.
This issue arises because the number of classes in the base YOLOv8 model is not matching the number of classes in the custom model I have trained with. Is it necessary that the number of classes in the base and custom YOLOv8 model should be the same?
The YOLOv8 Docs doesn't give a proper code which explains how transfer learning can be done.
I found this answer, it seems to apply to your issue. https://github.com/ultralytics/ultralytics/issues/7793#issuecomment-1908622002
Especially this part: