AlexeyAB / darknet

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

How to use the focal loss while training my classification model #5283

Open spaul13 opened 4 years ago

spaul13 commented 4 years ago

I want to add focal loss for my dataset training for classification to tackle the class imbalance problem. As I went through the focal_loss only applicable for yolo layer. Can anyone please tell me how to add a yolo layer at the end of any classification model?

image

In my custom cfg file, I replace the last layer from [softmax] groups=1 to _[yolo] focal_loss = 1_

before the last layer, I have a convolution filter (1X1) where # of filters = # of output labels or classes. The configuration file is also attached here.

myconvnet_yolo_tiny_focal_loss.txt

that gives me the error shown in the picture above. Can anyone please tell me how to get rid of the error?

AlexeyAB commented 4 years ago

No, you can't use focal_loss for training Classification model.

spaul13 commented 4 years ago

@AlexeyAB can u please suggest me any other techniques other than using focal_loss for classification model to tackle the class imbalance problem?

what I already tried is that I have 100 classes and the max class has 64 images so I repeat same files in .list multiple times to make the # of images under each class to be 64 (similar to oversampling) but for me with so many classes and diverse # of images under each class, it's not working well as expected.

Can u please tell me any other techniques for the classification model?