RetinaFace: Deep Face Detection Framework in TensorFlow for Python
Project description
RetinaFace
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.
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.
Notice that face recognition module of insightface project is called as ArcFace.
Installation
The easiest way to install retinaface is to download it from pypi.
pip install retina-face
Face Detection
RetinaFace offers a face detection function. It expects an exact path of an image as input.
from retina-face import RetinaFace
resp = RetinaFace.detect_faces("img1.jpg")
Then it returns 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
A modern face recognition pipeline consists of 4 common stages: detect, align, 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 extract faces function.
import matplotlib.pyplot as plt
faces = RetinaFace.extract_faces(img_path = "img.jpg")
for face in faces:
plt.imshow(img)
plt.show()
FAQ and troubleshooting
Pre-trained weights of the retinaface model is going to be downloaded from Google Drive once. Download limit of my Google Drive account might be exceeded sometimes. In this case, you will have an exception like "too many users have viewed or downloaded this file recently. Please try accessing the file again later". Still, you can access the pre-trained weights on Google Drive. Please, download it here and copy to the HOME/.deepface/weights folder manually.
You can find out your HOME_FOLDER with python as shown below.
from pathlib import Path
home = str(Path.home())
print("HOME_FOLDER is ",home)
Support
There are many ways to support a project. Starring⭐️ the repo is just one🙏
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.
Licence
This project is licensed under the MIT License - see LICENSE
for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file retina-face-0.0.1.tar.gz
.
File metadata
- Download URL: retina-face-0.0.1.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e164cb0d3b6c462b5dea48a808edcb2cfd8698b7f9e6439c9370af3f16edd58 |
|
MD5 | eca7b04bee64cd0ddce7f5b8fde7b22d |
|
BLAKE2b-256 | 40d3d640210ac72403ff5c9b6378f2e5f1edbe151e3c14bfa7d93252e7b1c4cf |
File details
Details for the file retina_face-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: retina_face-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cf68e0de5d870c15053c51e530b7ef37cda7c153eac712113e9de9cb7ba8e90 |
|
MD5 | d3b2f9a6a26948ebba77b10a2475e0a5 |
|
BLAKE2b-256 | 44256371924dc37e7d77cb73878ee849a85a5eba23843602794f68b55a418829 |