I cant understand what is the effect of shear parameter in ImageDataGenerator of keras
I had tried to use an image to apply the shear by apply_transform member function in ImageDataGenerator. I can see the image seems to be rotated and stretched out after apply this function. But I cant understand what exactly it did.
from keras.preprocessing.image import ImageDataGenerator
import matplotlib.pyplot as plt
import numpy as np
(train_x, train_y) , (test_x,test_Y) = cifar10.load_data()
img = train_x[0]
img_gen = ImageDataGenerator()
shear_intensity = np.arange(0,110,10, dtype = int)
nrow = 4
ncol = 3
plt.figure(figsize = (14,14))
for i,shear in enumerate(shear_intensity):
plt.title(f'shear intensity : {shear}')
plt.subplot(nrow, ncol, i+1)
plt.imshow(img_gen.apply_transform(img, {'shear' : shear}))
plt.show()
The image does have some change, but I cant understand the effect.
Keras ImageDataGenerator is a gem! It lets you augment your images in real-time while your model is still training! You can apply any random transformations on each training image as it is passed to the model. This will not only make your model robust but will also save up on the overhead memory!
The shear augmentation is a part of the suite of data augmentation options in the Roboflow platform. Data augmentation in computer vision is a technique to generate more training data from a base training set, by tweaking the base images programmatically.
shear_range specifies the angle of the slant in degrees.
Then the "ImageDataGenerator" will produce 10 images in each iteration of the training. An iteration is defined as steps per epoch i.e. the total number of samples / batch_size. In above case, in each epoch of training there will be 100 iterations.
'Shear' means that the image will be distorted along an axis, mostly to create or rectify the perception angles. It's usually used to augment images so that computers can see how humans see things from different angles.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With