AlexeyAB / darknet

YOLOv4 / Scaled-YOLOv4 / YOLO - Neural Networks for Object Detection (Windows and Linux version of Darknet )
http://pjreddie.com/darknet/
Other
21.65k stars 7.96k forks source link

Average Precision of a class is lower when trained as a single class configuration compared to training as a multi class configuration #4143

Open indrajitkurmi opened 4 years ago

indrajitkurmi commented 4 years ago

Hi all, I have recently started working with the darknet and trained a newly available FLIR thermal dataset with a multi-class configuration (3 classes - Person, bicycle, car). In this training instance for different iterations such as 4000, 5000 and 6000 iterations ( person class average precision are 77.25%, 76.29% and 72.41%). However, I wanted only single-class classification i.e detecting persons within FLIR thermal dataset hence I changed the configuration files, dataset annotations, names as described here:-

https://github.com/AlexeyAB/darknet#how-to-train-to-detect-your-custom-objects

i.e for single class config files ( filters preceding Yolo layer to be 5+3*n ie. 18 for single class and classes within Yolo layer to be: classes = 1)

[convolutional] filters=18 activation=linear

[yolo] mask = 6,7,8 anchors = 10,13, 16,30, 33,23, 30,61, 62,45, 59,119, 116,90, 156,198, 373,326 classes=1

and my .txt files for each image look likes for single class 0 0.100781 0.474609 0.020313 0.039062

However after training with these new configurations for single-class, for almost all iterations such as 4000, 5000 and 6000 iterations ( person class average precision are 73.45, 64.24 and 68.61%)

Could anyone point out why training with single-class classification configuration always yields lower average precision compared to a multi-class configuration? am I making some error in configurations or is there any general explanation for this?

Thank you for your time and help.

Thanks and Best Regards Indrajit Kurmi

AlexeyAB commented 4 years ago

@indrajitkurmi Hi,

indrajitkurmi commented 4 years ago

@AlexeyAB Hi, Thank you for your quick response.

AlexeyAB commented 4 years ago

In this training instance for different iterations such as 4000, 5000 and 6000 iterations ( person class average precision are 77.25%, 76.29% and 72.41%).

However after training with these new configurations for single-class, for almost all iterations such as 4000, 5000 and 6000 iterations ( person class average precision are 73.45, 64.24 and 68.61%)

Just try to train more iterations. if the mAP will be still higher in the first case, then check the annotations using yolo_mark. https://github.com/AlexeyAB/Yolo_mark

indrajitkurmi commented 4 years ago

@AlexeyAB Hi,

Could these instances of person class visible in images but not annotated be one of the reasons for this behavior? Does YoloV3 become super specific in identifying instances of a single class and identify persons who are not annotated? If this is the reason, I was wondering why it is different in multi-class instances and the same not annotated instances of person class not identified as the person class causing the same drop in average precision?

I am going to annotate all the instances of person class in all the images of the dataset and retrain to see if that helps.

However, it would be really helpful if you could provide any further insight or details regarding this learning behaviour.

Thanks for your help and guidance.

AlexeyAB commented 4 years ago

I could identify some instances of person class visible in images but not annotated or labeled (both in training and validation images).

Do you want to detect Persons in both cases? So all objects (Persons) must be labeled on all images.

Read: https://github.com/AlexeyAB/darknet#how-to-improve-object-detection

check that each object that you want to detect is mandatory labeled in your dataset - no one object in your data set should not be without label. In the most training issues - there are wrong labels in your dataset (got labels by using some conversion script, marked with a third-party tool, ...). Always check your dataset by using: https://github.com/AlexeyAB/Yolo_mark


Could these instances of person class visible in images but not annotated be one of the reasons for this behavior? Does YoloV3 become super specific in identifying instances of a single class and identify persons who are not annotated?

This is the reason. Any Human or ML-algorithm will be confused if he is simultaneously trained to detect an object and not detect the same object.

If this is the reason, I was wondering why it is different in multi-class instances and the same not annotated instances of person class not identified as the person class causing the same drop in average precision?

I don't know.