I have 100 images, I applied horizontal and vertical augmentation with a probability of 1 using Pytorch function RandomHorizontalFlip and RandomVerticalFlip. After this would my total number of images will be 300 or something else?
I have 100 images, I applied horizontal and vertical augmentation with a probability of 1 using Pytorch function RandomHorizontalFlip and RandomVerticalFlip. After this would my total number of images will be 300 or something else?
You can get 300 images if you keep the original 100 images then calling and store the return of two function separately, e.g:
from torchvision import transforms
import torch
trhf = transforms.RandomHorizontalFlip(p=1.)
trvf = transforms.RandomVerticalFlip(p=1.)
imgs = torch.rand(100, 3, 28, 28)
imgs_hf = trhf(imgs)
imgs_vf = trvf(imgs)
all_imgs = torch.cat((imgs, imgs_hf, imgs_vf), 0)
all_imgs.size()
Outputs:
imgs_hf size: torch.Size([100, 3, 28, 28]), imgs_vf size: torch.Size([100, 3, 28, 28]), all_imgs size: torch.Size([300, 3, 28, 28])
But if you using transforms.Compose or torch.nn.Sequential on those two function then it will only return same size of images (i.e 100)
the Above illustration is precise.[to show if you want to increase the dataset size]
but when you are using transforms.Compose function it augment images in the runtime and dumps them after the operation. this is because storage redundant data is only a storage overhead.