Is it possible to specify the amount of data augmentation

How much data is augmented in the function tfms_from_model? If yes, then is it possible to override it?

1 Like

There are some standard transformation functions in transforms.py. You can choose your own parameters for these functions and pass them to the tfms_from_model function.

augs = [
    RandomFlip(),
    RandomLighting(0.2, 0.2),
    RandomRotate(20)
    ]

tfms = tfms_from_model(arch, sz, aug_tfms = augs)

I haven’t tried it but I imagine you could write your own augmentation functions and pass them in if you wanted, as long as it works with OpenCV images.

2 Likes

Thanks Karl,
but do you know what percentage of images are augmented. I couldn’t find any parameters for it

Each augmentation function has a probability parameter/parameters that can be passed in. Random rotate defaults to 0.75, random flip defaults to 0.5. You can look at the code in transforms.py. For each image in your dataset, each augmentation function has some probability of being applied.

Thanks Karl, really appreciate your quick responses.
My question is little different. let us say i have 100 training images and if switch ON augmentation how many augmented images will be created (I know they are not real files). Also are there any guidelines on "how much " augmentation?

My understanding is that each time a training image is used it is randomly transformed. If you have flip, lighting, and rotation transforms, only one is randomly chosen per image per epoch, and is performed with a random magnitude within configured thresholds. Take a look at the source code if you want to be sure, or to change behaviour.

2 Likes

I don’t think that sort of question applies here. The augmentation functions are applied every time an image is passed from the dataloader to the model during training. So in a single epoch the model trains on one augmented version of each image in the data set.

1 Like