Back to paper library
Paper notesarXiv 2023CVPR 2023

STAR Loss

Iron Man's Jawline

Original paper

STAR Loss: Reducing Semantic Ambiguity in Facial Landmark Detection

Paper authors

Zhenglin Zhou · Huaxia Li · Hong Liu · Nanyang Wang · Gang Yu · Rongrong Ji

Publication
CVPR 2023Conference
First submitted to arXiv
arXiv:2306.02763
Cite this paper · BibTeX

The citation identifies the linked source version. It cites the original paper and its authors.

@misc{faceanalysisstarloss2023,
  title = {{STAR Loss: Reducing Semantic Ambiguity in Facial Landmark Detection}},
  author = {Zhenglin Zhou and Huaxia Li and Hong Liu and Nanyang Wang and Gang Yu and Rongrong Ji},
  year = {2023},
  eprint = {2306.02763},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2306.02763}
}
On this page
Original Figure 1: in the middle is a black-and-white photo of a face covered with red predicted points. On the left is an enlargement of a red box on the jaw contour: the upper half is a crop of the original image, where five models' predicted points line up in a long string along the jawline, with a green dot for their average; the lower half is one model's heatmap for this point, an elongated, slanted red blob. On the right is an enlargement of a blue box on an eye corner: the five predicted points nearly overlap, and the heatmap is a round blue dot. Along the bottom runs a band that points from the red word severe on the left, through Semantic Ambiguity, to the blue word mild on the right.
Original Figure 1, Zhou et al., from PDF page 1, CC BY 4.0.

The paper's very first figure uses Tony Stark's face.

The authors trained five models with the same architecture, the same data and the same settings. At the eye corner, the five predicted points stack up almost into one; at the chin, the five points string out along the jawline. The row below shows heatmaps: at the eye corner it's a round dot, while the chin point stretches into a long, slanted smear whose direction follows the contour exactly.

The authors believe the problem lies in the annotations. Datasets such as 300W and WFLW define contour points as "evenly distributed along the face contour," with no clear anatomical position. Annotators know the point has to land on the jawline but can't say where on the line; the same position, labeled by someone else or on another photo, lands somewhere different every time. A model that takes such annotations as ground truth learns a blob of uncertainty stretched along the contour.

First author Zhenglin Zhou is affiliated with Xiamen University, and the work was done during an internship at Tencent PCG; the co-authors include researchers from Tencent PCG and Japan's National Institute of Informatics, and the corresponding author is Rongrong Ji of Xiamen University. STAR stands for Self-adapTive Ambiguity Reduction. The idea is to let the heatmap itself say which direction is uncertain: take the long axis of the predicted distribution as the direction of ambiguity, and penalize a little less in that direction.

Defining the Problem

Heatmaps, soft-argmax and regression losses

Facial landmark detection takes a cropped face and outputs a predefined set of points: 98 for WFLW, 68 for 300W, 29 for COFW. The mainstream approach is heatmap regression, where the network outputs a heatmap for each point and the value of each pixel stands for how likely the point is to be there. In this paper the input is 256×256256\times256 and the heatmap is 64×6464\times64, so one heatmap cell equals 4 pixels of the original image.

The most direct way to get coordinates from a heatmap is to take the location of the maximum (argmax). It has two flaws: it can only land on grid points, with up to half a cell of quantization error, and it isn't differentiable, so the network can't be trained directly on the coordinate error.

That's why soft-argmax has become common in recent years: normalize the heatmap into a probability distribution that sums to 1, then take the expected value. Eq. (1) of the paper:

μ=∑ihi yi\mu=\sum_i h_i\,y_i

hih_i is the probability of the ii-th pixel, yi∈R2y_i\in\mathbb R^2 its coordinates, and μ\mu the predicted position. A one-dimensional example: three adjacent pixels at 10, 11 and 12 with probabilities 0.2, 0.5 and 0.3 give μ=2+5.5+3.6=11.1\mu=2+5.5+3.6=11.1, which falls between two cells and is differentiable with respect to every hih_i.

With μ\mu in hand, training is a regression loss, Eq. (2) of the paper:

Lreg=d(yt−μ)\mathcal L_{reg}=d\left(y_t-\mu\right)

yty_t is the annotated position, and dd can be L1, L2, smooth-L1 or Wing Loss. Whichever it is, dd has no idea which direction of error comes from the annotation itself being uncertain. With L2, say, an annotation off by 8 pixels along the jawline is penalized just as hard as one off by 8 pixels perpendicular to it.

