BlazeFace: Sub-millisecond Neural Face Detection on Mobile GPUs
- Publication
- CVPR Workshops 2019Workshop
- First submitted to arXiv
- arXiv:1907.05047
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{objectdetectionblazeface2019,
title = {{BlazeFace: Sub-millisecond Neural Face Detection on Mobile GPUs}},
author = {Valentin Bazarevsky and Yury Kartynnik and Andrey Vakunov and Karthik Raveendran and Matthias Grundmann},
year = {2019},
eprint = {1907.05047},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1907.05047}
}
Open your phone's front camera, put on an AR filter, and cat ears, glasses or a whole 3D face mesh stick to your face and move with it. For every frame, the program first has to know where the face is, then crop that region out and hand it to the landmark or mesh model that follows. At 30 frames per second, the whole pipeline has only 33 milliseconds, and finding the face is just the first step.
BlazeFace handles that step. It takes in a frame shrunk to and returns a box, six landmarks and a confidence score for each face. The paper says it needs only 0.6 milliseconds on the GPU of an iPhone XS.
The authors are the Google Research people behind MediaPipe (Bazarevsky, Kartynnik, Vakunov, Raveendran, Grundmann). The body of the paper is just over three pages, with no WIDER FACE and no FDDB; every accuracy number is measured on a private set of 2,000 images. The paper's last sentence says the technique already powers the major AR self-expression applications and AR developer APIs on phones; later on, MediaPipe's face detection and Face Mesh both run its descendants as their first step.
The question it answers is a pure engineering one. On a phone GPU, what kind of network and post-processing finds faces fast and keeps the boxes from shaking?
Defining the Problem
SSD Plus MobileNet
A common combination for real-time detectors on phones is an SSD detection head on a MobileNet backbone.
SSD lays anchors over several feature maps. An anchor is a reference box with a preset position and size, a few of them at each position of the feature map, and for each anchor the network answers two questions, whether there's something here, and where the box should move and how much it should grow. With a input, the stride-8 feature map is , each cell covering pixels of the original image; the stride-64 feature map is down to , each cell covering pixels and responsible for large faces. A typical SSD goes all the way down to , and every layer has its own prediction head.
MobileNet is built on depthwise separable convolution. An ordinary convolution mixes space and channels at the same time; depthwise separable convolution splits it into two steps, first a depthwise convolution on each channel separately, then a pointwise convolution to mix the channels. MobileNetV2 wraps this into an inverted residual block that "expands the channels, runs the depthwise, then squeezes them back."
The baseline the paper compares against is exactly such a MobileNetV2-SSD. The authors go after it in three places.
The Computation Is All in the Pointwise
Count the computation of a depthwise separable convolution first. For an input tensor of , a depthwise convolution takes multiply-adds; the following convolution to output channels takes . The ratio of the two is .
Plug in the paper's example, a tensor with . The depthwise is M multiply-adds, the convolution M, so the pointwise is 14 times the depthwise.
Measured, the gap is smaller. On an iPhone X with Metal Performance Shaders in 16-bit floating point, the authors measured 0.07 milliseconds for the depthwise and 0.3 milliseconds for the convolution, 4.3 times slower. The gap isn't as big as 14 times because every layer has fixed overhead and memory access.
Whichever number you take, the depthwise half is cheap.
Every Layer Pays a Fixed Cost on the GPU
This is where GPUs and CPUs part ways. Every time a GPU launches a layer of computation, there's a fixed dispatch cost, regardless of how much that layer actually computes. When the authors measured MobileNetV1, only 3.9 of its 4.9 milliseconds of total inference were actually spent in GPU shader computation.
For large objects, SSD shrinks the feature maps all the way down to , and . These layers compute very little, but every layer and every prediction head still pays the dispatch cost. On a CPU, computing less means spending less time; on a GPU, these fixed overheads stack up layer after layer.
Jitter on Video
The third problem only shows up on video.
The denser the feature map, the more anchors cover a large face. NMS (non-maximum suppression) sorts all candidate boxes by score, keeps the top one, and deletes everything that overlaps it too much; overlap is measured by IoU, the intersection area of two boxes divided by their union area. That's fine for a single photo. On video, a slight change in scores between two adjacent frames is enough to switch the winner from one anchor to the one next door, and the box jumps with it. The AR filter's crop follows the box, so the mesh and stickers shake along with it.
So the authors have three things to deal with. How do you get a large enough receptive field out of very few layers? How small should the feature maps get before stopping? How do you steady the boxes across consecutive frames?
Solving the Problem
Making the Depthwise 5×5
If the depthwise is cheap, make its kernel bigger.
On the same , a depthwise is M multiply-adds. The whole depthwise separable convolution goes from 55.0M to 61.4M, 11.7% more (computed for this note).
What it buys is receptive field. The receptive field is the input region one position of the output can see. On a feature map with a cumulative stride of , one convolution layer adds pixels to the receptive field, and a adds . To grow the same receptive field, needs only half as many layers, and the half that's saved is exactly the dispatch cost on the GPU.
BlazeBlock

