返回排行榜

serengil/retinaface

Pythonyoutube.com/watch

RetinaFace: Deep Face Detection Library for Python

face-detectionretinafaceretinaface-detectorpythontensorflowface-recognitionface-alignmentinsightfaceface-detector
Star 增长趋势
Star
2k
Forks
197
周增长
Issues
1
1k2k
2021年4月2023年1月2024年10月2026年7月
制品库PyPIpip install retinaface
README

RetinaFace

PyPI Downloads Stars License DOI

RetinaFace is a deep learning based cutting-edge facial detector for Python coming with facial landmarks. Its detection performance is amazing even in the crowd as shown in the following illustration.

RetinaFace is the face detection module of insightface project. The original implementation is mainly based on mxnet. Then, its tensorflow based re-implementation is published by Stanislas Bertrand. So, this repo is heavily inspired from the study of Stanislas Bertrand. Its source code is simplified and it is transformed to pip compatible but the main structure of the reference model and its pre-trained weights are same.


The Yellow Angels - Fenerbahce Women's Volleyball Team

Installation PyPI

The easiest way to install retinaface is to download it from PyPI. It's going to install the library itself and its prerequisites as well.

$ pip install retina-face

Then, you will be able to import the library and use its functionalities.

from retinaface import RetinaFace

Face Detection - Demo

RetinaFace offers a face detection function. It expects an exact path of an image as input.

resp = RetinaFace.detect_faces("img1.jpg")

Then, it will return the facial area coordinates and some landmarks (eyes, nose and mouth) with a confidence score.

{
    "face_1": {
        "score": 0.9993440508842468,
        "facial_area": [155, 81, 434, 443],
        "landmarks": {
          "right_eye": [257.82974, 209.64787],
          "left_eye": [374.93427, 251.78687],
          "nose": [303.4773, 299.91144],
          "mouth_right": [228.37329, 338.73193],
          "mouth_left": [320.21982, 374.58798]
        }
  }
}

Alignment - Tutorial, Demo

A modern face recognition pipeline consists of 4 common stages: detect, align, normalize, represent and verify. Experiments show that alignment increases the face recognition accuracy almost 1%. Here, retinaface can find the facial landmarks including eye coordinates. In this way, it can apply alignment to detected faces with its extracting faces function.

import matplotlib.pyplot as plt
faces = RetinaFace.extract_faces(img_path = "img.jpg", align = True)
for face in faces:
  plt.imshow(face)
  plt.show()

Face Recognition - Demo

Notice that face recognition module of insightface project is ArcFace, and face detection module is RetinaFace. ArcFace and RetinaFace pair is wrapped in deepface library for Python. Consider to use deepface if you need an end-to-end face recognition pipeline.

#!pip install deepface
from deepface import DeepFace
obj = DeepFace.verify("img1.jpg", "img2.jpg"
          , model_name = 'ArcFace', detector_backend = 'retinaface')
print(obj["verified"])

Notice that ArcFace got 99.40% accuracy on LFW data set whereas human beings just have 97.53% confidence.

Contribution Tests

Pull requests are more than welcome! You should run the unit tests and linting locally before creating a PR. Commands make test and make lint will help you to run it locally. Once a PR created, GitHub test workflow will be run automatically and unit test results will be available in GitHub actions before approval.

Support

There are many ways to support a project. Starring⭐️ the repo is just one 🙏

You can also support this work on Patreon, GitHub Sponsors, or Buy Me a Coffee.

Also, your company's logo will be shown on README on GitHub if you become sponsor in gold, silver or bronze tiers.

Acknowledgements

This work is mainly based on the insightface project and retinaface paper; and it is heavily inspired from the re-implementation of retinaface-tf2 by Stanislas Bertrand. Finally, Bertrand's implementation uses Fast R-CNN written by Ross Girshick in the background. All of those reference studies are licensed under MIT license.

Citation

If you are using RetinaFace in your research, please consider to cite its original research paper. Besides, if you are using this re-implementation of retinaface, please consider to cite the following research paper as well. Here is example of its BibTeX entry:

@article{serengil2026boosted,
  title     =  {Boosted LightFace: A Hybrid DNN and GBM Model for Boosted Facial Recognition},
  author    =  {Serengil, Sefik Ilkin and Ozpinar, Alper},
  journal   =  {Gazi University Journal of Science},
  volume    =  {39},
  number    =  {1},
  pages     =  {452-466},
  year      =  {2026},
  doi       =  {10.35378/gujs.1794891},
  url       =  {https://dergipark.org.tr/en/pub/gujs/article/1794891},
  publisher =  {Gazi University}
}

Finally, if you use this RetinaFace re-implementation in your GitHub projects, please add retina-face dependency in the requirements.txt.

Licence

This project is licensed under the MIT License - see LICENSE for more details.

相关仓库
ageitgey/face_recognition

The world's simplest facial recognition api for Python and the command line

PythonPyPIMIT Licensemachine-learningface-detection
56.6k13.7k
deepinsight/insightface

State-of-the-art 2D and 3D Face Analysis Project

PythonPyPIface-recognitionface-detection
insightface.ai
29.3k6.1k
justadudewhohacks/face-api.js

JavaScript API for face detection and face recognition in the browser and nodejs with tensorflow.js

TypeScriptnpmMIT Licenseface-recognitionjavascript
17.9k3.9k
davidsandberg/facenet

Face recognition using Tensorflow

PythonPyPIMIT Licenseface-recognitiontensorflow
14.3k4.8k
PaddlePaddle/PaddleDetection

Object Detection toolkit based on PaddlePaddle. It supports object detection, instance segmentation, multiple object tracking and real-time multi-person keypoint detection.

PythonPyPIApache License 2.0object-detectioninstance-segmentation
14.3k3k
ShiqiYu/libfacedetection

An open source library for face detection in images. The face detection speed can reach 1000FPS.

C++Otherface-detectioncnn
12.8k3k
esimov/caire

Content aware image resize library

GoGo ModulesMIT Licenseseam-carvingimage-processing
10.5k386
react-native-camera/react-native-camera

A Camera component for React Native. Also supports barcode scanning!

JavaMavenreact-nativeface-detection
react-native-camera.github.io/react-native-camera/
9.6k3.5k
exadel-inc/CompreFace

Leading free and open-source face recognition system

JavaMavenApache License 2.0face-recognitioncomputer-vision
exadel.com/accelerator-showcase/compreface/
8.1k1.1k
Linzaer/Ultra-Light-Fast-Generic-Face-Detector-1MB

💎1MB lightweight face detection model (1MB轻量级人脸检测模型)

PythonPyPIMIT Licenseface-detectionarm
7.5k1.5k
1adrianb/face-alignment

:fire: 2D and 3D Face alignment library build using pytorch

PythonPyPIBSD 3-Clause "New" or "Revised" Licensepythondeep-learning
adrianbulat.com
7.5k1.4k
amusi/daily-paper-computer-vision

记录每天整理的计算机视觉/深度学习/机器学习相关方向的论文

paperdeep-learning
6.8k1.3k