SSH: Single Stage Headless Face Detector
- Publication
- ICCV 2017Conference
- First submitted to arXiv
- arXiv:1708.03979
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{objectdetectionssh2017,
title = {{SSH: Single Stage Headless Face Detector}},
author = {Mahyar Najibi and Pouya Samangouei and Rama Chellappa and Larry Davis},
year = {2017},
eprint = {1708.03979},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1708.03979}
}
VGG-16 has 138 million parameters, 124 million of them in the last three fully connected layers (fc6 to fc8), and only 14.7 million in the convolutional layers. Two-stage detectors keep the first two of those three layers as the "head," and every proposal has to pass through it once.
SSH stands for Single Stage Headless, one stage and no head. It cuts VGG-16's fully connected layers out entirely, keeps only the convolutional layers, and attaches three small detection modules. Counting from the official network definition, the whole detector has about 19.8 million parameters, roughly a seventh of VGG-16 (this note's estimate).
The paper comes from Mahyar Najibi, Pouya Samangouei (joint first authors), Rama Chellappa and Larry Davis at the University of Maryland. The rival the authors were aiming at is Finding Tiny Faces (HR) from a few months earlier, a detector built from ResNet-101 plus an image pyramid whose 2× upscaled level goes up to 5,000 pixels per side, taking over a second per image. The question SSH wants to answer is whether, with no head, no pyramid and nothing but VGG-16's convolutional layers, it can beat that.
The context module RetinaFace later used comes from this paper.
Defining the Problem
The Head of a Two-Stage Detector
Faster R-CNN works in two steps. The first uses an RPN (region proposal network) to propose a few hundred candidate boxes on the convolutional feature map; the second crops out each candidate box's features, shrinks them to 7×7, and sends them through the remaining layers of the classification network to decide what it is and refine its position. In the VGG-16 version the second step is fc6 and fc7, and fc6 alone has hundred million parameters (about 103 million).
This head is expensive in two ways. It has many parameters, which take up memory, and it has to run once for every proposal, so the more proposals, the longer it takes.
RPN places a few fixed-size boxes in advance at each position of the feature map; these are called anchors. On a stride-16 feature map there's a set of anchors every 16 pixels, and Faster R-CNN puts 9 in each set (three sizes, 128, 256 and 512, times three aspect ratios). For each anchor the network answers "is there an object in this box," then predicts how the box should shift and resize to fit. Face detection has only one class, so swap "object" for "face" and RPN is a detector. That's exactly the road SSH takes, classifying and regressing anchors directly from early convolutional features, with classification and localization done in the same step.
The Cost of an Image Pyramid
Faces range from a few pixels to over a thousand. HR, the strongest on WIDER FACE at the time, handles scale with an image pyramid, scaling the same image to 0.25, 0.5, 1 and 2 times and running ResNet-101 on each, with the 2× level going up to 5,000 pixels per side. It's accurate, but by the SSH paper's measurement on a Quadro P6000, HR takes 1,010 milliseconds to process one WIDER FACE validation image.
Context has a cost too. CMS-RCNN adds context to Faster R-CNN by enlarging the area around each proposal, extracting a second set of features and running a second classification head, so both memory and time go up.
SSH has to deal with all three at once. Remove the head, remove the pyramid, and bring context back in a cheap way.
The Exam and the Scores
The main exam is WIDER FACE, with 32,203 images and 393,703 faces, split roughly 4:1:5 into training, validation and test. The validation and test sets are divided by difficulty into Easy, Medium and Hard, according to whether a traditional proposal method (EdgeBox) can find the face; the three groups are cumulative, and Hard contains the faces of the first two plus lots of small faces a dozen or so pixels across.
Scoring uses AP. A detection counts as correct if its IoU (intersection area divided by union area) with a labeled box is above 0.5; going down all detections sorted by score from high to low, precision and recall are computed along the way and plotted as a PR curve, and AP is the area under the curve. The test-set labels aren't public, so results have to be handed to the organizers for scoring.
Solving the Problem
One 1200×1600 Image

