Classification with unbalanced classes and big images

I am looking a code for a classification program with very unbalanced classes and big images (2500x1500) where details are very importants so with no resizing before enter in the neural network.
Thank you
Best regards

nobody has an answer ?

Hi Sylvain!

You say “classification” so I assume that you are dealing with (potentially
multi-class) classification, but not semantic segmentation.

Unless you have a very large number of classes, you would typically
use CrossEntropyLoss as your loss criterion. If you have enough
samples of your under-represented classes, I would suggest sampling
those classes more heavily, e.g., with WeightedRandomSampler. If you
don’t have enough samples to use WeightedRandomSampler without
duplicating samples within a batch, then user the weight constructor
argument of CrossEntropyLoss to reweight the underrepresented
classes in the loss.

2500x1500 is not excessively big. Have you tried any of the common
image classification networks on images of this size?

I was able to forward and backward pass a batch of two (three-channel)
2500x1500 images through torchvision.models.resnet18 on a gpu
4 GB of memory.

Note that torchvision’s resnet networks have are agnostic about the size
of the input image (as they have an AdaptiveAvgPool2d layer just
before their final fully-connected layer).


K. Frank

Ok thank you I have two trainings to do, one with 600 classes and the other with 10 classes. 600 classes is what you call very lot classes ?
Thank you very much

Are all images must have same size before enter into resnet ?

Thank you