Balancing Datasets

I’m working on Detection of pneumonia project but I’m stuck at the first step on how to balance datasets which have images only. Can I get the code to balance the datasets using Pytorch . I have training , testing and validation sets which have images only.

There is no general code for balancing a dataset. Yet there are methods for this purpose like data augmentation which means that you add artificial samples to your dataset so that each class has the same number of items. imgaug is a python library specifically developed for augmenting image data. You can use it to balance your datatset.