This page describes how to build image transformations for test time deployment of your exported models.
To maintain the expected performance of your model after exporting, it is vital that some image transformations used for validation be used again when deploying to the test environment. These transformations are serialized as a JSON file when you export your model.
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.
{
"__version__" "0.5.1",
"transform": {
"__class_fullname__": "albumenations.core.composition.Compose",
"p": 1,
"transforms": [
{
"__class_fullname__": "albumenations.augmentations.transforms.Resize",
"always_apply": false,
"p": 1,
"height": 224,
"width": 224,
"interpolation": 1
}
],
"bbox_params": null,
"keypoint_params": null,
"additional_targets": {}
}
}
Here we can see the "Resize" transformation was used, with the "height" and "width" parameters set to 224.
All of the transformations you will see in the transforms.json
file can be used from the very nice "albumentations"
library. The transformations can simply be loaded using the
albumentations library. To reproduce the transform from the example
above, it may look like:
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.
from PIL import Image
import albumentations as A
import numpy as np
transforms = A.load('transforms.json')
image = np.array(Image.open('/some/image/file/path'))
image = transforms(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