đ Retinaface
This is a PyTorch implementation of RetinaFace, a single - stage dense face localisation model in the wild. It can detect face bounding boxes, confidence scores, and 10 facial landmark keystones.
đ Quick Start
The Retinaface model is a powerful tool for face detection. It can be used to detect faces in images and return relevant information such as bounding boxes and facial landmarks. You can follow the example usage section below to start using this model.
⨠Features
- Based on a deep convolutional neural network architecture with multiple layers.
- Can use
mobilenet0.25
(only 1.7M parameters) or resnet50
as the backbone network.
- Returns bounding box locations, confidence scores, and 10 facial landmark keystones for each detected face.
đĻ Installation
The installation steps are not provided in the original document, so this section is skipped.
đģ Usage Examples
Basic Usage
import os
import torch
import json
from PIL import Image
from huggingface_hub import hf_hub_download
from feat.face_detectors.Retinaface.Retinaface_model import RetinaFace, postprocess_retinaface
from feat.utils.io import get_resource_path, get_test_data_path
from feat.utils.image_operations import convert_image_to_tensor, convert_color_vector_to_tensor
device = 'cpu'
face_config_file = hf_hub_download(
repo_id="py-feat/retinaface",
filename="config.json",
cache_dir=get_resource_path(),
)
with open(face_config_file, "r") as f:
face_config = json.load(f)
face_model_file = hf_hub_download(repo_id='py-feat/retinaface',
filename="mobilenet0.25_Final.pth",
cache_dir=get_resource_path())
face_checkpoint = torch.load(face_model_file, map_location=device, weights_only=True)
face_detector = RetinaFace(cfg=face_config, phase="test")
face_detector.load_state_dict(face_checkpoint)
face_detector.eval()
face_detector.to(device)
frame = Image.open(os.path.join(get_test_data_path(), "multi_face.jpg"))
single_frame = torch.sub(frame, convert_color_vector_to_tensor(np.array([123, 117, 104])))
predicted_locations, predicted_scores, predicted_landmarks = face_detector.forward(single_frame.to(device))
face_output = postprocess_retinaface(predicted_locations, predicted_scores, predicted_landmarks, face_config, single_frame, device=device)
đ Documentation
Model Description
This is a PyTorch implementation of [RetinaFace: Single - stage Dense Face Localisation in the Wild](RetinaFace: Single - stage Dense Face Localisation in the Wild) based on biubug6's implementation. The Retinaface model utilizes a deep convolutional neural network architecture with multiple layers. It uses mobilenet0.25
as the backbone network (only 1.7M parameters) but can also use resnet50
as the backbone to achieve better results, but with additional computational overhead.
This model returns bounding box locations of each detected face, confidence scores in the face detection, as well as 10 facial landmark keystones.
Model Details
Property |
Details |
Model Type |
Convolutional Neural Network (Mobilenet backbone) |
Framework |
pytorch |
Model Sources
Evaluation Results
The model was evaluated on the WIDER FACE dataset. See the benchmark results in biubug6 repository
Citation
If you use the Retinaface model in your research or application, please cite the following paper:
@misc{deng2019retinafacesinglestagedenseface,
title={RetinaFace: Single - stage Dense Face Localisation in the Wild},
author={Jiankang Deng and Jia Guo and Yuxiang Zhou and Jinke Yu and Irene Kotsia and Stefanos Zafeiriou},
year={2019},
eprint={1905.00641},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/1905.00641}
}
đ§ Technical Details
The technical details section in the original document is not detailed enough, so this section is skipped.
đ License
Acknowledgements
We thank the contributors and the open - source community for their valuable support in developing this model. Special thanks to the authors of the original Retinaface paper, the WIDER FACE dataset, and biubug6 for sharing weights and code.