Intelligent Photo Search Application Using AWS
We all have experienced smart labelling over photos on our phone's gallery app, which can identify and categorise certain features within the photos. But what about having those same features and even adding some of your own custom features to it on a long-term online backup storage? Wouldn’t that be awesome !!! An average person takes roughly 6,000 photos per year. This is based on various estimates and surveys, with some sources suggesting a higher range of 10,000 to 15,000 per year for those who are more active in photography. As suggested by some of the research conducted by SWNS Digital and Talker News. This means that we need to backup our photos to online solutions like Google Drive, iCloud, and some advanced people using cloud solutions like Google Cloud Storage, Amazon S3, Azure Blob Storage, and more. Over here, I present a solution that can not only store photos, but also provide smart labelling and custom label features, so that re-discovering your photos is much easier and reduces your effort taken.
Introduction to AWS Technologies Used
The project utilizes several AWS services, each serving a crucial role:
- AWS Lambda: A Serverless computing platform that allows code execution without managing servers. Lambdas were employed for image indexing and searching.
- Amazon S3: A Scalable cloud storage service used to store images uploaded by users and host the front-end application.
- Amazon API Gateway: Facilitates creating, publishing, and maintaining secure RESTful APIs, enabling interaction between the frontend and Lambda functions.
- Amazon Rekognition: A deep learning-based visual analysis service to detect objects, scenes, and labels in images.
- Amazon OpenSearch (formerly Elasticsearch): A distributed, scalable search engine enabling fast search operations on indexed data.
- AWS IAM: Manages access control, ensuring secure and authorized interactions among AWS services.
- AWS CodePipeline and CodeBuild: CI/CD tools facilitating automated deployment and continuous integration of Lambda functions and frontend
At its core, Amazon S3 acts as a scalable object storage system, storing user-uploaded images reliably and triggering downstream workflows. AWS Lambda, a serverless compute service, is used to process these image uploads in real time extracting labels using Amazon Rekognition, a powerful AI-based image analysis service that automatically detects objects, scenes, and concepts within the photos.
Once labels are identified, they are indexed into Amazon OpenSearch (formerly Elasticsearch Service) to make them searchable via natural language queries. Amazon API Gateway then provides a secure RESTful interface for users to search these images through HTTP endpoints, seamlessly invoking the Lambda powered backend logic. To streamline updates and maintain a continuous deployment workflow, AWS CodePipeline and CodeBuild automate the building and packaging of Lambda functions and frontend assets, which are then deployed to the respective S3 buckets and Lambda environments.
All of this is permissioned and managed through IAM roles and policies, ensuring secure, fine grained access to each service. By leveraging AWS’s fully managed and event driven architecture, this project demonstrates how developers can create scalable, intelligent, and cost-effective applications with minimal operational overhead.
Creation and Working
This app consists of two main functionalities:
- Image Indexing:
- Photos uploaded to an Amazon S3 bucket trigger an indexing Lambda function.
- Lambda invokes Amazon Rekognition to analyze images and detect labels.
- These labels, along with metadata, are stored in Amazon OpenSearch for quick retrieval.
2. Image Searching:
- Users access the frontend hosted on Amazon S3.
- Entering a search query triggers an API call via Amazon API Gateway.
- A Lambda function queries Amazon OpenSearch to match labels with user input.
- URLs of matched images from S3 are returned and displayed to users.
Continuous deployment and updates to backend Lambdas are managed via AWS CodePipeline and CodeBuild, ensuring rapid iteration and consistent reliability.
Features of Using Cloud Services
- Serverless Efficiency: By using AWS Lambda, we reduce the operational overhead by reducing the need to manage infrastructure manually.
- Scalable Storage and Fast Retrieval: Amazon S3 and OpenSearch provide highly reliable and scalable solutions that handle growth effortlessly.
- Automated Image Analysis: Leveraging Amazon Rekognition, the system accurately categorizes images, reducing manual labor and enhancing accuracy.
- Robust Security and Access Management: AWS IAM ensures that every interaction between components is secure, compliant, and appropriately authorized.
The application demonstrates a powerful, scalable, and highly automated approach to managing digital assets, setting a benchmark for efficient photo management and retrieval solutions.
This project exemplifies how cloud-native solutions can effectively address practical problems in digital content management, showcasing the integration of cutting-edge AWS technologies into seamless, user-friendly applications.
Pseudocode for AWS Photo Search Project
Step 1: Infrastructure Setup (AWS Services Initialization)
- Create S3 Buckets
Bucket 1 (Frontend hosting) (website)
Bucket 2 (Image storage)
Bucket 3 (Lambda code storage) (codebuild) - Set Up IAM Roles and Policies
Create IAM Role and assign permissions. - Set Up Amazon Elasticsearch
- Set Up Lambda Functions
Function 1:To index the photos
Function 2:To search the photos
- Set Up API Gateway
REST API endpoint (GET
request) - Set Up CodePipeline in AWS Code Build
Challenges Faced & Debugging Insights
- Dealing with
415 Unsupported Media Type
errors and how binary media types in API Gateway resolved it. YAML_FILE_ERROR
in CodeBuild and how you debuggedbuildspec.yml
.- Bucket policy permissions and the IAM role errors you overcame.
- Lambda zip packaging with dependencies like
requests-aws4auth
.
Security Best Practices
- Used IAM roles instead of hardcoded credentials.
- Restricted S3 bucket policies to only allow required actions.
- Enabled CORS for API Gateway.
- Handled public access safely for the frontend bucket.