Accepted way to over/under sample with imbalanced dataset in fastai2

What is the/an accepted way to deal with imbalanced data in fastai2? I found this callback but it doesn’t seem to have an explanation how it should work or how I would apply it to my data nor are the arguments documented. I’m working with image data that is loaded into the datablock:

datasets = DataBlock(blocks = (ImageBlock, CategoryBlock),
                 batch_tfms=aug_transforms(size=224, min_scale=0.75))
dls = datasets.dataloaders(path)

and my learner is:

learn = cnn_learner(dls, resnet34, metrics=accuracy)

The two categories are highly imbalanced and I was looking for a straightforward way to deal with that.

Does anyone have any insight into this?

I just updated this notebook that you can look at: and is based on this thread

Thanks, I’m going to try that out. Is there a reason when you do show_batch it still shows up as 70/30? is that just a random fluke?