MediaPipe Face Landmarker
MediaPipe Face Landmarker (Google, face_landmarker.task): finds faces and places 478 landmarks on each (face contour, eyes, lips, brows and both irises). BlazeFace detector plus a face-mesh network from the MediaPipe Tasks bundle. Apache-2.0 code and weights.
stable Fork of google-ai-edge/mediapipe@cad7f3a · backends: portable
- Paper Real-time Facial Surface Geometry from Monocular Video on Mobile GPUs arXiv · first released 15 Jul 2019
- Paper BlazeFace: Sub-millisecond Neural Face Detection on Mobile GPUs arXiv · first released 14 Jul 2019
- Authors’ code ai.google.dev/edge/mediapipe/solutions/vision/face_landmarker (MediaPipe Tasks (TFLite)), not the code forked here: Google's own runtime for the `.task` bundle; the port runs the same two graphs in torch.
Checkpoint mediapipe-face-landmarker
Paper 2019 Added in 0.4.0 Evaluated with 0.4.0
Use it
pip install fastforks Lean install with only what this model needs: pip install fastforks-core
from fastforks import pose
model = pose.load("mediapipe-face-landmarker") # fastest backend that runs here
result = model("photo.jpg", boxes=[[100, 50, 400, 700]]) # person boxes (x0, y0, x1, y1)
# result fields: keypoints, keypoint_scores, boxes, scores
keypoints = result.keypoints # a torch tensor
arrays = result.numpy() # the tensor fields as NumPy arrays: arrays["keypoints"]
result.backend # what ran: mode, device, dtype
Other ways to run it
- Precision:
pose.load("mediapipe-face-landmarker", dtype="float32") # full precision: slower, portable only - Options:
pose.load("mediapipe-face-landmarker", options={"score_threshold": 0.5, "presence_threshold": 0.5})
fastforks bench mediapipe-face-landmarker Times the model on this machine. load(…, mode="portable") or mode="kernels" picks a backend; usage guide.
Speed and memory
Every backend on one GPU (RTX 5060 Ti 16 GB) and the same input, the authors’ code included. Portable runs fp16 on CUDA.
| Backend | dtype | Time per call (ms) | vs original fp16 | Peak memory allocated / reserved | Load (s) | First call (s) |
|---|---|---|---|---|---|---|
| Original fp32 | fp32 | not measured | – | – | – | – |
| Original (own default)CPU run on all 16 cores of the host (the GPU is unused): memory columns are the process peak RSS above the idle process, not GPU memory | float16 weights (CPU XNNPACK) | 7.86 | – | – | 0.0 | 0.01 |
| Portable fp32 | fp32 | not measured | – | – | – | – |
| Portable | fp16 | 3.04 | 2.6× | 35 MiB/98 MiB | 0.3 | 0.00 |
| Kernels | not measured | – | – | – | – | |
| Portable + torch.compile | not measured here | – | – | – | – | |
| TensorRT | not measured here | – | – | – | – |
Measured on RTX 5060 Ti 16 GB, torch 2.14.1+cu130, 2026-11-28. Median of 10 after 3 warm-up, uint8 CUDA image, detector + mesh per call (CUDA graphs), peak = max over the timed calls. Ratios divide two
times of this table (same GPU, same input). Original fp16 is the authors’ own precision option, else torch.autocast. torch.compile and TensorRT: build time instead of load time. TensorRT memory (engine, not comparable) is the GPU memory the engine took, read from the driver because TensorRT allocates outside PyTorch, so it can't be compared with the PyTorch peaks of the other rows.
Other devices
Not measured on other devices yet.
Licence and weights
Commercial use allowed
- Code
- Apache-2.0 LICENSE
- Weights
- Apache-2.0 source
- Training data
- Google's own training images (BlazeFace: about 66k geographically diverse photos; face mesh: about 30k mobile-camera photos plus synthetic renders; model cards); not a public dataset
Our reading of the licences, not legal advice.
Weights
face_landmarker.task 3.8 MB· hosted on Google Drivefastforks downloads and checks these files on first use (fastforks download mediapipe-face-landmarker).
Accuracy
The test set through the authors’ code and through ours: same checkpoint, same protocol. The distance between the original’s fp32 and fp16 runs is what half precision alone costs; our runs should stay within it.
LaPa test (2000 faces)
six eye / mouth corners, error / outer eye-corner distance %, faces found %
| Run | dtype | nme ↑ | found ↑ | Δ nme vs fp32 original | faces | ms / face |
|---|---|---|---|---|---|---|
| Original fp32 | float16 weights | 2.353 | 98.5 | reference | 2000 | 8.58 |
| Original fp16 | not measured | |||||
| Portable fp32 | fp32 | 2.375 | 98.5 | +0.022 | 2000 | 3.50 |
| Portable | fp16 | 2.371 | 98.5 | +0.018 | 2000 | 3.38 |
| Kernels | not measured | |||||
Original = the authors’ code, same checkpoint and protocol. Measured on original fp32: CPU (XNNPACK), torch null, 2026-11-30; portable fp32, portable: RTX 5060 Ti, torch 2.14.1+cu130, fastforks 7c774f5fe, 2026-11-30.
Closeness to the original
Beyond the test-set scores: the raw output of ours against the original’s fp32 output on the same input, pixel by pixel. CPU, float32: max |diff| <= 0.05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.05 and p99 <= 0.15 (absolute error of the output keypoints).
| Check | Tolerance | Measured |
|---|---|---|
| CPU fp32, max |diff| | ≤ 0.05 | not recorded |
| GPU default dtypes, mean |diff| | ≤ 0.05 | not recorded |
| GPU default dtypes, p99 |diff| | ≤ 0.15 | not recorded |
No GPU comparison recorded for mediapipe-face-landmarker.
Details
MediaPipe Face Landmarker (Google, `face_landmarker.task`): the two-stage face mesh of the MediaPipe Tasks API. BlazeFace (short range, 128 x 128 input, SSD anchors on the stride 8 / 16 maps, weighted NMS) finds the faces with six keypoints; each face is cropped 1.5x its longer side and rotated so the eyes are level; the face-mesh network (256 x 256 crop) returns 468 face landmarks, 10 iris landmarks and a face-presence score. The portable runner reads the bundle's two TFLite graphs and runs them as plain torch operators (no TFLite runtime, ONNX-exportable `module()`); detection, rotated crops and projection follow the Tasks graphs. Landmarks are returned in input pixels (x, y; the network's relative depth is dropped, blendshapes and the facial transform matrix are not part of this port).
- Input / output
- Input: one RGB image and a box per person. Output: keypoints with confidence scores for every person.
- Input size
- any H x W >= 32, padded to a multiple of 32; tested up to 3000x4000 (417 MiB allocated)
- Options
score_threshold=0.50.0 to 1.0· changes the outputpresence_threshold=0.50.0 to 1.0· changes the output
- Outputs
keypoints,keypoint_scores,boxes,scores- CUDA kernels
- none: Not needed: two small depthwise-separable graphs (128 px detector, 256 px mesh) run as CUDA graphs in the portable path. RTX 5060 Ti, 512 px image with one face: 5.5 ms per call, of which the detector net is 0.3 ms and the mesh net 1.0 ms; the rest is host-side pre- and post-processing. To be 10 % faster, a kernel build would need to cut the network time by over 40 %, and its convolutions already take 1 to 3 us each.
Limitations
- module() is the landmark network on crops (landmarks in crop pixels and the presence probability); detection, crops and projection stay outside the exported graph.
- x, y only: the relative z, the 52 blendshape scores and the facial transformation matrix of the Tasks API are not returned.
- Short-range detector: faces smaller than about 1/10 of the image side are missed, and the input is one image per call (batch 1).
Full reference, generated from the repository
MediaPipe Face Landmarker (Google, face_landmarker.task): finds faces and places 478 landmarks on each (face contour, eyes, lips, brows and both irises). BlazeFace detector plus a face-mesh network from the MediaPipe Tasks bundle. Apache-2.0 code and weights.
Commercial use: yes.
| variant | input | backend | time (ms) | peak memory (MiB, allocated / reserved) |
|---|---|---|---|---|
mediapipe-face-landmarker | face photo (mediapipe-assets portrait.jpg) (1080x1920) | original portable kernels | 7.86 3.04 no kernels | – 35 / 98 no kernels |
mediapipe-face-landmarker | face photo (mediapipe-assets portrait.jpg) (256x256) | original portable kernels portable + torch.compile TensorRT fp16 | 7.60 3.00 no kernels 2.54 fails: unsupported: the ONNX export traces the 128x128 net input to | – 28 / 74 no kernels 38 / 94 – |
Details
- Original code: https://github.com/google-ai-edge/mediapipe at
cad7f3ab99eb - Code licence: Apache-2.0 (permissive); files:
LICENSE - Weights licence: Apache-2.0
- Licence evidence: https://github.com/google-ai-edge/mediapipe/blob/cad7f3ab99ebf175947e40c5252c642612aae927/LICENSE
- Training data: Google's own training images (BlazeFace: about 66k geographically diverse photos; face mesh: about 30k mobile-camera photos plus synthetic renders; model cards); not a public dataset
- Options:
score_threshold= 0.5 (0.0 to 1.0),presence_threshold= 0.5 (0.0 to 1.0) - Kernel libraries: none (Not needed: two small depthwise-separable graphs (128 px detector, 256 px mesh) run as CUDA graphs in the portable path. RTX 5060 Ti, 512 px image with one face: 5.5 ms per call, of which the detector net is 0.3 ms and the mesh net 1.0 ms; the rest is host-side pre- and post-processing. To be 10 % faster, a kernel build would need to cut the network time by over 40 %, and its convolutions already take 1 to 3 us each.)
- Variants:
mediapipe-face-landmarker - Outputs: keypoints, keypoint_scores, boxes, scores; label_set:
face-478 - Input size: any H x W >= 32, padded to a multiple of 32
- Tested up to (portable, fp16, RTX 5060 Ti 16 GB):
mediapipe-face-landmarker3000x4000 (0.4 GiB peak allocated, 0.4 reserved) - no kernels: Not needed: two small depthwise-separable graphs (128 px detector, 256 px mesh) run as CUDA graphs in the portable path. RTX 5060 Ti, 512 px image with one face: 5.5 ms per call, of which the detector net is 0.3 ms and the mesh net 1.0 ms; the rest is host-side pre- and post-processing. To be 10 % faster, a kernel build would need to cut the network time by over 40 %, and its convolutions already take 1 to 3 us each.
mediapipe-face-landmarker256x256, first call: portable + torch.compile 12 s (cold Inductor cache).mediapipe-face-landmarkeroriginal 1080x1920, original 256x256: CPU run on all 16 cores of the host (the GPU is unused): memory columns are the process peak RSS above the idle process, not GPU memorymediapipe-face-landmarkerload / first call: original 0.04 s / 0.008 s, portable 0.35 s / 0.003 s- Protocol, median of 10 after 3 warm-up, uint8 CUDA image, detector + mesh per call (CUDA graphs), peak = max over the timed calls
Measured
Original = the original code named under Details, same checkpoint and protocol.
| variant | dataset | original fp32 | portable | portable fp32 | note |
|---|---|---|---|---|---|
mediapipe-face-landmarker | LaPa test (2000 faces), six eye / mouth corners, error / outer eye-corner distance %, faces found % | 2.353 / 98.5 | 2.371 / 98.5 | 2.375 / 98.5 |
Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 7c774f5fe, 2026-11-30.
Parity
CPU, float32: max |diff| <= 0.05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.05 and p99 <= 0.15 (absolute error of the output keypoints).
| variant | kernels error vs original, mean / p99 | GPU, torch | kernels used |
|---|---|---|---|
mediapipe-face-landmarker | no kernels backend | - | - |
Limitations
- module() is the landmark network on crops (landmarks in crop pixels and the presence probability); detection, crops and projection stay outside the exported graph.
- x, y only: the relative z, the 52 blendshape scores and the facial transformation matrix of the Tasks API are not returned.
- Short-range detector: faces smaller than about 1/10 of the image side are missed, and the input is one image per call (batch 1).
Example output
No example rendered for this checkpoint yet.