I want to train the YOLOv7 with a custom dataset, the dataset is from COCO, but I want to train it only for sheep class. I have in the coco.yaml file:
path: /content/drive/MyDrive/Sheep/yolov7
train: data/train/images
val: data/val/images
test: data/val/images
nc=1
names: [ 'sheep' ]
In yolov7.yaml I have also set the number of classes to 1:
nc: 1 # number of classes
depth_multiple: 1.0 # model depth multiple
width_multiple: 1.0 # layer channel multiple
...
When I want to train the model in Colab, I get an error saying: assert mlc < nc, 'Label class %g exceeds nc=%g in %s. Possible class labels are 0-%g' % (mlc, nc, opt.data, nc - 1) AssertionError: Label class 1 exceeds nc=1 in data/coco.yaml. Possible class labels are 0-0
I understood that the labels have to start from 0, because i have nc=1
so I changed in every .txt file the labels to 0
where sheep are detected. I don't have any other class in the label's files. Here's an example of a label .txt file:
0 0.2 0.6652267818574514 0.05 0.11231101511879049
0 0.346875 0.6965442764578834 0.046875 0.1101511879049676
0 0.4578125 0.6889848812095032 0.040625 0.12095032397408208
0 0.49140625 0.6987041036717062 0.0515625 0.1101511879049676
0 0.553125 0.6922246220302376 0.05625 0.11447084233261338
0 0.5859375 0.6695464362850972 0.04375 0.07775377969762419
0 0.2890625 0.6781857451403888 0.034375 0.12095032397408208
Do I need to change anything in train.py ? I left the code as it was in https://github.com/WongKinYiu/yolov7
I'm new to machine learning so please help me solve this. Thank you!