Loading multiple images from same class

I am having a dataset with multiple classes with each class having multiple images.
While running the loop over data loader I want to get two images from each class in every iteration.
I would like to have an iterator like

for image1, image2, label in dataloader:

Please let me know how can I achieve this.

Blockquote
https://pytorch.org/tutorials/beginner/data_loading_tutorial.html\

Look this official tutorial. You should rewrite the getitem method for your custom dataset which inherite from torch.utils.data.Dataset module.

1 Like

@Nathan_Drake Thanks. Its done.

Hello,

The link seems to be broken.
@harshj94 Can you please share how you did that ?
Were u able to use torchvision.datasets.ImageFolder in some way ?

The updated link is: Data Loading Tutorial

You need to override the _len_ and _getitem_ function.
You can do one-time processing needed in the init function.

Thanks a lot !
I got it and finally manage to build a multi-inputs network (2 images and 1 vector of custom features).