I would suggest to write a custom Dataset as described here 4. This would allow you to define the logic to load and process each sample manually. Based on your description I guess the path and label might be stored as a string or tuple etc. so splitting them into a list containing image paths and the corresponding target tensor should work.