On the left is a single BlazeBlock, a depthwise followed by a convolution, plus a shortcut.
The side path on the right is labeled Optional. When the block's stride is 2, the main path halves the feature map, so the shortcut first does a max pooling to match the spatial size; when there are more output channels than input channels, the shortcut pads the extra channels with zeros. With 24 channels in and 48 out, for example, the shortcut appends 24 all-zero channels. The community asked about this zero-padded shortcut in MediaPipe issue #352, and a Google engineer answered that it's a deliberate design; people usually don't use residuals when channel counts differ, but it worked very well for the MediaPipe models.
On the right is the double BlazeBlock, which differs from MobileNetV2's bottleneck in two ways:
- Expansion and compression swap places. MobileNetV2 first expands the channels with a , runs the depthwise, then squeezes them back, so the residual connection sits at the narrow end. BlazeFace goes the other way, first squeezing 96 channels down to 24, then expanding back to 96 after the computation, so the residual connection sits at the wide end.
- There's an extra depthwise in the middle. Each of the two convolutions has a depthwise before it, so one block grows the receptive field twice.
This two-layer block is used in the later, more abstract layers of the network.
One 128×128 Input
Table 4 in the paper's appendix gives the front-camera model's full configuration. Follow a input through it:
| Layer | Output | Count |
|---|---|---|
| 5×5 conv (stride 2) | 64×64×24 | 1 |
| Single | 64×64×24 | 2 |
| Single (stride 2) | 32×32×48 | 1 |
| Single | 32×32×48 | 2 |
| Double (stride 2) | 16×16×96 | 1 |
| Double | 16×16×96 | 2 |
| Double (stride 2) | 8×8×96 | 1 |
| Double | 8×8×96 | 2 |
Compiled from Table 4 of the paper. Inside a double block, the channels are first squeezed to 24 and then expanded back to 96.
One convolution, 5 single blocks and 6 double blocks, at most 96 channels, with the smallest feature map stopping at .
The receptive field can be worked out along the way. Starting from the first layer's 5 pixels, each depthwise adds "4 times the cumulative stride at that point." At the output of the stage, the theoretical receptive field is 237 pixels; at it's 589 pixels (computed for this note). Both are larger than the 128 input, so every cell on already sees the whole frame. The theoretical receptive field overestimates the range that's actually effective, but the direction is clear, and the network doesn't need to drop resolution any further to "see the whole picture."
Anchors Stop at 8×8

