Image dataset
Let's start with building a Torch Dataset of images. You'll use it to explore the data and, later, to feed it into a model.
The training data for the cloud classification task is stored in the following directory structure:
clouds_train
- cirriform clouds
- 539cd1c356e9c14749988a12fdf6c515.jpg
- ...
- clear sky
- cumulonimbus clouds
- cumulus clouds
- high cumuliform clouds
- stratiform clouds
- stratocumulus clouds
There are seven folders inside clouds_train
, each representing one cloud type (or a clear sky). Inside each of these folders sit corresponding image files.
The following imports have already been done for you:
from torchvision.datasets import ImageFolder
from torchvision import transforms
This exercise is part of the course
Intermediate Deep Learning with PyTorch
Exercise instructions
- Compose two transformations, the first, to parse the image to a tensor, and one to resize the image to
128
by128
, assigning them totrain_transforms
. - Use
ImageFolder
to definedataset_train
, passing it the directory path to the data ("clouds_train"
) and the transforms defined earlier.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Compose transformations
train_transforms = ____([
transforms.____,
transforms.____,
])
# Create Dataset using ImageFolder
dataset_train = ____(
____,
transform=____,
)