Pixel-in-Pixel Net: Towards Efficient Facial Landmark Detection in the Wild
- Publication
- International Journal of Computer Vision 2021Journal
- First submitted to arXiv
- arXiv:2003.03771
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{faceanalysispipnet2020,
title = {{Pixel-in-Pixel Net: Towards Efficient Facial Landmark Detection in the Wild}},
author = {Haibo Jin and Shengcai Liao and Ling Shao},
year = {2020},
eprint = {2003.03771},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2003.03771}
}
Crop a face to and feed it to ResNet-18, and the last feature map is down to . Each cell covers a patch of the original image, the face's 98 landmarks are crammed into these 64 cells, and an eye takes up only one or two of them.
If the model only says which cell the point falls in and the cell center is taken as the answer, the average error is about 0.38 times the cell width, around 12 pixels. With WFLW's cropping, the two outer eye corners are about 129 pixels apart, so 12 pixels is a 9.5% error, just shy of the 10% usually counted as a failure.
The standard fix in heatmap regression is to scale the feature map back up, with deconvolution or an hourglass network, to , where each cell is only 4 pixels. That's accurate, but it costs a good chunk of extra computation. The paper measured a heatmap model made of ResNet-18 plus deconvolution at only 3.5 images per second on CPU.
PIPNet (Pixel-in-Pixel Net) comes from the Inception Institute of Artificial Intelligence (IIAI) in Abu Dhabi, by Haibo Jin, Shengcai Liao and Ling Shao. The authors choose to stay at and have each cell answer not only "is the point in me" but also "where inside me is it." The same ResNet-18 then runs at 35.7 images per second on CPU. The paper does two more things: it has each point guess its neighbors' positions on the side, and it keeps training on unlabeled photos to shrink the drop you get when switching datasets.
Defining the Problem
Landmarks and how they're scored
Facial landmark detection takes a face that has already been cropped and outputs a predefined set of points. 300W uses 68: 17 on the jaw contour, 10 on the eyebrows, 9 on the nose, 12 on the eyes and 20 on the mouth. WFLW uses 98, with the contour densified to 33 points, finer eyebrows and eyes, and two extra pupil points. COFW has 29 points concentrated on the facial features, with just one chin point, and is all about occlusion. AFLW uses 19 points in this paper.
Scoring uses NME (normalized mean error). For each image, compute the Euclidean distance between the predicted and annotated positions of every point, average them, divide by a normalizing distance, and finally average over the whole test set. This paper uses the inter-ocular distance, the distance between the two outer eye corners, on 300W, COFW and WFLW; the official code takes points 36 and 45 on 300W and points 60 and 72 on WFLW. Converting with the official mean face, the inter-ocular distance on WFLW's crop is about 129 pixels, so 1% NME is roughly 1.3 pixels.
Change the denominator and the numbers change with it. Some papers use the distance between the two pupils (inter-pupil) on COFW; it's shorter than the distance between the outer eye corners, so the same model's NME comes out larger. STAR Loss, three years later, reports both: 3.21 inter-ocular and 4.62 inter-pupil. AFLW uses the image size as the denominator in this paper and Menpo uses the face box diagonal, and both give much smaller numbers.
300W's 689 test images are split into common (554 images, from LFPW and HELEN) and challenging (135 images, all from iBUG), which together are called full. WFLW's 2,500 test images are also tagged by attribute into six subsets, pose, expression, illumination, make-up, occlusion and blur, and an image can belong to several of them at once. Many papers of the period also report the failure rate (FR, the fraction of images with NME above 10%) and the AUC. The AUC comes from the CED curve, whose horizontal axis is an NME threshold and whose vertical axis is the fraction of images with error no larger than that threshold; the area under the curve divided by the threshold is the AUC, with a maximum of 1. This paper reports only NME.
Two kinds of detection heads

