CV / 人物属性
Person Attribute ResNet
Person Attribute ResNet 在 R20 HailoRT 平台上对图像和预览帧进行人物属性分类。
大小
12.04 MB内存
4GB+精度
Hailo HEF / HailoRT 4.23.x选择你正在使用的设备,设置指南和文档将相应更新。
快速开始
部署
sudo docker run --rm \
--name cm5-hailo-person-attr-resnet \
--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-r20-cv/person_attr_resnet:latest \
python web_detection.py --model_path model/person_attr_resnet_v1_18.hef --video_path video/test.mp4REST API
使用 REST API 进行推理。复制以下命令。
Curl
curl -X POST "http://<R20_IP>:8000/api/models/person_attr_resnet/predict" \
-F "file=@test.jpg"Python
import requests
resp = requests.post(
"http://<R20_IP>:8000/api/models/person_attr_resnet/predict",
files={"file": open("test.jpg", "rb")},
timeout=30,
)
print(resp.json())模型详情
Person Attribute ResNet 在 reComputer R Series (CM5 + Hailo)
Person Attribute ResNet classifies person attributes from images and live sources through a HailoRT FastAPI service.
本页面内容改编自 rpi5_hailo8_person_attr_resnet/README.md 仓库中的 reComputer-R20-CV。目标平台为 reComputer R Series (CM5 + Hailo) 搭配 PCIe Hailo-8 加速器。
硬件与主机设置
| 项目 | 值 |
|---|---|
| 开发板 | reComputer R Series with Raspberry Pi CM5 |
| 加速器 | Hailo-8 M.2 over PCIe,设备节点 /dev/hailo0 |
| 操作系统 | Raspberry Pi 操作系统 Bookworm, aarch64 |
| 主机驱动 | hailo-all apt 包 |
| 已验证 HailoRT | 4.23.x; 主机驱动、固件、原生库和 Python wheel 必须共享相同的主版本号.次版本号 |
bash
sudo apt update
sudo apt install hailo-all
sudo 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使用演示视频运行
bash
sudo docker run --rm --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-r20-cv/person_attr_resnet:latest \
python web_detection.py --model_path model/person_attr_resnet_v1_18.hef --video_path video/test.mp4打开 http://<R20_IP>:8000 查看 Web 预览。 镜像包含模块源码、演示视频、HailoRT Python wheel 以及下列 HEF 文件。
libhailort.so 绑定挂载特地来自主机。如果您的固件版本不是 4.23.0,请将两个路径替换为 hailortcli fw-control identify 报告的版本号;如果主版本号.次版本号不同,请重新构建镜像。
USB 摄像头模式
bash
sudo docker run --rm --privileged --net=host \
-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-r20-cv/person_attr_resnet:latest \
python web_detection.py --model_path model/person_attr_resnet_v1_18.hef --camera_id 0HEF 文件
| HEF | 大小 | 备注 |
|---|---|---|
person_attr_resnet_v1_18.hef | 12.04 MB | 人物属性分类器 |
REST API
预测端点:
text
P操作系统T http://<R20_IP>:8000/api/models/person_attr_resnet/predict示例图片请求:
bash
curl -X P操作系统T "http://<R20_IP>:8000/api/models/person_attr_resnet/predict" \
-F "file=@test.jpg"通用服务端点:
| Endpoint | 方法 | 用途 |
|---|---|---|
/ | GET | Web 预览界面 |
/api/models/person_attr_resnet/predict | P操作系统T | 从上传的图片/视频或当前帧进行单帧推理 |
/video_feed | GET | MJPEG 预览流 |
/api/config | GET / P操作系统T | 读取或更新运行时阈值 |
/api/video/upload | P操作系统T | 上传视频进行离线分析 |
/api/video/analyze | P操作系统T | 开始离线分析 |
/api/video/status | GET | 轮询分析进度 |
/api/video/list | GET | 列出已上传和已处理的视频 |
/api/video/download/{filename} | GET | 下载处理后的输出 |
开发说明
- 源模块:
src/rpi5_hailo8_person_attr_resnet/ - Dockerfile:
docker/hailo8/person_attr_resnet.dockerfile - 主服务:
web_detection.py封装了 HailoRT 推理、后处理、MJPEG 预览、REST 预测和离线视频分析。 - 当替换自定义 HEF 时,确保输出布局与模块后处理代码兼容,或更新
post_process_hailo().
输入与输出
Input: image file for REST inference, plus video or camera source for preview. Output: attribute labels, scores, threshold, and annotated JPEG.