Adaptive Wing Loss for Robust Face Alignment via Heatmap Regression
- Publication
- ICCV 2019Conference
- First submitted to arXiv
- arXiv:1904.07399
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{faceanalysisawing2019,
title = {{Adaptive Wing Loss for Robust Face Alignment via Heatmap Regression}},
author = {Xinyao Wang and Liefeng Bo and Li Fuxin},
year = {2019},
eprint = {1904.07399},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1904.07399}
}

On the far left is a face that's both blurry and turned to the side; the three images to its right are heatmaps for 98 landmarks. The second is the annotation, one clear bright spot per point. The third is the prediction of a model trained with MSE, where the points around the left cheek, the lower right cheek and the eyebrows have dissolved into a faint glow; the fourth switches to this paper's loss, and the points separate again. In terms of error, 6.27% versus 4.23%.
By 2019, heatmap regression was the mainstream approach to facial landmarks. Networks had moved from hourglasses on to ever more elaborate designs, but the loss function was almost always MSE, and hardly anyone touched it. The previous year's Wing loss had shown that the loss function deserves careful design, but it was written for networks that "output coordinates directly"; when this paper's authors applied Wing to heatmaps, training never once converged.
First author Xinyao Wang is affiliated with both Oregon State University and JD Digits, and the other two authors, Li Fuxin and Liefeng Bo, are one at each. Starting from the role each pixel plays on the heatmap, the authors design a loss whose shape changes with the ground-truth pixel value, called Adaptive Wing (AWing); they then add a weight map to deal with the shortage of foreground, and finally add facial boundaries and coordinate encoding.
Defining the Problem
From heatmap to coordinates
First, the heatmap regression pipeline, start to finish.
A face detector boxes a face, which is cropped, resized to 256×256 and fed into the network. The network outputs a 64×64 heatmap for each landmark; WFLW has 98 points, so that's 98 maps. The ground-truth heatmap places a 2D Gaussian at the landmark's position, with a peak of 1 that falls off outward. The official code follows the approach of 1adrianb/face-alignment: the Gaussian is drawn only inside a 7×7 window centered on the landmark, with a standard deviation of about 1.75 heatmap pixels. Along the horizontal or vertical direction, the center is 1, one cell out is 0.85, two cells 0.52, three cells 0.23, and the four corners of the window are 0.05; everything outside the window is 0.
A 64×64 heatmap has 4,096 pixels, and only 49 of them are nonzero.
At inference, the heatmap has to be turned back into coordinates. The most direct way is to find the brightest cell (argmax), but that only gives integer positions, and one heatmap cell equals 4 pixels of the input image. The paper follows the hourglass paper: after finding the brightest cell, it checks which of its left and right neighbors is brighter and moves a quarter cell toward the brighter one; the same goes for up and down.
Take one row of numbers. Suppose the brightest cell is in column 20 with a value of 0.97, its left neighbor is 0.52 and its right neighbor 0.80; the right one is brighter, so x is taken as 20.25, and the neighbors above and below decide y the same way. Finally, multiply by 4 to get back to the 256 input. Ideally, plain argmax has a quantization error of at most half a cell, that is 2 pixels on the input; with the quarter-cell correction, at most 1 pixel is left. If the two outer eye corners are 100 pixels apart on the 256 input, 1 pixel is 1% NME, the same order of magnitude as the gaps between papers in recent years.
So the shape of the heatmap matters a lot. The peak has to be sharp and in the right cell, and the neighbors have to have the right brightness too, or the quarter-cell nudge goes the wrong way.
Measuring the error
The main metric is NME: take the Euclidean distance between each point's predicted and annotated positions, average them, then divide by a distance that stands for the size of the face.
is the number of points, and , are the annotated and predicted positions of the -th point. There are two common choices for . The inter-ocular distance is the distance between the outermost corners of the two eyes; the inter-pupil distance is the distance between the two pupil centers, and since the 68-point scheme has no pupils, the mean of the 6 points around each eye stands in. The inter-pupil distance is shorter, so the same error divided by it gives a bigger number. This paper reports both on 300-W: the same model scores 4.31% on the full set with inter-pupil distance and 3.07% with inter-ocular. The two numbers differ by forty percent, so always check the denominator before comparing tables.
An average alone gets dragged by a few faces that blow up, so there are two more metrics:
- FR (failure rate): the fraction of images whose NME exceeds a threshold (usually 10%; 300-W private also reports 8%).
- AUC: integrate the CED curve (horizontal axis an NME threshold, vertical axis the fraction of images below it) from 0 to the threshold, then divide by the threshold, which gives a number between 0 and 1. Put another way, clip each image's NME at 10% (anything above counts as 10%), average them and call the result ; the AUC equals . An AUC of 0.57 means the clipped average NME is about 4.3%.
Datasets used in this paper:
- 300-W: 68 points. The training set is the training parts of LFPW and HELEN plus AFW; the test set is split into common (the test parts of LFPW and HELEN, 554 images) and challenging (iBUG, 135 images, with large poses, exaggerated expressions and occlusion), which together make up full. There's also the private test set used for the 300-W competition, 300 indoor and 300 outdoor images.
- COFW: 29 points, 1,345 training and 507 test images, built to test large poses and occlusion, with 23% of the face occluded on average.
- WFLW: 98 points, 7,500 training and 2,500 test images, with the test set further split into six subsets by pose, expression, illumination, make-up, occlusion and blur.
Where MSE gets stuck
The authors start by sorting the pixels of a heatmap into types.

Foreground pixels are those whose ground truth is above 0, that is, the Gaussian; the mode (peak) in the very middle determines the coordinate. Background pixels have a ground truth of 0. The ring of background right next to the foreground is called difficult background; these pixels are the easiest to mistake for foreground, and they make the blob swell.
Foreground values have to be accurate, especially near the peak, where a small miss can move the peak into the next cell. The background only needs to stay dark; being off by 0.01 usually doesn't affect the coordinate. Difficult background is the exception: when it lights up, the peak spreads and its position gets vague.
MSE has two problems here.
First, MSE is insensitive to small errors. Its gradient is proportional to the error, so a small error gets a small gradient. A peak pixel predicted as 0.9 (off by 0.1) gets a gradient of 0.2; a background pixel predicted as 0.1 (also off by 0.1) gets 0.2 as well. The two are treated as equals, and the smaller the error the weaker the pull, so training may stall while many pixels still carry small errors.
Second, every pixel gets the same weight, but there's far more background. A 64×64 heatmap has 49 foreground pixels and 4,047 background ones; the foreground is only 1.2%.
Put the two together and heatmaps trained with MSE tend to be blurry and spread out, with low foreground intensity, exactly the third panel of the opening figure. For hard points with occlusion or odd lighting, the peak is fainter still, and picking the right cell out of a faint glow gets harder.
Why not just use L1 or Wing
The authors borrow the idea of the "influence function" from robust statistics: the influence of an error on training is proportional to the gradient of the loss at that error. At convergence, the gradients of all pixels have to cancel out, Eq. (1) of the paper:
is the training sample, and run over the heatmap's height, width and channels.
The gradient of L1 is always ±1, however small the error. For the sum above to be 0, the number of pixels with positive error must exactly equal the number with negative error; that balance is hard to maintain, and training tends to oscillate back and forth.
Wing is worse. In its log segment, Wing's gradient is , which is largest as the error approaches 0: 5 with Wing's original parameters and , and at 0 it jumps straight from −5 to +5. A heatmap has four thousand-odd background pixels, each off by only 0.001, and every one of them pulls with a force close to 5. In the authors' experiments, heatmap regression trained with Wing was "never able to converge."
So the loss a heatmap needs has two personalities. When the error is large, the influence should be constant, which keeps it robust to inaccurate annotations and occlusion. Once the error gets small, foreground pixels should get more influence to sharpen the peak, then drop back to 0 when the error is very close to 0, so they don't oscillate the way L1 and Wing do; background pixels, meanwhile, should behave like MSE, with influence shrinking as the error shrinks. No function of fixed shape can do both, so the loss has to decide its own shape from the ground-truth pixel value.
Solving the Problem
Changing shape with the ground truth
AWing's definition, Eq. (3) of the paper:
is this pixel's value on the ground-truth heatmap, between 0 and 1, and is the prediction. The four parameters , , and are all positive; the paper uses , , and .
Compared with Wing, there are two changes.
First, the switching point moves from to a separate . Heatmap values lie between 0 and 1, and errors are usually within 1 as well, so Wing's "log within 10" split makes no sense here. Errors below count as small and use the nonlinear segment; above 0.5, the linear segment.
Second, and this is the core of the paper, the absolute value gets an extra exponent, , which varies with the ground-truth pixel value.
- For peak pixels, , the exponent is .
- For background pixels, , the exponent is .
- For foreground pixels in between, say , the exponent is 1.6.
When the error is very small, , so the nonlinear segment is about , with . Plug in:
- Background (): about , a touch steeper than a square, like a scaled-up MSE; the gradient goes to 0 as the error shrinks.
- Peak (): about , almost an L1 scaled up 14 times, with just a slight curve that lets the gradient fall continuously to 0 at 0 instead of jumping the way Wing does.
The paper only says should be slightly larger than 2, because is restricted to between 0 and 1. The approximation above makes this more concrete. A peak pixel's exponent is , which must exceed 1 for the gradient to be continuous at 0; the background's exponent is , which must be at least 2 for it to behave like MSE. satisfies both, and it also makes the shape change smoothly as goes from 0 to 1.
The and of the linear segment make the two segments join continuously and smoothly at . Let . is just the slope of the nonlinear segment at ; differentiate and plug in :
makes the two segments take the same value at :
Since follows , and are computed separately for each pixel too. With the paper's parameters:
| Ground truth | Exponent | ||
|---|---|---|---|
| 0 (background) | 2.1 | 11.12 | 2.63 |
| 0.5 | 1.6 | 11.11 | 1.57 |
| 1 (peak) | 1.1 | 9.80 | −0.46 |
Computed for this note from Eq. (3) of the paper.
Next, the gradient. The table below gives the gradient magnitude for each error size :
| Peak | Bg. | MSE | ||
|---|---|---|---|---|
| 0.001 | 7.71 | 0.36 | 0.015 | 0.002 |
| 0.01 | 9.66 | 1.41 | 0.19 | 0.02 |
| 0.1 | 11.33 | 5.49 | 2.32 | 0.2 |
| 0.3 | 10.78 | 9.49 | 7.24 | 0.6 |
| 0.5 | 9.80 | 11.11 | 11.12 | 1.0 |
Computed for this note from Eq. (3) of the paper; MSE taken as . Bg. is background.
At an error of 0.01, the peak pixel's gradient is 9.66 and the background's is 0.19, about 50 times apart; under MSE both are 0.02. This is AWing's answer to MSE's first problem: for the same small error, push hard on the peak and leave the background be.
Now look at the peak column. The gradient is largest around 0.1 and only starts to fall on the way toward 0, still 7.71 at 0.001. Carry the formula further and it's still 3.9 at . The paper says the foreground's influence should decrease "rapidly" to 0 as the error gets very close to 0; in fact falls very slowly, and only comes down when you're very, very close to 0. The difference from Wing is that it's continuous, so the pull doesn't flip straight from −5 to +5 as the error crosses 0.

In the top chart, the three AWing curves are far apart near 0. Blue, the peak pixel, is the sharpest, so even a slight miss sends the loss up; green, the background, lies almost flat near 0 and, like MSE, barely cares about small errors. In the bottom chart, the blue line shoots up almost vertically near 0; that's what looks like, and at this scale it looks like a jump, but the function is still continuous at 0. Compare the dotted orange Wing line, which pulls on background pixels with a force of 5 as well; the paper sees this as the reason Wing can't converge on heatmaps.
The other two parameters act more directly. The larger and the smaller , the bigger the influence of small errors; the authors found experimentally that a large works better. is the switching point; the authors argue that since heatmap values lie between 0 and 1, treating only errors below 0.5 as "small" is enough.
The paper also notes that the nonlinear segment closely resembles the Lorentzian (Cauchy) loss of robust statistics. The difference is that such robust losses let the gradient of large errors fall to 0, which amounts to ignoring outliers; facial landmark annotations aren't very noisy and have no outliers that need ignoring, so AWing keeps a linear segment with a fixed slope for large errors. The authors also found experimentally that, for large errors, going linear works better than staying nonlinear.
Too little foreground: a weighted loss map
The second problem is quantity. The foreground is only 1.2%, so even if every foreground pixel has a bigger gradient than the background, four thousand-odd background pixels together still carry a lot of weight. The authors build an extra weight map.
First, a mask , Eq. (4):
is the ground-truth heatmap, and is its 3×3 gray dilation. Gray dilation replaces each pixel with the maximum of its 3×3 neighborhood, which amounts to pushing the bright blob outward by one cell. The mask then weights the loss, Eq. (5):
is element-wise multiplication, and . Pixels inside the mask get a weight of 11, everything else 1.
Try it on one landmark's 7×7 Gaussian. After dilation, all 49 foreground pixels inside the 7×7 have at least one neighbor above 0.2, so they all enter the mask. In the ring just outside the window, the 3 pixels in the middle of each edge (top, bottom, left and right) have that 0.23 among their neighbors and enter the mask too; near the corners the largest neighbor is only 0.195, so those stay out. One point's mask is therefore 49 + 4×3 = 61 pixels, and the extra 12 are the difficult background.
Now the weights. 61 pixels times 11 is 671, plus the other 4,035 background pixels at 1 each, for 4,706 in total. Pixels inside the mask go from 1.5% of the count to 14.3% of the weight.

