Giter VIP home page Giter VIP logo

cs129-18-face-detection's Introduction

CS 129.18 Final Project: Face Detection

A face detection system from webcam input that utilizes skin thresholding and canny edge detection to find candidate face locations, and classifies them based on an artificial neural network trained on face datasets. Aside from the ANN, the user can also opt to use the Naive Bayes algorithm for evaluating results.

Instructions

Using the Main Program

To run the program, call python webcam.py from the terminal.

Processing Specific Images

Place the images in the data/input directory. The second parameter of get_objects_from_file should be True if you want cropped sections of the image, and False if you want the entire annotated image. Run imgprocess.py. The resulting images will be in data/output.

Building the Training/Test Sets

Put the files you'd like to be part of the training/test sets in the data/train_images and data/test_images folders, respectively. Call python gabor.py from the terminal. The results will be in data/train.csv and data/test.csv.

Modifying the Artificial Neural Network

The ANN's topology is specified in mlp.py's create_brain function. Running python jann.py will either create a new multilayer perceptron (saving the configuration to mlp.net) or load the existing one, depending on which is not commented out. To test the ANN's performance on the test set, uncomment the call to load_validation and run the program.

Testing

To test the ANN classification on a pre-existing data/test.csv, call python jann.py. To test the Naive Bayes classification on a pre-existing data/test.csv with its predefined positive and negative means and variances in the main directory, call python nb.py.

Directory Structure

├── data/
│   ├── train_images/ : 450 images each
│   │   ├── positives/
│   │   ├── negatives/
│   ├── test_images/ : 50 images each
│   │   ├── positives/
│   │   ├── negatives/
│   ├── train.csv
│   ├── test.csv
│   ├── negative_mean.txt
│   ├── positive_mean.txt
│   ├── variance_pos.txt
│   ├── variance_neg.txt
│
├── webcam.py : Main driver file
├── gabor.py : Feature generation, create test/train CSVs
├── imgprocess.py : Process images to detect faces
│
├── jann.py : Artificial Neural Network
├── mlp.py
├── layer.py
├── neuron.py
├── mlp.net : Saved ANN configuration
│
├── nb.py : Naive Bayes

Implementation

Detection

To find regions of interest, we use the OpenCV findContours function after performing skin thresholding and edge detection.

Feature Set

For each image, the feature vectors are built by computing the mean amplitude and local energies of the response matrices using various convolutions from the Gabor filter.

We generate 16 Gabor filters of four orientations and four frequencies (by changing the theta and lambda parameters of the getGaborKernel, respectively). Each convolution results in a matrix, from which the local energy and mean amplitude is computed for a total of 32 features.

Artificial Neural Network

mlp.net Format

[Overall Net Error Upon Saving]
[Topology]
For each layer: 
[Output Weights of each Neuron, including Bias Neuron]

References

Aside from the OpenCV docs, we referred to/used the following:

Gabor Tutorials

Datasets

The training and test sets used were subsets of the following datasets:

Others

cs129-18-face-detection's People

Contributors

seanraf21 avatar

Watchers

James Cloos avatar Duy Cao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.