we want to train a DNN on a dataset, which consists of multiple datasets. Each dataset is a folder and has it’s own label. Now we have to combine these datasets, but don’t know, how to do this.
root consists of -> multiple subfolders always consists of -> multiple sub-subfolders always consists of -> pictures
Our idea (example with two datasets):
We load two datasets as trochvision.ImageFolder and combinde them with ConcatDataset.
datadir = “…/data/dir1…”
train_transforms = transforms.Compose([transforms.Resize(224),
train_data = datasets.ImageFolder(datadir,
trainloader = torch.utils.data.DataLoader(train_data,
train_data = ConcatDataset((datasets.ImageFolder(datadir2),datasets.ImageFolder(datadir)))
But now, we are not able to get the labels via “print(trainloader.dataset.classes)” or
“for values,labels in trainloader:
Is there a way to combine multiple datasets while keeping the labels?
We would be very greatful for an answer!
(this maybe helps to understand our folder structure):