Path: blob/master/notebooks/book1/19/image_augmentation_torch.ipynb
1192 views
Please find jax implementation of this notebook here: https://colab.research.google.com/github/probml/pyprobml/blob/master/notebooks/book1/19/image_augmentation_jax.ipynb
Data augmentation for images
We illustrate some simple data augmentation methods form images. Based on sec 13.1 of http://d2l.ai/chapter_computer-vision/image-augmentation.html
To visualize an image augmentation, which may be stochastic, we apply it multiple times to an image.
Flipping
Crop and resize
Below, we randomly crop a region with an area of 10% to 100% of the original area, and the ratio of width to height of the region is randomly selected from between 0.5 and 2. Then, the width and height of the region are both scaled to 200 pixels.
Changing color
We can change brightness, contrast, saturation and hue. First we change brightness, from 1-0.5=0.5 times less to 1+0.5=1.5 times more.
Now we change hue.
Now we change saturation.
Now we change contrast.
Now we change all of them.
Combining multiple augmentations in a pipeline
Using augmentations in a dataloader
We illustrate how we can transform training and test images from CIFAR10.