Face detection
RetinaFace MobileNet-0.25
A tiny face detector (1.7 MB of weights) that finds faces and five landmarks on each: eyes, nose tip and mouth corners.
About this model
RetinaFace finds every face in a photo and marks five points on each one: both eyes, the tip of the nose and the corners of the mouth. This version uses a MobileNet-0.25 backbone with 0.43 million parameters, small enough for any phone.
The author of this PyTorch implementation reports WIDER FACE validation AP of 90.7 / 88.2 / 73.8 (easy / medium / hard) when the photo is used at its own size. Slab runs it on a fixed 640 x 640 letterbox, which is faster but misses more of the smallest faces.
What you can build
- Count the people facing a camera
- Crop or center faces for thumbnails and video calls
- Align faces with the five landmarks before face recognition
- Blur faces for privacy
People laughing
f16State Library and Archives of Florida, Public domain, https://commons.wikimedia.org/wiki/File:People_laughing_at_a_dinner_(4563388022).jpg
22 faces on the Apple Neural Engine (FP16 pack), score 0.5 or more, duplicates removed at IoU 0.4: 1.00 at [301, 246, 353, 312] 1.00 at [96, 269, 144, 331] 1.00 at [46, 97, 73, 131] 1.00 at [514, 287, 572, 362] 0.99 at [431, 130, 467, 173] 0.99 at [452, 54, 477, 86] 0.99 at [395, 89, 427, 130] 0.98 at [314, 113, 338, 143] 0.98 at [23, 64, 46, 93] 0.97 at [52, 46, 74, 76] 0.96 at [0, 138, 26, 179] 0.96 at [234, 136, 266, 179] 0.96 at [155, 46, 175, 73] 0.94 at [183, 29, 203, 56] 0.94 at [452, 8, 477, 41] 0.93 at [397, 14, 421, 45] 0.93 at [222, 7, 241, 32] 0.92 at [137, 13, 154, 35] 0.90 at [332, 48, 356, 78] 0.88 at [506, 14, 526, 39] 0.85 at [94, 74, 116, 101] 0.78 at [92, 22, 114, 50]
Students campus
f16Lusanda Madikane, CC0, https://commons.wikimedia.org/wiki/File:Xhosa_Students_Association_Students_from_UFS_Bloemfontein_Campus.jpg
19 faces on the Apple Neural Engine (FP16 pack), score 0.5 or more, duplicates removed at IoU 0.4: 0.98 at [269, 656, 294, 690] 0.92 at [570, 659, 588, 681] 0.90 at [808, 670, 828, 696] 0.89 at [234, 576, 255, 602] 0.85 at [201, 653, 225, 684] 0.85 at [433, 658, 455, 685] 0.80 at [298, 579, 315, 599] 0.78 at [38, 586, 58, 614] 0.77 at [346, 656, 368, 684] 0.77 at [632, 651, 653, 678] 0.75 at [773, 687, 793, 714] 0.74 at [728, 680, 748, 707] 0.73 at [495, 656, 519, 687] 0.70 at [691, 559, 709, 581] 0.69 at [159, 585, 178, 608] 0.68 at [460, 557, 477, 579] 0.67 at [71, 602, 90, 625] 0.59 at [554, 575, 572, 597] 0.53 at [597, 573, 613, 592]
Astronaut crew portrait
f16Adam Cuerden, Public domain, https://commons.wikimedia.org/wiki/File:Portrait_of_ASTP_crews_-_restoration.jpg
5 faces on the Apple Neural Engine (FP16 pack), score 0.5 or more, duplicates removed at IoU 0.4: 1.00 at [315, 143, 368, 213] 1.00 at [607, 175, 664, 250] 1.00 at [207, 342, 269, 425] 0.99 at [690, 322, 754, 405] 0.99 at [462, 321, 523, 399]
Variants & downloads
Choose the build for your appModel files are hosted on Google Drive. Large files may open a confirmation page before downloading.
Standard
SlabWeights stored in FP16: half the size of FP32, the same faces.
Platforms: macos · android
retinaface-mobilenet-f16.slab
2.4 MB · Hosted download
SHA-256 checksum
15ec31aa75b80098baee25e287cc09ef95392d0a4691a642f143448e3022fbc4LICENSE-Pytorch_Retinaface.txt
1 KB
SHA-256 checksum
41034e3430e3b7fd63031bcc6f9dd9740fa910328f3168208ca032807f026147Conversion details
- command
- git clone https://github.com/biubug6/Pytorch_Retinaface && cd Pytorch_Retinaface && git checkout b984b4b775b2c4dced95c1eadd195a5c7d32a60b gdown --folder https://drive.google.com/drive/folders/1oZRSG0ZegbVkVwUd8wUIQx8W7yfZ_ki1 -O weights # the README's Google Drive folder (pip install gdown) python -c "import torch; from data import cfg_mnet; from models.retinaface import RetinaFace; net = RetinaFace(cfg=dict(cfg_mnet, pretrain=False), phase='test'); sd = torch.load('weights/mobilenet0.25_Final.pth', map_location='cpu', weights_only=True); net.load_state_dict({k[7:] if k.startswith('module.') else k: v for k, v in sd.items()}); torch.onnx.export(net.eval(), torch.randn(1, 3, 640, 640), 'model.onnx', input_names=['input'], output_names=['loc', 'conf', 'landms'], opset_version=17, dynamo=False)" echo face > labels.txt slab-load convert model.onnx model.slab --input input=1x3x640x640 --meta task=detect --meta resize=letterbox --meta color=bgr --meta normalize=raw255 --meta mean:f32=104,117,123 --meta decode=retinaface --meta labels:labels=@labels.txt slab-load quantize model.slab retinaface-mobilenet-f16.slab --f16 slab-load meta set retinaface-mobilenet-f16.slab default_backend.macos=npu
Integration examples
Python
python
import slab
cfg = slab.Config(cache_dir="/tmp/slab_cache", license=open("license.slablic.txt").read())
session = slab.Session(cfg, "retinaface-mobilenet-f16.slab", warmup=True)
out = session.run(slab.Input(frame=slab.Frame.open("photo.jpg")))
for b in out.boxes(score_threshold=0.5, iou_threshold=0.4):
print(round(b.score, 2), b.x1, b.y1, b.x2, b.y2, b.landmarks)
Device & backend compatibility
Pack default: macos / NPU. Fastest on the Mac (about 2 ms per frame) with the same faces as the CPU.
| Platform | Engine | Status | Precision |
|---|---|---|---|
| apple | CPU CPU | Supported Measured on macOS. | f32 |
| apple | Metal GPU | Supported Measured on macOS. | f32 |
| apple | Apple Neural Engine NPU | Supported Measured on macOS. The default. The Neural Engine computes in FP16. | f16 |
| android | CPU CPU | Supported Measured on a Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2, Adreno 740), Android 17. | f32 |
| android | Vulkan GPU | Supported Measured on a Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2, Adreno 740), Android 17. | f32 |
| android | Qualcomm Hexagon NPU (QNN) NPU | Supported Measured on a Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2, Adreno 740), Android 17. The NPU computes in FP16 (the int8 pack's weights are widened to FP16). | f16 |
Performance
Results depend on the device, runtime, and test conditions. Each measurement keeps its own context.
Mac with Apple M1 Max
Slab · CPU
macOS 26.6.2
14.5 ms
Measured time · scope below
Median of 100 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, letterboxing included: 15.08 ms median.
Mac with Apple M1 Max
Slab · GPU
macOS 26.6.2
2.5 ms
Measured time · scope below
Median of 100 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, letterboxing included: 3.13 ms median.
Mac with Apple M1 Max
Slab · NPU
macOS 26.6.2
2.0 ms
Measured time · scope below
Median of 100 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, letterboxing included: 3.94 ms median.
Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2)
Slab · CPU
Android 17
43.5 ms
Measured time · scope below
Median of 100 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, letterboxing and decoding boxes included: 41.7 ms median. open_ms: opening the session. Peak memory (resident) after the runs: 93 MB.
Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2)
Slab · GPU
Android 17
16.0 ms
Measured time · scope below
Median of 100 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, letterboxing and decoding boxes included: 28.1 ms median. open_ms: opening the session with the GPU programs already in the cache folder (the first open on a device compiles them, about 0.3 s more). Peak memory (resident) after the runs: 81 MB.
Samsung Galaxy S23 Ultra (Snapdragon 8 Gen 2)
Slab · NPU
Android 17
6.9 ms
Measured time · scope below
Median of 100 warm runs of the model (Slab's run time). From a 1920 x 1080 photo, preprocessing on the CPU included: 14.3 ms median. open_ms: opening the session, including preparing the model for the Hexagon NPU. Peak memory (resident) after the runs: 67 MB.
Accuracy checks
macos · CPU · f16
The upstream PyTorch network with the upstream prior-box decoding and NMS (score 0.5, NMS IoU 0.4), on the same 640 x 640 letterbox, 41 public-domain and CC0 photos with faces (Wikimedia Commons); a face matches with IoU 0.5 or more; landmark error is the mean distance of the five points as a share of the face box's diagonal
With Slab preprocessing and decoding: 228 of 228 faces matched (mean IoU 0.997), 0 extra, landmark error 0.06%. On identical input tensors, decoded by the upstream code: 228 of 228 matched (mean IoU 0.998), 0 extra, landmark error 0.03%, largest score difference 0.006.
macos · GPU · f16
The upstream PyTorch network with the upstream prior-box decoding and NMS (score 0.5, NMS IoU 0.4), on the same 640 x 640 letterbox, 41 public-domain and CC0 photos with faces (Wikimedia Commons); a face matches with IoU 0.5 or more; landmark error is the mean distance of the five points as a share of the face box's diagonal
With Slab preprocessing and decoding: 228 of 228 faces matched (mean IoU 0.997), 0 extra, landmark error 0.06%. On identical input tensors, decoded by the upstream code: 228 of 228 matched (mean IoU 0.998), 0 extra, landmark error 0.03%, largest score difference 0.006.
macos · NPU · f16
The upstream PyTorch network with the upstream prior-box decoding and NMS (score 0.5, NMS IoU 0.4), on the same 640 x 640 letterbox, 41 public-domain and CC0 photos with faces (Wikimedia Commons); a face matches with IoU 0.5 or more; landmark error is the mean distance of the five points as a share of the face box's diagonal
With Slab preprocessing and decoding: 228 of 228 faces matched (mean IoU 0.996), 0 extra, landmark error 0.09%. On identical input tensors, decoded by the upstream code: 228 of 228 matched (mean IoU 0.997), 0 extra, landmark error 0.08%, largest score difference 0.005.
android · NPU · f16
Slab's CPU engine (FP32) on the same 1920 x 1080 photo
Cosine similarity of the output with the CPU's: 0.99999.
Before you choose this model
- Finds faces only; it does not tell who a person is.
- At 640 x 640, faces smaller than about 16 pixels in the letterboxed image are often missed (crowds in large photos).
- Faces in profile, heavily covered or in very dark scenes score lower.
- The training data's terms restrict commercial use (see License).