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 Smallest max size augmentation;
Check out its parameters;
See how Smallest max size affects an image;
And check out how to work with Smallest max size using Python through the Albumentations library.
Let's jump in.
To define the term, Smallest max size is a data augmentation technique that reshapes an image so that the length of an image’s smallest size is equal to a certain number of pixels.
Maximum size of smallest side - sets the desired maximal length of the image in pixels. The values can vary from 256 to 3000.
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.SmallestMaxSize(max_size=1024, interpolation=1, p=1)
#default interpolation is INTER_LINEAR
image = np.array(Image.open('/some/image/file/path'))
image = transform(image=image)['image']
# Now the image is preprocessed and ready to be accepted by the model
Hasty is a unified agile ML platform for your entire Vision AI pipeline — with minimal integration effort for you.
Start for free Check out our services