CV / RetinaFace

RetinaFace MobileNet-v1

reComputer R Series (CM5 + Hailo-8)

在搭载 Hailo-8 的 reComputer R Series 上进行单类别人脸检测,并为每张人脸输出 5 个关键点。

18 次下载
大小
6.3 MB
内存
4GB+
精度
Hailo HEF / HailoRT 4.23.x

选择你正在使用的设备,设置指南和文档将相应更新。

快速开始

部署
sudo docker run --rm \
  --name cm5-hailo8-retinaface \
  --privileged \
  --net=host \
  -e PYTHONUNBUFFERED=1 \
  --device /dev/hailo0:/dev/hailo0 \
  -v /usr/lib/libhailort.so.4.23.0:/usr/lib/libhailort.so.4.23.0:ro \
  -v /usr/lib/libhailort.so:/usr/lib/libhailort.so:ro \
  ghcr.io/seeed-projects/recomputer-hailo8-cv/retinaface_mobilenet_v1:latest \
  python web_detection.py --model_path model/retinaface_mobilenet_v1.hef --video_path video/test.mp4

REST API

使用 REST API 进行推理。复制以下命令。

Curl
curl -X POST "http://<Board_IP>:8000/api/models/retinaface_mobilenet_v1/predict" \
  -F "file=@test.jpg"
Python
import requests

response = requests.post(
    "http://<Board_IP>:8000/api/models/retinaface_mobilenet_v1/predict",
    files={"file": open("test.jpg", "rb")},
    timeout=30,
)
print(response.json())

模型详情

RetinaFace MobileNet-v1 在 reComputer R Series(CM5 + Hailo-8)上运行

RetinaFace 通过 HailoRT 在 Hailo-8 上检测人脸及每张人脸的 5 个关键点(双眼、鼻尖、嘴角)。HEF 暴露 9 个原始输出头,解码在主机 CPU 上执行。

模型信息

属性值
架构RetinaFace,MobileNet-v1 骨干网络(biubug6/Pytorch_Retinaface)
任务人脸检测
输入736x1280x3 BGR(normalize_in_net mean [123,117,104])
输出9 个输出头:3 个尺度 x {bbox, conf, landmark}
先验框38,640 个锚框(2/单元,特征图 92x160/46x80/23x40)
类别数1(人脸)+ 每个检测结果 5 个关键点
参数量3.49M
运算量25.14G
mAP(WIDER FACE)81.3% 硬件参考值
HEFHailo Model Zoo v2.19.0, Hailo-8

上述精度值来自 Hailo Model Zoo 的参考数据,不是在 CM5 上实测的基准结果。

使用演示视频运行

bash
sudo docker run --rm \
  --name cm5-hailo8-retinaface \
  --privileged \
  --net=host \
  -e PYTHONUNBUFFERED=1 \
  --device /dev/hailo0:/dev/hailo0 \
  -v /usr/lib/libhailort.so.4.23.0:/usr/lib/libhailort.so.4.23.0:ro \
  -v /usr/lib/libhailort.so:/usr/lib/libhailort.so:ro \
  ghcr.io/seeed-projects/recomputer-hailo8-cv/retinaface_mobilenet_v1:latest \
  python web_detection.py --model_path model/retinaface_mobilenet_v1.hef --video_path video/test.mp4

打开 http://<Board_IP>:8000 查看网页预览(MJPEG 流上叠加人脸框和绿色关键点)。

REST API

bash
curl -X POST "http://<Board_IP>:8000/api/models/retinaface_mobilenet_v1/predict" \
  -F "file=@test.jpg"
端点方法用途
/GET网页预览界面
/api/models/retinaface_mobilenet_v1/predictPOST人脸 + 关键点(JSON)
/api/video_feedGETMJPEG 预览流
/api/configGET / POST置信度 / NMS IOU 阈值

实现说明

  • CPU 后处理(meta_arch=retinaface):不使用片上 NMS。锚框生成、SSD 解码(方差 10/5)、softmax 置信度、贪心 NMS 和关键点解码均基于 Model Zoo 的 face_detection_postprocessing.py 移植为 numpy 实现。
  • 按官方 reshape 的输出头布局:8 通道头 = bbox(2 个锚框 x 4 个坐标),4 通道头 = confidence(2 个锚框 x {background, face}),20 通道头 = landmarks(2 个锚框 x 10 个坐标)。
  • alls 脚本在 HEF 中应用 input_conversion(bgr_to_rgb);应用输入原始 uint8 BGR 帧。
  • 预处理:保持宽高比缩放,并在底部/右侧填充(颜色 0)至 736x1280。

开发说明

  • 源码模块: src/rpi5_hailo8_retinaface_mobilenet_v1/
  • Dockerfile: docker/hailo8/retinaface_mobilenet_v1.dockerfile
  • 容器: ghcr.io/seeed-projects/recomputer-hailo8-cv/retinaface_mobilenet_v1:latest
  • 系列:RetinaFace(变体:mobilenet_v1)

输入与输出

Input: image, video, or USB camera frame. Output: face boxes with confidences, 5 keypoints per face (eyes, nose, mouth corners), and an annotated MJPEG preview.