Project 5 / Face Detection with a Sliding Window

Example of a right floating element.

The aim of this project was to perform Sliding window classification using Histogram of Gradients and SVM. The modules implemented were :

  1. get_positive_features.m - Converted positively trained examples to HoG features
  2. get_random_negative_features.m - Get features for images with no faces
  3. classifier training - Train a linear classifier from the positive and negative examples
  4. run_detector.m - Runs the classifier on the test set

To get positive features, I ran the vl_hog function on each 36 x 36 image to get HoG features for each image. I then reshaped the HoG feature matrix to get a 1 row vector for each image.

To get random negative features, I take the number of required samples as input. Then I run a loop n times, where n is the number of samples. For each iteration of the loop, I randomply pick an image from the dataset, and randomly sample a 36 x 36 block from that image, and then create a feature from it using vl_hog.

The classifier that was trained was a linear classifier.

To run the classifier on the test set, we iterate over each image in the test set. Then we scale the image according to different scale values and for each scale value, we run vl_hog over the whole image to get a HoG feature. Then we take a sliding window over this feature, and plug it into SVM equation. If the confidence from an iteration of the sliding window is above some given confidence, then we treat this as a match and put it in our results set. At the end we do non-maximum suppression on results for each image.

Results

Below is the precision I got for my final run.

Below is the HoG template I got on my final run.

Results on class photos

The algorithm did well on photos with clear faces.

On photos with partial faces, there were some false face detections but a lot of true positives too.

On analyzing my result, I can say that my algorithm does a good job of detecting faces in images, though there are still some false detections. Across most examples, a lot of True positives were seen.

Some other results