Benchmarks and metrics

This paper evaluates on three datasets:

  • COFW: 1,345 training and 507 test images, 29 points concentrated on the facial features, with lots of occlusion.
  • 300W: 3,148 training and 689 test images, 68 points; the test set is split into common (554 images) and challenge (135 images), which together are called full.
  • WFLW: 7,500 training and 2,500 test images, 98 points, 33 of them on the contour; the test set is also split by attribute into six subsets: pose, expression, illumination, make-up, occlusion and blur.

The main metric is NME (normalized mean error). For each image, the prediction errors (Euclidean distances) of all points are averaged and divided by a normalizing distance, then averaged over the whole test set. 300W and WFLW use the inter-ocular distance (between the two outer eye corners), and COFW uses the inter-pupil distance (between the two pupils). The inter-pupil distance is shorter than the distance between the outer eye corners, so the same model's NME comes out somewhat larger; this paper's COFW score is 3.21 with the inter-ocular distance and 4.62 with the inter-pupil distance.

WFLW also reports two more numbers. FR (failure rate) is the fraction of images with NME above 10%. AUC comes from the CED curve, whose horizontal axis is an NME threshold (0 to 10%) and whose vertical axis is the fraction of images with NME no larger than that threshold; the area under the curve divided by 0.1 is the AUC, with a maximum of 1. FR looks at the worst-off images, AUC at the distribution as a whole.

Semantic ambiguity

The authors call the phenomenon from the opening semantic ambiguity: some points have no clear definition, so their annotations are inconsistent. Contour points are the worst, while points like eye corners and mouth corners, which sit at clear junctions, are relatively well defined.

Previous work handled it in a few ways:

  • SBR uses optical-flow consistency between adjacent frames as supervision, which the authors consider sensitive to lighting and occlusion.
  • LAB uses the face's boundary lines as a structural constraint, which is practical but computationally expensive.
  • SA (Semantic Alignment) treats the true annotation as a latent variable to optimize, with a complicated training procedure.
  • ADNet is the closest to this paper. For points on boundaries, its ADL loss applies a stronger constraint in the normal direction (perpendicular to the boundary) and a weaker one in the tangential direction; the direction is computed from the slope of neighboring points, and the strength is a manually set hyperparameter.

The authors' criticism of ADNet is that it's too coarse. Every boundary point gets the same strength, when the degree of ambiguity actually varies from point to point and from photo to photo. The appendix measures, for each point, the ratio between the variances along the long and short axes of the predicted heatmap (the λ1/λ2\lambda_1/\lambda_2 of the next section): 1.59 for eye points and 2.60 for contour points; 1.95 for easy samples (NME at most 3%) and 2.20 for hard samples (NME at least 8%).

So can the model, with no manual rules, estimate on its own, for every photo and every point, which direction is uncertain and by how much?

Solving the Problem

Architecture

Original Figure 2: the upper half is four chained hourglass modules. A black-and-white face enters on the left, goes through convolution and residual blocks into the first hourglass, and each hourglass's output is added to its input and passed to the next; a final Σ (soft-argmax) gives the prediction on the right. Below each hourglass hangs a gray block, that stack's STAR loss. The lower left of the figure enlarges one of these blocks, titled STAR: L_STAR with Restriction: the heatmap h goes one way through Weighted Mean to give μ and another way through Unbiased Weighted Covariance to give Σ, then through Eigendecomposition to give λ1, λ2 and v1, v2; to the right, L_STAR is written as 1/√λ1 times d(v1ᵀ(y_t − μ)) plus 1/√λ2 times d(v2ᵀ(y_t − μ)), and the Restriction below splits into Value Restriction and Detach Restriction. At the lower right are a sketch of an ellipse on a heatmap and the legend.
Original Figure 2, Zhou et al., from PDF page 2, CC BY 4.0.

The skeleton is four stacked hourglass networks, each outputting NN heatmaps of 64×6464\times64, with soft-argmax for coordinates and a STAR loss attached to every stack. The gray box in the lower half is all there is to STAR. From the heatmap, it first computes an expected value μ\mu and a covariance Σ\Sigma; eigendecomposition of Σ\Sigma gives two directions v1v_1, v2v_2 and two eigenvalues λ1\lambda_1, λ2\lambda_2, which are then used to re-measure the error.

