1 of 42

The Math of FaceID

Lesson 1: Images as Data

2 of 42

What is Machine Learning?

Why FaceID?

3 of 42

Take a look at your cell phone, and think for a moment about the information it holds.

From photos, contacts, your internet search history…lots of data is stored within your phone’s memory!

4 of 42

Furthermore, those data are extremely valuable. Technology companies are motivated to help people feel secure about storing information in their phones.

First came passcodes.

Next, fingerprint recognition.

And finally, FaceID.

5 of 42

Our goal is to understand how a recent innovation, FaceID, works. Although we don’t see it, much of FaceID relies on ideas from Statistics.

6 of 42

At its core, FaceID combines statistics and computing, which makes up a new-ish field called machine learning.

In machine learning, computers learn patterns that helps them to make decisions without being explicitly programmed.

Machine Learning

Computing

Statistics and Math

7 of 42

Motivation for machines to “learn” began more than a half century ago.

Scientists at the time were exploring ideas such as, “How to get a computer to beat a human player at Checkers.”

Samuel Arthur, in 1959, training a computer how to play checkers.

8 of 42

Now, machine learning is everywhere!

Many people aren’t even aware of machine learning, or just how heavily it uses math and statistics!

9 of 42

Goals of this Project Unit

  1. Understand how a machine learning technology, such as FaceID, works from a statistical standpoint.
    1. Answer the question, “How does a computer decide if an image contains me or not me?”

  1. Explore and raise questions about what machine learning technologies could and should do.

  1. Review concepts from AP Statistics that we’ve learned so far this year.

10 of 42

Goals for Lesson 1

  1. Describe what form data takes when it is used in FaceID.
  2. Describe how two images could be compared to one another using statistics and math.
  3. Explain the role of statistical measures of error when comparing images with one another.

11 of 42

Images and Numbers

12 of 42

First, let’s make sure that we’re all on the same page when it comes to FaceID.

FaceID begins when a user sets up their phone. The phone takes initial photos called reference images of their face. The phone stores the reference photos in memory.

13 of 42

First, let’s make sure that we’re all on the same page when it comes to FaceID.

FaceID begins when a user sets up their phone. The phone takes initial photos called reference images of their face. The phone stores the reference photos in memory.

Then, each time the user wants to unlock the phone, the phone takes a current image and compares it to the reference image. If the photos are “similar enough”, the phone unlocks.

14 of 42

When FaceID unlocks a phone, it asks, “Is the current image the same as the saved reference images of that person?”

15 of 42

But, how does it actually do that with math?

16 of 42

How can you describe a face with numbers?

17 of 42

Idea 1: A list of facial features using categorical variables

18 of 42

Idea 2: Use numbers to describe distances on faces.

19 of 42

Idea 3: Use numbers to describe pixel brightness.

Part of the picture described with pixel brightness values

20 of 42

[Optional: What is a pixel?]

21 of 42

A pixel is the most basic a unit of length in a digital image.

Each one of the little squares here is a pixel!

22 of 42

Pixels are represented by numbers according to their brightness.

In a black-and-white image, each pixel is represented by a number from 0 to 255.

23 of 42

Pixels are represented by numbers according to their brightness.

In the picture above, each square is a pixel and is represented by a 0-255 number that the computer reads in as a list.

So, whereas we see images and pixels, computers just process long lists of numbers when fed images.

24 of 42

Color images take up three dimensions: red, green, and blue. Each dimension is represented by a 0-255 value.

The cube above reinforces the idea that every pixel in a color image is made up of three numbers.

25 of 42

See pixel breakdowns for yourself! Navigate to the pinetools webpage and see an image broken into its RGB components.

26 of 42

How to decide if numbers are similar?

27 of 42

What does FaceID need to decide?

“Is a new test image similar to the reference image?

Test image

Reference image

28 of 42

What does FaceID need to decide?

“Is a new test image similar to the reference image?

Test image (current photo of you)

[126, 155, 75, 22, 21, 90, 35…]

Reference image (stored in your phone)

[177, 123, 80, 36, 44, 80, 55…]

The phone doesn’t see faces. It uses a numerical representation (the variables that describe the face picture)

29 of 42

What does FaceID need to decide?

“Is a new test image similar to the reference image?

Test image (current photo of you)

[126, 155, 75, 22, 21, 90, 35…]

Reference image (stored in your phone)

[177, 123, 80, 36, 44, 80, 55…]

The phone doesn’t see faces. It uses a numerical representation (the variables that describe the face picture)

“Are the test numbers similar enough to the reference numbers?”

30 of 42

How could we use math to determine if the sets of numbers are similar?

31 of 42

What does FaceID need to decide?

In Statistics, we can think about error as a deviation that we expect to see. There have been several ways that we have thought about error in the past:

  • Standard deviation
  • Residual
  • Sum of squared error
  • Mean-squared error
  • Absolute error (find all the error and take its absolute value)

32 of 42

What does FaceID need to decide?

Let’s hone in on one measure, the mean-squared error, which is like the average amount of error (or, “difference” in our case) from what we’d expect.

  • Standard deviation
  • Residual
  • Sum of squared error
  • Mean-squared error
  • Absolute error (find all the error and take its absolute value)

33 of 42

What does FaceID need to decide?

Going back to this photo, we could, for example, use mean-squared error to think about the average amount of difference between this person’s test and reference photos.

34 of 42

What does FaceID need to decide?

Idea 1: Compare difference between each individual pixel.

Idea 2: Compare difference between facial features’ distances.

35 of 42

Using either method on the previous slide will produce some amount of difference - after all, this guy looks similar in both photos, but not exactly the same.

How might companies like Apple decide what a “good amount” of error is?

36 of 42

If we measure error numerically (say, with the mean-squared error), we need to determine how much error is acceptable so that the phone:

  1. Still unlocks for pictures of us when we look different, but
  2. Does not unlock for complete strangers with similar facial features as us.

Saved image of user

Still the user, but different pose (should unlock)

Not the user (don’t unlock)

37 of 42

Experimenting with Image Similarity

38 of 42

Activity: Try it and see!

With a partner, you will test two simplified methods for FaceID: comparing pixel brightness and comparing distances on faces.

Using the widgets provided, you will capture reference and test images of yourself and a partner. Your goal is to find the lowest MSE that produces correct decisions for as many cases as possible. In this context, a “correct decision” means that the phone unlocks for its owner and remains locked for everyone else (in this case, your partner).

When you have found your best overall MSE, take a screenshot of your results and post them on this class powerpoint. Then summarize your findings in a few bullet points by responding to the prompts on the slides.

39 of 42

Whole-Group Discussion

40 of 42

Share out and Discussion

Which method worked better, and why?

What was the best MSE that you obtained?

Any interesting fail cases?

41 of 42

Wrapping Up

42 of 42

Today, we introduced FaceID and some statistical measures that can be used to answer the question, “Is this picture me or not me?” from a computer’s perspective.

IMPORTANT: neither of those methods are how FaceID actually works, but it’s good to start thinking about how computers can make comparisons. More on this next time!