If you have ever worked on a Computer Vision project, you might know that using augmentations to diversify the dataset is the best practice. On this page, we will:
Сover the Shear augmentation;
Check out its parameters;
See how Shear affects an image;
And check out how to work with Shear using Python through the Albumentations library.
Let’s jump in.
To define the term, Shear is a geometric augmentation that changes a form of an image along a specific axis to create a different perception angle.
As you can see in the picture above, Shear moves a side of an image, transforming its initial form of a square into a trapezoid. Shears are applied sequentially if you want to shear your image along the x- and y-axis. Data Scientists use Shear to augment pictures in such a way that an algorithm can identify an object from multiple angles.
Hello, thank you for using the code provided by Hasty. Please note that some code blocks might not be 100% complete and ready to be run as is. This is done intentionally as we focus on implementing only the most challenging parts that might be tough to pick up from scratch. View our code block as a LEGO block - you can’t use it as a standalone solution, but you can take it and add to your system to complement it. If you have questions about using the tool, please get in touch with us to get direct help from the Hasty team.
import albumentations as albu
from PIL import Image
import numpy as np
transform = albu.augmentations.geometric.transforms.Affine(shear = {'x': -45, 'y': 45})
image = np.array(Image.open('/some/random/image.png'))
augmented_image = transform(image=image)['image']
# We have the transformed image in augmented_image.
Only 13% of vision AI projects make it to production, with Hasty we boost that number to 100%.
Start for free Check out our services