Deep landmark models differ mainly in how they finally turn features into coordinates. The top row shows the two mainstream approaches of the time and the bottom row this paper's; we start with the top row.
Coordinate regression (a) flattens the whole feature map and attaches fully connected layers that output numbers directly, where is the number of points. All points share the same feature vector, and the output is usually a face with a plausible shape; the drawback is imprecise detail, with the eyes or the mouth often shifted as a group, and getting accuracy means chaining several stages.
Heatmap regression (b) draws a heatmap for each point, where each pixel's value stands for how likely the point is to be there, and inference takes the location of the maximum. The training target is usually a 2D Gaussian centered on the annotated point. It's more accurate than coordinate regression on most images, but each point is determined by features at a different position on the heatmap, independently of the others; under extreme poses or blur, once one point's peak jumps somewhere else, the shape of the whole face breaks.
The heatmap's resolution sets the quantization error. Assuming points are uniformly distributed within a cell and the cell center is taken as the answer, the average Euclidean error is about 0.383 times the cell width. Plug in a few numbers:
| Heatmap | Cell (px) | Mean error | ≈ NME |
|---|---|---|---|
| 32 | 12.2 px | 9.5% | |
| 4 | 1.5 px | 1.2% | |
| 1 | 0.4 px | 0.3% |
Computed for this note with a input, converting to NME with the 129-pixel inter-ocular distance of WFLW's mean face.
The best methods on WFLW at the time were around 4.4%, so a 1.2% quantization error is already substantial. That's why heatmap methods kept moving toward higher resolution: hourglass networks, U-Net and HRNet all look for ways to keep or restore resolution, and some don't downsample anywhere in the network. MapNet, which the paper uses as a baseline, is the Simple Baselines (Xiao et al.) architecture: ResNet-18 followed by deconvolution for upsampling, plus, at inference, a quarter-cell shift from the highest point toward the second highest to make up a little of the quantization error. All this computation is spent on large feature maps, and that's what hits the CPU hardest.
Switch datasets, lose a chunk
The other problem is generalization. Train PIPNet on the 300W training set and its NME on the 300W test set is 3.36%; test the same model on WFLW converted to 68 points (WFLW-68) and it becomes 8.09%.
Earlier work such as LAB, ODN and AVS adds specially designed modules during supervised learning, such as boundary information, occlusion handling or style transfer, and then tests directly on other datasets. The authors call this paradigm GSL (generalizable supervised learning). Labeling a few more datasets is of course the most direct fix, but landmark annotation is expensive; WFLW takes 98 points per face.
Unlabeled face photos, on the other hand, are cheap. The authors want to go the GSSL route (generalizable semi-supervised learning), using labeled data together with unlabeled data from all kinds of domains. The difference from unsupervised domain adaptation (UDA) is that UDA requires the unlabeled data to come from the test domain, while GSSL doesn't care where it comes from.
So the paper has two questions to answer. Is there a detection head as fast as coordinate regression and as accurate as heatmap regression? And can unlabeled face photos be used to narrow the cross-dataset gap?
Solving the Problem
Locating again inside the 8×8 grid

