Giter Club home page Giter Club logo

awslabs / serverless-photo-recognition Goto Github PK

View Code? Open in Web Editor NEW
382.0 24.0 104.0 1.8 MB

A collection of 3 lambda functions that are invoked by Amazon S3 or Amazon API Gateway to analyze uploaded images with Amazon Rekognition and save picture labels to ElasticSearch (written in Kotlin)

Home Page: https://aws.amazon.com/blogs/ai/use-amazon-rekognition-to-build-an-end-to-end-serverless-photo-recognition-system/

License: Apache License 2.0

Kotlin 50.17% Shell 49.83%
amazon-cognito amazon-api-gateway amazon-rekognition lambda-functions aws-lambda kotlin elasticsearch serverless-photo-recognition jwt architecture

serverless-photo-recognition's Introduction

Author: Vladimir Budilov

You can watch the video explanation of this architecture here

Serverless Photo Recognition

What is it?

A collection of 3 lambda functions that are invoked by Amazon S3, Amazon API Gateway, and directly (RESTful calls) to analyze uploaded images in S3 with Amazon Rekognition and save picture metadata to ElasticSearch

Before you start

  1. When you run the setup script your account will start incurring AWS infrastructure costs.
  2. This project was written a while back, before CloudFormation was available for all of the services in use, hence my use of the AWS CLI. If I were to write this today I would use CDK to create all of the resources (from IAM roles to ElasticSearch service). Check out this project for a reference.

The Architecture

Adding an image

Adding an image

Removing an image

Remove an image

Searching images

Search images

Tech Stack

Required Tools

AWS Services Involved In This Architecture

AWS Setup

Before we start, let’s make sure that your working environment is setup to run the script. Here's what you'll need:

  • An AWS Account with a default VPC
  • Java 8
  • The latest AWS CLI (Tested with aws-cli/1.11.29 Python/2.7.12)
  • Linux or Mac OS to run the setup script (the setup script won't work on Windows)

The following command will setup all of the needed resources, as well as print out the sample command that you can run to test your configuration:

# Clone it from github
git clone --depth 1 https://github.com/awslabs/serverless-photo-recognition.git
# Run the installation script
cd serverless-photo-recognition/setup
./setupEnvironment.sh

Running the installation script will modify the /src/main/kotlin/com/budilov/Properties.kt file with the newly-generated values. If you need to rerun the script, just revert the changes (otherwise the script will fail).

It will also create a deletion script under the tmp directory

At the end of the script, you'll see 3 commands (customized with your environment variables) that you can run to test out your configuration. Run the commands and see the functionality in action (copying and running the below commands will fail...use the ones that the script has generated):

-> Upload a picture
--------------------
aws s3 cp new-york.jpg s3://rekognition-20170307160632/usercontent/us-east-1:c61126b8-7f7b-48e8-8534-4c3a21dfef4e/

-> Sample search command
You might need to pipe the output to 'native2ascii -encoding UTF-8 -reverse' if you
want to copy and paste the signed url in the browser since curl encodes url output
-------------------------
curl -X POST -H "Authorization: $(aws cognito-idp admin-initiate-auth  --user-pool-id us-east-1_AEzYFK4mc --client-id 734810igh3bfdj4n33tfm9o08s --cli-input-json file:///tmp/authflow.json --query AuthenticationResult.IdToken --output text)" -H "search-key: building" -H "Cache-Control: no-cache" "https://57zt8cwa6j.execute-api.us-east-1.amazonaws.com/prod/picture/search/"

-> Remove the picture
----------------------
aws s3 rm s3://rekognition-20170307160632/usercontent/us-east-1:c61126b8-7f7b-48e8-8534-4c3a21dfef4e/new-york.jpg

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.