This Guidance helps users organize and implement search capabilities so they can efficiently locate the right photo from a large library of images. This Guidance uses artificial intelligence and machine learning (AI/ML) to find the right photo for immediate utilization, such as an image of a celebrity, politician, or well-known expert. With this Guidance, users can register images of a person with their name, detect human faces in images, search and analyze millions of photos, and compare images against one another to determine similarities – all through a simple user interface to add and search for images.
Architecture Diagram
Step 1
An Amazon CloudFront distribution with a web console is hosted in Amazon Simple Storage Service (Amazon S3) along with AWS Amplify to provide the architecture’s front-end web user interface (UI). AWS WAF is used for source IP restriction.
Step 2
An AWS Lambda function called through the Amazon API Gateway returns pre-signed URLs. All following requests to the API Gateway are authorized by Amazon Cognito.
Step 3
An S3 bucket stores your image library. Use the pre-signed URLs to upload images to the library.
Step 4
Uploading an image to Amazon S3 invokes a Lambda function. The Lambda function stores the metadata in Amazon OpenSearch Service and registers the image to Amazon Rekognition using the IndexFaces API.
Step 5
The register-name Lambda function assigns names to images. The set-tags Lambda function adds tags to images.
Step 6
The get-faces Lambda function searches the catalog of images against similar faces. It returns dimensions of faces detected in the image using the DetectFaces API.
Step 7
The get-similars Lambda function calls the SearchFacesByImage API to find images with faces similar to the one in the image the user specified. The function returns the images’ URLs on Amazon S3.
Step 8
The get-photos Lambda function searches for images using names or tags. The function returns the images’ URLs on Amazon S3 after it searches the URLs using OpenSearch Service.
Well-Architected Pillars
The AWS Well-Architected Framework helps you understand the pros and cons of the decisions you make when building systems in the cloud. The six pillars of the Framework allow you to learn architectural best practices for designing and operating reliable, secure, efficient, cost-effective, and sustainable systems. Using the AWS Well-Architected Tool, available at no charge in the AWS Management Console, you can review your workloads against these best practices by answering a set of questions for each pillar.
The architecture diagram above is an example of a Solution created with Well-Architected best practices in mind. To be fully Well-Architected, you should follow as many Well-Architected best practices as possible.
-
Operational Excellence
By choosing Lambda and Amazon S3, you can implement shared design standards. You can also use Amazon CloudWatch logs for Lambda to monitor your Lambda functions’ logs, troubleshoot issues, and create custom metrics based on log data. Additionally, you can enable Amazon S3 access logs to capture detailed information about every request made to the S3 bucket.
-
Security
This Guidance uses managed services to help you reduce security maintenance tasks, as part of the shared responsibility model. Managed services help you ensure AWS API calls are all done through HTTPS endpoints using transport layer security (TLS) communication, thus protecting data in transit. Data within Amazon Cognito is encrypted at rest in accordance with industry standards.
-
Reliability
API Gateway helps ensure highly available network connectivity for the public endpoint in this Guidance.
-
Performance Efficiency
With managed serverless services, you can offload the need to manage scaling requirements. For example, Lambda enables you to simply upload your code, and the service will manage everything required to run and scale that code. API Gateway handles all the tasks involved in accepting and processing up to hundreds of thousands of concurrent API calls. The distributed nature of OpenSearch Service enables this service to process large volumes of data in parallel to quickly find the best matches for your queries.
-
Cost Optimization
This Guidance uses serverless services, such as Lambda with API Gateway, to remove the need to manage resources. With managed and serverless services, you can set attributes that help ensure you have sufficient capacity without paying for additional unused resources. You must set and monitor these attributes to keep your excess capacity to a minimum while still maximizing performance.
-
Sustainability
Managed services remove the need to identify periods of low or no resource usage. Examples of managed services in this Guidance include Lambda, Amazon S3, API Gateway, CloudFront, OpenSearch Service, Amazon Rekognition, Amazon Cognito, Amplify, and AWS WAF.
Disclaimer
The sample code; software libraries; command line tools; proofs of concept; templates; or other related technology (including any of the foregoing that are provided by our personnel) is provided to you as AWS Content under the AWS Customer Agreement, or the relevant written agreement between you and AWS (whichever applies). You should not use this AWS Content in your production accounts, or on production or other critical data. You are responsible for testing, securing, and optimizing the AWS Content, such as sample code, as appropriate for production grade use based on your specific quality control practices and standards. Deploying AWS Content may incur AWS charges for creating or using AWS chargeable resources, such as running Amazon EC2 instances or using Amazon S3 storage.
References to third-party services or organizations in this Guidance do not imply an endorsement, sponsorship, or affiliation between Amazon or AWS and the third party. Guidance from AWS is a technical starting point, and you can customize your integration with third-party services when you deploy the architecture.