For visualization, this figure stacks all channels into one by taking the maximum, including the boundary channel covered later, which is why the mask in (c) looks like a whole face. In the actual computation, each channel has its own mask, and in a landmark channel only 61 pixels are 1.
The official repo doesn't include code for the loss function. Below is a PyTorch version written from Eqs. (3)–(5) of the paper; the AWing part follows mmpose's AdaptiveWingLoss, and the weight map follows the official generate_weight_map (the official code uses > 0.2 where the paper writes ):
import torch
import torch.nn.functional as F
def awing(pred, target, alpha=2.1, omega=14.0, eps=1.0, theta=0.5):
"""pred, target: (B, K, 64, 64) heatmaps, ground truth in [0, 1]. Returns the per-pixel loss, eq. (3)."""
delta = (target - pred).abs()
p = alpha - target # the exponent follows the ground-truth pixel value
A = omega / (1 + (theta / eps) ** p) * p * (theta / eps) ** (p - 1) / eps
C = theta * A - omega * torch.log1p((theta / eps) ** p)
return torch.where(delta < theta, omega * torch.log1p((delta / eps) ** p), A * delta - C)
def loss_weight(target, W=10.0, thr=0.2):
"""Eqs. (4)-(5): 3x3 grey dilation of the ground truth, threshold, then W * M + 1."""
dilated = F.max_pool2d(target, kernel_size=3, stride=1, padding=1)
return W * (dilated >= thr).float() + 1
loss = (awing(pred, target) * loss_weight(target)).mean()
A gray dilation is just max pooling with stride 1.
Boundaries and coordinates
The last two pieces have nothing to do with the loss; they're added to the network.

