This post describes how to deploy the AWS stack for Lookout. The instructions are based on the AWS Serverless Application Model (SAM) and AWS cli. While you could build out the components manually, I highly recommend taking the time to set up SAM + AWS cli.

Requirements

Adding Images for Facial Recognition

The Lookout stack contains a lambda to build a Rekognition collection from face images in S3. The solution contains one test image used to demonstrate the solution. You can add your own face crops to S3 to be included in the index.

Deploy with Makefile

If your system supports make you can use the supplied Makefile to simplify the process:

  1. Clone the lookout repo.
    git clone https://github.com/2412labs/lookout.git
    cd lookout
    
  2. (Optional) - add your own face images to lookout/img/faces for indexing.
  3. Edit the Makefile (vi Makefile) and update these variables with your S3 bucket and region:
    BUCKET := YOUR-BUCKET
    REGION := us-east-1
    
  4. Run the release target - this will package, deploy, copy test images and faces, and index faces from img/faces (you can add your own jpg files to this folder for facial recognition and announce by name):
    make release
    
  5. If the deploy failed, review the cli output and the stack log within the AWS console (services -> management tools -> cloudformation).
  6. The deploy will print some stack output values similar to the following - save these for future use:

lookout cloudformation output

 

Deploy with shell commands

Use this method if your system doesn’t have make or you want to understand what each command does.

  1. Clone the lookout repo.
    git clone https://github.com/2412labs/lookout.git
    cd lookout
    
  2. (Optional) - add your own face images to lookout/img/faces for indexing.
  3. Package the stack artifacts. Substitute your own values for YOUR-BUCKET and YOUR-REGION.
    sam package --template-file template.yml --output-template-file project.yml --s3-bucket YOUR-BUCKET --region YOUR-REGION
    
  4. Deploy the artifacts. This step actually builds each component in AWS and make take a few minutes.
    sam deploy --template-file project.yml --stack-name lookout --capabilities CAPABILITY_NAMED_IAM --region YOUR-REGION
    
  5. If the deploy failed, review the cli output and the stack log within the AWS console (services -> management tools -> cloudformation).
  6. Use the AWS cli to get stack output variables. Save these values for future steps.
    aws cloudformation describe-stacks --stack-name lookout --query "Stacks[0].Outputs" --region YOUR-REGION
    
  7. That’s it, the full aws solution is deployed! Now lets do a couple things from the cli to set up data for testing. You need the values for “S3BucketName” and “IndexFaces” output keys from the previous step.
    aws s3 sync img/ s3://S3BucketName_VALUE_HERE/img/
    aws lambda invoke --invocation-type RequestResponse --payload '{}' \
    --region YOUR-REGION  --function-name IndexFaces_VALUE_HERE /dev/stdout
    

Related Posts