In this blog, I am going to show you how we can use rekognition for image analysis using AWS CLI. So you can test the image analysis on your local machine. We will be going to perform label detection and object detection for an image so basically we are performing image analysis in this blog by using AWS CLI.
How will be the flow for Image Analysis:
In My Image analysis using AWS Rekognition via Lambda function blog, I already explained what is Rekognition and the benefits and use cases of Rekognition. So here will directly start with the implementation part.
For Image analysis, we are using the following services of AWS.
So The flow for image analysis will be:
Step 1: Creating a User by using IAM:
Step 2: Create an S3 bucket to store images:
For the image analysis, I uploaded the following image.
Step 3: Set Up the AWS CLI
pip3 --version
python --version
Or
python3 --version
pip3 install awscli --upgrade --user
OR
sudo apt-get install awscli
aws --version
aws configure
aws rekognition detect-labels --image "S3Object={Bucket=buket_name,Name=image_name}" --region region_name
Note: In place of the bucket name provide s3 bucket name that you created in step 2 and for image name give the image name that is present inside the s3 bucket. In place of region give your region name for e.g[us-east-1]
{
"Labels": [
{
"Parents": [],
"Instances": [],
"Name": "Human",
"Confidence": 98.7396011352539
},
{
"Parents": [],
"Instances": [
{
"BoundingBox": {
"Left": 0.4745420217514038,
"Top": 0.12450992316007614,
"Height": 0.8302116990089417,
"Width": 0.42319080233573914
},
"Confidence": 98.7396011352539
}
],
"Name": "Person",
"Confidence": 98.7396011352539
},
{
"Parents": [
{
"Name": "Person"
}
],
"Instances": [],
"Name": "Sitting",
"Confidence": 98.73041534423828
},
{
"Parents": [
{
"Name": "Person"
}
],
"Instances": [],
"Name": "Female",
"Confidence": 97.1566162109375
},
{
"Parents": [
{
"Name": "Person"
}
],
"Instances": [],
"Name": "Dating",
"Confidence": 90.18348693847656
},
{
"Parents": [
{
"Name": "Female"
},
{
"Name": "Person"
}
],
"Instances": [],
"Name": "Woman",
"Confidence": 85.65811157226562
},
{
"Parents": [
{
"Name": "Person"
}
],
"Instances": [],
"Name": "Child",
"Confidence": 82.99960327148438
},
{
"Parents": [
{
"Name": "Person"
}
],
"Instances": [],
"Name": "Teen",
"Confidence": 82.99960327148438
},
{
"Parents": [
{
"Name": "Female"
},
{
"Name": "Person"
}
],
"Instances": [],
"Name": "Girl",
"Confidence": 82.99960327148438
},
{
"Parents": [
{
"Name": "Teen"
},
{
"Name": "Girl"
},
{
"Name": "Female"
},
{
"Name": "Woman"
},
{
"Name": "Kid"
},
{
"Name": "Person"
}
],
"Instances": [],
"Name": "Blonde",
"Confidence": 82.99960327148438
},
{
"Parents": [
{
"Name": "Person"
}
],
"Instances": [],
"Name": "Kid",
"Confidence": 82.99960327148438
},
{
"Parents": [
{
"Name": "Electronics"
},
{
"Name": "Computer"
}
],
"Instances": [],
"Name": "Pc",
"Confidence": 71.96940612792969
},
{
"Parents": [
{
"Name": "Electronics"
}
],
"Instances": [],
"Name": "Computer",
"Confidence": 71.96940612792969
},
{
"Parents": [],
"Instances": [],
"Name": "Electronics",
"Confidence": 71.96940612792969
},
{
"Parents": [
{
"Name": "Electronics"
},
{
"Name": "Pc"
},
{
"Name": "Computer"
}
],
"Instances": [],
"Name": "Laptop",
"Confidence": 55.87724685668945
}
],
"LabelModelVersion": "2.0"
}
In response, you will get a list of labels and a corresponding numeric confidence index. You can compare the image that I have mentioned above with the response. In my image, one lady is reading a book and also some electronic objects are present in the image. So in response, you can see different labels are shown related to images like a person, female, and computer.
In this way, you can try image analysis on different images based on your use case.
Enjoy Coding 😃