How to load image dataset into pytorch

i have a dataset ( image and mask) i want to do preprocessing then unet but i cannot find a way to load them on pytorch most of the way online are very specific for datasets like MNSIT

1 Like

You could write a custom Dataset to load the images and their corresponding masks.
Have a look at the Data loading tutorial for a basic approach.
Here is a dummy implementation using the functional API of torchvision to get identical transformations on the data and target images.

1 Like

thank you for replying , the problem with this tutorial is the data is already downloaded and available on torchvision , my data is just on my pc … maybe i am missing something here !

The second link shows a simple implementation of a custom Dataset, where your data is stored locally.
You would just have to pass the paths for the images and masks.

Hi, I have a similar problem where I want my dataset to be containing both input and output as images. I basically want to train a pytorch model (grayscale images to colour images translation) using fastai. I would like to know how to load this format of data.