SoundLoader: A Function To Create Custom Dataloader in PyTorch for An Environmental Sound Classification
Import Classes from SoundCustomDataloader_Train.py and SoundCustomDataloader_Test.py to Get the Training and Test Dataset for Sound Classification. Forward this dataset as an argument to dataloader in PyTorch.
Sample Example Code:
- import torch
- from torch.utils.data import DataLoader
- from torchvision.transforms import transforms
- from SoundCustomDataloader_Train import Sound_Data_Train
- from SoundCustomDataloader_Test import Sound_Data_Test
- transform = transforms.Compose([transforms.Resize([224,224]),transforms.ToTensor(),transforms.Normalize(mean=[0.485], std=[0.229])])
- batch_size=32
- Training_Data=Sound_Data_Train(transform=transform)
- Test_Data=Sound_Data_Test(transform=transform)
- Train_loader=DataLoader(dataset=Train_Data,batch_size=batch_size,shuffle=True) # Pytorch dataloader for Training
- Test_loader=DataLoader(dataset=Test_Data,batch_size=batch_size,shuffle=True) Pytorch dataloader for Test