The official code is built on ADNet's codebase, so the model comes with two of ADNet's accessories. One is AAM (Anisotropic Attention Module), used in both the paper's ablations and its main table; the other is CoordConv (extra coordinate input channels), which the paper doesn't mention. AAM has each stack also predict a point heatmap and a boundary heatmap, multiplies the two into an attention mask, and multiplies that back onto the main heatmap before taking coordinates. The point and boundary heatmaps are supervised with Adaptive Wing Loss, at 10 times STAR's weight; the loss weights of the four hourglasses, from shallow to deep, are 0.125, 0.25, 0.5 and 1.

An ellipse from a heatmap

The first step condenses a heatmap into the shape of a 2D Gaussian. The authors call it PCA of a discrete probability distribution, done in two steps.

Estimating the mean and covariance. The mean is just the μ\mu of Eq. (1). The covariance is each pixel's offset from the mean, weighted by probability (Eq. (3)):

Σb=1V1∑ihi (yi−μ)⊤(yi−μ),V1=∑ihi\begin{aligned} \Sigma_b&=\frac{1}{V_1}\sum_i h_i\,(y_i-\mu)^\top(y_i-\mu),\\ V_1&=\sum_i h_i \end{aligned}

yi−μy_i-\mu is written as a row vector, so (yi−μ)⊤(yi−μ)(y_i-\mu)^\top(y_i-\mu) is a 2×22\times2 outer product. A covariance estimated from weighted samples comes out too small, so the authors multiply in an unbiased correction, giving Eq. (4):

Σub=∑ihi (yi−μ)⊤(yi−μ)V1−V2/V1,V2=∑ihi2\begin{aligned} \Sigma_{ub}&=\frac{\sum_i h_i\,(y_i-\mu)^\top(y_i-\mu)}{V_1-V_2/V_1},\\ V_2&=\sum_i h_i^2 \end{aligned}

Eigendecomposition. Eq. (5) is Σ=VLV−1\Sigma=VLV^{-1}, where V=[v1,v2]V=[v_1,v_2] holds two mutually perpendicular unit vectors, L=diag(λ1,λ2)L=\mathrm{diag}(\lambda_1,\lambda_2), and λ1≥λ2\lambda_1\ge\lambda_2. v1v_1 is the direction in which the distribution stretches the most, and λ1\lambda_1 is the variance along it; λ1\sqrt{\lambda_1} and λ2\sqrt{\lambda_2} are the lengths of the ellipse's two semi-axes (in standard deviations).

Let's walk through a heatmap with only five nonzero pixels. Coordinates are in heatmap cells, with the origin at the center:

Position (x,y)(x,y)Prob. hih_i
(−1,−1)(-1,-1)0.25
(0,0)(0,0)0.30
(1,1)(1,1)0.25
(1,−1)(1,-1)0.10
(−1,1)(-1,1)0.10

Illustrative numbers compiled for this note.

The three high-probability pixels lie on the diagonal from upper left to lower right, and the two off the diagonal carry just a little.

  1. Mean. The four corner points come in symmetric pairs, so μ=(0,0)\mu=(0,0).
  2. Weighted covariance. The variance in xx is the sum of hi⋅12h_i\cdot1^2 over the four corners, 0.25+0.25+0.1+0.1=0.70.25+0.25+0.1+0.1=0.7, and the yy direction is also 0.7. For the cross term, look at the sign of x⋅yx\cdot y: (−1,−1)(-1,-1) and (1,1)(1,1) give +1+1 and the other two give −1-1, so it's 0.25+0.25−0.1−0.1=0.30.25+0.25-0.1-0.1=0.3. V1=1V_1=1, and Σb=[0.70.30.30.7]\Sigma_b=\begin{bmatrix}0.7&0.3\\0.3&0.7\end{bmatrix}.
  3. Unbiased correction. V2=0.252×2+0.32+0.12×2=0.235V_2=0.25^2\times2+0.3^2+0.1^2\times2=0.235, so the denominator is 1−0.235=0.7651-0.235=0.765, and the whole matrix is divided by 0.765.
  4. Eigendecomposition. The eigenvalues of Σb\Sigma_b are 0.7±0.30.7\pm0.3, that is 1.0 and 0.4, which become λ1=1.307\lambda_1=1.307 and λ2=0.523\lambda_2=0.523 after dividing by 0.765. The corresponding directions are v1=(1,1)/2v_1=(1,1)/\sqrt2, along that diagonal, and v2=(1,−1)/2v_2=(1,-1)/\sqrt2, perpendicular to it.

