RetinaFace MobileNet0.25 โ Core ML
A lightweight Core ML conversion of py-feat/retinaface for fast, local face detection and five-point facial landmarks on Apple Silicon.
This model is integrated into Hugging Mac, where developers can build private camera apps, face-aware interfaces, games, plugins, and agents on macOS.
Model details
| Property | Value |
|---|---|
| Backbone | MobileNet0.25 |
| Parameters | 426,608 |
| Input | image: 1 ร 3 ร 640 ร 640 FP32 RGB tensor |
| Face boxes | locations: 1 ร 16800 ร 4 FP32 |
| Scores | scores: 1 ร 16800 ร 2 FP32 |
| Landmarks | landmarks: 1 ร 16800 ร 10 FP32 |
| Core ML compute | FP16 |
| Package size | 0.94 MB |
The ten landmark values represent five (x, y) points: both eyes, nose, and both mouth corners. Outputs are raw and require prior decoding, confidence filtering, NMS, and restoration to the original image coordinates.
Core ML example
from pathlib import Path
import coremltools as ct
import numpy as np
from huggingface_hub import snapshot_download
from PIL import Image, ImageOps
root = Path(snapshot_download(
repo_id="hugging-mac/retinaface-coreml",
allow_patterns=["retinaface.mlpackage/**"],
))
model = ct.models.MLModel(root / "retinaface.mlpackage", compute_units=ct.ComputeUnit.ALL)
image = ImageOps.pad(Image.open("face.jpg").convert("RGB"), (640, 640))
value = np.asarray(image, dtype=np.float32).transpose(2, 0, 1)
value -= np.asarray((123.0, 117.0, 104.0), dtype=np.float32)[:, None, None]
outputs = model.predict({"image": np.ascontiguousarray(value[None])})
print(outputs["locations"].shape) # (1, 16800, 4)
print(outputs["scores"].shape) # (1, 16800, 2)
print(outputs["landmarks"].shape) # (1, 16800, 10)
For complete preprocessing and postprocessing, use the Hugging Mac RetinaFace SDK.
Provenance and integrity
- Upstream model: py-feat/retinaface
- Upstream revision:
31702389094fccc7060c15299e6ad712ee880de6 - Conversion: fixed 640ร640 input, ML Program, FP16 compute
- Directory SHA-256:
6290800b08e20d9d6506795e5e47f1da35f2586ad4e75dcbb08a14ed11b2ed6b
License
The converted model retains the upstream MIT license. Hugging Mac is an independent open-source project and is not affiliated with or endorsed by py-feat.
- Downloads last month
- 5
Model tree for hugging-mac/retinaface-coreml
Base model
py-feat/retinaface