Giter Site home page Giter Site logo

face_recognition's Introduction

Face Recognition

Face Recognization is a personal project, which applies RetinaFace to detect faces. After that, I'm using the Insight Face model to create embedding from faces that have been split before.

In the register section, all embedding vectors will be normalized and store in the pool.

With the recognization section, faces detected will also normalized. The dot product of it with the pool above, which was used to find the nearest face.

Pre-requirement

  1. Refer using GPU device to get best performance.
  2. Install requirement.txt package list.
  3. Make system can record all your angle face during register step like iPhone.

Note: camera_url (integer) - mean select camera device id.

To register

python3 register.py

from argparse import ArgumentParser

args = ArgumentParser()
args.add_argument('-c', '--camera_url', default=0, type=str, help='0 - local camera')
args.add_argument('-dt', '--detect_threshold', default=0.975, type=float, help="Threshold of face detection")
args.add_argument('-rf', '--register_threshold', default=0.8, type=float, help="Threshold of face recognition")
args.add_argument('--device', default='cuda:0', type=str, help="Device run model. `cuda:<id>` or `cpu`")
args.add_argument('--detect_face_model', default='data/pretrained/mobilenet_header.pth',
                  type=str, help="Face detector model path")
args.add_argument('--detect_face_backbone', default='data/pretrained/mobile_backbone.tar',
                  type=str, help="Face detector backbone path")
args.add_argument('--recognized_model', default='data/pretrained/embedder_resnet50_asia.pth'
                  , type=str, help="Face embedding model path")
args.add_argument('--model_registered', default='model_faces.npy', type=str, help="Model contain face's vectors")
args.add_argument('--model_ids', default='model_face_ids.npy', type=str, help="Model contain face's ids")
args.add_argument('--register_name', required=True, type=str, help="(Required) Register's name!")
  1. Write register's name in console.
  2. Let the program recording your face from any angle.
  3. Press Q: quit and save model | Ctr-C: interrupt process without model saving.

If press Q, model_faces.npy and model_face_ids.npy will be created, which store all vectors and vector's id.

To recognize

python3 recognize.py
-h to get help
from argparse import ArgumentParser

args = ArgumentParser()
args.add_argument('-c', '--camera_url', default=0, type=str, help='0 - local camera')
args.add_argument('-dt', '--detect_threshold', default=0.975, type=float, help="Threshold of face detection")
args.add_argument('-rf', '--recognized_threshold', default=0.8, type=float, help="Threshold of face recognition")
args.add_argument('--device', default='cuda:0', type=str, help="Device run model. `cuda:<id>` or `cpu`")
args.add_argument('--detect_face_model', default='data/pretrained/mobilenet_header.pth',
                  type=str, help="Face detector model path")
args.add_argument('--detect_face_backbone', default='data/pretrained/mobile_backbone.tar',
                  type=str, help="Face detector backbone path")
args.add_argument('--recognized_model', default='data/pretrained/embedder_resnet50_asia.pth'
                  , type=str, help="Face embedding model path")
args.add_argument('--model_registered', default='model_faces.npy', type=str, help="Model contain face's vectors")
args.add_argument('--model_ids', default='model_face_ids.npy', type=str, help="Model contain face's ids")
args = args.parse_args()
  • Press Q or Ctr-C to exit.

Try it. :) Have fun.

Test

Tux, the Linux mascot

References

  1. Jiankang Deng, Jia Guo, Niannan Xue (2019), ArcFace: Additive Angular Margin Loss for Deep Face Recognition - https://arxiv.org/pdf/1801.07698.pdf
  2. Jiankang Deng, Jia Guo, Yuxiang Zhou, Jinke Yu, Irene Kotsia, Stefanos Zafeiriou (2019), RetinaFace: Single-stage Dense Face Localisation in the Wild - https://arxiv.org/pdf/1905.00641.pdf?fbclid=IwAR3yk-dQamoT-AD0YiK8HSOsxJruNdAz0vWjJlYSoS63p16TDb01UjB5F7U
  3. Yang Li, FACE RECOGNITION SYSTEM - https://arxiv.org/ftp/arxiv/papers/1901/1901.02452.pdf
  4. LAVENDER, Deep Learning và bài toán nhận dạng khuôn mặt - https://techblog.vn/deep-learning-va-bai-toan-nhan-dang-khuon-mat
  5. cs231n, Convolutional Neural Networks (CNNs / ConvNets) - https://cs231n.github.io/convolutional-networks/
  6. Jay Wang, Robert Turko, Omar Shaikh, Haekyu Park, Nilaksh Das, Fred Hohman, Minsuk Kahng, and Polo Chau, CNN Explainer - https://poloclub.github.io/cnn-explainer/
  7. Volodymyr Kovenko (2019), How to precisely align face in Python with OpenCv and Dlib - https://towardsdatascience.com/precise-face-alignment-with-opencv-dlib-e6c8acead262

face_recognition's People

Contributors

tindang97 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

connortran216

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.