Sample and Computation Redistribution for Efficient Face Detection
- Publication
- ICLR 2022Conference
- First submitted to arXiv
- arXiv:2105.04714
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{objectdetectionscrfd2021,
title = {{Sample and Computation Redistribution for Efficient Face Detection}},
author = {Jia Guo and Jiankang Deng and Alexandros Lattas and Stefanos Zafeiriou},
year = {2021},
eprint = {2105.04714},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2105.04714}
}
TinaFace's abstract sets one sentence in bold, saying "there is no gap between face detection and generic object detection."
It backs the claim with results, too. Using ResNet-50 plus modules common in generic object detection, TinaFace reaches 92.1% single-model, single-scale on the WIDER FACE Hard test set, and 92.4% with test-time augmentation. When the SCRFD paper was written, that was the best result on the WIDER FACE leaderboard.
Half a year later, the InsightFace team retested TinaFace, changing only one thing, the size of the test images.
| Test scale | Hard AP | GFLOPs |
|---|---|---|
| Multi-scale | 93.4 | 42,333.64 |
| Long side 1650 | 93.0 | 1,021.82 |
| Original (≈1024) | 91.4 | 508.47 |
| 640 | 81.4 | 172.95 |
Compiled from Table 1 of the paper, WIDER FACE Hard validation set.
The single scale TinaFace refers to is the 1650 row of the table. Images are first enlarged, with the short side up to 1,100 and the long side up to 1,650 pixels. WIDER FACE originals average about , so this row costs over a thousand GFLOPs per image. Shrink the input to 640 pixels, common for ordinary camera streams, and it still costs 173 GFLOPs, while Hard drops by nearly 12 percentage points.
This team built RetinaFace two years earlier. This time their question is a more practical one. If the test resolution is fixed at VGA (640×480) and the compute budget is limited, where should the training data and the computation each be spent?
Defining the Problem
Where TinaFace Spends Its Computation
A face detector, to recap, takes in an image and outputs a box and a confidence score for every face; InsightFace's versions also output five landmarks (the two eyes, the nose tip, the two mouth corners) for aligning the face before recognition.
WIDER FACE is the standard exam for this task, with about 32,000 images and 390,000 face boxes, split by difficulty into Easy, Medium and Hard. Hard contains every face, many of them very small. Scoring uses AP. A detection counts as correct if its IoU with a labeled box exceeds 0.5, and AP is the area under the precision–recall curve.
TinaFace is a standard RetinaNet architecture. The backbone is ResNet-50 and the neck is FPN, running from P2 all the way to P7; each level's head first passes through an inception-style feature enhancement module, then four stacked convolutions for classification, box regression and IoU prediction. Each level has anchors at three scales, from about 10 pixels on P2 up to 512 pixels on P7.

The right half of the figure breaks down TinaFace's 172.95 GFLOPs at 640×480 input.
By component, the backbone takes 19.45G, the neck 17.40G and the head 136.07G, so the head makes up about 79%. By feature-map stride, the stride-4 level alone takes 118.77G, about 68%. The largest single piece is H2, the four convolution layers on stride 4, at 91.46G.
The reason isn't hard to work out. The stride-4 feature map is , which is 19,200 positions, and every position runs through the whole feature enhancement module and four convolutions. Put the same head on stride 32 and there are only positions, 1/64 of stride 4.
The backbone, meanwhile, is carried over unchanged from an ImageNet classification network and takes only about 11%. The authors argue that this allocation ignores the characteristics of faces and is "redundant and sub-optimal."
The left half of the figure shows another problem. Real face detection systems usually demand very high precision (above 98%, say), or there are too many false alarms. Counting AP only over the part where precision is above 98%, TinaFace gets 0.750 at long side 1650 and only 0.539 at 640.
At 640 Pixels, Most Faces Are Small

