I am using pytorch for image classification using this code from github. I need to add data augmentation before training my model, I chose albumentation to do this. here is my code when I add albumentation:
data_transform = {
"train": A.Compose([
A.RandomResizedCrop(224,224),
A.HorizontalFlip(p=0.5),
A.RandomGamma(gamma_limit=(80, 120), eps=None, always_apply=False, p=0.5),
A.RandomBrightnessContrast (p=0.5),
A.CLAHE(clip_limit=4.0, tile_grid_size=(8, 8), always_apply=False, p=0.5),
A.ShiftScaleRotate(shift_limit=0.05, scale_limit=0.05, rotate_limit=15, p=0.5),
A.RGBShift(r_shift_limit=15, g_shift_limit=15, b_shift_limit=15, p=0.5),
A.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
ToTensorV2(),]),
"val": A.Compose([
A.Resize(256,256),
A.CenterCrop(224,224),
A.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
ToTensorV2()])}
I got this error:
KeyError: Caught KeyError in DataLoader worker process 0.
KeyError: 'You have to pass data to augmentations as named arguments, for example: aug(image=image)'
This Albumentations function takes a positional argument 'image' and returns a dictionnary. This is a sample to use it :