Weighting for Class Imbalance in Semantic Segmentation

Hi! I have a tiny dataset (n=69 images) for semantic segmentation. In this dataset, we have two classes with instances that occur in every image. We also have 3 classes that do not occur in every image, with one class only appearing in 26 images. I have created a custom torch.utils.data.Dataset for this dataset.

Am I able to balance this class imbalance, and how should I do so?