Run LARGE machine learning models on AWS Lambda with ONNX. The ONNX models can be over 1 GBs.
This model has two dependencies, the python Pillow and onnxruntime libraries. These need to be added as AWS Lambda Layers. Numpy is included in the onnxruntime.
In order to create the Lambda Layers, do a Docker pull:
docker pull highpoints/aws-lambda-layer-zip-builder:latest
Then run:
docker run --rm -v $(pwd):/package highpoints/aws-lambda-layer-zip-builder Pillow
docker run --rm -v $(pwd):/package highpoints/aws-lambda-layer-zip-builder onnxruntime
This should create:
pillow3.8.5.zip
onnxruntime3.8.5.zip
Add these as your AWS Lambda Layers. Make sure you include the key "PYTHONPATH" with the value "/opt/" in the AWS Lambda Environmental Variables configuration. The AWS Lambda runtime setting should be Python 3.8, and the IAM Role should include S3 Read and Write privledges.
Example:
Original Image:
ONNX 10x Super Resolution:
Happy Coding!