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.
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:
from PIL import Imageimport albumentations as Aimport numpy as nptransforms = 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