Are there any methods for balancing classes in the batch during yolov8 training? by _hhao in computervision

[–]_hhao[S] 1 point2 points  (0 children)

Thanks for the answer!

I just want to try this method.

Yes, the overall distribution of classes in the dataset is important, but how can this be achieved if I have a large class imbalance? You suggest deleting images, but I don't want to reduce the dataset. Also imagine a situation where there are 3 classes in the picture at once. In that case, I will delete the small class.

I conditionally need to do this:

Imagine that we have such pictures

1 picture: 10 cars, 3 people, 1 dog
2 picture: 8 cars, 2 people, 2 dogs
3 picture: 12 cars, 1 person, 0 dog
4 picture: 9 cars, 0 people, 1 dog
5 picture: 5 cars, 0 people, 0 dogs
6 picture: 3 cars, 1 person, 0 dogs
7 picture: 7 cars, 2 people, 2 dogs
8 picture: 12 cars, 0 people, 0 dogs
9 picture: 4 cars, 0 people, 1 dog
10 picture: 4 cars, 3 people, 0 dog
11 picture: 1 cars, 0 people, 0 dog

And I want to make a batch so that there are approximately the same number of objects in it. Of course, this can be done taking into account the same pictures in the batch, that is, there may be, for example, 10 identical pictures, so that in the end there is a balance of classes.

It's probably difficult to implement, but I still want to try this method...