The unbiased correction only multiplies both eigenvalues by the same factor, so the directions and the ratio λ1/λ2=2.5\lambda_1/\lambda_2=2.5 stay the same. The 1.59 and 2.60 from the appendix earlier are this ratio computed on eye points and contour points.

Original Figure 3: on the left is a face tinted red by the heatmap, with a small pale blue ellipse and a pair of yellow and blue arrows on every landmark; on the right are enlargements of two regions. The upper one is around an eye, where most ellipses are nearly circular and the yellow arrows point every which way. The lower one is the jaw contour at the lower right, where the ellipses are stretched long and the yellow arrows all follow the tangent of the contour. At the far right is a color bar for the heatmap values, from 0 to about 0.175.
Original Figure 3, Zhou et al., from PDF page 4, CC BY 4.0.

This is the same computation applied to real heatmaps (from a model trained with L2 distance plus distribution regularization). The yellow arrows are the first principal component v1v_1, the blue arrows v2v_2, the arrow lengths are the eigenvalues, and the darker blue an ellipse, the larger its λ1/λ2\lambda_1/\lambda_2. The lower enlargement on the right is the jaw contour, where the yellow arrows all follow the jawline and the ellipses are long and dark; the upper one is the eye, where the ellipses are much rounder and paler.

The authors draw two inferences from this figure. The first principal direction of the contour points matches the direction in which the annotations themselves are uncertain, and the larger the eigenvalue, the more inconsistent the annotations are in that direction.

Splitting the error along the principal axes

A detail from the lower right of Original Figure 2: a slanted, elongated black ellipse drawn on a pale red heatmap, with its center labeled μ. The long axis is the blue v1, labeled with the length √λ1; the short axis is v2, labeled √λ2. Above the ellipse is a red dot y_t, and the red arrow from μ to y_t is split into two segments, one along the long axis and one along the short axis.
Original Figure 2 (lower-right detail), Zhou et al., from PDF page 2, CC BY 4.0.

With the ellipse in hand, the STAR loss projects the error yt−μy_t-\mu onto the two principal axes, applies the distance function to each, and divides each by the standard deviation in that direction (Eq. (6)):

LSTAR=1λ1 d ⁣(v1⊤(yt−μ))+1λ2 d ⁣(v2⊤(yt−μ))\begin{aligned} \mathcal L_{STAR}={}&\frac{1}{\sqrt{\lambda_1}}\,d\!\left(v_1^\top(y_t-\mu)\right)\\ &+\frac{1}{\sqrt{\lambda_2}}\,d\!\left(v_2^\top(y_t-\mu)\right) \end{aligned}

vk⊤(yt−μ)v_k^\top(y_t-\mu) is the component of the error along the kk-th principal axis. The more λ1\lambda_1 exceeds λ2\lambda_2, the more lightly errors along v1v_1 are penalized.

Continuing with the same heatmap, λ1=1.143\sqrt{\lambda_1}=1.143 and λ2=0.723\sqrt{\lambda_2}=0.723, with the distance dd taken as the absolute value:

  • The annotated point is off by 1 cell (4 pixels) along v1v_1: the loss is 1/1.143=0.8751/1.143=0.875.
  • The annotated point is off by 1 cell along v2v_2: the loss is 1/0.723=1.3831/0.723=1.383.
  • The annotated point is 1 cell directly to the right, yt−μ=(1,0)y_t-\mu=(1,0): both components are 1/2=0.7071/\sqrt2=0.707, and the loss is 0.707/1.143+0.707/0.723=0.619+0.978=1.5970.707/1.143+0.707/0.723=0.619+0.978=1.597.

For the same 1-cell error, being off along the long axis is penalized only 63% as much as being off in the perpendicular direction, that is, λ2/λ1=0.4\sqrt{\lambda_2/\lambda_1}=\sqrt{0.4}. The same goes for the gradient: the component along the long axis is multiplied by a smaller coefficient, so the model is less likely to be dragged around by annotation noise along the contour.

