Face Detector

Google Inc
Supported Device
Vision Kit

The Face Detector model locates and identifies faces from an image. It also provides a “joy score” for each face.

Already included in the AIY Vision Kit SD card image


Demo: Face Detector

Time: 20 minutes

This demo uses your Vision Kit camera or an image to guess how many faces are present.

What you’ll need

  • Assembled Vision Kit
  • Connection to your device
Step 1: Get connected

First, make sure you’re connected to your device and have a terminal open. Otherwise you can’t tell your kit to start identifying faces.

Step 2: Stop your current demo

Your Vision Kit may already have another demo running, like the Smile Detector which runs by default when your kit is turned on. You’ll need to turn off any demos that are currently running. To do that, press Control-C.

Try it out

You can use the face detector demo in two ways: by taking a video with the camera, or by using a saved image on your computer or kit SD card.

Face Detector with a saved image

To run face detection on an image file, find a saved image on your SD card image and enter the following (you’ll also need to specify a place to save the output image):

~/AIY-projects-python/src/examples/vision/face_detection.py --input <input image> --output <output image>

If you ran into an error, check Help.

The face detector will try to figure out the location of the faces and draw a box around them (which you’ll see in the output file).

Face Detector with the Vision Kit camera You can use the face detector using the Vision Kit camera. While the demo is running, the face detector will try to identify the number of faces in the camera’s vision.

To run it, enter the following in your terminal, replacing with the number of frames you want the camera to process (try 20 to start):

~/AIY-projects-python/src/examples/vision/face_detection_camera.py --num_frames <number of frames>

Note: It takes some time for the demo to start. Please be patient!

If you ran into an error, check Help.

Once you enter that command, the demo will start--so point that camera at some faces! You’ll notice in your terminal window that the kit will report out the number of faces in each frame, so try pointing at different faces or one face and then a couple of faces.

Note: If you do not specify number of frames, the demo will keep going until you tell it to stop! To tell the demo to stop, press Control-C.

Finding an image to use with your model

You can find an image online using the Wget program. When you have an image in mind, here’s how to use it:

  1. Make sure you’re connected to your kit via SSH or through peripherals and have a terminal window open
  2. Make sure you also have the image’s URL available
  3. In your terminal, enter: wget
    • For example: wget https://www.example.com/example.jpg
    • The file will be downloaded to the current directory