I want to use one of the image augmentation techniques (for example rotation or horizontal flip) and apply it to some images of the CIFAR-10 dataset and plot them in PyTorch.
I know that we can use the following code to augmented images:
from torchvision import models, datasets, transforms
from torchvision.datasets import CIFAR10
data_transforms = transforms.Compose([
# add augmentations
transforms.RandomHorizontalFlip(p=0.5),
# The output of torchvision datasets are PILImage images of range [0, 1].
# We transform them to Tensors of normalized range [-1, 1]
transforms.ToTensor(),
transforms.Normalize(mean, std)
])
and then I used the transforms above when I want to load the Cifar10 dataset:
train_set = CIFAR10(
root='./data/',
train=True,
download=True,
transform=data_transforms['train'])
As far as I know, when this code is used, all CIFAR10 datasets are transformed.
Question
My question is how can I use data transform or augmentation techniques for some images in data sets and plot them? for example 10 images and their augmented images.