Humans have an innate need to be identified with a group, that drives us to be an important part of something bigger than us. This implies a relationship that is greater than familiarity or acquaintances. “Facial structure” plays a big part in that identity, making online services like find-your-celebrity-look-alike a guaranteed success.
Today, we are going to look under the figurative hood: How this technology works. We will be building a sample find-your-celebrity-look-alike application on Ruby using “Kairos”, a Third party face recognition api. With a simple example, we will discover how face recognition works, how we use data from kairos and briefly also touch on collecting and cleaning up celebrity facial data. The other alternative to using Kairos api includes face++, Animetrics.com or rekognition.com.
The first step would be building a cache of celebrity faces. Before the advent of publicly available face data on the internet, this tedious job had to be done manually but thanks to crowdsourcing, now a lot of public repositories are available with “facial” data, to use for non-commercial purposes.
One such repository, FaceScrub is a database of 1,00,000 photos of 530 celebrities classified by gender and name.
A snippet of it looks like this
So to begin, first download the data set using the following command.
Unzip the file.
$ unzip faceScrub.zip
The compressed file is password protected and you can get the password by filling out this form . This would yield a file with the name: facescrub_actors.txt . You can view the content of the file by using vim.
$ vim facescrub_actors.txt
$ vim facescrub_actresses.txt
Now you have a file that acts as an index to the final cache of face images of celebrities we need. So now we have to write a ruby script to read this file and create a cache in a new directory.
$gem install kairos-api
$gem install typhoeus
Unified code to upload the data and match your facebook profile photo to the celebrities
In my next post, we will take the concepts discussed here and create a full blown web application in Ruby on Rails .
Follow me on Twitter