Automated Image Labeling System Using AWS Rekognition: A Serverless Approach

jeshlin_pv_1628a63168e90

Jeshlin P V

Posted on August 17, 2024

Automated Image Labeling System Using AWS Rekognition: A Serverless Approach

To create an image labeling system using AWS services, you can leverage AWS Rekognition, a powerful image and video analysis service. Below are the general steps to set up an image labeling system:

Step-by-Step Guide

1. Set Up AWS Rekognition

Go to the S3 console and create a new bucket.
Upload images to this bucket. I uploaded an image named 'street.jpg'.
Configure IAM Role: Ensure the IAM role has the necessary permissions to access S3 and use Rekognition.
Attach the following policies to the IAM role:

-AmazonRekognitionFullAccess
-AmazonS3ReadOnlyAccess

2. Use AWS Rekognition to Detect Labels

Python Script: Use Boto3, the AWS SDK for Python, to interact with Rekognition.
To configure AWS, run the command "aws configure".
Create a working directory and create a file named 'labels.py'.

Image description
Copy and paste the code in the text editor.

import boto3

def detect_labels(photo, bucket):
    client = boto3.client('rekognition')

    response = client.detect_labels(Image={'S3Object': {'Bucket': bucket, 'Name': photo}},
                                    MaxLabels=10)

    print('Detected labels for ' + photo)
    for label in response['Labels']:
        print(f"{label['Name']} : {label['Confidence']}")

def main():
    bucket = 'image-labels-bucket'
    photo = 'street.jpg'
    detect_labels(photo, bucket)

if __name__ == "__main__":
    main()

Enter fullscreen mode Exit fullscreen mode

3. Run the Script

Run your Python script:

python labels.py
Enter fullscreen mode Exit fullscreen mode

Output:
Image description
The image I used (street.jpg):

Image description
4. Test with Different Images

You can test the script with different images by modifying the image name.

Conclusion

This project effectively demonstrates the use of AWS Rekognition to automate image labeling, providing an efficient and scalable solution for processing visual data. By utilizing a serverless architecture, the system is both cost-effective and easy to maintain, making it a practical approach for real-world applications.

💖 💪 🙅 🚩
jeshlin_pv_1628a63168e90
Jeshlin P V

Posted on August 17, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related