Rekognition with Console
Amazon Rekognition gives us the chance to recognize celebrities in images and videos. For our example, I will choose the images of Antentokounmpo Brothers and we will see if the Rekognition can recognize them.
You can try this image in the AWS Console. Let’s see what we get:
As we can see, it managed to detect Giannis and Thanasis Antentokounmpo! The rest brothers should wait until they become true celebrities apparently 🙂
Rekognition with boto3
We can get call the API via Python and boto3 and we can get all the info from the API response which is in json
format. We will provide an example of how you can simply get the name of the celebrities. We will work again with the same image.
import boto3 import json # create a connection with the rekognition client=boto3.client('rekognition') #define the photo photo = "Giannis-Antetokounmpo-Brothers.jpg" # call the API and get the response with open(photo, 'rb') as image: response = client.recognize_celebrities(Image={'Bytes': image.read()}) for celebrity in response['CelebrityFaces']: print ('Name: ' + celebrity['Name'] + ' with Confidence: ' + str(celebrity['MatchConfidence']))
Output:
Name: Thanasis Antetokounmpo with Confidence: 58.999996185302734
Name: Giannis Antetokounmpo with Confidence: 57.0
Notice that the response contains much information like the Bounding Boxes
etc.
As you can see we used the boto3, if you want to learn more about it you can have a look at the Basic Introduction to Boto3