When the distance is the absolute value, each term ∣vk⊤(yt−μ)∣/λk|v_k^\top(y_t-\mu)|/\sqrt{\lambda_k} is the error along a principal axis divided by the standard deviation in that direction, what statistics calls whitening; STAR amounts to whitening the error first and then computing L1. The projection and the division both happen outside the distance function, so dd can be swapped for smooth-L1, Wing, AWing or any other. The paper's default is smooth-L1 (Eq. (8)), with threshold s=0.01s=0.01:

d(e)={0.5s e2,∣e∣<s∣e∣−0.5 s,otherwised(e)=\begin{cases}\dfrac{0.5}{s}\,e^2, & |e|<s\\[4pt] |e|-0.5\,s, & \text{otherwise}\end{cases}

Compared with ADNet's ADL, the differences lie in two places. ADL's direction is computed from the slope of neighboring annotated points and applies only to points on boundaries; STAR's direction comes from the model's own heatmap and works directly for any point and any annotation scheme, however many points it has. ADL's strength is one fixed hyperparameter; STAR's strength is each photo's and each point's own λ1\lambda_1 and λ2\lambda_2.

Eigenvalues running wild

Written this way, there's a loophole. λ\lambda sits in the denominator, so the model can just smear the heatmap to make λ\lambda larger, and the loss shrinks without the point being predicted any more accurately.

Run the same example. If the heatmap is smeared out overall so that both eigenvalues become 4 times larger, the standard deviations double and every error term is cut in half; the loss for being 1 cell off along v2v_2 falls from 1.383 to 0.692. In their experiments, the authors did see the eigenvalues grow abnormally large and the model converge prematurely.

The authors propose two restrictions:

  • Value restriction: add the eigenvalues themselves to the loss, Eq. (7) Lvalue=(λ1+λ2)/2\mathcal L_{value}=(\lambda_1+\lambda_2)/2, with weight ww. In the example above, this term goes from 0.915 to 3.66, so smearing the heatmap now comes at a price.
  • Detach restriction: the eigenvalues and eigenvectors pass back no gradient and are treated as constants. STAR still uses them to measure the error, but the model can't lower the loss by changing the heatmap's shape.
WFLWBasic+AAM
No STAR4.344.14
STAR, no restriction4.604.61
STAR, value restr.4.174.02
STAR, detach4.204.05

Compiled from Table 5 of the paper, smooth-L1 distance, NME %.

Without a restriction, STAR does worse than leaving it out, 4.60 against 4.34. The two restrictions differ by only 0.03, from which the authors conclude that the improvement comes mainly from STAR's decomposition and that the value-restriction term adds nothing extra on its own. With ww varied from 1 to 20, NME stays between 4.17 and 4.20; the default is value restriction with w=1w=1.

The official starLoss_v2.py writes the formulas above in a dozen or so lines. Below is a version compiled from the original file, with the original variable names, a few lines merged, and comments added for this note:

Python
# heatmap: (bs, npoints, 64, 64); groundtruth: (bs, npoints, 2); coordinates live on a [-1, 1] grid
heatmap = heatmap / torch.clamp(heatmap.sum([2, 3]), min=1e-6).view(bs, npoints, 1, 1)
means = self.weighted_mean(heatmap)                         # soft-argmax, Eq. (1)
covars = self.unbiased_weighted_covariance(heatmap, means)  # Eq. (4)

_covars = covars.view(bs * npoints, 2, 2).cpu()             # eigen-decomposition is done on the CPU
evalues, evectors = torch.linalg.eigh(_covars)              # ascending: index 0 is the smaller eigenvalue
evalues = evalues.view(bs, npoints, 2).to(heatmap)
evectors = evectors.view(bs, npoints, 2, 2).to(heatmap)

# ambiguity_guided_decompose(), Eq. (6)
error = groundtruth - means
normal_error = torch.matmul(evectors[:, :, 0].unsqueeze(-2), error.unsqueeze(-1)).squeeze(-1)
tangent_error = torch.matmul(evectors[:, :, 1].unsqueeze(-2), error.unsqueeze(-1)).squeeze(-1)
normal_dist = self.dist_func(normal_error, torch.zeros_like(normal_error), reduction='none')
tangent_dist = self.dist_func(tangent_error, torch.zeros_like(tangent_error), reduction='none')
dist = torch.cat((normal_dist.reshape(bs, npoints, 1), tangent_dist.reshape(bs, npoints, 1)), dim=-1)
loss_trans = (dist / torch.sqrt(evalues + self.EPSILON)).sum(-1)   # EPSILON = 1e-5

loss_eigen = torch.abs(evalues.view(bs, npoints, 2)).sum(-1)       # value restriction
star_loss = (loss_trans + self.w * loss_eigen).mean()

A few implementation details:

  • Coordinates sit on a [−1,1][-1,1] grid, so one cell of a 64×6464\times64 heatmap is 2/632/63, and smooth-L1's s=0.01s=0.01 is about a third of a cell.
  • eigh returns the eigenvalues in ascending order, and the code calls the direction of the smaller one normal and that of the larger one tangent, dividing each by its own λ\sqrt\lambda; this matches Eq. (6), just in reverse order.
  • The eigendecomposition is moved to the CPU, and a comment in the source says a GPU version is still a TODO.
  • The value restriction is written as ∣λ1∣+∣λ2∣|\lambda_1|+|\lambda_2|, without dividing by 2, which amounts to doubling the ww of Eq. (7); since ww from 1 to 20 all lands between 4.17 and 4.20, this difference matters little.

Training setup

  • Data preprocessing: following ADNet, faces are cropped by their boxes and resized to 256×256256\times256; augmentation includes rotation by 18°, scaling by ±10%, random cropping by ±5%, grayscale with 20% probability, 30% blur, 40% occlusion and 50% horizontal flipping.
  • Model: four stacked hourglasses, each outputting 64×6464\times64, with 13.37M parameters.
  • Optimization: Adam, learning rate 10−310^{-3}, 500 epochs, divided by 10 at epochs 200, 350 and 450; four V100s, batch 16 per GPU.
  • Baselines: 14 methods, with numbers taken from their own papers.

Discussion

Against other methods

The results on WFLW, with both FR and AUC at a 10% threshold:

MethodNMEFRAUCParams
AWing4.362.840.57225.1M
LUVLi4.373.120.577–
PIPNet4.31––45.7M
ADNet4.142.720.60213.37M
SLPT4.142.760.5959.98M
HIH4.082.600.60522.68M
DTLD4.082.76–13.3M
STAR4.022.320.60513.37M

Compiled from Table 1 of the paper; NME and FR in %.

300W and COFW:

MethodFullComm.Chal.COFW
AWing3.072.724.524.94
PIPNet3.192.784.89–
HIH3.092.654.894.63
ADNet2.932.534.584.68
DTLD2.962.594.50–
STAR2.872.524.324.62

Compiled from Table 1 of the paper, NME %; 300W uses the inter-ocular distance, COFW the inter-pupil distance.

  1. On WFLW, NME leads by 0.06 and FR by 0.28. Against the 4.08 of HIH and DTLD, NME is 0.06 lower; the failure rate drops from HIH's 2.60% to 2.32%, roughly 7 fewer failures among the 2,500 test images. AUC ties with HIH.
  2. The gap is largest on 300W's challenge subset. 4.32 against DTLD's 4.50. The authors' explanation in the appendix is that ambiguity is more severe in hard samples, leaving STAR more room.
  3. COFW is nearly a tie. 4.62 against HIH's 4.63.
  4. The parameter count is identical to ADNet's. Both are 13.37M, because STAR is the same network with a different loss function. A direct comparison further on, replacing ADL with STAR inside ADNet, takes WFLW from 4.14 to 4.02.

The PIPNet in the table is the ResNet-101 version, and its COFW cell is left blank. The appendix has a separate COFW table with the inter-ocular distance, where STAR's 3.21 ties HIH for first (PIPNet just happens to be missing from it). PIPNet's own reported COFW inter-ocular scores are 3.18 for ResNet-50 and 3.08 for ResNet-101, and both sets of official code take COFW's points 8 and 9 for the inter-ocular distance.

On WFLW's six subsets, STAR's NME is the lowest in the table on pose, illumination, make-up, occlusion and blur, with pose going from HIH's 6.87 to 6.76 and occlusion from 4.85 to 4.80. On the expression subset, HIH (4.06) and RePFormer (4.22) do better, with STAR at 4.27; HIH also has lower failure rates on the expression and blur subsets.

Ablations: which distance, which regularizer

The authors add STAR to four distance functions and pair each with two common accessories. DR (distribution regularization) uses the JS divergence to pull the heatmap toward an isotropic Gaussian with σ=1\sigma=1; AAM is the ADNet attention module covered earlier. The table below shows two of the distances on WFLW:

WFLWsL1+STARL2+STAR
Basic4.344.174.794.31
+DR4.184.104.294.21
+AAM4.144.024.374.11

Compiled from Table 3 of the paper, NME %; sL1 is smooth-L1.

  1. Every cell improves. Across three datasets, four distances and three settings, all 36 combinations do better with STAR. In the basic setting, the average improvement is 0.33 on COFW, 0.19 on 300W and 0.25 on WFLW.
  2. L2 benefits the most. In the basic setting, L2 goes from 4.79 to 4.31, an improvement of 0.48, nearly three times smooth-L1's. L2 penalizes large errors the hardest, so the large errors caused by annotation noise hit it the hardest, which may be why (this note's conjecture).
  3. The gain is smallest with DR. On WFLW with DR, the four distances improve by only 0.07 on average, against 0.16 with AAM. DR pulls the heatmap into an isotropic circle, while what STAR reads is precisely the heatmap's long and short axes; the two pull in opposite directions, which may be why the effect is diluted (this note's conjecture; the paper doesn't analyze it).
  4. The best combination is smooth-L1, AAM and STAR, which is the 4.02 of the main table.

