I was wondering if I could get a better understanding of data Augmentation in PyTorch. From what I know, data augmentation is used to increase the number of data points when we are running low on them. So we use
transforms to transform our data points into different types. I am suing data transformation like this:
transform_img = transforms.Compose([ transforms.RandomResizedCrop(224), transforms.RandomHorizontalFlip(), transforms.ToTensor(), # transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]) ])
class dataload(Dataset): def __init__(self, x, transform=None): self.data = x self.transform = transform def __len__(self): return len(self.data) def __getitem__(self, i): img = Image.open(self.data[i]) # img = img.transpose((2, 0, 1)) # img = torch.from_numpy(img).float() tmp = np.int32(filenames[i].split('/')[-1].split('_')) label = np.zeros(67) label[tmp] = 1 label = torch.from_numpy(label).float() if self.transform: img = self.transform(img) return img,label
train_dataloader = dataload(filenames, transform=transform_img)
Now, it seems to work but I don’t get one thing. It does the transformation but it doesn’t increase the number of data points. I was hoping that each label would have 2 extra images since we are doing that transformation. But it doesn’t seem to do that. The total number of training samples is still the same.
So am I getting something wrong about augmentation or have I implemented this in the wrong way?