Skip to content

riya-17/FaceRecognition

Repository files navigation

Note: NOT ACTIVE


Face Recognizer

Face Recognizer identifies the face of an individual by their name with the help of their facial features.

Face Recognizer uses deep learning algorithms to compare a live capture or digital image with the stored faceprints(also known as datasets) to verify an identity.

The algorithm used for classification is k-NN model i.e. k-Nearest Neighbor classifier. It uses Euclidean distance to compare images for similarity.

Prerequisites

Install cmake library

pip install cmake

Clone the dlib repository

git clone https://github.com/davisking/dlib.git

Make build directory

cd dlib
mkdir build
cd build

Install setup.py

cmake ..
cmake --build
cd ..
python setup.py install

Setup

Windows:

pip install -r requirements.txt

Linux:

  • Setup environment

    sudo apt-get update
    sudo apt-get upgrade
    
  • Install dependencies for OpenCV

    sudo apt-get install build-essential cmake unzip pkg-config
    sudo apt-get install libjpeg-dev libpng-dev libtiff-dev
    sudo apt-get install libjasper-dev
    sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
    sudo apt-get install libxvidcore-dev libx264-dev
    sudo apt-get install libgtk-3-dev
    sudo apt-get install libatlas-base-dev gfortran
    sudo apt-get install python3.6-dev
    sudo apt-get install libboost-all-dev
    
  • Install OpenCV

    • OpenCV
      pip install opencv-python
      
    • OpenCV Contrib
      pip install opencv-contrib-python
      
  • Install other project dependencies pip install -r requirements.txt

    Further error can be solved

    • On installing opencv: https://www.pyimagesearch.com/2018/05/28/ubuntu-18-04-how-to-install-opencv/
    • On dlib: https://www.pyimagesearch.com/2017/03/27/how-to-install-dlib/

Set the path of the input images in the code and run the following command:

python FaceRecognizer.py

How Does It Work?

* An image that contains the face to be recognized is loaded (e.g., input image).

* The face is detected and segmented.

* The face is aligned if it is not aligned straight

* Landmarks (e.g., 68 (x, y) coordinates) are detected from the facial structure.

* The detected face landmarks are encoded (e.g., 128-d embeddings of the image are created).

* The input image[encoding] is passed to the k-NN model for classification.

* The k-NN model returns the name with the highest precision



Outputs:

  • Input Image - The image in which faces are to be recognized:

Input Image

  • Original Image - The cropped input image

Original Image Original Image!

  • Aligned Image - Aligning the image increases the efficiency of the algorithm

Aligned image Aligned Image

  • Landmarks - Shows the landmarks of the detected faces

Landmark

  • Detected Face - The face is recognized and the name of the recognized face is displayed along with the face. If the face does not belong to the dataset then the face is labeled as Unknown.

Detected face




Another Recognition:

  • Input Image:

Input Image

  • Original Image:

Original Image

  • Aligned Image:

Aligned Image

  • Landmarks :

Landmarks

  • Detected Face :

Detected Face


encode-faces.py

It is used to create 128-d face embeddings of the input image as well as custom dataset. These embeddings are used to compare input image(embeddings) with the dataset(embeddings). The one with the highest votes is preferred.

DAT file

Link to Download Dat File

Resources

About

Recognizes faces

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages