Table of Contents:


11:59PM, Saturday, February 26, 2022


Face recognition is 1:K matching problem. That means we have K images in a gallery and a test image. We want to match this test image to every image in the gallery and find a match that is the most similar to the test image. For example, if you are trying to find a match for a test image in a gallery of three images, the face recognition algorithm should find the middle image of the gallery to be the most similar.

For a live demo of face recognition in the real time, check out the following link.

In this project the goal is to practice implementation of principal components analysis technique to represent faces in a lower dimensional space and to recognize them. This technique was first presented by Turk and Pentland in their seminal paper Eigenfaces for Recognition. You will be implementing this paper following the implementation of the following case study. You may see some differences between the way the covariance matrix is computed in the original paper and the case study. We will be following the case study so that your implementation is consistent with the rest of the implementation. Specifically use step 6 instead of step 5 to compute covariance matrix. Alternatively, use svd on matrix A instead of the covariance matrix to find the eigen vectors.

A starter code file to read, display an image and display the pixel values alongwith the training and the test datasets can be downloaded from here.

What you need to do

You are required to do the following:

  • Implement PCA to represent faces onto a lower dimensional space. You would need to do some experimentation to pick the appropriate number of basis vectors in the lower dimensional space, let us say K eigenvectors.
  • Display some of the top K eigenvectors also called the eigenfaces.
  • Show (display) few examples of faces represented as a linear combination of the K eigenvectors and compare it with the original image
  • Perform face recognition in the lower dimensional space on the test images. Pick any test image to show the results. You may use any of the images from the test dataset and find the closest images to that image from the training dataset. If your face recognition is working well, you would find the images of the same person as the test image. You won’t need to do this step on all the test images. Don’t forget to project the test image to the Eigen vector space before finding its match. Display the best match and the top 5 matches.
  • Write a report.

Submission Guidelines

Please submit the project once for your group – there’s no need for each member to submit it. Make sure you write the names of all the students who worked on the project.

File tree and naming

Your submission on Canvas must be a zip file, following the naming convention For example, The file must have the following directory structure.

  • results/. containing some eigen faces and face recognition resulting images.
  • pca.ipynb
  • report.pdf


Logistics and bookkeeping you must include at the top of your report (-5 points for each one that’s missing):

  • The name of each group member.
  • A brief (one paragraph or less) description of what each group member contributed to the project.

For each section of the project, explain briefly what you did, and describe any interesting problems you encountered and/or solutions you implemented. You must include the following details in your writeup:

  • how you picked the the lower dimensional basis vectors,
  • the lower dimensional representation of a face and how similar or dissimilar it is to the original image.
  • Report the accuracy of face recognition. Accuracy is defined as the ratio of the number of test images correctly recognized to the total number of test images.
  • discuss briefly what you learned in the project.

As usual, your report must be full English sentences, not commented code. There is a word limit of 1500 words and no minimum length requirement

Allowed libraries

numpy, os, matplotlib

Collaboration Policy

You are encouraged to work on this project in groups of three at the most. The code should be your own, and should be the result of you exercising your own understanding of it. If you reference anyone else’s code in writing your project, you must properly cite it in your code (in comments) and your writeup. For the full honor code refer to the CMSC426 Spring 2022 website.