Package: retina-face
RetinaFaceRetinaFace 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 ofinsightfaceproject. The original implementation is mainly based on mxnet. Then, its tensorflow basedre-implementationis published byStanislas 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 TeamInstallationThe easiest way to install retinaface is to download it fromPyPI. It's going to install the library itself and its prerequisites as well.$pipinstallretina-faceRetinaFace is also available atConda. You can alternatively install the package via conda.$condainstall-cconda-forgeretina-faceThen, you will be able to import the library and use its functionalities.fromretinafaceimportRetinaFaceFace Detection-DemoRetinaFace 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,DemoA modern face recognitionpipelineconsists of 4 common stages: detect,align,normalize,representandverify. 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.importmatplotlib.pyplotaspltfaces=RetinaFace.extract_faces(img_path="img.jpg",align=True)forfaceinfaces:plt.imshow(face)plt.show()Face Recognition-DemoNotice that face recognition module of insightface project isArcFace, and face detection module is RetinaFace. ArcFace and RetinaFace pair is wrapped indeepfacelibrary for Python. Consider to use deepface if you need an end-to-end face recognition pipeline.#!pip install deepfacefromdeepfaceimportDeepFaceobj=DeepFace.verify("img1.jpg","img2.jpg",model_name='ArcFace',detector_backend='retinaface')print(obj["verified"])Notice that ArcFace got 99.40% accuracy onLFW data setwhereas human beings just have 97.53% confidence.ContributionPull requests are more than welcome! You should run the unit tests and linting locally before creating a PR. Commandsmake testandmake lintwill help you to run it locally. Once a PR created, GitHub test workflow will be run automatically and unit test results will be available inGitHub actionsbefore approval.SupportThere are many ways to support a project. Starring⭐️ the repo is just one 🙏You can also support this work onPatreonAcknowledgementsThis work is mainly based on theinsightfaceproject andretinafacepaper; and it is heavily inspired from the re-implementation ofretinaface-tf2byStanislas Bertrand. Finally, Bertrand'simplementationusesFast R-CNNwritten byRoss Girshickin the background. All of those reference studies are licensed under MIT license.CitationIf you are using RetinaFace in your research, please consider to cite itsoriginal research paper. Besides, if you are using this re-implementation of retinaface, please consider to cite the following research papers as well. Here are examples of BibTeX entries:@inproceedings{serengil2020lightface,title={LightFace: A Hybrid Deep Face Recognition Framework},author={Serengil, Sefik Ilkin and Ozpinar, Alper},booktitle={2020 Innovations in Intelligent Systems and Applications Conference (ASYU)},pages={23-27},year={2020},doi={10.1109/ASYU50717.2020.9259802},url={https://doi.org/10.1109/ASYU50717.2020.9259802},organization={IEEE}}@inproceedings{serengil2021lightface,title={HyperExtended LightFace: A Facial Attribute Analysis Framework},author={Serengil, Sefik Ilkin and Ozpinar, Alper},booktitle={2021 International Conference on Engineering and Emerging Technologies (ICEET)},pages={1-4},year={2021},doi={10.1109/ICEET53442.2021.9659697},url={https://doi.org/10.1109/ICEET53442.2021.9659697},organization={IEEE}}Finally, if you use this RetinaFace re-implementation in your GitHub projects, please add retina-face dependency in the requirements.txt.LicenceThis project is licensed under the MIT License - seeLICENSEfor more details.