CV / RetinaFace
RetinaFace MobileNet-v1
reComputer R Series (CM5 + Hailo-8)
Gesichtsdetektion als einzelne Klasse mit 5 Gesichtspunkten pro Gesicht auf reComputer R Series mit Hailo-8.
Wähle das Gerät, das du verwendest. Die Einrichtungsanleitung und Dokumentation werden entsprechend aktualisiert.
Erste Schritte
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.mp4REST API
Verwende die REST API für die Inferenz. Kopiere die folgenden Befehle.
curl -X POST "http://<Board_IP>:8000/api/models/retinaface_mobilenet_v1/predict" \
-F "file=@test.jpg"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())Modelldetails
RetinaFace MobileNet-v1 auf reComputer R Series (CM5 + Hailo-8)
RetinaFace erkennt über HailoRT auf Hailo-8 Gesichter und jeweils 5 Merkmale (Augen, Nasenspitze, Mundwinkel). Das HEF stellt 9 rohe Ausgabeköpfe bereit; die Decodierung läuft auf der Host-CPU.
Modellinformationen
| Eigenschaft | Wert |
|---|---|
| Architektur | RetinaFace, MobileNet-v1-Backbone (biubug6/Pytorch_Retinaface) |
| Aufgabe | Gesichtsdetektion |
| Eingabe | 736x1280x3 BGR (normalize_in_net mean [123,117,104]) |
| Ausgabe | 9 Köpfe: 3 Skalen x {bbox, conf, landmark} |
| Prior-Anchors | 38,640 Anchors (2/Zelle, Feature-Maps 92x160/46x80/23x40) |
| Klassen | 1 (Gesicht) + 5 Merkmale je Erkennung |
| Parameter | 3.49M |
| Operationen | 25.14G |
| mAP (WIDER FACE) | 81.3% Hardware-Referenz |
| HEF | Hailo Model Zoo v2.19.0, Hailo-8 |
Der obige Genauigkeitswert ist eine Referenz aus Hailo Model Zoo, kein auf CM5 gemessener Benchmark.
Mit Demovideo ausführen
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Öffnen Sie http://<Board_IP>:8000 für die Webvorschau (Gesichtsboxen und grüne Merkmale über dem MJPEG-Stream).
REST-API
curl -X POST "http://<Board_IP>:8000/api/models/retinaface_mobilenet_v1/predict" \
-F "file=@test.jpg"| Endpunkt | Methode | Zweck |
|---|---|---|
/ | GET | Webvorschau-Oberfläche |
/api/models/retinaface_mobilenet_v1/predict | POST | Gesichter + Merkmale (JSON) |
/api/video_feed | GET | MJPEG-Vorschaustream |
/api/config | GET / POST | Konfidenz-/NMS-IOU-Schwellen |
Implementierungshinweise
- CPU-Nachverarbeitung (
meta_arch=retinaface): kein NMS auf dem Chip. Anchor-Erzeugung, SSD-Decodierung (Varianzen 10/5), Softmax-Konfidenz, Greedy NMS und Merkmalsdecodierung sind eine numpy-Portierung vonface_detection_postprocessing.pyaus Model Zoo. - Kopflayout gemäß offiziellen Umformungen: 8 Kanäle = bbox (2 Anchors x 4 Koordinaten), 4 Kanäle = confidence (2 Anchors x {background, face}), 20 Kanäle = landmarks (2 Anchors x 10 Koordinaten).
- Das alls-Skript wendet
input_conversion(bgr_to_rgb)im HEF an; die Anwendung liefert rohe uint8-BGR-Bilder. - Vorverarbeitung: Skalierung unter Beibehaltung des Seitenverhältnisses, dann Padding unten/rechts (Farbe 0) auf 736x1280.
Entwicklungshinweise
- Quellmodul:
src/rpi5_hailo8_retinaface_mobilenet_v1/ - Dockerfile:
docker/hailo8/retinaface_mobilenet_v1.dockerfile - Container:
ghcr.io/seeed-projects/recomputer-hailo8-cv/retinaface_mobilenet_v1:latest - Familie: RetinaFace (Variante: mobilenet_v1)
Eingaben und Ausgaben
Eingabe: Bild, Video oder USB-Kamerabild. Ausgabe: Gesichtsbereiche mit Konfidenzwerten, 5 Schlüsselpunkte pro Gesicht (Augen, Nase, Mundwinkel) und eine annotierte MJPEG-Vorschau.