Open yingzhec opened 5 years ago
On 14.11.2018 22:49, yingzhec wrote:
Hi, I'm working on a multiple class detection with imbalanced training data, which means the distribution of images on each class is far from uniform. Any part of code in AlexeyAB repository could solve the problem? Thanks in advance.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/AlexeyAB/darknet/issues/1935, or mute the thread https://github.com/notifications/unsubscribe-auth/AHjhQ8B2SAIRphIvcW5rpTSaYON2x2hZks5uvI_egaJpZM4YepVw.
Yolov3 allows multiclass labeling/prediction. Depending what you consider unbalanced(count nr of object(bboxes) not only nr of images) this could solve your "unbalanced" classes problem.
I personally also prefer alexs repo but this is not exclusive to that repo but a feature of yolov3(no plain softmax anymore).
I worry about the imbalanced training data could affect the weights generated from training. I have an idea of modifying the loss function in yolo but haven't know where to start
Hi, Just train as usual.
There are some features for imbalanced training - but both work poorly:
set focal_loss=1
in each of 3 [yolo]
layer in your cfg-file - Focal Loss more increase probability of such classes which are rare: https://github.com/AlexeyAB/darknet/blob/14ed6fcb6e31dd111fc5c35c31ffa6e45fe52737/src/yolo_layer.c#L121
set adam=1
in the [net]
section in your cfg-file - ADAM optimizer changes more such weights which are changed rarely: https://github.com/AlexeyAB/darknet/blob/14ed6fcb6e31dd111fc5c35c31ffa6e45fe52737/src/convolutional_kernels.cu#L685
But even imbalance training will work better without these features ) May be we should check implementations again.
@AlexeyAB Hello, if adding focal_loss=1 is added in 3 [yolo] layers? Can you add the focal_loss function? Thank you very much!
@lvshuaigg
Can you add the focal_loss function?
It is already added: https://github.com/AlexeyAB/darknet/blob/14ed6fcb6e31dd111fc5c35c31ffa6e45fe52737/src/yolo_layer.c#L121-L139
You can use focal_loss=1
in the [yolo]
layers in cfg-file.
And you can use adam=1
in the [net
] section in cfg-file.
@AlexeyAB Thank you very much!
@AlexeyAB would manually duplicating certain minority class work for rebalancing classes? for example replicating the same line multiple times in a file 15 x x x x (org) 15 x x x x (rep1) 15 x x x x (rep2) 0 x x x x 1 x x x x 2 x x x x
@arkjiang
No, multiple identical lines will not solve imbalancig problem, and willn't have any influence at all.
You can duplicate lines with image-path in train.txt
- it can solve imbalancing problem.
@AlexeyAB what if the class imblance is embedded in each image ? For example, all images has 5 timese more Class A object than Class B. Is there a way to balance up class B
@arkjiang
what if the class imblance is embedded in each image ? For example, all images has 5 timese more Class A object than Class B. Is there a way to balance up class B
There is no simple way to balance it. You should add images with class B.
But any imbalance partially will be solved automatically, since there is used decay
https://github.com/AlexeyAB/darknet/issues/1943#issuecomment-439560675
Hi, I'm working on a multiple class detection with imbalanced training data, which means the distribution of images on each class is far from uniform. Any part of code in AlexeyAB repository could solve the problem? Thanks in advance.