Shrink the WIDER FACE validation images to a long side of 640 and look at how big the faces are. In the Hard group, 13.36% of faces are smaller than , 51.85% smaller than and 78.93% smaller than . Easy faces are mostly larger than 32 pixels, Medium faces mostly larger than 16.
Picture a surveillance frame. Shrunk to a long side of 640, it becomes , scaled down by a factor of three; a face 90 pixels wide in the original is down to 30 pixels, and a 48-pixel face to 16. On a VGA budget, the vast majority of faces have to be found with high-resolution shallow features.
Earlier architecture searches touched only part of the detector. CR-NAS only redistributes computation across the backbone's stages, BFbox searches the backbone and neck together but leaves the head alone, and ASFD searches only the neck's feature enhancement module. Detectors like RetinaFace and HAMBox were hand-designed from experience.
SCRFD first fixes two premises. One, test images are no larger than VGA. Two, there are no anchors on stride 4; stride 8 gets anchors with sides of 16 and 32, stride 16 gets 64 and 128, and stride 32 gets 256 and 512. Without stride 4, the most expensive level disappears outright; the cost is that nearly all the small faces land on stride 8.
What remains is how to get stride 8 to learn from enough small faces, and how to split a limited compute budget among the backbone, neck and head.
Solving the Problem
The Fixed Skeleton
Both redistributions work on the same skeleton. The backbone is from the ResNet family. Its stem is three convolutions, followed by four stages C2 to C5, each a repeated stack of the same kind of residual block (basic or bottleneck). The neck is PAFPN, which adds a bottom-up path on top of FPN's top-down path and outputs three levels at strides 8, 16 and 32. The head is a few convolutions, with weights shared by the three levels and Group Normalization.
The training recipe is fixed as well, with ATSS for positive/negative assignment, GFL for the classification loss and the DIoU loss for box regression. In the official code, the head is set up like this:
- Each anchor position predicts the distances from the anchor center to the four sides of the box (in units of the stride), written the same way as in GFL and FCOS.
- The classification branch uses the Quality Focal Loss from GFL, with the IoU between the predicted and labeled boxes as the target for positives, so the score stands for both "is this a face" and "how well does the box fit." The other half of GFL (the Distribution Focal Loss) is switched off in the config.
- The box DIoU loss is weighted by the predicted score, with a loss weight of 2.0.
- On each level, ATSS takes the 9 anchors closest to the center of the labeled box as candidates and uses the mean plus the standard deviation of the candidates' IoUs as the threshold, deciding automatically which anchors are positives.
All models are trained from scratch, without ImageNet pretraining. SGD with momentum 0.9 and weight decay , on four V100s with 8 images each; the learning rate rises linearly from to 0.01 over the first 3 epochs, the final models train for 640 epochs, and the rate is multiplied by 0.1 at epochs 440 and 544. Testing uses a single scale only, with images no larger than VGA.
Sample Redistribution: Making Faces Smaller
The first change touches only data augmentation.
During training, a random square is cropped from the original image with a side equal to some multiple of the short side, then resized to . The baseline picks the multiple from ; SCRFD adds . When the multiple is above 1, the crop extends past the original image, and the part outside is filled with the mean RGB value.
Take a training image, with a short side of 768.
- Multiple 0.3: crop 230 pixels and enlarge to 640, and faces grow about 2.8×;
- multiple 1.0: crop 768 pixels and shrink to 640, and faces become 0.83× their original size;
- multiple 2.0: crop 1,536 pixels and shrink to 640, and faces are down to 0.42× their original size.
A face 40 pixels wide in the original is 33 pixels at multiple 1.0 and 17 pixels at 2.0, landing right on stride 8's 16-pixel anchor. RetinaFace's crop range is 0.3 to 1×, which mostly enlarges faces; SCRFD extends the range to 2×, and the added half shrinks them.

