In this blog, I am going to show you how we can use rekognition for image analysis using lambda function.we will be going to perform label detection and object detection for an image so basically we are performing image analysis in this blog.
What is AWS Rekognition?
Rekognition is one of the AWS services to perform image and video analysis. So here all we need to provide is the image or video to the AWS Rekognition service and it will help us to identify an object, people, text, activities, and scenes.
Benefits of using Amazon Rekognition are as follows:
  1. Integrating powerful image and video analysis into your apps.
  2. Deep learning-based image and video analysis.
  3. Scalable image analysis.
  4. Integration with other AWS services.
  5. Low cost
Common use cases for using Amazon Rekognition mentioned in the following:
  1. Searchable image and video libraries
  2. Face-based user verification
  3. Sentiment and demographic analysis
  4. Facial Search
  5. Unsafe content detection
  6. Celebrity recognition
  7. Text detection
  8. Custom labels
For Image analysis, we are using four services of AWS.
  1. IAM
  2. S3
  3. Lamda
  4. Rekognition[This service we are using within the lambda function]
So the flow for image analysis will be:
Step 1: Creating an IAM role:
a. AmazonRekognitionFullAccess
b. AWSLambdaExecute
Step 2: Create an S3 bucket to store images:
For the image analysis, I uploaded the following image.
Step 3: Create a Lamda Function:
Note: In place of buket_name and image_name plz mentioned your S3 bucket name and uploaded image name.
import json
import boto3
def lambda_handler(event, context):
client = boto3.client("rekognition")
#passing s3 bucket object file reference    
response = client.detect_labels(Image = {"S3Object": {"Bucket":       "bucket_name", "Name": "image_name"}}, MaxLabels=3,  MinConfidence=70)
print(response)
return "Thanks"
What exactly you will get in response:
This rekognition API takes individual images as input and returns an ordered list of labels and a corresponding numeric confidence index. As you can see I have uploaded a person image with a car. So in response, you can see you will get all kinds of labels like a person, human, vehicle, car, and it also returns bounding boxes coordinates for items that are detected in images (for e.g height and width of persons face).
The response you will get is based on the image that you upload in the S3 bucket.
Try adding different images in the S3 bucket and check the image analysis.
I hope you like the blog. 
Happy Coding 😃