AlexeyAB / darknet

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

Will cropping images in training set negatively affect model? #3275

Open LukeAI opened 5 years ago

LukeAI commented 5 years ago

Hi,

I'm trying to work out an approach to balancing my dataset, which is a subset of a google openimages - some classes are represented orders of magnitude more than others and I am hesistant to simply throw away data. The approach I want to try next is roughly: 1) Add a single instance of every image to the training set. 2) Crop out instances of the majority class from entire dataset and then add these cropped images to the dataset. keep adding these cropped images to training set until number of instances of 2nd majority class is close to number of instances of 1st majority class. 3) Crop out instances of second majority class and repeat (2) 4) keep going until all images have been cropped down to the minority class and dataset is roughly balanced.

This approach would mean that no instance of any class would be repeated more often than any other instance of the same class. My concern is that the minority classes will end up being predominantly represented in training by heavily cropped images. I'm not sure but I don't think this would matter in a two-stage object detector but I'm concerned that it might be a problem for a one-stage detector if, for some classes, it was predominantly trained on images that were cropped to various degrees.

The alternative to doing this would be undersampling ie. just throwing away most of the data which I'm hesistant to do.

Anyway, it would be really great to get some opinions on this in the context of Yolov3? Is yolov3 sufficiently robust at scale-invariance that training on many examples that are cropped/larger than what they are likely to be at test time?

AlexeyAB commented 5 years ago

@LukeAI Hi,

Is yolov3 sufficiently robust at scale-invariance that training on many examples that are cropped/larger than what they are likely to be at test time?

No.

If you cropped objects, then you should keep the same size of them. Simply insert objects in their original size on a white background, this will work more or less normally.

LukeAI commented 5 years ago

ok, thanks very much for your perspective. I will try what you have suggested and report back here. Do you think it would be better to fill in undesirable objects with white squares or to clip out desirable objects and move them to white backgrounds?

AlexeyAB commented 5 years ago

I don't know )