Git Product home page Git Product logo

face_api's Introduction

๐Ÿงฐ Dlib facial recognition system

demo

This is a DEMO system that uses Django, PostgreSQL, OpenCV and Dlib to perform facial recognition.

The dataset used for the tests is the LFW

๐Ÿท๏ธ Stack

  • Django - Python web framework
  • OpenCV - Computer Vision library
  • Dlib - Modern C++ toolkit containing machine learning algorithms
  • Postsgresql - (with CUBE extension) - Open source object-relational database

๐Ÿ“š Theory

The training mode

For the "training" of a person's face, a photo is uploaded to the system. If there is a face in the image, 128 points (features) are extracted from that face. This array of points are then stored in the database.

Facial recognition

To recognize a person's face, we pass a photograph to the system. The system will extract a matrix of 128 points from the face and then it will try to locate in the database which previously trained face has the matrix of points closest to the searched face. To do this search in the PostgreSQL database the CUBE extension is used. This extension provides a function that calculates the Euclidean distance of the face points with the points saved in the database. The query returns the id of the face with the closest array of points to the points of the queried face.

๐Ÿ› ๏ธ Prerequisites

To run this demo it is necessary GIT and DOCKER / DOCKER COMPOSE installed on your machine.

If you don't have docker, just follow the step by step according to your operating system at this LINK.

๐Ÿ‘๐Ÿฝโ€๏ธ Hands-on

Clone repository

git clone https://github.com/psilva1982/face_api.git

Starting the system

 cd face_api
 docker compose -f 'docker/dev/docker-compose.yml' up

โš ๏ธ ATTENTION

  • The container image creation step takes some time. (~5 minutes ๐Ÿ˜ด)

  • If you wish, it is not necessary to load and train images from the LFW dataset. The training is a very slow process, there are more than 13000 images to extract the points matrix and save it in the database. On my personal computer, this process takes an average of 90 minutes , so if you choose to go this route while the images are being processed, you can walk away a bit, grab a coffee โ˜• , etc... On the other hand, if you choose not to import the dataset there is an option in django-admin to register and train your personal images for testing.

Download, extract and loading the LFW dataset into database.

docker compose -f 'docker/dev/docker-compose.yml' run --rm django bash -c "python src/manage.py load_lfw"

Training / extract points from images (more time needed... ๐Ÿ’ค)

docker compose -f 'docker/dev/docker-compose.yml' run --rm django bash -c "python src/manage.py training_photos"

Test system on browser in http://localhost:8000/ with the credentials below.

user: [email protected]
password: demo

Adding new persons

For add a new person go to persons list in http://localhost:8000/admin/recognizer/person/ and click add person button on top right corner.

Training new persons

Select the person you want to train the images from the persons list in http://localhost:8000/admin/recognizer/person/ and choose the action "Training person(s) photo(s)" and then click the go button.

Test facial recognition

On persons list http://localhost:8000/admin/recognizer/person/ click in facial recognition button on top right corner

See the result

๐Ÿ˜Ž Enjoy !!!


๐Ÿ’ก Tips and Ticks

  • Facial recognition is more effective with more trained photos of the person you are looking for. This helps to avoid false positives. Some people in the LFW dataset only have a single photo.
  • Images with more than one face cannot be trained on this system.
  • To register a new user or recover password, you can access this link http://localhost:8025 (mailhog) to verify the emails received.

โœ๏ธ Notes

This project is for educational purposes only.

face_api's People

Contributors

psilva1982 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  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.