All annotation is now free in Hasty

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('/some/image/file/path'))
image = transform(image=image)['image']

# Now the image is preprocessed and ready to be accepted by the model

Further Resources

Removing the risk from vision AI.

Only 13% of vision AI projects make it to production, with Hasty we boost that number to 100%.