Dataset with augmentations
You have already built the image dataset from cloud pictures and the convolutional model to classify different cloud types. Before you train it, let's adapt the dataset by adding the augmentations that could improve the model's cloud classification performance.
The code to set up the Dataset and DataLoader is already prepared for you and should look familiar. Your task is to define the composition of transforms that will be applied to the input images as they are loaded.
Note that before you were resizing images to 128 by 128 to display them nicely, but now you will use smaller ones to speed up training. As you will see later, 64 by 64 will be large enough for the model to learn.
from torchvision import transforms
has been already executed for you, so let's get to it!
This exercise is part of the course
Intermediate Deep Learning with PyTorch
Exercise instructions
- Define
train_transforms
by composing together five transformations: a random horizontal flip, random rotation (by angle from 0 to 45 degrees), random automatic contrast adjustment, parsing to tensor, and resizing to 64 by 64 pixels.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Define transforms
train_transforms = transforms.Compose([
____,
____,
____,
____,
____,
])
dataset_train = ImageFolder(
"clouds_train",
transform=train_transforms,
)
dataloader_train = DataLoader(
dataset_train, shuffle=True, batch_size=16
)