This figure is the whole of PIP regression; let's follow the red dot through it.
The input is and the network's total stride is , so the last layer is . The red dot is the inner corner of the right eye; suppose it sits at in the original image. Dividing by 32 gives in cell units, which falls in the cell at column 3, row 3, counting from 0. The authors call this the positive cell, and the other 63 cells are negative cells.
Besides the positive cell, we also need to know where inside the cell the point is. and , meaning the red dot is 30% of the cell width across and 80% down from the positive cell's top-left corner.
So each point gets three label maps:
- Score map: 1 at the positive cell, 0 elsewhere.
- x-offset map: 0.3 at the positive cell, 0 elsewhere.
- y-offset map: 0.8 at the positive cell, 0 elsewhere.
98 points means 98 score maps plus 196 offset maps. On the network side there's just one convolution layer, which takes ResNet-18's final 512-channel feature map and directly outputs scores and offsets, with no upsampling at all. The heatmap's size is set by the stride:
and are the input height and width, and and the heatmap height and width (Eq. (4) of the paper).
The training loss has a score part and an offset part, Eq. (1) of the paper:
The score term treats the problem as classification and applies L2 to all cells (Eq. (2)):
is the label of the -th point at cell , and is the prediction. The offset term is regression and uses L1 on the positive cell only (Eq. (3)):
are the x and y directions, and is an offset label between 0 and 1. Whatever offsets the negative cells output, they never enter the loss. The authors found experimentally that L2 works better for classification and L1 for regression, the latter agreeing with the conclusion of the Wing Loss paper.
At stride 32, , which brings the two terms to similar magnitudes. The official config writes this as a classification weight of 10 and a regression weight of 1, the same ratio. The score map's label is 1 in a single cell, with no Gaussian smoothing; the heatmap method MapNet, by contrast, has to adjust its Gaussian radius to the stride (radii 1, 2 and 4 for strides 4, 2 and 1), which the authors also count as a reason PIP is easier to train.
At inference, take the cell with the highest score, add that cell's offset, and multiply by the stride. Suppose the model outputs an offset of at cell ; the prediction is , off from the annotation by , a Euclidean distance of 1.4 pixels, about 1.1% NME.
From this formulation, the authors see PIP as a generalization of two older approaches. Set the stride to the size of the image and the heatmap shrinks to a single cell; drop the score, and the offset that remains is coordinate regression, just with the fully connected layer swapped for a convolution. Set the stride to 1 and drop the offsets, and you're back to heatmap regression (with differences in label smoothing and inference details). A stride in between amounts to low-resolution heatmap regression over the whole image plus coordinate regression inside each cell, which is where the name "pixel-in-pixel" comes from.
So what stride? The authors randomly hold out 1,500 images from the WFLW training set as a validation set and train PIPNet without the neighbor module:
| Stride | Heatmap | NME |
|---|---|---|
| 16 | 4.03 | |
| 32 | 3.94 | |
| 64 | 3.96 | |
| 128 | 4.10 |
Compiled from Table 1 of the paper, WFLW validation set. Strides above 32 add stride-2 convolutions after the ResNet; strides below 32 add deconvolutions.
A larger stride means fewer cells to classify, so picking the right one gets easier; but each cell gets bigger, so the range the offset has to regress grows too. 32 strikes the balance between the two, and it also happens to be ResNet's original stride, with no layers added.
The neighbor regression module
PIP solves speed, but the stability problem remains. The authors picked a few WFLW test images to compare four heads, with average NME of 6.61% for coordinate regression, 5.90% for stride-1 heatmap regression, 4.84% for PIP and 4.67% for PIP plus the neighbor module. Coordinate regression gives a plausible shape under large poses, but the eyes and mouth shift as a group, and small changes like a blink or an open mouth may be missed; heatmap regression and PIP get the details right, but under extreme poses the contour points each go their own way.
The authors' explanation is that in heatmap-style methods, each point draws on features at a different position, with no constraint between points; in coordinate regression, all points share the same feature vector, which the authors believe is the key to its stability.
The neighbor regression module (NRM) borrows this property from coordinate regression. Besides predicting its own offset in the positive cell, each point also predicts the positions of neighbors from that same positive cell, which adds a neighbor map to the output. Neighbors are defined simply: compute the mean face from the training set, and for each point take the points nearest in Euclidean distance (excluding itself); the authors also tried defining them by correlation coefficient, with similar results.
Back to the red dot. The blue dot is the outer corner of the same eye, at , which is in cell units. It isn't in the red dot's positive cell, but the neighbor's position is still measured from the top-left corner of the red dot's positive cell: and . So the red dot's x-neighbor map holds 1.8 at cell , and its y-neighbor map holds 0.7.
Neighbor offsets can exceed 1, and they can also be negative. Computed on the official WFLW mean face, the median distance to the 10th-nearest neighbor is about 30 pixels, and the farthest is 58 pixels, nearly 1.8 cells.
With neighbors added, the loss becomes Eqs. (5) and (6):
indexes the neighbor, and the other symbols are as in ; takes the same value as , and again only the positive cell counts.
At inference, each point collects the predictions made for it by "the points that list it as a neighbor," adds its own prediction, and takes the average.
Take WFLW's point 0, the topmost point of the left contour. Its own 10 neighbors are contour points 1 to 4, eyebrow points 33, 34 and 41, and eye points 60, 61 and 67. Going the other way, the only points that list it as a neighbor are contour points 1 to 5 and eyebrow point 33, six votes in all, which with its own makes 7 predictions. The pupils are far more popular: point 96 is a neighbor of 15 points.
Unequal vote counts make the matrix operations awkward to arrange. The official code uses a trick when it builds the index. Below is a version compiled from lib/functions.py and lib/test.py, with the original variable names, a few lines merged, and comments added for this note:
# get_meanface(): meanface_indices[i] = the num_nb landmarks nearest to landmark i on the mean face
meanface_indices_reversed = {i: [[], []] for i in range(meanface.shape[0])}
for i in range(meanface.shape[0]):
for j in range(num_nb):
nb = meanface_indices[i][j]
meanface_indices_reversed[nb][0].append(i) # landmark i votes for nb ...
meanface_indices_reversed[nb][1].append(j) # ... through its j-th neighbour channel
# "tricks, make them have equal length for efficient computation"
for i in range(meanface.shape[0]):
meanface_indices_reversed[i][0] += meanface_indices_reversed[i][0] * 10
meanface_indices_reversed[i][1] += meanface_indices_reversed[i][1] * 10
meanface_indices_reversed[i][0] = meanface_indices_reversed[i][0][:max_len]
meanface_indices_reversed[i][1] = meanface_indices_reversed[i][1][:max_len]
# test.py: own prediction + max_len neighbour votes, plain mean
tmp_nb_x = lms_pred_nb_x[reverse_index1, reverse_index2].view(cfg.num_lms, max_len)
tmp_x = torch.mean(torch.cat((lms_pred_x, tmp_nb_x), dim=1), dim=1)
max_len is the largest vote count among all points: 17 on WFLW with . A point with fewer than 17 votes has its voter list copied over and over until it's full. Point 0's 6 votes are padded to 17 slots, with contour points 1 to 5 appearing 3 times each and point 33 twice. Finally its own prediction is added, and the 18 numbers are averaged.
Going by the paper's "take the average," point 0's own prediction should count for one seventh. In the code that actually runs, every point's own prediction counts for only 1/18, and the rest of the weight goes to the neighbors according to how many times they were copied (your own vote counts least). On 300W, max_len is 22, so a point's own share is 1/23. This indexing has been there since the first commit in September 2020, and the official weights with this code do reproduce the paper's 3.31% on COFW (see issue #4 below).
The number of neighbors is also picked on the same validation set. Without the neighbor module the NME is 3.94; with it, every tested does better, bottoming out around (about 3.79) and creeping back to about 3.86 by the time it reaches 60. The rest of the experiments use .
The neighbor head is cheap. WFLW's channels, produced by a convolution from 512 channels, take about 1 million parameters; the head runs only on the map, at about 64 million multiply-adds per image, which is small next to the computation of ResNet-18 itself on a input (estimated for this note).
Training setup:
- Faces are cropped with the boxes each dataset provides and resized to ; the boxes are enlarged by 10% for the 68-point datasets and by 20% for WFLW, keeping a bit of surrounding context.
- The default backbone is ResNet-18 pretrained on ImageNet; ResNet-50, ResNet-101, MobileNetV2 and MobileNetV3 are also tried.
- Adam, 60 epochs, learning rate , multiplied by 0.1 at epochs 30 and 50, batch 16.
- Data augmentation, each with probability one half: translation by ±30 pixels, rectangular occlusion (sides up to 100 pixels), horizontal flipping and rotation by ±30°; plus Gaussian blur (radius up to 5) with probability 0.3.
Training on with unlabeled photos
The neighbor module steadies the predictions somewhat, but accuracy still drops when the dataset changes. Next, the authors take on GSSL.
The basic tool is self-training. First train a model on the labeled data and use it to predict landmarks on unlabeled photos as pseudo-labels, then retrain on the two combined, and repeat. The risk is that the model learns the errors in the pseudo-labels, produces more of the same errors in the next round, and drifts further with each round.