The left plot shows the scales of the labeled boxes seen in one epoch. Faces under 32 pixels clearly become more common, and the smallest bin goes from just over ten thousand to over forty thousand. Faces smaller than match no anchor and are simply ignored in training.
The right plot has the numbers that actually matter, the positives matched to anchors. The 16-pixel anchor goes from 72.3K to 118.3K, over sixty percent more; the 32-pixel one from 95.9K to 115.1K. Summed over the two anchors on stride 8, positives grow by nearly forty percent.
The same figure also shows the cost. Positives for all four scales from 64 to 512 go down, by about a third for 256 and by nearly half for 512. The paper doesn't discuss this.
Computation Redistribution: First the Backbone, Then the Whole Detector
The second change is neural architecture search, following RegNet. RegNet's idea is that rather than hunting for the single best network in a huge space, you randomly sample and train a large batch of models and then look for the patterns the good ones share.
Search space. A detector has these tunable parameters:
- Each of the backbone's four stages has a depth (number of blocks) and a width (number of channels), 8 degrees of freedom in total. The stem's channel count equals the width of C2's first block, so it is folded into . The sampling ranges are and (multiples of 8), with , so the network gets wider with depth.
- The neck's output channels .
- The head's channels and its number of convolution layers , shared by the three levels with a fixed channel count. The sampling ranges are , (multiples of 8) and .
How big is this space? As a rough count, each stage's depth has 24 choices, so four stages give ; width has 64 choices, and the non-decreasing combinations over four stages number ; the neck and head multiply in another . All together that's about , before counting block types. The paper itself calls the space "unwieldy," and it relies on random sampling plus statistics rather than evolutionary algorithms or reinforcement learning.
Sampling and training. Take SCRFD-2.5GF. Configurations are generated at random over and over, keeping only those whose compute lands near 2.5 GFLOPs, until there are 320 models. Each model trains for 80 epochs on the WIDER FACE training set and is tested for AP on the Hard group of the validation set.
For each model you can compute each component's share of the computation, , for example C2's FLOPs divided by the whole detector's FLOPs. That gives 320 pairs .
Empirical bootstrap. Plotted as a scatter, the 320 points are very noisy. RegNet uses a resampling procedure to estimate "where the best models usually fall":
- draw 25% of the 320 pairs with replacement, that is, 80 pairs;
- among these 80, pick the model with the highest AP and record its ;
- repeat 10,000 times to get 10,000 values of ;
- take the middle 95% as the confidence interval and the median as the most likely optimum.
Look only at the best of the 320 points and it's easy to be fooled by one lucky training run; resampling ten thousand times shows how the best models are distributed over as a whole.

This is the first step, searching only the backbone. The neck is fixed at 32 channels and the head at two convolution layers with 96 channels, and only the backbone's depths and widths vary.
When reading the figure, look at the light purple bands first. The best models spend 10% to 20% of their computation on the stem, 24% to 39% on C2, 26% to 47% on C3, only 4% to 15% on C4 and 1% to 16% on C5. Stem, C2 and C3 together range from 72% to 91%, so roughly 80% of the backbone's computation flows to the shallow stages.
An ordinary ResNet is the exact opposite. In the three ResNet baselines of Figure 7 further down, C4 takes the most backbone computation every time. And in the C4 scatter plot, models with a share above 0.3 all fall to around 62 AP.
This figure has its limits too. The vertical axis spans only 60 to 70, because these are results after 80 training epochs, a notch below the final models. The bands are also wide, with C3's spanning 21 percentage points. The figure points the way, and the exact shares still have to be confirmed by the second search step and retraining.
The second step searches the whole detector. The backbone's computation distribution must fall within the ranges from the first step, while the neck's and the head's and vary at random, again until there are 320 models at 2.5 GFLOPs. This gives the backbone 67% to 88%, the head 10% to 26% and the neck only 1% to 7%.
Why split it into two steps? Search everything at once and 320 models are scattered over a very large space, which makes patterns hard to see. Fix the backbone's distribution first, and the second step's space is much smaller.
The Four Searched Models
The same two-step method is applied to three more compute levels, 0.5, 10 and 34 GFLOPs. The four SCRFDs it finds are:
| Compute | Block | Depth | Width | Neck/head |
|---|---|---|---|---|
| 0.5GF | depthwise | 2, 3, 2, 6 | 40, 72, 152, 288 | 16/[64, 64] |
| 2.5GF | basic | 3, 5, 3, 2 | 24, 48, 48, 80 | 24/[64, 64] |
| 10GF | basic | 3, 4, 2, 3 | 56, 88, 88, 224 | 56/[80, 80, 80] |
| 34GF | bottleneck | 17, 16, 2, 8 | 56, 56, 144, 184 | 128/[256, 256] |
Compiled from the legends of Figure 7 and Figure 8 of the paper. "Depthwise" is depthwise separable convolution; the brackets give the channels of each head layer.
Each compute level has a hand-designed baseline with almost the same computation: MobileNet at a quarter width, ResNet-34 at a quarter and at half width, and the original ResNet-50, in that order.