The input-resolution experiment points the same way. With inputs of 64, 128 and 256 pixels, adding STAR improves the four distances by 0.20, 0.30 and 0.25 on average. At 128 pixels with STAR, all four distances match or beat 256 pixels without STAR; for example, L2 gets 4.45 against 4.78, and smooth-L1 4.31 against 4.34.

Stability

Original Figure 6: two overlapping histograms, with Variance (0 to about 1.5) on the horizontal axis and the number of points (0 to 6,000) on the vertical axis. Blue is the five models trained with L2 distance alone, peaking near 0.4 at about 5,000; red is the five models trained with L2 plus STAR, whose peak shifts left to near 0.25 at about 5,900. Two dashed lines mark the means, red at 0.69 and blue at 0.79. To the right of 0.4, red is always lower than blue.
Original Figure 6, Zhou et al., from PDF page 8, CC BY 4.0.

Back to the five models from the opening. Under identical settings, the authors trained five models each with and without STAR (L2 distance), computed the variance of the five models' predictions for every point in the WFLW test set, and plotted it as a histogram. With STAR, the whole distribution shifts left, the mean falls from 0.79 to 0.69, and the long tail on the right flattens out too.

The appendix splits WFLW into two subsets for another look. Keeping only the points on the facial features (similar to COFW), the variance across the five models is 0.517; keeping only contour points, it's 1.066, twice as large. Against ADNet, NME on the facial-feature subset drops from 3.39 to 3.27 and on the contour subset from 6.07 to 5.84; the more ambiguity, the bigger the improvement. The authors also use this to explain why the improvement on COFW isn't obvious: COFW's 29 points are almost all on the facial features.

