0

I am using Google Colab to train and test my network. I have been working with it the past few days and following your tutorial which worked fine.

I wanted to create my own dataset. So I labeled all my images using LabelImg (I set format to Yolo). I ended up with 2 classes. So I created a custom_data.yaml file in where I put my nc to 2. I edited the coco128.yaml to match those 2 classes.

But whenever I want to start the training process I get this error(AssertionError):

> Traceback (most recent call last):   File "train.py", line 667, in
> <module>
>     main(opt)   File "train.py", line 562, in main
>     train(opt.hyp, opt, device, callbacks)   File "train.py", line 238, in train
>     assert mlc < nc, f'Label class {mlc} exceeds nc={nc} in {data}. Possible class labels are 0-{nc - 1}' AssertionError: Label class 15
> exceeds nc=2 in /content/yolov5/data/custom_data.yaml. Possible class
> labels are 0-1

I am starting it with this command:

!python train.py --img 416 --batch 16 --epochs 3 --data /content/yolov5/data/custom_data.yaml --weights yolov5s.pt --cache

My custom_data.yaml looks like this:

train: ../train_data/images/train/  
val: ../train_data/images/val/  
nc: 2
names: ['Sapi terdeteksi pink-eye', 'Sapi bermata sehat'] 

I don't have any idea what I have to do.

desertnaut
  • 57,590
  • 26
  • 140
  • 166

1 Answers1

0

There is no issue in your YAML File. But, In your text file you should keep like below: Because index start with 0

0 0.156 0.321 0.254 0.198
1 0.574 0.687 0.115 0.301

Hope this will fix.

Ranjit Kumar
  • 273
  • 3
  • 16