On the left is the SSD-style configuration, two anchors per cell on , , and , for in total. On the right is BlazeFace, which drops and and raises from 2 to 6 anchors per cell, for in total.
The authors give two reasons. One is the GPU dispatch cost mentioned above, which makes deep, small layers a poor deal; the other is Google's own Pooling Pyramid Network, which showed that once feature maps get small enough, further computation is mostly redundant. Faces don't vary much in aspect ratio, so 1:1 anchors throughout are enough.
Turning cells into pixels makes this more tangible. One cell on is 8 pixels, and one cell on is 16 pixels. When the paper evaluates the front-camera model, it counts only faces covering more than 20% of the frame's area; for a square face, that means a side of at least 45% of the input width, about 57 pixels. Such a face spans about 3.6 cells on and about 7 cells on ; the anchors whose centers fall inside the face number over a hundred across the two layers (computed for this note). This is the point made earlier, that the larger the face, the more anchors it covers.
Open MediaPipe's config and there's a detail the paper doesn't mention. The short-range model's anchor setup has four layers with strides 8, 16, 16 and 16, and the three layers with the same stride merge into 6 per cell on , matching the count in Figure 2; but the config also turns on fixed_anchor_size, which fixes the width and height of every anchor at 1 (in units of the input width). So the 6 anchors in one cell have the same position and the same size; they're just 6 output slots, and the network regresses the box size directly.
17 Numbers per Anchor
Each anchor outputs 16 regression values and 1 score. The 16 regression values are 4 numbers for the box's center offset and size, plus 2 coordinates for each of the 6 landmarks. The score goes through a sigmoid to become a confidence between 0 and 1.
MediaPipe decodes them like this, with the anchor center in units of the input width:
are the network's raw outputs. Because the anchor width and height are fixed at 1, these four numbers are really pixels on the input.
Take the anchor in column 3, row 4 (counting from 0) on . Its center is , or in pixels. If the network outputs , the box is centered at , 60 pixels wide and 64 tall. The landmarks work the same way, as the anchor center plus an offset of a few pixels.
The six landmarks are the centers of the two eyes, the tragion of each ear (the notch above the small cartilage at the front of the ear), the center of the mouth and the tip of the nose. Six points aren't enough to describe the shape of a face, but they're enough to compute its in-plane rotation (roll). When MediaPipe feeds Face Mesh, it uses the line between the eyes to set the crop's rotation, enlarges the box 1.5 times and pads it to a square before handing it to the mesh model. The model downstream always gets a face that's roughly upright and centered.
Replacing NMS With a Weighted Average
Last comes the jitter. The authors' approach is called blending, which keeps all the overlapping candidate boxes and takes a score-weighted average of their regression parameters.

