train_tfm = transforms.Compose([
# Resize the images into the fixed size
transforms.Resize((128, 128)),
'''
Do some Image Enhancement
'''
# ToTensor() should be the last transformation
transforms.ToTensor(),
])
# Rotation
transform_rotate = transforms.RandomRotation(degrees=30)
# Translation
transform_translate = transforms.RandomAffine(degrees=0, translate=(0.1, 0.1))
# Flipping
transform_flip = transforms.RandomHorizontalFlip(p=0.5)
# Scaling
transform_scale = transforms.RandomResizedCrop(size=224, scale=(0.8, 1.0))
# Shearing
transform_shear = transforms.RandomAffine(degrees=0, shear=20)
# Brightness Adjustment
transform_brightness = transforms.ColorJitter(brightness=0.5)
# Contrast Adjustment
transform_contrast = transforms.ColorJitter(contrast=0.5)
# Satuation Adjustment
transform_saturation = transforms.ColorJitter(saturation=0.5)
# Hue Adjustment
transform_hue = transforms.ColorJitter(hue=0.2)
Cropping and Padding
# Random Cropping
transform_random_crop = transforms.RandomCrop(size=224)
# Padding
transform_padding = transforms.Pad(padding=4)
Image Enhancement
# Random Erasing
transform_random_erasing = transforms.RandomErasing(p=0.5, scale=(0.02, 0.33), ratio=(0.3, 3.3), value=0)