In the left column, the blue and magenta lines have two quite different personalities. Take 2.5GF. The ResNet baseline spends about a third of its computation on the head, and C4 gets a fifth; SCRFD's head is down to just over a tenth, C3 alone takes nearly forty percent, and C2 another twenty-odd percent.
From the four compute levels, the authors draw four conclusions:
- Computation concentrates in the backbone, and the neck and head get squeezed.
- At 2.5, 10 and 34 GFLOPs, capacity goes to the shallow stages, because of how small the faces in WIDER FACE are.
- 34GF picks bottleneck blocks and goes deeper rather than wider in the shallow stages. C2 stacks 17 blocks and C3 16, with the width held at 56 throughout. Widening grows the parameter count faster than deepening and overfits more easily; SCRFD-34GF has 9.80M parameters, against 24.81M for the ResNet-50 baseline at the same compute.
- 0.5GF instead puts its capacity in the deepest stage, C5 (6 blocks, 288 channels). The authors explain that this lets the deep layers learn discriminative features, which the neck's top-down path then sends back to the shallow layers to help detect small faces.
Discussion
Ablation: Sample Redistribution Is the Cheapest Trick
| Method | Easy | Medium | Hard |
|---|---|---|---|
| ResNet-2.5GF | 91.87 | 89.49 | 67.32 |
| + sample redist. | 93.21 | 91.11 | 74.47 |
| + compute redist. (backbone) | 92.32 | 90.25 | 69.78 |
| + compute redist. (all at once) | 92.61 | 90.74 | 70.98 |
| + compute redist. (two-step) | 92.66 | 90.72 | 71.37 |
| Both (SCRFD-2.5GF) | 93.78 | 92.16 | 77.87 |
Compiled from Table 3 of the paper, WIDER FACE validation set. The middle three rows apply only computation redistribution on top of the baseline.
- Sample redistribution alone adds 7.15 percentage points of Hard AP, with no added computation at inference at all; training simply crops a few more sizes.
- Computation redistribution alone adds 4.05 percentage points (two-step). Searching only the backbone gives +2.46, searching everything at once +3.66, and the two-step method another 0.39 on top of that.
- Together they give +10.55, close to the 11.20 from adding the two separately. The authors call the two orthogonal.
The 0.39 gap between the two-step and one-step methods comes from a single search of 320 random models each, and the paper reports no variance across repeated searches. This row supports "splitting into two steps is no worse"; to claim that two steps are definitely better, the evidence is thin.
Comparison With Other Detectors