The backbone is a stacked hourglass network with the improved convolution blocks of Bulat and Tzimiropoulos; the paper uses four hourglasses, and the output of every one of them goes into the loss against the ground-truth heatmap.
Boundary channel. LAB uses 13 facial boundary lines (face outline, eyebrows, eyes, nose, lips...) as an intermediate representation, one map per line. AWing merges all the boundary lines into one map and appends it to the landmark heatmaps as one extra channel (the 99th on WFLW), trained together with the landmarks. The boundary map is generated from the landmarks: points on the same boundary are joined into a curve, then a distance transform gives values that are higher the closer a pixel is to the curve; the official code keeps distances within 3 pixels, decaying as . Where several boundaries overlap at a pixel, the maximum is taken.
Coordinate encoding. Convolution is translation-invariant: the same kernel does the same thing anywhere in the image, and the paper argues that this keeps the network from picking up coordinate information. CoordConv concatenates two extra channels before a convolution, holding each pixel's x and y coordinates normalized to −1 to 1 (the original version can also add a distance-to-center channel). For face alignment, the inputs are faces already cropped by a detector, so position and size don't vary much: the chin is mostly at the bottom and the eyes mostly near the top, and absolute position is useful information.
AWing adds two more "boundary coordinate" channels that keep the coordinates only on the boundaries predicted by the previous hourglass, Eq. (6):
is the x-coordinate channel and the boundary channel output by the previous hourglass; works the same way. For example, on a 64×64 map the x coordinate of column 10 is ; if that cell happens to sit on the predicted jaw contour, is −0.68, and if it's on no boundary, 0. Coordinate encoding is added before the network's first convolution layer and before the first convolution block of each hourglass.
Training setup
- Cropping: with the boxes provided by the datasets, taking the longer side to crop a square. WFLW's boxes aren't very accurate, so they're enlarged by 10% in each direction; 300-W private has no official boxes, so it's cropped directly from the ground-truth landmarks.
- Network: 256×256 input, a 64×64 output from each hourglass, four hourglasses, trained from scratch.
- Optimization: RMSProp, initial learning rate , momentum 0, weight decay ; 240 epochs of training, dropping to and at epochs 80 and 160.
- Data augmentation: rotation by ±50°, translation by ±25 pixels, horizontal flipping with 50% probability and scaling by ±15%, plus random Gaussian blur, noise and occlusion.
- Inference: argmax plus the quarter-cell correction, as in the earlier example.
Discussion
Ablations: most of it comes from the loss
The ablations are done on WFLW. In these experiments, faces are cropped from the extent of the ground-truth landmarks (the paper calls this GTBbox), which is more accurate than cropping with the dataset's boxes, so the numbers come out a bit better than the official results.
| Setting | NME (%) |
|---|---|
| MSE | 5.39 |
| MSE + WM | 5.04 |
| AW | 4.65 |
| AW + WMbase | 4.49 |
| AW + WM | 4.30 |
| AW + WM + B | 4.28 |
| AW + WM + B + C | 4.26 |
| AW + WM + B + C + CB | 4.21 |
Compiled from Table 7 of the paper. AW is AWing, WM the weighted loss map, B the boundary channel, C CoordConv and CB the boundary coordinates.
- The loss itself contributes the most. Swapping MSE for AWing brings 5.39 down to 4.65, 0.74 less. The paper also admits that this MSE baseline is itself worse than the best methods of the time.
- The weighted loss map helps both losses. On MSE it takes off 0.35 (5.04), and on AWing also 0.35 (4.30).
- Difficult background matters. WMbase is a simple weight map that weights only by heatmap value (written in the paper), with no special care for difficult background; it only reaches 4.49, against 4.30 with the dilated mask.
- Boundaries and coordinate encoding add up to 0.09. Each of the three pieces takes off 0.02 to 0.05, icing on the cake.
The parameter ablations use the same setup. With , 15 combinations of from 10 to 18 and from 0.5 to 2 land between 4.21 and 4.30; with and fixed, from 0.3 to 0.7 lands between 4.21 and 4.26. The authors conclude that AWing isn't very sensitive to its parameters. The best value in both parameter tables is 4.21, exactly the full model's number in the table above; WFLW has no official validation set and the paper doesn't mention carving one out, so the parameters appear to have been picked directly on the test set. Fortunately, the whole table moves by only 0.09, so whichever combination you pick makes little difference.
The supplementary material has two more experiments:
- Training loss. With the original stacked hourglass and no weight map, both models are measured with MSE throughout training. At epoch 200, the MSE-trained model's MSE on foreground pixels is 0.92 and the AWing-trained model's is 0.71, 23% lower; by epoch 50 it's already 30% lower. In other words, heatmaps trained with AWing are better even by MSE's own standard.
- Annotation noise. On WFLW, a random fraction of the points is moved in a random direction by a fraction of the inter-ocular distance. With 10% of the points moved by 10%, NME goes from 4.65 to 4.64; 20% moved by 20% gives 4.66; only at 30% moved by 30% does it rise to 4.86.
WFLW
The official results crop with the dataset's boxes (enlarged by 10%). NME is normalized by inter-ocular distance:
| Method | Full | Pose | Occl. | Blur |
|---|---|---|---|---|
| LAB | 5.27 | 10.24 | 6.79 | 6.32 |
| Wing | 5.11 | 8.75 | 6.37 | 5.81 |
| AWing | 4.36 | 7.38 | 5.19 | 4.96 |
| AWing (GTBbox) | 4.21 | 7.21 | 4.99 | 4.82 |
| Method | FR (%) | AUC |
|---|---|---|
| LAB | 7.56 | 0.5323 |
| Wing | 6.00 | 0.5504 |
| AWing | 2.84 | 0.5719 |
| AWing (GTBbox) | 2.04 | 0.5895 |
Compiled from Table 1 of the paper; both FR and AUC use a 10% threshold.
AWing leads on all six subsets, with NME of 4.58, 4.32 and 4.27 on expression, illumination and make-up. The biggest gap is in the failure rate, down from 6.00% to 2.84%: of the 2,500 test images, failures drop from about 150 to about 71. On the pose subset the failure rate falls from 22.70% to 13.50%, and on occlusion from 12.50% to 5.98%.
The Wing numbers in the table are for its ResNet-50 version, which is stronger than the CNN-6/7 used in the Wing paper. The Wing paper itself has no WFLW experiments; this 5.11 comes from the README of Wing's official repo, which later, in October 2019, changed it to 4.99, making little difference against AWing's 4.36.
The GTBbox row changes only the cropping, using the extent of the ground-truth landmarks, and NME drops from 4.36 to 4.21. That 0.15 difference is more than the 0.09 that boundaries and coordinate encoding add up to.
300-W: the denominator decides the ranking
| Method | Com. | Chall. | Full |
|---|---|---|---|
| Inter-pupil | |||
| DCFE | 3.83 | 7.54 | 4.55 |
| LAB | 3.42 | 6.98 | 4.12 |
| Wing | 3.27 | 7.18 | 4.04 |
| AWing | 3.77 | 6.52 | 4.31 |
| Inter-ocular | |||
| SAN | 3.34 | 6.60 | 3.98 |
| LAB | 2.98 | 5.19 | 3.49 |
| DU-Net | 2.90 | 5.15 | 3.35 |
| AWing | 2.72 | 4.52 | 3.07 |
Compiled from Table 3 of the paper, NME (%).
With inter-ocular distance, AWing is first in all three columns. With inter-pupil distance, AWing is best only on challenging (6.52); its common score of 3.77 loses to Wing's 3.27 and LAB's 3.42, and its full score of 4.31 loses to both of them too. The paper's text says it achieves "the state-of-the-art performance on the 300W testing dataset," and stresses that on challenging it outperforms Wing "by a significant margin"; in the table, Wing's 3.27 and 4.04 are set in bold, so the table itself hides nothing.
Wing reports only inter-pupil numbers, so the only part where the two papers can really be compared head to head is the top half. AWing wins on the hardest 135 images and loses on the 554 normal ones.
On the 600 images of 300-W private (cropped with the ground-truth landmarks), AWing's NME is 3.56, with a failure rate of 0.83% at an 8% threshold, just 5 failures out of 600; the previous best, DCFE, had 3.88 and 1.83%.
COFW and AFLW
COFW is normalized by inter-pupil distance: AWing's NME is 4.94 against Wing's 5.44, and the failure rate at a 10% threshold drops from 3.73% to 0.99%. The human annotator performance reported with COFW is 5.60%, so AWing is more accurate than people.
This table has a small backstory. In November 2019, someone pointed out in issue #4 of the official repo that some of the comparison methods' numbers in the table were actually normalized by inter-ocular distance. The author replied that this was indeed the case, PCD-CNN for example, and that it would be corrected on arXiv. The v3 of May 2020 corrected only the AUC in that same table; the PCD-CNN row is still in place, and the 3.73 in the text's "reduce the failure rate measured at 10% NME from 3.73% to 0.99%" is that very row (PCD-CNN still competing on inter-ocular distance). On top of that, Wing's official README had posted the ResNet-50 version's 5.07 and 3.16% on COFW back in October 2018, while the table lists CNN-6's 5.44 and 3.75%. Neither changes AWing's lead; it's just that, when you read this table, you should know the numbers in one column aren't all measured with the same ruler.
The supplementary material also covers AFLW (19 points, normalized by box size): AWing gets 1.53% and Wing 1.65%. With only 19 points, AFLW can't produce complete boundary lines, so the authors use only the eyebrows, the eyes and the bottom of the nose.
How many hourglasses are enough
The supplementary material compares the number of hourglasses. The GPU is a GTX 1080Ti, batch 1:
| Hourglasses | WFLW | 300-W Full | FPS |
|---|---|---|---|
| 1 | 4.50 | 4.46 / 3.18 | 120.5 |
| 2 | 4.29 | 4.38 / 3.12 | 63.8 |
| 4 | 4.21 | 4.31 / 3.07 | 34.5 |
Compiled from Table 12 of the paper's supplementary material. 300-W is NME (%) as inter-pupil / inter-ocular; WFLW uses GTBbox cropping.
One hourglass already runs at 120 images per second, and its WFLW score of 4.50 already beats the 5.11 the table lists as "previous best." This table's WFLW column, though, uses GTBbox cropping, while 5.11 is Wing's result measured with the dataset's boxes, so the conditions differ; with the same cropping, the gap should be somewhat smaller.
Human pose
The authors also took AWing to another heatmap regression task. On the LSP human pose dataset (14 joints), again with four hourglasses trained from scratch and scored by [email protected] (a joint counts as correct if its error is under 20% of the torso length), MSE gets 81.8 and AWing 85.9, with all seven body parts improving; the wrists, from 72.0 to 78.2, and the ankles, from 80.6 to 86.4, improve the most.
Official code and community
The official repo, protossw512/AdaptiveWingLoss, released evaluation code and pretrained four-hourglass weights for WFLW in October 2019. The README's "Future Plans" lists three items: training code, models for 300-W/AFLW/COFW, and an API for landmark detection; by the last commit in April 2020, not one had been checked off. The repo doesn't contain an implementation of the AWing loss either.
In November 2019, someone asked in issue #10 where the loss was; the author replied that it would be uploaded together with the training code, and added that "it should be very easy to implement by yourself." In June 2021, someone in the same thread commented "It's 2021 already. So much for that promise?"; the same month, another issue was titled "Two years have passed, have you considered release the train code?", and the +1s under it stretched all the way to a "+10086" in September 2022. The repo's last commit was the April 2020 addition of a LICENSE.
As for "very easy to implement by yourself," someone had already tried it in the very first issue. In issue #1 (October 2019), the asker implemented AWing themselves and trained HRNet on 300-W: 3.37 with MSE and 3.34 with AWing, practically no difference. The author first said the asker's formula for the linear segment was wrong, then reversed a few hours later, admitting that what they had on hand was an "old experimental branch" with settings different from the paper's, and that the asker's implementation was the correct one. In issue #27 (August 2021), someone trained it themselves to 4.68 on WFLW and asked how to reach 4.36; there was no reply.
A cleaner comparison comes from mmpose. In its WFLW configs, the two config files for HRNetV2-W18 with MSE and with AWing differ only in the loss line, with NME of 4.06 against 4.02, and the gaps on every subset are within 0.07. mmpose's AdaptiveWingLoss has only Eq. (3), with no weighted loss map.
This squares with the paper's ablations. The paper's MSE baseline of 5.39 was weak to begin with, so swapping the loss could take off 0.74; with HRNet, which is strong to begin with, swapping only the loss leaves 0.04. In the paper the weighted loss map contributed another 0.35, and mmpose's implementation doesn't have it.
Two more practical reminders come from the issues. In issue #3, someone asked how to switch to GTBbox; the author explained how, then said they wouldn't recommend it, since real applications only get a detector's boxes and research usually compares with detection boxes too. The paper's ablations and parameter tables all use GTBbox. In issue #9, someone tested on video and saw the landmarks jitter noticeably; the author replied that jitter on video is to be expected and smoothing has to be added separately.
Conclusion
AWing makes the loss change shape with the ground-truth pixel value, correcting peak pixels with a push close to L1 and leaving background pixels be, as MSE does, then uses a dilated mask to raise the weight of the foreground and the difficult background 11-fold. On WFLW, the failure rate drops from 6.00% to 2.84%; in the ablations, the loss itself contributes 0.74, the weight map 0.35, and boundaries plus coordinate encoding 0.09 together.
Before swapping out MSE in your own heatmap model, check two things. First, the ground-truth heatmap's peak should be 1 and its background 0, since the exponent is designed for that range; if your heatmaps are normalized into a probability distribution that sums to 1, the peak is only a few hundredths and every pixel gets treated as background. Second, add the weight map along with it: mmpose swapped only the loss and measured a gap of just 0.04 on HRNet. For the parameters, the paper's , , and are fine; the authors' experiments show that tuning them makes little difference.
In August 2018, AWing's author opened the first issue on Wing's repo, asking how to compute the inter-pupil distance. On AWing's own 300-W table, in the inter-pupil half, first place on common and full still belongs to Wing.