CV / ArcFace

ArcFace MobileFaceNet

ArcFace face recognition (2.04M params, 99.4% LFW) on reComputer R Series with Hailo-8 or Hailo-10H.

15 downloads
Size
3.91 MB
Memory
4GB+
Precision
Hailo HEF / HailoRT

Choose the device you're using, the set up guide and documentation will update accordingly.

Getting Started

Deploy
sudo docker run --rm \
  --name cm5-hailo8-arcface \
  --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/arcface_mobilefacenet:latest \
  python web_detection.py --model_path model/arcface_mobilefacenet.hef --video_path video/test.mp4

REST API

Use the REST API to run inference. Copy the commands below.

Curl
curl -X POST "http://<Board_IP>:8000/api/models/arcface_mobilefacenet/predict" \
  -F "file=@face.jpg"
Python
import requests
resp = requests.post(
    "http://<Board_IP>:8000/api/models/arcface_mobilefacenet/predict",
    files={"file": open("face.jpg", "rb")},
    timeout=30,
)
print(resp.json())

Model Details

reComputer R Series (CM5 + Hailo-8)

ArcFace MobileFaceNet on reComputer R Series (CM5 + Hailo-8)

ArcFace with a MobileFaceNet backbone extracts 512-dim face embeddings on Hailo-8 through HailoRT. The embedding is used for face verification and identification; face comparison itself is done by the client with cosine similarity.

This page targets reComputer R Series (CM5 + Hailo-8) with a PCIe Hailo-8 accelerator.

Model Info

PropertyValue
ArchitectureArcFace with MobileFaceNet backbone
TaskFace recognition (embedding extraction)
Input112x112x3 RGB (letterboxed, normalization compiled into the HEF)
Output512-dim face embedding
Parameters2.04M
LFW accuracy99.4% (Hailo Model Zoo reference)
HEFHailo Model Zoo v2.19.0, Hailo-8

The accuracy value is Hailo's Model Zoo reference. It is not a benchmark measured on CM5.

Hardware and Host Setup

ItemValue
BoardreComputer R Series with Raspberry Pi CM5
AcceleratorHailo-8 over PCIe, exposed as /dev/hailo0
RuntimeHailoRT 4.23.x
Python in container3.11, aarch64

Install the Hailo-8 packages on the host and confirm that the driver and device are ready before starting the container:

bash
sudo apt update

# Both candidates must be 4.23.x before installation.
apt-cache policy hailort hailort-pcie-driver

sudo apt install hailort=4.23.0 hailort-pcie-driver=4.23.0
sudo reboot

# After reboot
hailortcli --version
hailortcli fw-control identify
ls -l /dev/hailo0

The expected HailoRT version for this image is 4.23.x. Do not continue if apt-cache policy selects HailoRT 5.x; that runtime targets Hailo-10H and does not match this Hailo-8 container.

Run With Demo Video

bash
sudo docker run --rm \
  --name cm5-hailo8-arcface \
  --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/arcface_mobilefacenet:latest \
  python web_detection.py --model_path model/arcface_mobilefacenet.hef --video_path video/test.mp4

Open http://<Board_IP>:8000 to view the web preview. Each frame is annotated with the embedding dimension, and the REST API returns the full 512-dim vector.

USB Camera Mode

bash
sudo docker run --rm \
  --name cm5-hailo8-arcface \
  --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-hailo8-cv/arcface_mobilefacenet:latest \
  python web_detection.py --model_path model/arcface_mobilefacenet.hef --camera_id 0

REST API

Prediction endpoint:

text
POST http://<Board_IP>:8000/api/models/arcface_mobilefacenet/predict
bash
curl -X POST "http://<Board_IP>:8000/api/models/arcface_mobilefacenet/predict" \
  -F "file=@face.jpg"
json
{
  "success": true,
  "source": "uploaded image",
  "embedding": [0.023, -0.156, 0.089, "..."],
  "dimension": 512,
  "image": { "width": 1280, "height": 720 }
}
EndpointMethodPurpose
/GETWeb preview UI
/api/models/arcface_mobilefacenet/predictPOSTFace embedding (JSON)
/api/video_feedGETMJPEG preview stream
/api/configGET / POSTRead or change runtime thresholds
/api/video/uploadPOSTUpload a source video
/api/video/analyzePOSTStart offline video analysis
/api/video/statusGETRead analysis progress
/api/video/download/{filename}GETDownload the annotated result

Face verification is not exposed as a separate endpoint: compare two returned embeddings with cosine similarity on the client side (L2-normalize both vectors first).

Implementation Notes

  • The HEF contains its own normalization layer, so the application letterboxes frames to 112x112, converts BGR to RGB, and feeds raw uint8 pixels.
  • The embedding is read from the arcface_mobilefacenet/fc1 output when the vstream name is exposed; otherwise the first output tensor is used. The first inference logs every vstream name and shape so the mapping can be verified on hardware.
  • Empty or non-finite embeddings are rejected instead of being returned as a valid result.
  • --class_path is accepted for CLI compatibility but has no effect: ArcFace has no class label table.

Development Notes

  • Source module: src/rpi5_hailo8_arcface_mobilefacenet/
  • Dockerfile: docker/hailo8/arcface_mobilefacenet.dockerfile
  • Container: ghcr.io/seeed-projects/recomputer-hailo8-cv/arcface_mobilefacenet:latest
  • HEF: model/arcface_mobilefacenet.hef (4,100,573 bytes)
  • The module uses the HailoRT 4.23 VStreams API and a Hailo-8-specific HEF.

Inputs and Outputs

Input: image (112x112 RGB). Output: 512-dim face embedding vector.