🌱Introduction

🀑 Concepts of Image Augmentation Technique

  • πŸ’₯ Basics of Image Augmentation which is a technique to avoid overfitting

  • ⭐ When we have got a small dataset we are able to manipluate the dataset without changing the underlying images to open up whole scenarios for training and to be able to train by variuos techniques of image augmentation

Note: Image augmentation is needed for both training and test set πŸ˜…

🚩 Basic Concept of Image Augmentation

πŸ‘©β€πŸ« The concept is very simple though:

If we have limited data, then the chances of you having data to match potential future predictions is also limited, and logically, the less data we have, the less chance we have of getting accurate predictions for data that our model hasn't yet seen.

πŸ™„ If we are training a model to spot cats, and our model has never seen what a cat looks like when lying down, it might not recognize that in future.

  • Augmentation simply amends our images on-the-fly while training using transforms like rotation.

  • So, it could 'simulate' an image of a cat lying down by rotating a 'standing' cat by 90 degrees.

  • As such we get a cheap ✨ way of extending our dataset beyond what we have already.

πŸ”Ž Note: Doing image augmentation in runtime is preferred rather than to do it on memory to keep original data as it is πŸ€”

πŸ€Έβ€β™€οΈ Image Augmentation Techniques

βœ… Mirroring

Flipping the image horizontally

πŸš€ Example

βœ‚ Random Cropping

Picking an image and taking random crops

πŸš€ Example

🎨 Color Shifting

Adding and subtracting some values from color channels

πŸš€ Example

πŸ“ Shearing Transformation

Shear transformation slants the shape of the image

πŸš€ Example

πŸ‘©β€πŸ’» Code Example

The following code is used to do image augmentation

from tensorflow.keras.preprocessing.image import ImageDataGenerator

train_datagenerator = ImageDataGenerator(
      rescale = 1./255,
      rotation_range = 40,
      width_shift_range = 0.2,
      height_shift_range = 0.2,
      shear_range = 0.2,
      zoom_range = 0.2,
      horizontal_flip = True,
      fill_mode = 'nearest')

Full code example is here 🐾 πŸ‘ˆ

🧐 References

Last updated