Featured as community example for Serverless framework at serverless/examples
Storing images in S3 Bucket with label information. AWS Rekognition is used for detecting labels in image. You can later query the API endpoint provided by this serverless service to get the list of images which belongs to particular label.
On deploying, this provisions 2 Lambda functions in your AWS setup. One Lambda function is responsible to store the image labels on each successful PUT operation in specified S3 bucket. The other Lambda function is used to retrieve the images of a particular label.
This project uses serverless
framework. So, make sure you get that first and give the necessary permissions to serverless cli
. Follow this page for getting started.
Before sls deploy
, make sure you have setup these resources in AWS.
aws dynamodb create-table --cli-input-json file:https://setup/create-label-to-s3-mapping-table.json --region us-east-1
aws dynamodb create-table --cli-input-json file:https://setup/create-master-image-label-table.json --region us-east-1
aws s3 mb s3:https://serverless-image-labelling-bucket --region=us-east-1
# Install the necessary plugin
$ sls plugin install -n serverless-python-requirements
# Deploy to AWS
$ sls deploy
After deployment is successful, you can check the setup details using sls info
. Now, you can test the services by uploading an image on S3. This would label the image and store the details in DyanamoDB. You can later query the endpoint for getting images associated to the label.
Example,
curl -X POST \
https://xxxxxxxxxxxx.amazonaws.com/dev/getImagesByLabel \
-H 'Content-Type: application/json' \
-H 'Postman-Token: f769a23f-d285-4aba-9fc1-f3d8dd4b9f33' \
-H 'cache-control: no-cache' \
-d '{"label":"Furniture"}'