Using machine learning from Algorithmia to train a model to recognize faces
Name That Actor is a minimal demo from Algorithmia to show how anyone can use a classic face recognition algorithm. In the box below, enter the URL to a photo of one of the actors from the TV show “Parks and Recreation” or click on one of the example images, which were not used in training the facial recognizer model. The algorithm will run the image input against the model to predict the name of the actor.
[stag_button url="//blog.algorithmia.com/quickly-building-a-face-recognizer/" style="red" size="large" type="stroke" target="_blank" icon="exclamation" icon_order="before"]This demo is out-of-date. Please See blog.algorithmia.com/quickly-building-a-face-recognizer/ instead.[/stag_button]
How we made it
Because Parks and Rec is a celebrated show (for good reason–we hope you agree!), we decided to use the main cast as the recognition model for the algorithm. To train the model, we used the Train Face Recognizer algorithm with a collection of images of the actors.
We started by downloading 10 photos from Google Images of each actor playing the main characters:
- Amy Poehler as Leslie Knope
- Nick Offerman as Ron Swanson
- Chris Pratt as Andy Dwyer
- Aziz Ansari as Tom Haverford
- Aubrey Plaza as April Ludgate
- Adam Scott as Ben Wyatt
- Rashida Jones as Ann Perkins
- Retta as Donna Meagle
- Jim O'Heir as Jerry Gergich (or Garry or Larry or…)
Using the Algorithmia API, we uploaded all the images to a data collection. Then we ran the Train Face Recognizer algorithm against the collection, providing the actor’s name for each photo, to train the model against the collection as a dataset. To analyze new images, we call the Recognize Faces algorithm which uses the trained model to predict the name of the actor.
Note: Our method for detecting and recognizing faces works best for frontal face images. Faces at a profile are harder to detect and recognize with the same level of accuracy. It also helps when the faces are reasonably large relative to the size of the image, a modest 1/64 of the size of the image in pixels. Read more about face recognition using Algorithmia here.