{"id":27026867,"url":"https://github.com/serengil/retinaface","last_synced_at":"2025-04-27T04:48:53.897Z","repository":{"id":37365323,"uuid":"361532431","full_name":"serengil/retinaface","owner":"serengil","description":"RetinaFace: Deep Face Detection Library for Python","archived":false,"fork":false,"pushed_at":"2025-03-31T11:38:25.000Z","size":14084,"stargazers_count":1490,"open_issues_count":1,"forks_count":169,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-04-25T18:23:08.174Z","etag":null,"topics":["face-alignment","face-detection","face-detector","face-recognition","insightface","python","retinaface","retinaface-detector","tensorflow"],"latest_commit_sha":null,"homepage":"https://www.youtube.com/watch?v=Wm1DucuQk70\u0026list=PLsS_1RYmYQQFdWqxQggXHynP1rqaYXv_E\u0026index=3","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/serengil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"serengil","patreon":"serengil","buy_me_a_coffee":"serengil"}},"created_at":"2021-04-25T20:34:22.000Z","updated_at":"2025-04-25T03:41:08.000Z","dependencies_parsed_at":"2024-02-10T22:21:17.164Z","dependency_job_id":"ada72ca9-09e3-40d6-af12-aa7dc649a332","html_url":"https://github.com/serengil/retinaface","commit_stats":{"total_commits":130,"total_committers":6,"mean_commits":"21.666666666666668","dds":0.09999999999999998,"last_synced_commit":"878a1f6c5fa38227aa19b9881f1169b361563615"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serengil%2Fretinaface","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serengil%2Fretinaface/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serengil%2Fretinaface/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serengil%2Fretinaface/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serengil","download_url":"https://codeload.github.com/serengil/retinaface/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250869967,"owners_count":21500413,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["face-alignment","face-detection","face-detector","face-recognition","insightface","python","retinaface","retinaface-detector","tensorflow"],"created_at":"2025-04-04T23:16:13.608Z","updated_at":"2025-04-25T18:23:20.744Z","avatar_url":"https://github.com/serengil.png","language":"Python","funding_links":["https://github.com/sponsors/serengil","https://patreon.com/serengil","https://buymeacoffee.com/serengil","https://www.patreon.com/serengil?repo=retinaface"],"categories":["Projects","Python","Open-Source Libraries"],"sub_categories":["Global AI Projects","General-Purpose Machine Learning","Face Detection \u0026 Tracking"],"readme":"# RetinaFace\n\n\u003cdiv align=\"center\"\u003e\n\n[![PyPI Downloads](https://static.pepy.tech/personalized-badge/retina-face?period=total\u0026units=international_system\u0026left_color=grey\u0026right_color=blue\u0026left_text=downloads)](https://pepy.tech/project/retina-face)\n[![Stars](https://img.shields.io/github/stars/serengil/retinaface?color=yellow\u0026style=flat\u0026label=%E2%AD%90%20stars)](https://github.com/serengil/retinaface/stargazers)\n[![License](http://img.shields.io/:license-MIT-green.svg?style=flat)](https://github.com/serengil/retinaface/blob/master/LICENSE)\n[![Tests](https://github.com/serengil/retinaface/actions/workflows/tests.yml/badge.svg)](https://github.com/serengil/retinaface/actions/workflows/tests.yml)\n[![DOI](http://img.shields.io/:DOI-10.17671/gazibtd.1399077-blue.svg?style=flat)](https://doi.org/10.17671/gazibtd.1399077)\n\n[![Blog](https://img.shields.io/:blog-sefiks.com-blue.svg?style=flat\u0026logo=wordpress)](https://sefiks.com)\n[![YouTube](https://img.shields.io/:youtube-@sefiks-red.svg?style=flat\u0026logo=youtube)](https://www.youtube.com/@sefiks?sub_confirmation=1)\n[![Twitter](https://img.shields.io/:follow-@serengil-blue.svg?style=flat\u0026logo=x)](https://twitter.com/intent/user?screen_name=serengil)\n\n[![Patreon](https://img.shields.io/:become-patron-f96854.svg?style=flat\u0026logo=patreon)](https://www.patreon.com/serengil?repo=retinaface)\n[![GitHub Sponsors](https://img.shields.io/github/sponsors/serengil?logo=GitHub\u0026color=lightgray)](https://github.com/sponsors/serengil)\n[![Buy Me a Coffee](https://img.shields.io/badge/-buy_me_a%C2%A0coffee-gray?logo=buy-me-a-coffee)](https://buymeacoffee.com/serengil)\n\n\u003c!--\n[![DOI](http://img.shields.io/:DOI-10.1109/ASYU50717.2020.9259802-blue.svg?style=flat)](https://doi.org/10.1109/ASYU50717.2020.9259802)\n[![DOI](http://img.shields.io/:DOI-10.1109/ICEET53442.2021.9659697-blue.svg?style=flat)](https://doi.org/10.1109/ICEET53442.2021.9659697)\n--\u003e\n\n\u003c/div\u003e\n\nRetinaFace 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.\n\nRetinaFace is the face detection module of [insightface](https://github.com/deepinsight/insightface) project. The original implementation is mainly based on mxnet. Then, its tensorflow based [re-implementation](https://github.com/StanislasBertrand/RetinaFace-tf2) is published by [Stanislas Bertrand](https://github.com/StanislasBertrand). 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.\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/serengil/retinaface/master/tests/outputs/img3.jpg\" width=\"90%\" height=\"90%\"\u003e\n\u003cbr\u003e\u003cem\u003eThe Yellow Angels - Fenerbahce Women's Volleyball Team\u003c/em\u003e\n\u003c/p\u003e\n\n## Installation [![PyPI](https://img.shields.io/pypi/v/retina-face.svg)](https://pypi.org/project/retina-face/)\n\nThe easiest way to install retinaface is to download it from [PyPI](https://pypi.org/project/retina-face/). It's going to install the library itself and its prerequisites as well.\n\n```shell\n$ pip install retina-face\n```\n\nThen, you will be able to import the library and use its functionalities.\n\n```python\nfrom retinaface import RetinaFace\n```\n\n**Face Detection** - [`Demo`](https://youtu.be/Wm1DucuQk70)\n\nRetinaFace offers a face detection function. It expects an exact path of an image as input.\n\n```python\nresp = RetinaFace.detect_faces(\"img1.jpg\")\n```\n\nThen, it will return the facial area coordinates and some landmarks (eyes, nose and mouth) with a confidence score.\n\n```json\n{\n    \"face_1\": {\n        \"score\": 0.9993440508842468,\n        \"facial_area\": [155, 81, 434, 443],\n        \"landmarks\": {\n          \"right_eye\": [257.82974, 209.64787],\n          \"left_eye\": [374.93427, 251.78687],\n          \"nose\": [303.4773, 299.91144],\n          \"mouth_right\": [228.37329, 338.73193],\n          \"mouth_left\": [320.21982, 374.58798]\n        }\n  }\n}\n```\n\n**Alignment** - [`Tutorial`](https://sefiks.com/2020/02/23/face-alignment-for-face-recognition-in-python-within-opencv/), [`Demo`](https://youtu.be/WA9i68g4meI)\n\nA modern face recognition [pipeline](https://sefiks.com/2020/05/01/a-gentle-introduction-to-face-recognition-in-deep-learning/) consists of 4 common stages: detect, [align](https://sefiks.com/2020/02/23/face-alignment-for-face-recognition-in-python-within-opencv/), [normalize](https://sefiks.com/2020/11/20/facial-landmarks-for-face-recognition-with-dlib/), [represent](https://sefiks.com/2020/12/14/deep-face-recognition-with-arcface-in-keras-and-python/) and [verify](https://sefiks.com/2020/05/22/fine-tuning-the-threshold-in-face-recognition/). 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.\n\n```python\nimport matplotlib.pyplot as plt\nfaces = RetinaFace.extract_faces(img_path = \"img.jpg\", align = True)\nfor face in faces:\n  plt.imshow(face)\n  plt.show()\n```\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/serengil/retinaface/master/tests/outputs/alignment-procedure.png\" width=\"80%\" height=\"80%\"\u003e\u003c/p\u003e\n\n**Face Recognition** - [`Demo`](https://youtu.be/WnUVYQP4h44)\n\nNotice that face recognition module of insightface project is [ArcFace](https://sefiks.com/2020/12/14/deep-face-recognition-with-arcface-in-keras-and-python/), and face detection module is RetinaFace. ArcFace and RetinaFace pair is wrapped in [deepface](https://github.com/serengil/deepface) library for Python. Consider to use deepface if you need an end-to-end face recognition pipeline.\n\n```python\n#!pip install deepface\nfrom deepface import DeepFace\nobj = DeepFace.verify(\"img1.jpg\", \"img2.jpg\"\n          , model_name = 'ArcFace', detector_backend = 'retinaface')\nprint(obj[\"verified\"])\n```\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/serengil/retinaface/master/tests/outputs/retinaface-arcface.png\" width=\"100%\" height=\"100%\"\u003e\u003c/p\u003e\n\nNotice that ArcFace got 99.40% accuracy on [LFW data set](https://sefiks.com/2020/08/27/labeled-faces-in-the-wild-for-face-recognition/) whereas human beings just have 97.53% confidence.\n\n## Contribution [![Tests](https://github.com/serengil/retinaface/actions/workflows/tests.yml/badge.svg)](https://github.com/serengil/retinaface/actions/workflows/tests.yml)\n\nPull 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](https://github.com/serengil/retinaface/actions) before approval.\n\n## Support\n\nThere are many ways to support a project. Starring⭐️ the repo is just one 🙏\n\nYou can also support this work on [Patreon](https://www.patreon.com/serengil?repo=retinaface), [GitHub Sponsors](https://github.com/sponsors/serengil), or [Buy Me a Coffee](https://buymeacoffee.com/serengil).\n\n\u003ca href=\"https://www.patreon.com/serengil?repo=retinaface\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/serengil/retinaface/master/icons/patreon.png\" width=\"30%\" height=\"30%\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://buymeacoffee.com/serengil\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/serengil/retinaface/master/icons/bmc-button.png\" width=\"25%\" height=\"25%\"\u003e\n\u003c/a\u003e\n\nAlso, your company's logo will be shown on README on GitHub if you become sponsor in gold, silver or bronze tiers.\n\n## Acknowledgements\n\nThis work is mainly based on the [insightface](https://github.com/deepinsight/insightface) project and [retinaface](https://arxiv.org/pdf/1905.00641.pdf) paper; and it is heavily inspired from the re-implementation of [retinaface-tf2](https://github.com/StanislasBertrand/RetinaFace-tf2) by [Stanislas Bertrand](https://github.com/StanislasBertrand). Finally, Bertrand's [implementation](https://github.com/StanislasBertrand/RetinaFace-tf2/blob/master/rcnn/cython/cpu_nms.pyx) uses [Fast R-CNN](https://arxiv.org/abs/1504.08083) written by [Ross Girshick](https://github.com/rbgirshick/fast-rcnn) in the background. All of those reference studies are licensed under MIT license.\n\n## Citation\n\nIf you are using RetinaFace in your research, please consider to cite its [original research paper](https://arxiv.org/abs/1905.00641). Besides, if you are using this re-implementation of retinaface, please consider to cite the following research papers as well. Here are examples of its BibTeX entries:\n\n```BibTeX\n@article{serengil2024lightface,\n  title     = {A Benchmark of Facial Recognition Pipelines and Co-Usability Performances of Modules},\n  author    = {Serengil, Sefik and Ozpinar, Alper},\n  journal   = {Journal of Information Technologies},\n  volume    = {17},\n  number    = {2},\n  pages     = {95-107},\n  year      = {2024},\n  doi       = {10.17671/gazibtd.1399077},\n  url       = {https://dergipark.org.tr/en/pub/gazibtd/issue/84331/1399077},\n  publisher = {Gazi University}\n}\n```\n\n```BibTeX\n@inproceedings{serengil2020lightface,\n  title        = {LightFace: A Hybrid Deep Face Recognition Framework},\n  author       = {Serengil, Sefik Ilkin and Ozpinar, Alper},\n  booktitle    = {2020 Innovations in Intelligent Systems and Applications Conference (ASYU)},\n  pages        = {23-27},\n  year         = {2020},\n  doi          = {10.1109/ASYU50717.2020.9259802},\n  url          = {https://doi.org/10.1109/ASYU50717.2020.9259802},\n  organization = {IEEE}\n}\n```\n\nFinally, if you use this RetinaFace re-implementation in your GitHub projects, please add `retina-face` dependency in the requirements.txt.\n\n## Licence\n\nThis project is licensed under the MIT License - see [`LICENSE`](https://github.com/serengil/retinaface/blob/master/LICENSE) for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserengil%2Fretinaface","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserengil%2Fretinaface","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserengil%2Fretinaface/lists"}