This figure is the authors' starting point. The vertical axis is the fraction of cases where the highest-scoring cell is the positive cell. The larger the stride, the fewer the cells and the easier it is to pick the right one; at stride 128 the whole image has just 4 cells, and both datasets are close to 97% accuracy. WFLW climbs more steeply than 300W from stride 16 to 32, from which the authors infer that the harder the data, the more it gains from a coarse task.
PIP's structure makes this easy to set up. Beyond the PIP layer, the authors attach two coarser score heads, and , defining three tasks:
- Task 1: grid classification, asking only which quadrant of the face the point is in, with each cell pixels.
- Task 2: grid classification, with 64-pixel cells.
- Task 3: standard PIPNet, with the scores, offsets and neighbors.
The procedure first trains on the labeled data with Task 3, estimates pseudo-labels, then retrains; the labeled data always goes through Task 3, while the pseudo-labeled data goes through Task 1, Task 2 and Task 3 in turn. In other words, the first retraining round trusts the pseudo-labels only on "which quadrant," the next round trusts them down to 64-pixel cells, and only at the end are the in-cell offsets trusted as well. Task 3 is then repeated for a few rounds, and the authors observed convergence after three. At inference the two extra heads are simply thrown away, and the model is the same as standard PIPNet.
The official implementation is even leaner than the figure. The two coarse heads apply max pooling once and twice to the feature map and feed the same score convolution, with shared weights. Every round retrains for 60 epochs from the ImageNet-pretrained weights; the author's explanation in an issue is that once the pseudo-labels have improved, training from scratch keeps the previous round's errors from lingering in the model. All pseudo-labels are used, with no confidence threshold, and they take the positions merged by the neighbor module. The curriculum version retrains 5 rounds in total (Task 1, Task 2, then Task 3 three times), while the standard self-training control does 3 rounds of Task 3.
The unlabeled data comes in two settings. UDA uses the training sets of COFW-68 and WFLW-68 with the labels removed; GSSL uses CelebA's 202,599 photos, with boxes detected by RetinaFace. In both settings the labeled data is just the 3,148 images of the 300W training set, and evaluation is on three test sets: 300W, COFW-68 and WFLW-68.
Drawing a face where there is none
The authors also ran a slightly mischievous experiment.

