Custom color mapping in data loader for UNET image segmentation

I export my masks as a JPG with the following settings on GIMP.

So for example, with the following mask saved as a JPG, the Python program above reads 85 unique color values as opposed to 2 (green and white).