Lambda Labs Face Recognition API Introduction

We hate long and boring documentation too. Let's skip right to the code examples (the full documentation starts below the horizontal line). So here's facial recognition in just Four Easy Steps.

Step 0. Sign up for the API

Sign Up to Our Facial Recognition API

Step 1. Create an Album

An album is a set of tagged images that can be used to recognize new ones. Let's instantiate an api and create an album. (Album names are globally unique, so you'll have to choose something other than 'Presidents'.)

from FaceRecognition import FaceRecognition 
api = FaceRecognition("YOUR_PUBLIC_KEY", "YOUR_PRIVATE_KEY")
# create an album 'Presidents' and save album_key
album = "Presidents"
album_key = api.createAlbum(album).body['albumkey']

Step 2. Train the Album

Give the album a few labeled images to work with. The more images you give it, the more accurate the model will be. Note, you can give us either urls or files.

# train the 'bush' label (two urls and one file)
api.trainAlbum(album, album_key, 'bush', None, "http://lambdal.com/bush/0.jpg") # using variable arguments
api.trainAlbum(album, album_key, 'bush', urls="http://lambdal.com/bush/1.jpg") # using kwargs
api.trainAlbum(album, album_key, 'bush', files=open("bush2.jpg"))
...

# train the 'clinton' label (using all files [but two ways to call it])
api.trainAlbum(album, album_key, 'clinton', open("clinton1.jpg"))
api.trainAlbum(album, album_key, 'clinton', open("clinton2.jpg"))
api.trainAlbum(album, album_key, 'clinton', files=open("clineton3.jpg"))
...

Step 3. Rebuild the Album

Tell the album to build a model itself using the labeled images.

# rebuild the album after training
api.rebuildAlbum(album, album_key)

Step 4. Recognize an Image

Give the album an image to recognize. You can see that there are two options, urls and files.

# run recognition using a url
link_response = api.recognize(album, album_key, urls="http://lambdal.com/clinton/19.jpg")  
# run recognition using a file upload
file_response = api.recognize(album, album_key, files=open("clinton.jpg"))
print("Bill Clinton was classified as:")
print(link_response.body['photos'][0]['tags'][0]['uids'])

<!---------------------- Begin Boring Full Docs ---------------------->
  1. Sign Up
  2. Get Keys
  3. Download Client
  4. Code Examples
  5. Current & Upcoming Functionality
  6. Support

1. Sign Up

  1. Select a plan to access our API.

  2. Create an account

    Get an API Account

2. Get Keys

Log in at mashape.com and get your public and private keys.

Get your Public Key Get Your Public & Private Key

3. Download Client

Download the Lambda Labs Face API Client from mashape

Download your API Client

4. Code Examples

Use the newly downloaded client

Here are some code samples:

Detect

Recognize

5. Current & Upcoming Functionality

Available Now:

6. Support

If you have any more questions, feedback, or need help integrating, please don't hesitate to reach out:

Email: s@lambdal.com