{"id":13547058,"url":"https://github.com/awslabs/serverless-photo-recognition","last_synced_at":"2025-04-02T19:32:21.352Z","repository":{"id":41526968,"uuid":"78151622","full_name":"awslabs/serverless-photo-recognition","owner":"awslabs","description":"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)","archived":true,"fork":false,"pushed_at":"2020-04-17T20:58:43.000Z","size":1839,"stargazers_count":387,"open_issues_count":2,"forks_count":105,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-03-13T02:37:56.021Z","etag":null,"topics":["amazon-api-gateway","amazon-cognito","amazon-rekognition","architecture","aws","aws-apigateway","aws-lambda","aws-s3","elasticsearch","jwt","kotlin","kotlin-language","lambda-functions","picture","s3-storage","serverless","serverless-photo-recognition"],"latest_commit_sha":null,"homepage":"https://aws.amazon.com/blogs/ai/use-amazon-rekognition-to-build-an-end-to-end-serverless-photo-recognition-system/","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/awslabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-05T21:58:35.000Z","updated_at":"2025-03-11T15:16:19.000Z","dependencies_parsed_at":"2022-09-23T12:54:23.121Z","dependency_job_id":null,"html_url":"https://github.com/awslabs/serverless-photo-recognition","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awslabs%2Fserverless-photo-recognition","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awslabs%2Fserverless-photo-recognition/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awslabs%2Fserverless-photo-recognition/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awslabs%2Fserverless-photo-recognition/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/awslabs","download_url":"https://codeload.github.com/awslabs/serverless-photo-recognition/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246880180,"owners_count":20848819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amazon-api-gateway","amazon-cognito","amazon-rekognition","architecture","aws","aws-apigateway","aws-lambda","aws-s3","elasticsearch","jwt","kotlin","kotlin-language","lambda-functions","picture","s3-storage","serverless","serverless-photo-recognition"],"created_at":"2024-08-01T12:00:50.353Z","updated_at":"2025-04-02T19:32:20.043Z","avatar_url":"https://github.com/awslabs.png","language":"Kotlin","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"readme":"\n### Author: Vladimir Budilov\n* [YouTube](https://www.youtube.com/channel/UCBl-ENwdTlUsLY05yGgXyxw)\n* [LinkedIn](https://www.linkedin.com/in/vbudilov/)\n* [Medium](https://medium.com/@budilov)\n* [Twitter](https://twitter.com/VladimirBudilov)\n\nYou can watch the video explanation of this architecture [here](https://www.youtube.com/watch?v=GIdJz7VnP58)\n\nServerless Photo Recognition\n===================================================\n### What is it?\nA collection of 3 lambda functions that are invoked by Amazon S3, Amazon API Gateway, and directly (RESTful calls) \nto analyze uploaded images in S3 with Amazon Rekognition and save picture metadata to ElasticSearch\n\n### Before you start\n1. When you run the setup script your account will start incurring AWS infrastructure costs. \n2. This project was written a while back, before CloudFormation was available for all of the services in use, hence \nmy use of the AWS CLI. If I were to write this today I would use [CDK](https://aws.amazon.com/cdk/) to create all of the resources (from IAM roles to ElasticSearch service). Check out [this project](https://github.com/vbudilov/aws-cdk-starter) for a reference.  \n \n### The Architecture\n\n#### Adding an image\n![Adding an image](/setup/img/ServerlessPhotoRecognition_Add_Image.png?raw=true)\n\n#### Removing an image\n![Remove an image](/setup/img/ServerlessPhotoRecognition_Remove_Image.png?raw=true)\n\n#### Searching images\n![Search images](/setup/img/ServerlessPhotoRecognition_Search_Image.png?raw=true)\n\n### Tech Stack\n#### Required Tools\n* [aws cli](http://docs.aws.amazon.com/cli/latest/userguide/installing.html)\n* [awslogs utility](https://github.com/jorgebastida/awslogs)\n\n#### AWS Services Involved In This Architecture\n* [Amazon Rekognition](https://aws.amazon.com/rekognition/)\n* [Amazon Cognito](https://aws.amazon.com/cognito/)\n* [AWS Lambda](https://aws.amazon.com/lambda/)\n* [Amazon API Gateway](https://aws.amazon.com/api-gateway/)\n* [Amazon S3](https://aws.amazon.com/s3/)\n* [Amazon Elasticsearch](https://aws.amazon.com/elasticsearch-service/)\n\n### AWS Setup\nBefore we start, let’s make sure that your working environment is setup to run the script. Here's what you'll need:\n\n* An AWS Account with a default VPC\n* Java 8\n* The latest AWS CLI (Tested with aws-cli/1.11.29 Python/2.7.12)\n* Linux or Mac OS to run the setup script (the setup script won't work on Windows)\n\nThe following command will setup all of the needed resources, as well as print out the sample command that you can run\nto test your configuration:\n```\n# Clone it from github\ngit clone --depth 1 https://github.com/awslabs/serverless-photo-recognition.git\n```\n```\n# Run the installation script\ncd serverless-photo-recognition/setup\n./setupEnvironment.sh\n```\nRunning 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). \n\nIt will also create a deletion script under the ```tmp``` directory\n\nAt 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):\n\n```\n-\u003e Upload a picture\n--------------------\naws s3 cp new-york.jpg s3://rekognition-20170307160632/usercontent/us-east-1:c61126b8-7f7b-48e8-8534-4c3a21dfef4e/\n\n-\u003e Sample search command\nYou might need to pipe the output to 'native2ascii -encoding UTF-8 -reverse' if you\nwant to copy and paste the signed url in the browser since curl encodes url output\n-------------------------\ncurl -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/\"\n\n-\u003e Remove the picture\n----------------------\naws s3 rm s3://rekognition-20170307160632/usercontent/us-east-1:c61126b8-7f7b-48e8-8534-4c3a21dfef4e/new-york.jpg\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawslabs%2Fserverless-photo-recognition","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawslabs%2Fserverless-photo-recognition","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawslabs%2Fserverless-photo-recognition/lists"}