Using torchvision transforms for data augmentation

Transforms are common image transformations. torchvision transforms are used to augment the data with scaling, rotations, mirroring, cropping etc. Transforms are common image transformations. 

Let us create some possible transforms like RandomRotation , Resize, RandomResizedCrop etc.

Below is the code to use transforms for the training, validation, and testing sets

transforms.Compose(
[transforms.Resize(224),
transforms.CenterCrop(64),
transforms.ToTensor()])

Most neural networks expect the images of a fixed size. Therefore, we may need to write some preprocessing code.

Leave a Reply

%d bloggers like this: