CV / LightFace
LightFace Slim
reComputer R Series(Hailo-8 / Hailo-10H,HailoRT)上的超轻量人脸检测(0.26M 参数)。
64 次下载
内存
4GB+精度
Hailo HEF选择你正在使用的设备,设置指南和文档将相应更新。
快速开始
部署
sudo docker run --rm \
--name cm5-hailo8-lightface \
--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/lightface_slim:latest \
python web_detection.py --model_path model/lightface_slim.hef --video_path video/test.mp4REST API
使用 REST API 进行推理。复制以下命令。
Curl
curl -X POST "http://<Board_IP>:8000/api/models/lightface_slim/predict" \
-F "file=@test.jpg"Python
import requests
resp = requests.post(
"http://<Board_IP>:8000/api/models/lightface_slim/predict",
files={"file": open("test.jpg", "rb")},
timeout=30,
)
print(resp.json())模型详情
reComputer R Series (CM5 + Hailo-8)reComputer R 系列(CM5 + Hailo-8)上的 LightFace Slim
超轻量人脸检测(0.26M 参数)在 Hailo-8 上经 HailoRT 4.23 运行。HEF 输出 SSD 风格的原始分支头(无片上 NMS):主机侧生成 4,420 个锚点,完成 SSD 框解码(方差 10/5)、背景/人脸 logits 的 softmax、阈值筛选与贪心 NMS。
本页面向 reComputer R 系列(CM5 + Hailo-8),使用 PCIe 接口的 Hailo-8 加速器。
模型信息
| 属性 | 值 |
|---|---|
| 架构 | Ultra-Light-Fast-Generic-Face-Detector-1MB(SSD 结构,stride 8/16/32/64) |
| 任务 | 人脸检测(单类 "face",WIDER FACE) |
| 输入 | 240×320×3(应用侧送入 uint8 BGR;mean 127 / std 128 已编译进 HEF) |
| 输出 | 8 个原始分支头:4 个尺度 × {框增量、背景 + 人脸 logits} |
| 解码 | 主机侧 SSD 解码(方差 10/5)+ softmax + 贪心 NMS(meta_arch=retinaface) |
| 参数量 | 0.26M |
| 运算量 | 0.16G |
| 参考 mAP | 39.71(WIDER FACE,全精度,Hailo Model Zoo;非本板实测) |
| 许可 | MIT(Ultra-Light-Fast-Generic-Face-Detector-1MB) |
| 来源 | Hailo Model Zoo |
硬件与宿主环境
| 项目 | 值 |
|---|---|
| 主板 | reComputer R 系列,搭载 Raspberry Pi CM5 |
| 加速器 | Hailo-8(PCIe),设备节点 /dev/hailo0 |
| 运行时 | HailoRT 4.23.x(宿主与容器的主.次版本必须一致) |
| 容器内 Python | 3.11,aarch64 |
bash
sudo apt update
sudo apt install hailort hailort-pcie-driver python3-hailort
sudo reboot
# After reboot
hailortcli fw-control identify
ls /dev/hailo0
# Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh --mirror Aliyun
sudo systemctl enable docker
sudo systemctl start docker直接安装
hailort hailort-pcie-driver python3-hailort,不要用hailo-all(它可能拉到 Hailo-10H / HailoRT 5.x 的包)。
使用内置演示视频运行
bash
sudo docker run --rm --privileged --net=host \
--name cm5-hailo8-lightface \
-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/lightface_slim:latest \
python web_detection.py --model_path model/lightface_slim.hef --video_path video/test.mp4USB 摄像头模式
bash
sudo docker run --rm --privileged --net=host \
--name cm5-hailo8-lightface \
-e PYTHONUNBUFFERED=1 \
--device /dev/hailo0:/dev/hailo0 \
--device /dev/video0:/dev/video0 \
-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/lightface_slim:latest \
python web_detection.py --model_path model/lightface_slim.hef --camera_id 0浏览器打开 http://<Board_IP>:8000 查看 Web 预览。
HEF 文件
| HEF | 大小 | 说明 |
|---|---|---|
lightface_slim.hef | 1,907,332 字节 | Hailo Model Zoo v2.19.0 的 Hailo-8 构建;8 个原始分支头 |
来源:
text
https://hailo-model-zoo.s3.eu-west-2.amazonaws.com/ModelZoo/Compiled/v2.19.0/hailo8/lightface_slim.hefSHA256:e448c0f692f9e907bb7328fc2305ced4d3569f1e0aa26d44439d1a6f003e9314
REST API
text
POST http://<Board_IP>:8000/api/models/lightface_slim/predictbash
curl -X POST "http://<Board_IP>:8000/api/models/lightface_slim/predict" \
-F "file=@test.jpg"返回示例(box 为原图像素坐标 [x1, y1, x2, y2]):
json
{
"predictions": [
{"box": [220, 156, 260, 196], "confidence": 0.98}
]
}| 接口 | 方法 | 说明 |
|---|---|---|
/ | GET | Web 预览界面 |
/api/models/lightface_slim/predict | POST | 人脸框(JSON) |
/api/video_feed | GET | MJPEG 预览流 |
/api/config | GET / POST | 置信度 / IoU 阈值 |
实现说明
- 锚点集来自 zoo 配置:steps 8/16/32/64,min_sizes [10,16,24] / [32,48] / [64,96] / [128,192,256] → 4,420 个锚点。
- 预览置信度阈值 0.5;zoo 评估使用 0.1 与 NMS IoU 0.3。
- 图像按等比缩放并在右侧/底部补 0,与 zoo 的人脸检测预处理一致。
开发说明
- 源码:
src/rpi5_hailo8_lightface_slim/ - Dockerfile:
docker/hailo8/lightface_slim.dockerfile - 验证记录:
src/rpi5_hailo8_lightface_slim/TEST_REPORT.md
输入与输出
Input: image (240x320 RGB). Output: face bounding boxes with confidence scores.