Error: in the file data/coco.names number of names 80 that isn't equal to classes=13

4.8k views Asked by At

I was using Google Colab to train Yolo-v3 to detect custom objects. I'm new to Colab, and darknet.

I used the following command for training:

!./darknet detector train "/content/gdrive/My Drive/darknet/obj.data" "/content/gdrive/My Drive/darknet/cfg/yolov3-PID.cfg" "/content/gdrive/My Drive/darknet/backup/yolov3-PID_final.weights" -dont_show

The training finished as follows, and it didn't display any details of the epochs (I don't know how many epochs actually run). Actually, it took very short time until it displayed Done!, and saved the weights as shown in the above image enter image description here

Then, I tried to detect a test image with the following command:

!./darknet detect "/content/gdrive/My Drive/darknet/cfg/yolov3-PID.cfg" "/content/gdrive/My Drive/darknet/backup/yolov3-PID_final.weights" "/content/gdrive/My Drive/darknet/img/MN 111-0-515 (45).jpg" -dont-show

However, I got the following error:

Error: in the file data/coco.names number of names 80 that isn't equal to classes=13 in the file /content/gdrive/My Drive/darknet/cfg/yolov3-PID.cfg

Even, the resulting image didn't contain any bounding boxes, so I don't know if the training worked or not. enter image description here

Could you pls advise what might be wrong with the training, and why the error is referring to coco.names, while I'm using other files for names, and configuration?

3

There are 3 answers

0
zakk616 On

i was having the same problem when i was training custom model in colab. i just cloned darknet again in another folder and edited coco.name and moved it to my training folder. and it worked!!

0
rdxvicky1 On

Nice work!!! coming this far. Well, everything is fine, you just need to edit the data folder of the darknet. By default it's using coco label, go to darknet folder --> find data folder --> coco.names file --> edit the file by removing 80 classes(in colab just double click to edit and ctrl+s to save) --> Put down your desired class and it's done!!!

0
B200011011 On

You did not share the yolov3-PID.cfg, obj.data and coco.names. I am assuming coco.names contain 80 classes as in the repo.

The error likely is in obj.data, where it seems your goal here is to detect 13 custom objects. If this is the case, then set classes=13, also replace names=data/coco.names with names=data/obj.names. Here, obj.names file should contain 13 lines for the custom class names. Also modify yolov3-PID.cfg to contain same amount of classes.

I suggest using this repo below if you are not already using this. It contains google colab training and inference script for yolov3, yolov4.

Here are the instructions for custom object detection training.