🚀 Retinaface
Retinaface是一个基于深度学习的人脸检测模型,它能够精准定位人脸的边界框和面部关键点。该模型基于PyTorch实现,具有高效、准确的特点,可广泛应用于人脸识别、表情分析等领域。
🚀 快速开始
Retinaface模型的使用示例如下:
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)
✨ 主要特性
- 基于PyTorch实现,易于使用和扩展。
- 采用
mobilenet0.25
作为骨干网络,参数少,计算效率高;也可使用resnet50
作为骨干网络,以获得更好的检测效果。
- 能够返回检测到的每个人脸的边界框位置、人脸检测的置信度分数以及10个面部关键点。
📚 详细文档
模型描述
这是基于biubug6的实现的[RetinaFace: Single-stage Dense Face Localisation in the Wild](RetinaFace: Single-stage Dense Face Localisation in the Wild)的PyTorch实现。Retinaface模型采用了具有多层结构的深度卷积神经网络架构。它使用mobilenet0.25
作为骨干网络(仅170万个参数),但也可以使用resnet50
作为骨干网络以获得更好的结果,但会增加计算开销。
该模型返回每个检测到的人脸的边界框位置、人脸检测的置信度分数以及10个面部关键点。
模型详情
属性 |
详情 |
模型类型 |
卷积神经网络(Mobilenet骨干网络) |
框架 |
pytorch |
模型来源
评估结果
该模型在WIDER FACE数据集上进行了评估,具体的基准测试结果可参考biubug6的仓库。
引用
如果您在研究或应用中使用了Retinaface模型,请引用以下论文:
@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}
}
致谢
感谢贡献者和开源社区在模型开发过程中的宝贵支持。特别感谢原Retinaface论文的作者、WIDER FACE数据集以及biubug6分享的权重和代码。
许可证