WeightedNonMaxSuppression.The figure shows three candidate boxes on a face that isn't moving, in two adjacent frames. The three boxes are in exactly the same positions in both frames; only the scores shift slightly because of noise.
NMS keeps A, the top scorer, in the first frame; in the second frame B's score overtakes it, the output switches to B, and the left edge jumps 6 pixels at once. On a input, 6 pixels is 4.7% of the frame width.
The weighted average gives a left edge of in the first frame and 41.20 in the second, a move of only 0.05 pixels. Small changes in scores only nudge the average slightly; they never hand the output to a different box.
MediaPipe's implementation is in non_max_suppression_calculator.cc. Translated into Python, it's roughly this:
import numpy as np
def iou(box, boxes):
# box: (4,); boxes: (N, 4); format [xmin, ymin, xmax, ymax]
ix = np.clip(np.minimum(box[2], boxes[:, 2]) - np.maximum(box[0], boxes[:, 0]), 0, None)
iy = np.clip(np.minimum(box[3], boxes[:, 3]) - np.maximum(box[1], boxes[:, 1]), 0, None)
inter = ix * iy
area = lambda b: (b[..., 2] - b[..., 0]) * (b[..., 3] - b[..., 1])
return inter / (area(box) + area(boxes) - inter)
def weighted_nms(coords, scores, iou_thresh=0.3):
# coords: (N, 16), two box corners plus 6 landmarks; scores: (N,)
order = np.argsort(-scores)
out = []
while len(order) > 0:
top = order[0]
overlap = iou(coords[top, :4], coords[order, :4]) > iou_thresh # includes top itself
group, order = order[overlap], order[~overlap]
if len(group) == 0: # a zero-area box doesn't even match itself
out.append((coords[top], scores[top]))
break # MediaPipe breaks out here to avoid an infinite loop
w = scores[group, None]
merged = (coords[group] * w).sum(axis=0) / w.sum()
out.append((merged, scores[top])) # keep the top box's score
return out
The only difference from ordinary NMS is the merged line. The box's four coordinates (two corners) and the six landmarks are averaged together, so the landmarks become steadier too. The overlap threshold in MediaPipe's config is IoU 0.3.
The PyTorch port the community commonly uses, hollance/BlazeFace-PyTorch, differs in two ways. First, its output score is the average of the overlapping boxes' scores, and a code comment notes that MediaPipe keeps the top score. Second, it lacks that break condition. In May 2023 someone reported in issue #15 that the loop never stops when the remaining box can't produce an IoU with itself, and hollance replied that the repo is no longer maintained and that perhaps MediaPipe had fixed it long ago. MediaPipe's C++ version does indeed have that line.
The paper says blending adds almost no computation. Its effect is measured with a jitter metric, which feeds the network a few slightly shifted versions of the same image, compensates the outputs for the shift, and computes the root-mean-square difference from the original image's predictions. With blending, jitter drops by 40% on the front-camera dataset and by 30% on the back-camera dataset, where faces are smaller. The paper also has one line saying "this adjustment resulted in a 10% increase in accuracy," without saying which metric.
Discussion
Data and Evaluation
The training data is 66K images and the evaluation data 2K "geographically diverse" images, and neither is public. Evaluation of the front-camera model counts only faces covering more than 20% of the frame's area; for the back-camera model the threshold is 5%.
Detection uses AP, where a detection counts as correct if its IoU with a labeled box exceeds 0.5. AP is the area under the precision–recall curve, obtained by sorting all detections by score, counting down the list, and computing precision and recall at each step. The regression errors of the box and landmarks are normalized by the inter-ocular distance (the distance between the two eye centers) and the median is taken; the jitter metric is normalized by inter-ocular distance as well.
Speed
| Device | MobileNetV2-SSD | BlazeFace | Speedup |
|---|---|---|---|
| iPhone 7 | 4.2 | 1.8 | 2.3× |
| iPhone XS | 2.1 | 0.6 | 3.5× |
| Pixel 3 | 7.2 | 3.4 | 2.1× |
| Huawei P20 | 21.3 | 5.8 | 3.7× |
| Galaxy S9+ | 7.2 | 3.7 | 1.9× |
Compiled from Table 2 of the paper, in milliseconds, TensorFlow Lite GPU, 16-bit floating point; the speedups are computed for this note.
The two models use the same anchor encoding and differ in the backbone. BlazeFace is 1.9 to 3.7 times faster on the five phones.
The sub-millisecond in the title is reached only by the iPhone XS among the five phones. The abstract says 200 to 1000+ FPS on flagship devices, and the Huawei P20's 5.8 milliseconds works out to 172 per second (even flagships come in tiers).
On accuracy, MobileNetV2-SSD's AP on the front-camera dataset is 97.95% and BlazeFace's 98.61%. This dataset has only large faces, both are close to a perfect score, and a 0.66 percentage-point gap doesn't say much.
How Much Worse the Regression Got
| Model | Regression error | Jitter |
|---|---|---|
| MobileNetV2-SSD | 7.4% | 3.6% |
| BlazeFace | 10.4% | 5.3% |
Compiled from Table 3 of the paper, normalized by inter-ocular distance.
The paper is quite candid in including this table. BlazeFace's box and landmark error is 40% higher than the baseline's, and its jitter is larger too. The authors' position is that the degradation caused by a smaller model doesn't necessarily make the whole AR pipeline proportionally worse.
That statement only makes sense back inside the pipeline. Section 5 of the paper uses face contour estimation as its example. BlazeFace provides the box and six points, the face contour model computes a finer contour on a slightly enlarged crop, and a more accurate box is then derived from the contour. The next frame tracks with this box directly, without rerunning the detector; the contour model also judges whether the face is still in the box, and only when it isn't does BlazeFace run again on the whole frame. The detector is only responsible for finding the face at the start and when tracking is lost; box accuracy is mostly made up by the models downstream.
A year later, BlazePose, with the same first author, took this line of thinking further. Single-person pose estimation needs to find the person first, and the BlazePose paper states that it uses a fast on-device face detector as a stand-in for a person detector, citing none other than BlazeFace; the reasoning is that in single-person AR scenarios, the head should always be visible.
The Released Model Isn't the One in the Paper
In 2019 MediaPipe released a face_detection_front.tflite. Open it up and there's no double BlazeBlock inside, and the depthwise convolutions are .
As early as August 2019 someone asked about this in MediaPipe issue #21, and the first author, Bazarevsky, replied that the released models don't exactly follow the architectures in the papers, since architecture development continued after the papers were submitted; the training pipeline and data sourcing, though, mostly stayed the same, and for those the papers are still a reference.
Put the two side by side. What the paper spells out clearly is the architecture, which the model doesn't use; what the model carries over is the training pipeline and data, neither of which is public. In hollance's issue #1, someone asked for the training code and got the answer "Ask Google if they are willing to open source their version"; MediaPipe issue #735 wanted the original model for retraining, and in June 2020 the maintainer replied that there was no plan to release it.
hollance's PyTorch port writes out the released front-camera model in full. After the first convolution come 16 single BlazeBlocks, with channels growing from 24 to 88 in steps of 4 to 8, and the last few blocks at 96; the layer gets 2 anchors per cell and the layer 6, for 896 in total, and the activation is ReLU. The anchor count, input size, six landmarks and blending all match the paper; what changed is the backbone.
Short Range, Full Range and the Model Cards
MediaPipe later split the model into two, and the model cards spell out what each is for.
- Short-range model (model card from June 2021): input, 224 KB, for faces within 2 meters, mainly from the front camera. The face box's side has to be at least 20% of the corresponding side of the frame, roll and pitch within 45°, yaw within 90°, and at least 70% of the face inside the frame.
- Full-range model (model card from January 2021): 1.1 MB, for faces within 5 meters, mainly from the back camera, with a face box side of only 5% required. The architecture is described as "CenterNet-like"; MediaPipe's config uses a input with one anchor per cell on a stride-4 feature map, 2,304 in total. There's also a sparse version, with 70% of the weights pruned from most convolutions, at 680 KB.
Both model cards explicitly list out-of-scope uses, including counting people in crowds, faces turned away from the camera or heavily tilted, faces beyond the distance range, and any form of surveillance or identity recognition. In MediaPipe issue #910, someone fed in upside-down faces; the boxes were reasonably accurate, but the landmarks were all wrong, and Google's reply was that data augmentation in training only rotated up to 45°.
The short-range model card's "Documentation" field links to arXiv 2006.10204 (that's BlazePose).
The full-range model had long been usable in the old MediaPipe Solutions, yet when things moved to the new MediaPipe Tasks it sat at "Coming soon." MediaPipe issue #4990 asked in November 2023 when it would be released, people kept nudging underneath from 2023 all the way into 2026, and in April 2026 the maintainer replied with one line, "It's available now :)" ("coming soon" for over two years).
On WIDER FACE
With no results on public benchmarks in the paper, the community had to fill them in itself. PaddleDetection reimplemented the configuration from the paper's appendix (double blocks included), changed the anchors to two sizes, 16 and 24 pixels, on stride 8 and six sizes, 32 to 128 pixels, on stride 16, and trained on WIDER FACE with inputs. WIDER FACE divides faces by detection difficulty into Easy, Medium and Hard groups; Hard contains every face, many of them small faces a dozen or so pixels wide. PaddleDetection evaluates multi-scale on the validation set; the docs on the release/0.3 branch give Easy/Medium/Hard as 0.915/0.892/0.797, and those on the release/2.8 branch give 0.885/0.855/0.731.
These numbers show that the paper's backbone, retrained on WIDER FACE with larger inputs, can handle small faces to some degree, but they answer a different question. MediaPipe's released short-range model takes a input and is designed for face boxes whose side is at least a fifth of the frame; squeeze a crowd photo into and a face 40 pixels wide is down to 5 pixels, far outside that range. The model card also lists crowd counting as out of scope.
Conclusion
In August 2019, Bazarevsky acknowledged in issue #21 that the released model doesn't exactly follow the paper's architecture. Checked against hollance's port, the paper's three designs met different fates. The double BlazeBlock never made it into the released front-camera model; the 896 anchors stopping at (same count, now fixed in size) and the score-weighted average replacing NMS both remain in MediaPipe's short-range model. What the paper itself measured is a drop from MobileNetV2-SSD's 2.1 milliseconds to 0.6 milliseconds on the iPhone XS, with 40% more regression error, left for the models downstream to make up.
The weighted-average step has nothing to do with the backbone. Any detector running on video can swap "keep the top score" for "average weighted by score" at the NMS step, and the paper measured 30% to 40% less jitter; MediaPipe's overlap threshold is IoU 0.3. Picking a MediaPipe model comes down to face size. Short range suits selfies and video calls, full range suits faces two to five meters away, and crowd photos with even smaller faces fall outside the scope of both model cards.
The paper's title says Mobile GPUs. Two years later, the short-range model card gives its speed as about 275 per second on a single Pixel 2 CPU core; the January 2024 MediaPipe Tasks docs measure the whole pipeline on a Pixel 6 at 2.94 milliseconds on CPU and 7.41 milliseconds on GPU.