I want to train YOLO to only detect the class person. Therefor I downloaded the COCO dataset, adjusted the labels to only this class and changed the config files accordingly, I then trained YOLO by following the steps described in the section "Training YOLO on COCO" on this site https://pjreddie.com/darknet/yolo/. But the mean average precision (map) with my trained weights for the class person is much worse than the map for the same class when I use the trained weights from the same page under the caption "Performance on the COCO Dataset". I was wondering what could be the reason for this, and which data was used to train the weights available at the homepage.
2 Answers
Probably there's something wrong when you modify the cfg file (classes, filters, etc). Anyway what's the purpose of your task? Do you really need to retrain the model, or you only need to filter 1 class and make detection?
If you want to filter the Person label only out of 80 classes, you can simply do this workaround method. You don't need to retrain the model, you just need to use the weight provided by the author on yolo website.
For easy and simple way using COCO dataset, follow these steps :
- Modify (or copy for backup) the
coco.names
file indarknet\data\coco.names
- Delete all other classes except person
- Modify your cfg file (e.g.
yolov3.cfg
), change the 3 classes on line 610, 696, 783 from 80 to 1 - Change the 3 filters in cfg file on line 603, 689, 776 from 255 to 18 (derived from
(classes+5)x3
) - Run the detector
./darknet detector test cfg/coco.data cfg/yolov3.cfg yolov3.weights data/your_image.jpg
For more advance way using COCO dataset you can use this repo to create yolo datasets based on voc, coco or open images. https://github.com/holger-prause/yolo_utils .
Also refer to this : How can I download a specific part of Coco Dataset?

- 3,981
- 5
- 35
- 61
-
I tried the steps you described to only detect the class person, but this does not work. If I follow these steps nothing is detected and I get a map of 0% for the class person. – Bixilein Oct 03 '19 at 08:39
-
@Bixilein What repo are you using? If I remember correctly the original repo doesn't show any mAP during prediction. – gameon67 Oct 04 '19 at 00:01
-
I am using the repo from AlexeyAB, and I am using ./darknet detector map to calculate the mAP. – Bixilein Oct 07 '19 at 06:55
It would be much simpler, IMMO, to use the pretrained weights with the presupplied *.names, *.data and *.cfg. Then you run the detector for single images or for a list of image file names in the mode (I do not remember the details) where YOLO outputs a list of detections in the form of class name, confidence and bbox. You then simply ignore anything other than the "person" class.