Discover yourself

16/11/2018 Michiel Vanderlinden

Do you know the burden? Do you feel the pain? Returning home from a great music festival or a fantastic party, a great time and nothing to remember it by. There must be some pictures. You search the website or Facebook page of the event and there it is, an album full of memories of that great time, 1697 of them! The date is November 12 2018 and nobody has time to search for embarrassing pictures of themselves. But there is hope, these days we are not only cursed with the burden of little time but blessed with the gift of technology as well, the gift of cloud computing for everyone, the gift of AWS Rekognition, our lord, our savior.

In this blog we will use AWS Rekognition to search for ourselves in a collection of pictures.

First we need to acquire this collection, I simply used a Chrome extension to download all pictures of a specific Facebook album.

Next, we will create an S3 bucket to store the pictures, because this project reminds me a bit of where’s waldo I will name the bucket ‘awesome-waldo-bucket’.

Now we will upload all the pictures to this bucket using the command.

Enjoy the terminal doing its job, casual snap some screenshots to non-IT friends. It scores well. #hackerMan

While the pictures are uploading we will create the AWS Rekognition collection with the following command.

After we create our collection and the pictures are uploaded we will use a Python script to add faces to the collection. The script will loop all the pictures in the S3 bucket and send them to the Rekognition collection with the ‘index faces’ operation, when a picture is added to the collection AWS will automatically process it and detect the faces, these faces will be stored in a map which we will be able to query later.

AWS documentation on this operation.

I added a hard-coded counter in this script just to follow progress.

Next execute the Python script.

You will find that it takes a very long time to process this number of pictures. For the sake of keeping it simple we did not do any batch processing in this blog but it is possible.

AWS documentation for batch processing.

After the images are done processing find a clear and recent picture of yourself, name it ‘me.png’ and upload it to the S3 bucket.

Be sure that it is a clear picture of your face and that you are the only one in it.
For example.

Now that we have all elements in place we can use the following command to retrieve faces matching our sample.

aws rekognition search-faces-by-image --image '{"S3Object":{"Bucket":"awesome-waldo-bucket","Name":"me.png"}}' --face-match-threshold 70 --collection-id "awesome-waldo-collection"

You can play with the ‘—face-match-threshold’ to get more or less correct results. The command will return json containing data on the matched faces.

You can repeat this with different sample pictures of your face to get more results.

And now the moment of truth, as it turns out I was not that popular with the photographers on the festival this year as I’m only in two pictures. Better luck next year!

As you can see, AWS Rekognition is a great service to find yourself in a picture even in a big crowd!

This picture surprised me the most, even when your face is very blury AWS Rekognition can still find you! What a gift of technology indeed!

I hope this blog has given you some insight in the possibilities with AWS Rekognition and wish you the best of luck in finding yourself!

Share this AWSome post
, , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *