Longest Max Size

This data augmentation tool allows you to create a diversified dataset by changing the length of the longest max size of an image.

The maximum length that is to be set or the longest side can be added. Several of these values can be added and these values will be used randomly for each image. This makes the dataset more diversified.

Original Image
Longest max size applied with the value set to 500

Notice that the longest max size augmentation increased the length in both dimensions even though only the longest side was supposed to be affected. But the aspect ratio of the image is preserved and hence the other side is also proportionally scaled.

Code Implementation

import albumentations as albu
from PIL import Image
import numpy as np

transform =albu.LongestMaxSize(max_size=500, 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

Further Resources

Last updated on Jun 01, 2022

Get AI confident. Start using Hasty today.

Automate 90% of the work, reduce your time to deployment by 40%, and replace your whole ML software stack with our platform.