Reading Images in .mat format in Python

I think writing a custom Dataset class with scipy.io.loadmat() in your __getitem__() method would be the easiest option. Although with 11 channels you won’t be able to convert/transform them with PIL.

It depends how you have your dataset structured but something like this:

class MyDataset(Dataset):
    """custom dataset for .mat images"""

    def __init__(self, list_of_urls):
        self.list_of_urls = list_of_urls

    def __len__(self):
        return len(self.list_of_urls)

    def __getitem__(self, index):
        image_url = self.list_of_urls[index]
        image = scipy.io.loadmat(image_url)
        label = ...
        ...