I want to train a multi-stream CNN model with pytorch. My data looks like this:
Two folder train1 and train2, under these two folders, there are 2 classes, 1 and 2, in each class there are bunch of images. The name of the pictures under train1 and train2 are same.
For pytorch, how can I input two images from train1 and train2 simutaneously. For example, if we set batch size as 1:
train1/1/a1.jpg and train2/1/a1.jpg should be returned by the data loader at the same time.
How can I implement this, or any other ideas to do this any help will be appreciated
Thanks
Your solution works well. I want to know how to set batch size in your this customized Dateset class?
for example: I want set batch-size as 5, so that I can get 5 images during the training process?
Wrap the Dataset in a DataLoader, where you can specify the batch_size besides other useful features like shuffling and the usage of multiple workers. Have a look at the docs for more information and maybe the Data loading tutorial for some more information on the data loading pipeline.