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.

18 Downloads
Größe
6.3 MB
Speicher
4GB+
Präzision
Hailo HEF / HailoRT 4.23.x

Wähle das Gerät, das du verwendest. Die Einrichtungsanleitung und Dokumentation werden entsprechend aktualisiert.

Erste Schritte

Bereitstellen
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

Verwende die REST API für die Inferenz. Kopiere die folgenden Befehle.

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())

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

EigenschaftWert
ArchitekturRetinaFace, MobileNet-v1-Backbone (biubug6/Pytorch_Retinaface)
AufgabeGesichtsdetektion
Eingabe736x1280x3 BGR (normalize_in_net mean [123,117,104])
Ausgabe9 Köpfe: 3 Skalen x {bbox, conf, landmark}
Prior-Anchors38,640 Anchors (2/Zelle, Feature-Maps 92x160/46x80/23x40)
Klassen1 (Gesicht) + 5 Merkmale je Erkennung
Parameter3.49M
Operationen25.14G
mAP (WIDER FACE)81.3% Hardware-Referenz
HEFHailo 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

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

Öffnen Sie http://<Board_IP>:8000 für die Webvorschau (Gesichtsboxen und grüne Merkmale über dem MJPEG-Stream).

REST-API

bash
curl -X POST "http://<Board_IP>:8000/api/models/retinaface_mobilenet_v1/predict" \
  -F "file=@test.jpg"
EndpunktMethodeZweck
/GETWebvorschau-Oberfläche
/api/models/retinaface_mobilenet_v1/predictPOSTGesichter + Merkmale (JSON)
/api/video_feedGETMJPEG-Vorschaustream
/api/configGET / POSTKonfidenz-/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 von face_detection_postprocessing.py aus 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

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.