Deploy image to text service using AWS Lambda function and SAM
cd image-to-text
sam build
aws cloudformation delete-stack --stack-name image-to-text
sleep 10
sam deploy --stack-name image-to-text --guided
cd image-to-text
sam build
sam local start-api --debug
-
Input image
./image-to-text/data/example.png
-
Convert input image to base64 encoding
python3 image-to-text/app/encode.py
This will generate
image-to-text/data/example.json
-
Deploy locally and test
curl -X POST http://127.0.0.1:3000/image-to-text \ -H "Content-Type: application/json" \ --data "@image-to-text/data/example.json"
Output
{"message": "This is a lot of 12 point text to test the\nocr code and see if it works on all types\nof file format.\n\nThe quick brown dog jumped over the\nlazy fox. The quick brown dog jumped\nover the lazy fox. The quick brown dog\njumped over the lazy fox. The quick\nbrown dog jumped over the lazy fox.\n\f"}