🚀 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分享的權重和代碼。
許可證