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.
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.
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