Head to head with ADNet and LUVLi

WFLWFullPoseOccl.Blur
ADL4.146.965.064.79
STAR4.026.764.804.58

Compiled from Table 6 of the paper, NME %; on the other three subsets (expression, illumination, make-up), STAR is also lower.

This set swaps only ADL for STAR inside ADNet, leaving every other setting unchanged. The ADL row is identical to the numbers ADNet reports in its own paper.

The LUVLi comparison is smaller. The authors replaced STAR's decomposition with the Mahalanobis distance (yt−μ)⊤Σ−1(yt−μ)(y_t-\mu)^\top\Sigma^{-1}(y_t-\mu) from the LUVLi loss, with everything else the same: WFLW gives 4.32, against STAR's 4.17 (basic setting, smooth-L1). Both use the covariance to measure the error; the difference is that STAR applies the distance function to each principal axis and divides by the standard deviation, while the Mahalanobis distance squares the error and divides by the variance. The authors also stress that STAR computes its covariance directly from the heatmap, without the extra prediction branch LUVLi needs.

Cross-dataset

The last set of experiments trains on 300W and tests directly on the 300VW videos. 300VW has three categories: Category-A is 31 well-lit videos, B is 19 moderately unconstrained ones, and C is 14 with blur and heavy occlusion.

On the hardest, Category-C, adding STAR to the three distances improves them by about 0.2 on average; smooth-L1, for example, drops from 8.69 to 8.42. The first two categories change much less: L1 doesn't move at all on Category-A (4.08 against 4.08), and on Category-B it actually gets worse, from 3.33 to 3.37.

