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 Shift Scale Rotate augmentation;
Check out its parameters;
See how Shift Scale Rotate affects an image;
And check out how to work with Shift Scale Rotate using Python through the Albumentations library.
Let’s jump in.
To define the term, Shift Scale Rotate is a data augmentation technique used to randomly apply affine transformations such as shift, scale, and rotate.
Using Shift Scale Rotate helps Data Scientists increase the variety of points of view on an object in the training set. This approach creates the needed diversity without the need to find and label more data.
Shift factor - specifies a specific range from which a random shift factor is picked and used to shift an image both horizontally and vertically;
Scale factor - specifies a specific range from which a random scale factor is picked and used to rescale an image;
Rotation range - specifies a specific range from which a random angle (in degrees) is picked and used to rotate an image;
Probability of applying transform - defines the likelihood of applying Shift Scale Rotate to an image.
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.ShiftScaleRotate(shift_limit = 0.0625, scale_limit = 0.1, rotate_limit = 45)
image = np.array(Image.open('/some/random/image.png'))
augmented_image = transform(image=image)['image']
# We have the augmented 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