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),
                 get_items=get_image_files, 
                 splitter=RandomSplitter(seed=42),
                 get_y=label_func,
                 item_tfms=Resize(460),
                 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)
learn.fine_tune(5)

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: https://github.com/asvcode/fmi/blob/master/tutorial_nbs/medical_imaging_tutorial.ipynb 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?