Official code and community reports

The official code is at ZhenglinZhou/STAR, with three pretrained models, for WFLW, 300W and COFW. Open it up and there are a few things to know.

The validation set is the test set. The config sets valset = "test.tsv", and training evaluates on the test set every epoch, once for the raw model and once for the EMA model, saving whichever has the lowest NME as best_model.pkl. This setup is inherited from ADNet's code, which validates every 10 epochs. The paper doesn't say which checkpoint the numbers in its tables come from.

Batch size. In April 2024, a user reported in issue #28 that training with batch 128 only reached 4.08 on WFLW, exactly the runner-up's number in the main table. The author suggested switching to 32 and gave results for two random seeds:

BatchWFLW NME
1284.05, 4.09
644.05, 4.06
324.03, 4.02

Compiled from the author's reply in issue #28.

The paper says four GPUs with 16 each, 64 in total, which comes out at 4.05 and 4.06; the 4.02 shows up at batch 32 (the paper's own setting misses the top two). Change the seed or the batch size and the number moves between 4.02 and 4.09, while STAR's lead over the runner-up in the main table is 0.06. In the same thread, two months later, another user reported training to 0.040189, that is 4.02, so the paper's number can be reproduced, as long as you pick the right setting.

Compute. The paper reports only the parameter count. When someone asked in issue #9 (August 2023), the author measured the WFLW model with thop at 13.48M parameters and 17.49 GFLOPs. Also on WFLW, PIPNet's ResNet-18 version reports 2.4 GFLOPs at an NME of 4.57; the two sides used different counting tools, so only the orders of magnitude are comparable.

Preprocessing tied to dlib. The demo detects faces with dlib, then multiplies the bounding box of dlib's 68 points by 1.05 to set the crop. In issue #16 (September 2023), someone plugged in their own detector's box directly, and the output points shrank into a little clump; the author said STAR is sensitive to the alignment done in preprocessing, and switching detectors is best done with retraining. Issue #21 reported 0.07 seconds per frame on 640×480 camera video, and the author said the bottleneck is the CPU version of dlib.

Occlusion and visibility. Issue #26 (February 2024) reported that when the face is occluded or the head tilted, the model still draws complete lips and a complete contour. The author replied that the model is encouraged to output structurally constrained points to begin with, and that LUVLi could be considered for judging visibility. In issue #19, the author suggested using λ1λ2\sqrt{\lambda_1\lambda_2} as a confidence and λ1/λ2\lambda_1/\lambda_2 as the degree of ambiguity, both computable from the output heatmap the same way the loss function does it.

Numerical stability. In issue #37 (May 2025), someone got NaN on the very first step with their own data and traced it to eigenvalues that were too large. The author suggested clamping the eigenvalues to between 10−610^{-6} and 10210^2 before taking the square root, and training with AAM.

As for licensing, the repo has no license file; the author has said twice in issues that it's Apache-2.0, while an earlier question about commercial use got the answer to contact the corresponding author. If you want to use it commercially, get this settled first.

Conclusion

STAR condenses each point's predicted heatmap into an ellipse, splits the error along the long and short axes, and divides each part by the standard deviation in that direction; it then adds an eigenvalue restriction term to keep the model from lowering the loss by smearing the heatmap. Swapping out ADL in the ADNet architecture takes WFLW from 4.14 to 4.02, with a 2.32% failure rate; with five models trained on L2 distance for each side, the group with STAR also shows noticeably less prediction variance, and the contour points improve the most.

STAR can only be attached to models that take coordinates from heatmaps with soft-argmax, and the heatmap needs some width; a single-pixel peak doesn't yield a meaningful covariance. Clamp the eigenvalues and keep the eigenvalue restriction on, or it's easy to hit NaN right at the start, or to watch the heatmaps get blurrier the longer you train. If you use the official models as they are, follow the demo's dlib preprocessing, and retrain if you switch detectors; when comparing scores, remember that the authors' own numbers jump between 4.02 and 4.09 just from a different batch size or seed.

Two years later, Chiao-An Yang and Raymond A. Yeh at Purdue called STAR "the current SOTA with public code," kept its architecture and data pipeline, replaced soft-argmax and the ReLU used to normalize the heatmap with a different training objective, and reached 3.99 on WFLW; to get NME down to 4.50, the new method needs 20 epochs and STAR needs 44.