The three output images on the right show the division of labor well. The largest face is found by M3, the face in the picture frame by M2, and the two even smaller faces in the photo inside the frame by M1.
Let's follow an image with a short side of 1,200 and a long side of 1,600 through the network, the size SSH trains and tests at on WIDER FACE.
The image first goes through VGG-16's convolutional layers. conv4_3 has a stride of 8 and a 150×200×512 feature map; conv5_3 has a stride of 16 and a 75×100×512 feature map. The three detection modules attach in three places:
| Module | Feature map | Stride | Anchor sides | Anchors |
|---|---|---|---|---|
| M1 | 150×200 | 8 | 16, 32 | 60,000 |
| M2 | 75×100 | 16 | 64, 128 | 15,000 |
| M3 | 38×50 | 32 | 256, 512 | 3,800 |
Computed for this note from Sections 3.2 and 4.1 of the paper and the official network definition. M1's input is the 128-channel fused feature; M2 and M3 take 512 channels.
M2 attaches directly to conv5_3. M3 does one more stride-2 max pooling on conv5_3, so its stride becomes 32 and the 75×100 feature map shrinks to 38×50 (rounding up).
M1, which has to find the smallest faces, uses fused features. conv4_3 and conv5_3 each go from 512 to 128 channels through a 1×1 convolution (the paper says to save memory); the conv5_3 copy is enlarged 2× with bilinear upsampling, added to the conv4_3 copy, and followed by a 3×3 convolution. M1 thus sees the high-resolution 150×200 grid of positions and also gets semantics from one layer deeper.
Anchors are a base size of 16 pixels times each module's multipliers, {1, 2} for M1, {4, 8} for M2 and {16, 32} for M3, so each M1 position has two square anchors of 16 and 32 pixels, and so on. The authors use only anchors with an aspect ratio of 1, since in their experiments multiple aspect ratios didn't clearly help for faces. The three modules have 78,800 anchors in total, 76% of them in M1.
Each module ends in two 1×1 convolutions. The classification one outputs channels, two scores per anchor (face, background); the regression one outputs channels, four corrections per anchor. , so these come to 4 and 8 channels.
The Detection Module and the Context Module

The detection module has two paths. The upper path is a 3×3 convolution that looks around the anchor's center; the lower path is the context module, which looks farther out. Each path outputs channels, concatenated into and handed to the 1×1 convolutions for classification and regression. M1 has ; M2 and M3 have .

