Skip to content

Data Augmentation with PyTorch, Tensorflow, Imgaug and Albumentations. It also involves bounding box augmentation.

License

Notifications You must be signed in to change notification settings

abdullahbas/Data-Augmentation

Repository files navigation

Here I showed augmentation of images with and without bounding boxes using PyTorch, Tensorflow, Albumentations and Imgaug.

Enjoy !

You can find bbox augmentation outputs in imgaug and albumentations folders. I looked bbox augmentation on tensorflow and PyTorch but I couldn't find any. May be there is not but I am not sure. I think someone who wants to create CV models should use PyTorch+Albumentations. Also, I have to say that you shouldn't use that much of augmentation. I set the probabilities of augmentations relatively high because of the visualization purpose of this repo. If you use that much augmentation your model will converge very slow. Furthermore, I am not sure if it will become more robust or worser. ** Augmentation is a very effective method to make your method more robust. As a matter of fact if you try to create models that Works quite well you should consider to use data augmentation.

First install all of the requirements.



pip install -r requirements.txt


"Any fool can know. The point is to understand." Albert Einstein



Using imgaug

Actually top left one the original one but I set titles of all images according to their augmentation. I automated the process and I told myself if I set probability 0 for fliplr it will return original image. Sorry I am too lazy to code if else for naming.

Rotate

Using imgaug 2

Same code but different output because of the probabilities.

Channel Shuff

Original Images

Tensorflow

Using Tensorflow

Tensorflow has tf.image function that can be used for augmentations.

Tensorflow

Using Tensorflow (2)

On training you can consider these images as epochs. As you can see, although you have same original image you will end up with completely different images.

Tensorflow 2

Using PyTorch

On training you can consider these images as epochs. As you can see, although you have same original image you will end up with completely different images.

PyTorch

Using PyTorch (2)

PyTorch2

Using Albumentations -- I think the best one especially when you work on object detection task.

You can add augmentation to your pipeline easily with albumentations. Actually I decided to write new library because of not-adequate built-in functions for bbox augmentation before I met albumentations. You can use it in dataloader of PyTorch, in generators of Tensorflow and also can combine with other augmentations from other frameworks. Thanks albumentations you nailed it !

Albumentations

Using Albumentations (2)

Albumentations

Releases

No releases published

Packages

No packages published

Languages