Image classification
Last updated
Last updated
Image classification datasets are used to train a model to classify an entire image. There are a wide variety of applications enabled by these datasets such as identifying endangered wildlife species or screening for disease in medical images. This guide will show you how to apply transformations to an image classification dataset.
Before you start, make sure you have up-to-date versions of albumentations
and cv2
installed:
Copied
This guide uses the dataset for identifying the type of bean plant disease based on an image of its leaf.
Load the dataset and take a look at an example:
Copied
The dataset has three fields:
image
: a PIL image object.
image_file_path
: the path to the image file.
labels
: the label or category of the image.
Next, check out an image:
Now apply some augmentations with albumentations
. You’ll randomly crop the image, flip it horizontally, and adjust its brightness.
Copied
Create a function to apply the transformation to the images:
Copied
Copied
You can verify the transformation worked by indexing into the pixel_values
of the first example:
Copied
Use the function to apply the transformation on-the-fly to batches of the dataset to consume less disk space:
Now that you know how to process a dataset for image classification, learn and use it for inference.