Data augmentation types

What are the different types of data augmentations beside transforms_side_on we could use in fastai library and how should we use the right one ?

They are all defined in the file of the library:

transforms_basic    = [RandomRotate(10), RandomLighting(0.05, 0.05)]
transforms_side_on  = transforms_basic + [RandomFlip()]
transforms_top_down = transforms_basic + [RandomDihedral()]

So the basics are a random rotation of something between -10 and 10 degrees, then a bit of change in the contrast of the picture.
For side_on we add a random horizontal flip, for top_down we add all the possible way of turning a square (the Dihedral stands for this) which is any combination of a horizontal flip, vertical flip, and the two rotations of 90 degrees. This last one is useful when you have satellite images, or pictures with nucleis for instance.

Of course, you can define your own list of augmentation transforms as easily as those three are defined in the fastai library.


This might be helpful

1 Like

These transforms expect a single image. Is it possible to define transforms on a list of images? This is useful for models with multi image inputs.

For instance, instead of the normal tuple, our ImageData takes as input a training set of ( (train1, train2, train3, …), train_output )

You will need to define your custom Dataset for this. Just look at the Dataset class in the fastai library and copy paste it to change what you need. The method you need to override is get:

def get(self, tfm, x, y):
        return (x,y) if tfm is None else tfm(x,y)

where the result for x should be something like [tfm(inp, None) for inp in x]

1 Like

Oh thanks. I had taken to rewriting the functions I needed for multiple images. This is much easier.