The context module first applies a 3×3 convolution with output channels, then splits into two branches. The upper branch stacks one more 3×3 on top, the lower branch two more.
Two-stage detectors add context by enlarging the area around a proposal and extracting features again. SSH's anchors are classified with convolutions on the feature map, so switching to a larger kernel amounts to enlarging the area each anchor looks at. What the authors wanted were 5×5 and 7×7 kernels; what they actually used were stacked 3×3s.
Why are two stacked 3×3 layers the same as a 5×5? Look at just one direction. An output position in the second layer reads three positions of the first layer, , and ; the first layer's in turn reads input positions to , and reads to . Together, output can see input positions to , 5 cells in all. One more layer makes it 7.
The parameters are fewer. With channels in and out, a 7×7 convolution has parameters, while three 3×3s have only , plus two extra ReLUs in between. SSH's two branches also share the first 3×3. The "5×5" branch is that first layer plus one more, and the "7×7" branch is the first layer plus two more.
The region of the input image that a position on the feature map can see is called its receptive field. In pixels, how much farther each extra layer sees depends on the stride of that layer. On a feature map with stride , each extra stacked 3×3 grows the receptive field by pixels. So M1's three paths () see 16, 32 and 48 pixels beyond the receptive field of the input feature itself, and M3's () 64, 128 and 192 pixels. As the authors put it, context added this way is proportional to the stride, and therefore to the size of the faces each module is responsible for.
Measured against anchor size, it looks different. M1's 16-pixel anchor sees 48 extra pixels, 3 times the anchor; M3's 512-pixel anchor sees 192 extra pixels, only 0.375 times (this note's estimate). Relative to face size, small faces get far more surroundings than large ones, in the same direction as Tiny Faces' human experiment.
The paper says the context module raises mAP on the WIDER FACE validation set by more than 0.5 percentage points, without giving a table. Another of its claims can be checked by hand. The paper says the detection module, context included, has fewer parameters than the module Faster R-CNN uses to propose boxes. Counting from the official network definition, M2's detection module has about 2.22 million parameters, and RPN's 512-channel 3×3 convolution plus its two output layers about 2.39 million, so it is indeed fewer (this note's estimate).
Dividing the Anchors Among Three Modules
An anchor counts as a positive only if its IoU with some face is above 0.5; one with an IoU below 0.3 against every face is background, and anything in between doesn't count. Here there's one key difference from Faster R-CNN. Faster R-CNN forcibly assigns the highest-IoU anchor to each labeled box even if that IoU is below the threshold; SSH doesn't.
This choice makes the three modules divide the work naturally. A 100-pixel face has an IoU of at most about 0.1 with M1's 32-pixel anchors, so it produces no positives in M1; only M2's 128-pixel anchors take it as a positive. Each module learns positives only from faces within its own size range, so the three modules each specialize in one range of scales.
The price is that some faces get no positives at all. Work through a 20×20 face. M1's anchor centers are every 8 pixels. If the face's center lines up exactly with an anchor center, its intersection with the 16-pixel anchor is 256 and the union 400, an IoU of 0.64, so it's a positive. If the face's center falls right in the middle of four anchor centers, 4 pixels off in both directions, its intersection with the 16-pixel anchor shrinks to , the union is , and the IoU is about 0.426; its IoU with the 32-pixel anchor is . Both fall short of 0.5, and this face is never treated as a positive during training.

generate_anchors.This figure does the same calculation for every size of square face. The blue line is the highest IoU when the face's center lines up with an anchor center; the orange line is the highest IoU when the face's center falls at the worst position.
Faces with sides of 11 pixels or less get no positive anchor wherever they fall; centered on a 16-pixel anchor, the IoU is the side squared divided by 256, which needs at least 11.3 pixels to reach 0.5. Faces of 12 to 22 pixels are down to luck. Scanning every position at 0.5-pixel steps, a 12-pixel face gets no positive at more than half of the positions, and a 20-pixel face at about a tenth. Between 23 and 724 pixels, every position has at least one positive anchor; beyond 724 pixels, even the largest 512-pixel anchor, perfectly centered, gives an IoU below 0.5.
Loss and Hard Example Mining
The three modules each have their own classification and regression losses, summed up:
runs over the three modules, and is the set of anchors of module . is the predicted class of anchor and is its label; is the ordinary softmax cross-entropy. is the predicted box correction and the target, is smooth-L1, and restricts regression to positives.
The two denominators are each module's own sample counts, being the number of anchors in that take part in the classification loss and the number of positives in . Each module is averaged internally first and then added up, so M1 and M3, whose anchor counts differ by more than a factor of ten, end up on the same footing. The paper doesn't give the value of ; in the official training configuration, classification and regression both have a weight of 1.
The regression targets follow Faster R-CNN, with center offsets divided by the anchor side and log ratios for width and height:
are the anchor's center, width and height, and those of the labeled box.
Background anchors far outnumber positives, so they have to be selected. SSH uses online hard example mining (OHEM), and selects separately for each module. Each image and each module gets 256 anchors, with positives taking at most a quarter of them (64); the positives picked are those the current model scores lowest as "face," and the remaining slots go to the background anchors with the highest scores. Selecting separately pays off directly. In a 1200×1600 image M1 has 60,000 anchors and M3 only 3,800, and if they were mixed together, M3 might not get a single slot.
Training and Test Settings
Fine-tuning starts from VGG-16 pretrained on ImageNet, with the convolutional layers before conv3_1 frozen. 4 GPUs, SGD, a learning rate of 0.004, 21,000 iterations of training, divided by 10 at iteration 18,000; momentum 0.9, weight decay . Training images are scaled to a short side of 1,200 and a long side of at most 1,600, with horizontal flipping.
At test time, each module first takes its 1,000 highest-scoring anchors, and the three modules then go through one NMS together at IoU 0.3 (non-maximum suppression, which keeps only the highest-scoring box among boxes that overlap too much).
To compare full strength against HR, SSH can also use a pyramid. The image is first shrunk to a short side of at most 800 and a long side of at most 1,200, then scaled into four levels with short sides of 500, 800, 1,200 and 1,600; all three modules run on every level, except that M3 skips the largest one.
Discussion
WIDER FACE Validation Set
| Method | Easy | Medium | Hard |
|---|---|---|---|
| CMS-RCNN | 89.9 | 87.4 | 62.9 |
| HR-VGG16 + pyramid | 86.2 | 84.4 | 74.9 |
| HR-ResNet101 + pyramid | 92.5 | 91.0 | 80.6 |
| SSH | 91.9 | 90.7 | 81.4 |
| SSH + pyramid | 93.1 | 92.1 | 84.5 |
Compiled from Table 1 of the paper, WIDER FACE validation set; SSH's backbone is VGG-16.
With VGG-16 on both sides, SSH without a pyramid is 5.7, 6.3 and 6.5 percentage points above HR's VGG-16 version. Add the pyramid and Hard reaches 84.5, 3.9 above HR's ResNet-101 version.
The most eye-catching sentence in the abstract, "with a headless VGG-16, SSH beats the ResNet-101-based state-of-the-art," rests on SSH without a pyramid beating the ResNet-101 HR on Hard as well (81.4 against 80.6). That 80.6 is worth tracing. It matches the HR validation curve that comes with WIDER FACE's official evaluation tool (this note recomputes it as 0.806 with the tool's method). The Tiny Faces paper itself reports higher numbers, 82.3 for the ResNet-101 version and 83.1 for the pruned final version. Measured against HR's own numbers, SSH without a pyramid loses (1.7 points decided the winner).
The test set doesn't have this problem; both sides handed their results to the WIDER FACE authors for scoring.

What was submitted was SSH with the pyramid, and the authors say they submitted only once. Hard is 0.844 against HR's 0.819, 2.5 percentage points higher, which is the abstract's "improving the AP by 2.5%." Easy and Medium are 0.927 against 0.923 and 0.915 against 0.910, much smaller gaps. SSH without the pyramid was never submitted.
Resolution and Time
With the image pyramid gone, the effect of input resolution rests entirely on a single size.
| Max size | Hard AP | Time |
|---|---|---|
| 400×800 | – | 48 ms |
| 600×1000 | 68.6 | 74 ms |
| 800×1200 | 78.4 | 107 ms |
| 1200×1600 | 81.4 | 182 ms |
| 1400×1800 | 81.0 | – |
Hard AP is from Table 3 of the paper, on the WIDER FACE validation set, with that size used for both training and testing; time is from Table 2 of the paper, averaged over the WIDER FACE validation set on a Quadro P6000 GPU. "600×1000" means the short side is scaled to 600 with the long side at most 1,000.
Raising the resolution from 600 to 1,200 adds nearly 13 percentage points on Hard, and going higher actually lowers it slightly. 800×1200's 78.4 is still above HR-VGG16's 74.9.
This table also explains a reproduction problem. In November 2017 a user reported in issue #11 that the official model gave only 92.5/90.9/73.7 on the validation set, nearly 8 points short on Hard. A few days later the person who asked found the cause themselves, a wrongly set input resolution; switching to 1200×1600 matched the paper.
Speed has to be read with its conditions. 182 milliseconds is a GPU number, and 19.8 million parameters speaks only to the parameter count. VGG-16's convolutional layers alone take about 587 billion multiply-adds on a 1200×1600 image, and about 625 billion with the three modules added (this note's estimate). Community reports of running it on a CPU range from over ten seconds to about twenty seconds per image (issue #39, issue #57). SSH is "light" relative to the head of a two-stage detector; it's still a long way from a phone.
Ablations
| Setting | Hard AP |
|---|---|
| SSH | 81.4 |
| M2 only | 68.6 |
| Without OHEM | 76.6 |
| No fusion in M1 | 80.7 |
| Denser anchor scales | 78.4 |
Compiled from the legend of Figure 7 of the paper, WIDER FACE validation Hard, no pyramid.
- Multiple modules matter most. Remove M1 and M3, move all three groups of anchors to M2 on conv5_3, keep everything else the same, and Hard drops 12.8 percentage points. A stride-16 feature map has to handle anchors of both 16 and 512 pixels, and small faces are the first to suffer.
- OHEM is worth 4.8 percentage points. The authors believe that with VGG-16's pretrained head gone, this lightweight detector leans especially hard on hard example mining.
- Feature fusion is only 0.7 percentage points. It adds almost no computation, so it stays.
- Denser anchors aren't better. With finer scales, M1's anchors become 4, 8, 16, 32 and 48 pixels, and M2 and M3 each go from two sizes to five; inference slows down, and Hard actually drops 3 percentage points. The authors' explanation is that false positives went up.
Point 4 is interesting next to the IoU chart earlier. Denser anchors could close the gap of small faces missing their anchors, yet the paper's result is more false positives and a lower AP. S3FD, from the same year, tiled them another way, putting 16-pixel anchors on a stride-4 feature map with every anchor's spacing fixed at a quarter of its side, and then changing the matching rule to top up anchors for small faces.
FDDB and Pascal Faces
FDDB has 2,845 images and 5,171 faces, labeled with ellipses. Scoring plots an ROC curve, with the total number of false positives (boxes drawn on things that aren't faces) on the horizontal axis and the fraction of faces found on the vertical axis. The discrete score counts a detection with an IoU above 0.5 as 1 and everything else as 0; the continuous score uses the IoU value directly, so the more tightly the box fits the ellipse, the higher the score. Pascal Faces is 851 images picked from Pascal VOC. SSH trains on neither dataset; it uses the model trained on WIDER FACE, with input scaled to a short side of 400 and a long side of at most 800, under 50 milliseconds per image.
| Method | discrete | continuous |
|---|---|---|
| SSH | 0.981 | 0.744 |
| HR-ER | 0.976 | 0.790 |
| HR | 0.970 | 0.688 |
| Conv3D | 0.901 | 0.759 |
| MTCNN | 0.944 | 0.708 |
Excerpted from the legends of Figure 6 (a)(b) of the paper, FDDB.
SSH ranks first on the discrete score. On the continuous score it loses to HR-ER and Conv3D, both of which output ellipses, and HR-ER also trained a box-to-ellipse regressor with 10-fold cross-validation on FDDB. Against HR, which outputs rectangles as well, SSH's continuous score is 5.6 percentage points higher. On Pascal Faces SSH's AP is 98.27, with Faster R-CNN second at 97.84.
FDDB's images are low-resolution, so the input size has to change with them. In November 2017 someone in issue #8 tested FDDB with WIDER FACE's 1200/1600 setting and got only about 0.90 at 400 false positives; the author pointed out that the paper used 400/800, and after the change the numbers matched.
Official Code and Community
The official code is at mahyarnajibi/SSH, forked from py-faster-rcnn, written for Caffe, MIT-licensed, with pretrained models.
Reading the code turns up a few things.
- Network details. The first layer of the context module is a 3×3 convolution, and the detection module's 3×3 path together with the context module outputs 256 + 128 + 128 = 512 channels for M2 and M3, and half that for M1.
- How OHEM is written. The training network definition carries an extra
*_ohembranch that shares weights with the main branch and passes back no gradient, used only to compute the scores for picking samples. In issue #17 someone pointed out that the main branch's scores could be used directly, and reported in July 2018 that removing the branch gave the same results. - Batch size. The paper says a mini-batch is 4 images. In the code each GPU reads 1 image at a time, but the solver sets
iter_size: 2, updating the weights only after two forward passes; by Caffe's semantics, four GPUs means each update sees 8 images. Issue #45 (November 2018) asked exactly this; other users answered, and the authors never weighed in. - How long to train. The authors explained in issue #10 that the 21,000 iterations came from stopping when validation performance started to decline, and that the final comparison should rest on the test set, submitted only once. The validation numbers therefore carry a bit of selection.
False positives have been reported too. Issue #42 (October 2018) ran the pretrained model on the reporter's own data and picked up quite a few cat and dog faces, with more false positives than a cascade CNN; it got no reply.
Independent reproduction does work, though. In July 2018 the InsightFace team released mxnet-SSH, whose README gives validation results of 0.935/0.923/0.845, against 0.931/0.921/0.846 for the original Caffe model, almost identical.
How Later Work Used It
The next year, the same InsightFace team made RetinaFace. It attaches an SSH-style context module to each level of the feature pyramid, and the functions in its official code are even named ssh_context_module and ssh_detection_module; the sample config's anchors are also SSH's three groups, at strides 8, 16 and 32, with two sizes per level.
PyramidBox reworked SSH's context module into a deeper prediction module (CPM), and ran a comparison too. On Hard of the WIDER FACE validation set, DSSD's prediction module gets 88.2, SSH's context module 88.4 and CPM 88.5. The authors observed that stacking SSH's and DSSD's modules together gains almost nothing over SSH's alone, and that the large receptive field is what matters. As late as MogFace in 2022, the training recipe still lists an "SSH head."
Conclusion
Hook SSH up to a 720p surveillance stream, and whether the frames get upscaled decides outright how small a face it can find. It has no image pyramid, so every face it can find is tied to six anchors of 16 to 512 pixels; the more the image is shrunk, the more faces fall out of M1's range. On the WIDER FACE validation set, switching both training and testing to a short side of 600 drops Hard from 81.4 to 68.6. The official setting for WIDER FACE is a short side of 1,200 and a long side of 1,600, and low-resolution images like FDDB's use 400/800; the user in November 2017 who got only 73.7 ran into exactly this.
The whole detector has 19.8 million parameters and takes 182 milliseconds per image on a GPU without a pyramid, scoring 81.4 on validation Hard; with the pyramid it scores 0.844 on test Hard, 2.5 above HR. The most important thing in the ablations is the three modules each handling their own layer, and keeping only M2 costs 12.8. As for the context module, the paper says only that it's worth more than 0.5 percentage points, without so much as a table, and it's exactly the part RetinaFace went on to adopt.