Day 2: Data augmentation
I admit that my sample images for jars are too few. However, using data augmentation technique I can increase the sample images.
What is data augmentation?
Data augmentation is an automatic way to boost the number of different images you will use to train your Deep learning algorithms. A good simple definition taken from here. Reading this article, I can get a good understanding of the data augmentation. But still, taking the context to pytorch, I am still confused to generate thousands images from 48 images. Below are the lines of code that augmenting the training data (Lesson 2 Part 7),
What is data augmentation?
Data augmentation is an automatic way to boost the number of different images you will use to train your Deep learning algorithms. A good simple definition taken from here. Reading this article, I can get a good understanding of the data augmentation. But still, taking the context to pytorch, I am still confused to generate thousands images from 48 images. Below are the lines of code that augmenting the training data (Lesson 2 Part 7),
train_transforms = transforms.Compose([transforms.RandomRotation(30),
transforms.RandomResizedCrop(224),
transforms.RandomHorizontalFlip(),
transforms.ToTensor()])
train_data = datasets.ImageFolder(data_dir + '/train',
transform=train_transforms)
trainloader = torch.utils.data.DataLoader(train_data, batch_size=32)
train_transforms is the definition of transforming images.
train_data is the location definition of the images and applying the transform function.
train_loader is the data model loading process of train_data with batch_size = 32.
Lesson 2 Part 7 has 11250 images of dogs and 11250 images of cats. Total images is 22500 images (len(train_data)). len(trainloader) is resulting in 704. Hence, 704 * 32 = 22528, enough to cover 22500 images in 704 batches.
Code is understood well now. But, still I am looking for to augmenting my 48 images into thousands.
Somebody can help?
Comments
Post a Comment