It is really as simple as defining a class (preferable a subclass of Dataset) that has __len__ and __getitem__. The len is typically trivial and getitem should return a single record from the dataset for any number 0…len-1. You might look at the data loading tutorial 23 for inspiration. You can really return anything from the dataset, but so a pair of tensors would probably fit best for your application.
Our book 4 also has some elementary examples.
The image folder really only does the same and I’d say you’re ready to just dive into the source 4 after the tutorial.
Best regards
Thomas
PS I might add that a considerable amount of magic happens in the dataloader to get batching, parallel loading from multiple workers etc., but you wouldn’t need to concern yourself with it at this point.