(a) replaces every 300W training image with an all-black one, keeps the labels as they are, and after training feeds in an all-black image. All three heads draw a tidy average face. There's nothing in the input, yet the model still knows where the points "usually are"; the authors cite the work of Islam et al. showing that CNNs can encode absolute position through zero padding.
(b) to (d) are normally trained models fed a cat, a deer and a truck from CIFAR-10 at test time. All three heads still draw a face, and coordinate regression draws the most complete one. The authors call this an implicit prior learned from the data; coordinate regression has the strongest prior, which also explains why it's stable but biased.
This experiment has very practical consequences. A landmark model memorizes roughly where the points sit inside the crop box, so cropping has to be done the same way in training and in inference. Datasets provide boxes in different styles; the authors plotted the mean faces of the three datasets, and while 300W and COFW-68 are similar, WFLW-68's face sits noticeably lower in the box. The cross-dataset experiments therefore move the top edge of WFLW-68's boxes down by 20%, then enlarge the three datasets' boxes by 30%, 30% and 20% respectively, so the mean faces roughly line up.
Discussion
Bias and variance
This set of experiments trains everything on 300W and evaluates on three test sets, comparing four heads:
- CoordNet: ResNet-18 followed by three fully connected layers (512, 512, ), L1 loss.
- MapNet: heatmap regression at strides 1, 2 and 4, L2 loss.
- PIPNet-32 (no neighbors) and PIPNet-32: stride 32.
The 300W test set is the closest to the training set, so a good score there means strong fitting ability (low bias); WFLW-68 differs most from the training set, so a good score there means good generalization (low variance). The authors also compute a Point-Var: for each test image, the variance of "annotation minus prediction," averaged over the test set. The authors admit it isn't exactly variance in the statistical sense and only reflects how consistent the predictions are.
| Method | 300W | COFW-68 | WFLW-68 |
|---|---|---|---|
| CoordNet | 4.17 | 5.18 | 8.92 |
| MapNet-1 | 3.54 | 4.58 | 8.42 |
| PIP (no NRM) | 3.48 | 4.69 | 8.43 |
| PIPNet | 3.36 | 4.55 | 8.09 |
| Point-Var | 300W | COFW-68 | WFLW-68 |
|---|---|---|---|
| CoordNet | 1.36 | 2.57 | 6.13 |
| MapNet-1 | 1.33 | 2.75 | 11.08 |
| PIP (no NRM) | 1.34 | 2.86 | 9.62 |
| PIPNet | 1.19 | 2.44 | 6.48 |
Compiled from the values printed on Figure 12(c)(f) of the paper. The top table is NME (%), the bottom one Point-Var ().
- Coordinate regression has the largest bias. Its NME is the worst on all three test sets, but its Point-Var on WFLW-68 is the lowest, 6.13.
- Heatmap regression has low bias and high variance. MapNet-1's NME on 300W is 0.63 lower than coordinate regression's, yet its Point-Var on WFLW-68 climbs to 11.08, nearly double.
- The neighbor module mainly suppresses variance. With it, Point-Var on WFLW-68 drops from 9.62 to 6.48, close to coordinate regression, while NME is the lowest on all three test sets at the same time.
The stride pulls on both of these as well. Moving MapNet from stride 1 to 4 changes its 300W NME from 3.54 to 4.5 and lowers WFLW-68 from 8.42 to 7.91: more bias, less variance. For PIPNet (no neighbors), going from stride 16 to 128 brings WFLW-68 steadily down from 9.01 to 7.99, while 300W only gets noticeably worse at stride 128 (3.62, 3.48, 3.54, 3.9). From this the authors conclude that PIP's bias holds up better than heatmap regression's when the stride changes.
Against the methods of the time
In the table below, 300W and COFW use inter-ocular normalization and AFLW uses image-size normalization:
| Method | Full | Chal. | COFW | AFLW |
|---|---|---|---|---|
| HRNet | 3.32 | 5.15 | 3.45 | 1.57 |
| AWing | 3.07 | 4.52 | – | – |
| LUVLi | 3.23 | 5.16 | – | – |
| PIP-MBv3 | 3.36 | 5.07 | 3.40 | 1.52 |
| PIP-R18 | 3.36 | 5.18 | 3.31 | 1.48 |
| PIP-R101 | 3.19 | 4.89 | 3.08 | 1.42 |
Compiled from Table 3 of the paper (NME %). Full and Chal. are 300W's full and challenging subsets; PIP-MBv3, PIP-R18 and PIP-R101 are PIPNet with MobileNetV3, ResNet-18 and ResNet-101 backbones.
On COFW, the ResNet-18 version's 3.31 is already below every prior method in the table, with HRNet at 3.45. On AFLW, the ResNet-18 version's 1.48 loses only to Wing's 1.47 and to LAB (1.25), which uses external boundary data. 300W is AWing's turf, and the ResNet-101 version's 3.19 ranks second among the methods that use no external data.
WFLW has six subsets; here are the three hardest:
| Method | Full | Pose | Occl. | Blur |
|---|---|---|---|---|
| HRNet | 4.60 | 7.94 | 5.44 | 5.42 |
| AVS+SAN | 4.39 | 8.42 | 5.60 | 4.86 |
| AWing | 4.36 | 7.38 | 5.19 | 4.96 |
| LUVLi | 4.37 | – | – | – |
| PIP-R18 | 4.57 | 8.02 | 5.66 | 5.25 |
| PIP-R101 | 4.31 | 7.51 | 5.36 | 5.02 |
Compiled from Table 4 of the paper (NME %).
The ResNet-101 version's 4.31 is the best overall, and it's also the best on three subsets, expression, illumination and make-up; it loses to AWing on pose and occlusion and to AVS on blur. The ResNet-18 version's 4.57 is a little better than HRNet and 0.21 worse than AWing. What PIPNet is really competing on is how fast it runs at the same accuracy.
On the other two benchmarks it wins some and loses some. On Menpo 2D's extreme poses, the ResNet-101 version scores 1.27 on semi-frontal and 1.89 on profile (normalized by the face box diagonal), losing to the challenge winner's 1.20 and 1.72; the winner first frontalized the faces with an extra detector and landmark model, which PIPNet doesn't do. On the 300VW video dataset, the authors use no temporal information and predict frame by frame, yet beat existing methods in all three difficulty categories; on the hardest, Category 3, it scores 5.28 against the previous best of 5.98.
Speed
Speed is measured on a Xeon E5-2698 v4 (2.2GHz) and a Tesla V100, batch 1, averaged over the WFLW test set, in images per second:
| Model | Params | GFLOPs | CPU | GPU |
|---|---|---|---|---|
| CoordNet-R18 | 28.3M | 2.4 | 37.5 | 256 |
| MapNet-R18 | 28M | 3.0 | 3.5 | 200 |
| PIP-R18 | 12.0M | 2.4 | 35.7 | 200 |
| PIP-MBv3 | 4.5M | 0.4 | 28.4 | 80 |
| PIP-R101 | 45.7M | 10.5 | 8.8 | 56 |
| HRNet | 9.7M | 4.8 | 4.4 | 11.7 |
| AWing | 24.1M | 26.7 | 1.8 | 24.2 |
| G-RMI-R50 | 23.9M | 25.5 | 0.1 | 6.8 |
Compiled from Table 9 of the paper. MapNet uses stride 2 here, which the authors say balances speed and accuracy best of the three strides.
- Ten times faster on CPU. PIP-R18 takes about 28 milliseconds per image, while MapNet with the same backbone takes 286 milliseconds. Coordinate regression is slightly faster (37.5 images), but we've already seen that its NME lags well behind.
- The gap disappears on GPU. PIP-R18 and MapNet-R18 both run at 200 images per second; the authors' explanation is that PyTorch's deconvolution is very well optimized on GPU. So this paper's speed advantage is mainly on CPU.
- Fewer GFLOPs, not necessarily faster. The MobileNetV3 version has only 0.4 GFLOPs yet is slower than the ResNet-18 version on both CPU and GPU, which the authors attribute to PyTorch's implementation of such networks not yet being optimized.
- Fewer parameters. PIP-R18's 12.0M is the smallest of the ResNet-18 family in the table; coordinate regression's fully connected layers and the heatmap method's deconvolutions each eat up a dozen-odd M.
G-RMI is Google's human pose method, which predicts disk-shaped heatmaps plus offsets at high resolution and then uses Hough voting; the authors consider it the prior work closest to PIP. Its NME is about the same as PIPNet's, but on CPU it runs at only 0.1 images per second.
Does unlabeled data help?
| Setting | 300W | COFW-68 | WFLW-68 |
|---|---|---|---|
| Labeled only (GSL) | 3.36 | 4.55 | 8.09 |
| UDA + DANN | 3.42 | 4.55 | 8.01 |
| UDA + self-train | 3.35 | 4.34 | 7.45 |
| UDA + STC | 3.34 | 4.28 | 7.28 |
| GSSL + DANN | 3.43 | 4.56 | 8.13 |
| GSSL + self-train | 3.27 | 4.32 | 7.77 |
| GSSL + STC | 3.23 | 4.23 | 7.53 |
Compiled from Table 7 of the paper, ResNet-18, NME %. STC is curriculum self-training; UDA's unlabeled data is the training sets of COFW-68 and WFLW-68, and GSSL's is CelebA.
- Domain adaptation methods from classification don't carry over. DANN, the classic adversarial domain adaptation method, does almost nothing here: WFLW-68 drops by only 1.0%, and 300W actually gets 1.8% worse; with CelebA, all three test sets get worse.
- Self-training works, and the curriculum adds a bit more. In the UDA setting, WFLW-68 goes from 8.09 to 7.45 (−7.9%), and to 7.28 (−10.0%) with the curriculum; COFW-68 is −4.6% versus −5.9%.
- GSSL works. The model never sees a single photo from the target domain during training, only CelebA, and COFW-68 still drops from 4.55 to 4.23, better than UDA. On WFLW-68, UDA comes out ahead (7.28 versus 7.53). The authors' explanation is that CelebA is large, but its style is closer to 300W and COFW; unlabeled data has to be not just plentiful but varied enough.
In a direct comparison with prior work, again training only on 300W and testing on COFW-68, LAB scores 4.62, ODN 5.30 and AVS (with SAN) 4.43; PIPNet scores 4.55 with supervised learning alone and 4.23 with GSSL on CelebA, 4.5% below AVS.
This table has one uncontrolled variable. The curriculum version runs two more rounds of pseudo-labeling and retraining than standard self-training (5 rounds versus 3), and the paper offers no control of "standard self-training for 5 rounds," so how much the curriculum itself contributes can't really be separated out. Then there's the cost. CelebA is 64 times the size of the 300W training set, and every round trains from scratch for 60 epochs.
Official code and community reports
The official code is at jhb86253817/PIPNet, under the MIT license, and the README links to pretrained models, including the supervised WFLW models and the 300W-plus-CelebA GSSL models. Going through the issues, you'll hit a few practical pitfalls.
Integer division. In March 2021, a user reported in issue #4 that testing COFW with the official ResNet-18 weights gave 8.758%, against the paper's 3.31%. The author replied that integer tensor division behaves differently in PyTorch 1.6 and later, and that the line which divides the cell index by the width to get the row number at inference has to take the integer part; with that change the numbers matched. The official code switched to integer division (//) in May 2021, but anyone on an earlier version or an old fork can still trip over it.
Confidence scores can exceed 1. In issue #33 (October 2022), someone found values above 1 in the max_cls returned by forward_pip. The score map regresses 0-and-1 labels with L2 and never goes through a sigmoid, and the author suggested simply clipping it at 1. In issue #35, the same asker wanted to use the scores to tell which points were occluded, and found that occluded points actually scored higher; the author's view was that PIPNet was designed to be fairly robust and insensitive to occlusion, and that to make it sensitive, one could try removing the occlusion augmentation during training.
Input size. The asker in issue #44 changed the input to and got an NME worse than their original coordinate regression, which only improved after going back to . The author replied in April 2023 that 80 isn't an integer multiple of the stride and introduces localization error, and that at stride 32 the heatmap is only , where heatmap regression hardly makes sense; shrinking the input means lowering the backbone's stride at the same time.
Detector and cropping. In issue #56 (January 2024), someone found that the detector's quality greatly affects the landmarks; the author replied that the landmark model's training crops have to match the detector's boxes at inference, and different detectors produce boxes of different tightness. This is the same thing as the implicit prior above. Another case of tripping up is issue #29: a user who downloaded 300W from an unofficial source and retrained GSSL got 4.92% on COFW-68 and 7.81% on WFLW-68; with the official data it was 4.23% and 7.44%, on par with the paper's 4.23% and 7.53%. The author added that the code doesn't fix the random seed, so the numbers fluctuate somewhat.
The community implementations listed in the official README include torchlm, installable with pip and supporting ONNX export, and lite.ai.toolkit, which also has C++ versions for MNN, NCNN, TNN and ONNXRuntime. torchlm's README ran one evaluation on WFLW with its own trained ResNet-18 weights: NME 4.45%, FR 4.2%, AUC 0.573. The paper reports no failure rate, so this is one of the few such numbers you can find.
Conclusion
35.7 images per second on CPU and 4.57% on WFLW is what the ResNet-18 PIPNet delivers. It takes ResNet's stride-32 feature map directly as the heatmap, with each cell predicting both a score and an in-cell offset, which skips the whole upsampling chain; the neighbor module has each point vote for the points around it, pushing the variance of the heatmap approach down close to that of coordinate regression. With ResNet-101 it's 4.31%. Curriculum self-training on unlabeled photos brings the 300W-trained model's 8.09% on WFLW-68 down to 7.28%.
If you're actually deploying it, deal with cropping first. How the training boxes are enlarged and how tight the detector's boxes are has to be exactly the same at inference, or the position prior the model has memorized will pull the points off. Keep the input size a multiple of 32 and no smaller than 256, and if you shrink it, lower the backbone's stride along with it. The max_cls you get back can serve as a confidence score; remember to clip it at 1, and don't count on it to tell you which points are occluded. If your target platform is a GPU, heatmap methods aren't much slower; where PIPNet really pulls ahead is on CPU.
In the paper, each point averages its own prediction with its neighbors'. In the official code, on WFLW, each point's own prediction counts for 1/18, and the rest of the weight goes to the neighbors.