The conditions are stated in the figure's caption, with every method tested at VGA resolution. SCRFD's curve lies entirely above and to the left of the other methods, reaching the same AP with an order of magnitude less computation.
The full numbers follow; latency is the network forward time for a VGA image on an RTX 2080 Ti:
| Model | Hard | GFLOPs | ms |
|---|---|---|---|
| DSFD (ResNet-152) | 71.39 | 259.55 | 55.6 |
| RetinaFace (ResNet-50) | 64.17 | 37.59 | 21.7 |
| HAMBox (ResNet-50) | 76.75 | 43.28 | 25.9 |
| TinaFace (ResNet-50) | 81.43 | 172.95 | 38.9 |
| ResNet-34GF | 84.02 | 34.16 | 11.8 |
| SCRFD-34GF | 85.29 | 34.13 | 11.7 |
| ResNet-10GF | 80.42 | 10.18 | 6.3 |
| SCRFD-10GF | 83.05 | 9.98 | 4.9 |
| ResNet-2.5GF | 74.47 | 2.57 | 5.4 |
| SCRFD-2.5GF | 77.87 | 2.53 | 4.2 |
| Lightweight model | Hard | GFLOPs | ms |
|---|---|---|---|
| RetinaFace (MobileNet-0.25) | 47.32 | 0.802 | 7.9 |
| FaceBoxes | 24.18 | 0.275 | 2.5 |
| MobileNet-0.5GF | 66.68 | 0.507 | 3.7 |
| SCRFD-0.5GF | 68.51 | 0.508 | 3.6 |
Compiled from Table 4 of the paper, WIDER FACE validation set, single scale, long side at most 640. The ResNet and MobileNet baselines also use sample redistribution.
SCRFD-34GF scores 96.06/94.92/85.29 on Easy, Medium and Hard, the highest in the table on all three. Against TinaFace, its Hard is 3.86 higher at only 19.7% of the computation, and its latency is 11.7 vs 38.9 ms, 3.3× faster. In the lightweight group, SCRFD-0.5GF beats the MobileNet-0.25 version of RetinaFace by 21.19 on Hard, at 63% of its computation and less than half its latency.
Two things in this table have to be read together.
First, the baselines are already strong. ResNet-34GF is an unsearched ResNet-50 that only adds sample redistribution and the same training recipe, and it already reaches 84.02 on Hard, 2.59 above TinaFace. Of SCRFD-34GF's 3.86 lead over TinaFace, computation redistribution contributes 1.27. This matches the ablation table, where the biggest gain comes from data augmentation.
Second, everyone else is competing at a resolution they aren't good at. The ResNet-50 version of RetinaFace has only 64.17 on Hard in this table, while its own README reports 90.4 with multi-scale testing. Someone asked in InsightFace's issue #1748 why RetinaFace is so low here, and the maintainer's answer was a single line, "Test on VGA resolution". SCRFD's problem setting is VGA to begin with, so comparing this way isn't wrong; the table just answers "who is better at 640 pixels." At higher resolutions the ranking changes, and TinaFace is at 93.0 with a long side of 1650.
The conclusion also holds under the high-precision requirement. Counting only the part where precision is above 98%, SCRFD-2.5GF's AP is 53.7 and TinaFace's 53.9, almost a tie, with SCRFD using only 1.46% of TinaFace's computation and 10.8% of its time.
Official Code and Model Packs
The code lives in InsightFace's detection/scrfd, built on mmdetection. The configs broadly match the paper. The ten crop multiples of sample redistribution, the three-level, two-size anchors, ATSS's 9 candidates and the four searched sets of depths and widths are all there.
The configs come in two families. The versions without keypoints are the paper's setup, with Group Normalization in the head and weights shared by the three levels. The versions with _bnkps in their names add a five-point landmark branch (smooth-L1, weight 0.1), switch the head to BatchNorm and stop sharing weights across levels; in the README's pretrained table, the 10GF keypoint version scores 82.80 on Hard, slightly below the paper version's 83.05. The repo also has a 1GF version the paper doesn't mention.
In InsightFace's Python package, FaceAnalysis() loads the buffalo_l model pack by default; its detector is SCRFD-10GF and its recognition model a ResNet-50 trained on WebFace600K. The detector's five points go straight to the recognition model for alignment, so the pack uses the keypoint version. In issue #1845 (November 2021), someone noticed that det_10g.onnx was loaded as the RetinaFace class, and the maintainer answered, "They're actually scrfd models, but can be called with both retinaface and scrfd names." Both generations of detector output boxes plus five points, so the package's alignment and recognition pipeline didn't have to change.
For the search, only an example script for 2.5GF is included. The README's procedure first generates 64 backbone configs, trains each for 80 epochs, picks the single most accurate one as the template, then generates a second round of configs based on its per-stage computation shares (within ±10%). That is not the same thing as the paper's 320 models with bootstrap intervals. The example's sampling ranges differ too, with at most 10 blocks per stage and an overall scaling of 0.5 to 3× in the second step. To reproduce statistics like those in Figure 5, you'd have to add the sample count and the bootstrap back yourself.
Community Reports: Resolution and Large Faces
SCRFD was built for VGA, and community reports mostly circle around resolution.
The most common one is about large faces. In May 2021, just days after SCRFD was released, a user reported in issue #1518 that faces taking up more than 40% of the frame got very low scores or weren't detected at all, especially in square images; lowering the detection size from 640 to 480 actually helped, and raising it to 1024 made things worse. Maintainer nttstar explained that this has to do with the anchor design and suggested inputs of 384, 256 or even 128 for single-face scenarios, or running 640 and 256 together, "only 16% more flops than the single 640 input" (). The reporter later found that the problem seemed to occur only with the _bnkps models; after swapping BatchNorm back to GroupNorm and retraining 2.5GF, they got 76.08 on Hard, a little below the official 77.13.
People were still asking about this in 2026. Issue #2877 (April 2026) reports a clear frontal face scoring only about 0.3, and no maintainer has replied to date. In May of the same year, InsightFace's Python package changed SCRFD's default detection size to running and together. The 128 pass adds only 4% computation (), and a face filling the frame is about 100 pixels wide in a 128 input, right within the range of the middle level's anchors.
The other direction is original image size. In issue #1639, a user argued that SCRFD degrades away from its training resolution and that RetinaFace does better at the original scale; nttstar's reply was "Ten people may have ten conclusions." The official README does give one set of numbers, though, with SCRFD-0.5GF scoring 82.03 on Hard when tested at original size and 68.51 at 640×480. The Hard group is mostly small faces, which get even smaller when shrunk to 640, the exact opposite direction from the large-face problem.
Reproduction has its pitfalls too. In issue #1938, a user's scores kept coming out low, and the fix the thread settled on was a score threshold of 0.02 and NMS at 0.45; another user got 0.711 with mmdetection's default test.py and only got matching numbers after switching to test_widerface.py. In issue #2246 (February 2023), someone retrained the 10GF keypoint version and got 92.89/92.59/82.36, against the official 95.40/94.01/82.80. Hard matched, but Easy was off by 2.5 (turns out Easy is harder to reproduce than Hard). This issue has no maintainer reply either.
Latency, on the other hand, reproduces better. In issue #1761, someone measured 31 ms for SCRFD-0.5GF, and the maintainer asked them to check whether the GPU build of onnxruntime was installed; another user measured 3.6 ms for 0.5GF, 4.2 ms for 2.5GF and 5.9 ms for 10GF on an RTX 3080, close to the paper. The official README also lists single-thread CPU numbers, with SCRFD-0.5GF at 28.3 ms on 640×480 (AMD Ryzen 9 3950X).
Conclusion
Neither of SCRFD's two moves is complicated. Sample redistribution just widens the training crop range to 2×; positives on stride 8 grow by nearly forty percent and Hard AP gains 7 percentage points, with inference cost unchanged. Computation redistribution uses RegNet-style random sampling and the bootstrap to find that a face detector at VGA should put most of its backbone computation in the shallow stages and keep the head small. Combined, a 34-GFLOPs model beats TinaFace at 640 pixels with only a fifth of the computation.
Before using buffalo_l or any other SCRFD model, check how big the faces in your frames are. Surveillance footage, group photos and other scenes full of small faces are exactly what the 640 setting does best. For selfies, ID photos and other scenes where one face fills the frame, shrink the input, or, like the newer package, run an extra 128 input. When evaluating, remember to use the official test_widerface.py and that low-threshold setting; otherwise, scores that don't match the paper are entirely to be expected.
TinaFace says there is no gap between face detection and generic object detection. At the same 2.5 GFLOPs, the ResNet baseline spends a third of its computation on the head alone; SCRFD puts about three quarters into the stem, C2 and C3, leaving the head just over a tenth.