Dataset should only take one sample and Dataloader would stack them to one batch automatically.
I’m not sure you take the entire VOC dataset in Dataset, if so it’s the wrong way.
I think you can find VOCDataset in torchvision which should be a good example.