Back to paper library
Paper notesarXiv 2020CVPR 2021

img2pose

Buy One, Get One Free

Original paper

img2pose: Face Alignment and Detection via 6DoF, Face Pose Estimation

Paper authors

Vítor Albiero · Xingyu Chen · Xi Yin · Guan Pang · Tal Hassner

Publication
CVPR 2021Conference
First submitted to arXiv
arXiv:2012.07791
Cite this paper · BibTeX

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

@misc{objectdetectionimg2pose2020,
  title = {{img2pose: Face Alignment and Detection via 6DoF, Face Pose Estimation}},
  author = {Vítor Albiero and Xingyu Chen and Xi Yin and Guan Pang and Tal Hassner},
  year = {2020},
  eprint = {2012.07791},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2012.07791}
}
On this page
Original Figure 2: the top half is a group photo in front of a stage, with seven or eight people in the front row and twenty-odd more in the back and at the sides; every face is covered by a silver 3D face model whose orientation and size match the face beneath it, down to the small faces of the audience in the background. The bottom half puts the same silver 3D faces back into 3D space; the front-row faces are large and low, the back-row faces small and high, showing how far each face is from the camera.
Original Figure 2, Albiero et al., from PDF page 3, arXiv license, scholarly quotation.

The top half is a group photo with a silver 3D face laid over every face, including the back-row audience faces only a dozen or so pixels wide. The bottom half puts the same 3D faces back into space, and who's in front and who's behind is obvious at a glance.

The model that drew this figure ran no face detector and looked for no landmarks. For every face in the frame, it directly outputs six numbers, three describing how much the face is turned and three describing where the face is in front of the camera. The silver faces are drawn by projecting a standard 3D face back into the photo with these six numbers. The face boxes are projected the same way.

The authors are Vítor Albiero of Notre Dame and Xingyu Chen of Facebook AI (joint first authors), along with Xi Yin, Guan Pang and Tal Hassner, also of Facebook AI. Around 2017, Hassner and collaborators published several papers on face alignment without landmarks, such as FacePoseNet, which regresses pose directly from face images, but all of them assumed the face had already been detected and cropped. This paper removes that assumption too.

The question the paper wants to answer is whether, with 6DoF pose as the only supervision, you can get good face detection thrown in.

Defining the Problem

From Boxes and Landmarks to Pose

Traditionally, finding out which way a face is pointing takes three steps. First a detector finds the box, then a landmark model finds landmarks inside the box (five or 68 points), and finally the landmarks are paired with the corresponding points on a standard 3D face to solve a PnP problem, which gives the face's rotation and position.

PnP (Perspective-n-Point) is the following problem. Given the coordinates of nn points on a 3D model, their 2D positions in the photo and the camera intrinsics, find a rotation and translation that project the 3D points exactly onto those 2D positions. Five points, the two eyes, the nose tip and the two mouth corners, are enough to solve it, and OpenCV's solvePnP does it in one line.

The authors point out three problems with this pipeline:

  1. The landmark detector is tied to the detector. A landmark model is usually trained on one particular detector's boxes; change how tight the boxes are and the landmarks have to be retuned.
  2. The two models are optimized separately. Accuracy has to be tuned twice and fairness checked twice; the computation of detection and landmarks adds up, and the full version of RetinaFace uses ResNet-152.
  3. Small faces make 68 points hard to pin down. In the back row of the opening figure, faces are only a dozen or so pixels; marking 68 points on them isn't very realistic.

Six Numbers

img2pose regresses 6DoF (six degrees of freedom) pose directly, which the paper writes as

hi=(rx,ry,rz,tx,ty,tz)h_i = (r_x, r_y, r_z, t_x, t_y, t_z)

The first three numbers are a rotation vector, whose direction is the rotation axis and whose length is how many radians it turns. A face turned 30° about the vertical axis has a rotation vector along the vertical axis with length 30π/180≈0.52430\pi/180\approx0.524. The last three numbers are the translation, the position of the face's center in the camera coordinate system, with tzt_z the distance from the camera.

Many head-pose papers estimate only three angles, yaw (turning the head left and right), pitch (nodding) and roll (tilting the head). Euler angles are easy to read, but they break down when yaw goes beyond ±90°, where a small change in yaw makes the pitch and roll values jump wildly. This comes up again in the evaluation later.

The authors start from two observations.

First, 6DoF is easier to estimate than landmarks. Six numbers make a 6-dimensional regression; five points are 10 dimensions, 68 points 136. Pose describes only a face's rigid transformation, while landmarks also mix in expression and each person's face shape.

Second, 6DoF carries more information than a box. Once the camera intrinsics are known, the pose can project the 3D face into the photo, and the face's position in the photo comes along with it. A box takes 4 numbers; pose takes 2 more, and in exchange gives 3D position and orientation.

Projection

Projection uses the pinhole camera model, equation (2) of the paper:

[Q1]∼K [R∣t][P1]\begin{bmatrix} Q \\ 1 \end{bmatrix} \sim K\,[R \mid t] \begin{bmatrix} P \\ 1 \end{bmatrix}

PP is nn points on the surface of the 3D face, RR and tt are the rotation matrix and translation converted from the pose, KK is the camera intrinsics, QQ is the 2D points projected into the photo, and ∼\sim means dividing by the third coordinate afterward.

KK looks like this:

K=[f0cx0fcy001]K = \begin{bmatrix} f & 0 & c_x \\ 0 & f & c_y \\ 0 & 0 & 1 \end{bmatrix}

ff is the focal length in pixels, and (cx,cy)(c_x, c_y) is the principal point, where the optical axis passes through the image. A point (X,Y,Z)(X, Y, Z) in camera coordinates projects into the photo at (fX/Z+cx, fY/Z+cy)(fX/Z + c_x,\ fY/Z + c_y).

Work it out for a 640×480640\times480 photo. img2pose assumes ff equals the width plus the height, 1,120, with the principal point at the image center, (320,240)(320, 240). For a face centered at (4.8,−2.7,28)(4.8, -2.7, 28), the projected xx coordinate is 1120×4.8/28+320=5121120\times4.8/28+320=512 and the yy coordinate is 1120×(−2.7)/28+240=1321120\times(-2.7)/28+240=132. The larger ZZ is, the smaller a face of the same size projects.

Project all the points of the 3D face, take the leftmost, rightmost, topmost and bottommost, and you have a box.

The idea is simple, but putting it into practice has two pitfalls. The detector's second-stage head sees only the features inside each proposal, yet the translation in the pose depends on the whole photo, so how can the head regress it? And WIDER FACE has only boxes and no pose labels, so where does the training data come from?

Solving the Problem

Architecture

Original Figure 4: flowchart of the method overview. At top left, the image enters FPN + RPN, producing Proposals, which go through ROI Pooling + FC Layers and split into two outputs, Faceness Score and Pose (6 DoF). The green and red blocks, present only in training, include the box B* projected from the ground-truth pose and the Proposal Loss, the conversion of the global ground-truth pose into proposal coordinates, the projection of two sets of calibration points into 2D, and the Pose Loss and Calibration Points Loss. The yellow blocks, present only at test time, include converting the proposal pose into a global pose, projecting a box B from the pose, and NMS, finally outputting the global pose and the faceness score.
Original Figure 4, Albiero et al., from PDF page 5, arXiv license, scholarly quotation.

The gray part is a standard Faster R-CNN with FPN, on a ResNet-18 backbone. In the first stage, the RPN (region proposal network) proposes candidate boxes that might contain faces on the feature pyramid (proposals, as the diagram below labels them); in the second stage, RoI pooling crops the features inside each proposal to a fixed size, followed by a few fully connected layers that split into two heads. One is the faceness score (is it a face), the other the 6DoF pose. In the official code, the pose head is a 256-dimensional fully connected layer, BatchNorm and ReLU, followed by one more layer that outputs 6 numbers.

Compared with an ordinary Faster R-CNN, the second stage has no box regression head. At test time (the yellow blocks), the pose predicted on a proposal is first converted into a pose for the whole photo, then projected into a box, and finally NMS is applied (of boxes that overlap too much, only the highest-scoring one is kept). The green and red parts exist only in training. Even the RPN's supervision is replaced; the RPN learns the boxes B∗B^* projected from the ground-truth pose, and the boxes originally labeled in WIDER FACE aren't used directly.

The RPN lays several reference boxes, called anchors, at every position of the feature map in advance, then judges whether each anchor contains a face and how to correct it. The anchors in the official code start at 16 pixels (torchvision's default starts at 32); in issue #53 the authors say this is to catch very small faces, and everything else follows torchvision's Faster R-CNN settings.

Two Sets of Coordinates for One Face

RoI pooling shrinks the features inside a proposal to the same size no matter how big the proposal is. To the second-stage head, a small, distant face framed just right looks almost the same as a large, nearby face framed just right. From these features, the head has no way to know how far the face is from the camera or which side of the photo it's on.

The authors' approach is to have the head predict a "local" pose, pretending each proposal is a photo taken by a camera of its own, and then use the proposal's position and size to convert it back into a "global" pose for the whole photo.

The proposal's own camera has intrinsics given by equation (3), with focal length ff equal to the box's width plus height and the principal point at the box's center. The whole photo's camera is equation (5), with focal length equal to the image's width plus height and the principal point at the image center. In between there's a transitional KboxK_{box}, equation (4), with the whole image's focal length and the principal point at the proposal's center:

Kbox=[w+h0cx+x0w+hcy+y001]K_{box} = \begin{bmatrix} w+h & 0 & c_x+x \\ 0 & w+h & c_y+y \\ 0 & 0 & 1 \end{bmatrix} Kimg=[w+h0w/20w+hh/2001]K_{img} = \begin{bmatrix} w+h & 0 & w/2 \\ 0 & w+h & h/2 \\ 0 & 0 & 1 \end{bmatrix}

w,hw, h are the width and height of the whole image, the proposal B=(x,y,wbb,hbb)B=(x, y, w_{bb}, h_{bb}) has its top-left corner at (x,y)(x, y), and (cx,cy)(c_x, c_y) are the coordinates of the box center relative to the box's top-left corner.

Algorithm 1, local to global, has two steps:

  1. Scale. tz←tz⋅(w+h)/(wbb+hbb)t_z \leftarrow t_z \cdot (w+h)/(w_{bb}+h_{bb}).
  2. Move the principal point. t′=Kimg−1Kbox tt' = K_{img}^{-1} K_{box}\, t, and the rotation matrix likewise becomes R′=Kimg−1KboxRR' = K_{img}^{-1} K_{box} R.
A diagram drawn for this note. On the left, two squares stand for the two proposals' own cameras: Proposal A is 64×64 with f = 128 and principal point (32, 32); Proposal B is 128×128 with f = 256 and principal point (64, 64); both have local t = (0, 0, 3.2). In the middle, an arrow is labeled Algorithm 1. On the right is the full 640×480 image, f = 1120, principal point (320, 240); box A is at the top right, centered at (512, 132), with global t = (4.8, −2.7, 28.0); box B is at the bottom left, centered at (200, 300), with global t = (−1.5, 0.75, 14.0). The calculations for the two steps are listed below.
Drawn for this note from equations (3)–(5) and Algorithm 1 of the paper.

Walk two proposals through it. The photo is 640×480640\times480, and KimgK_{img} has a focal length of 1,120.

Proposal A is at the top right, 64×6464\times64, centered at (512,132)(512, 132); B is at the bottom left, 128×128128\times128, centered at (200,300)(200, 300). Suppose both faces exactly fill their own boxes; the local poses the head predicts will then be the same, both with translation (0,0,3.2)(0, 0, 3.2). A's local focal length is 128, and a 3D face placed at depth 3.2 projects to about 59 pixels wide, just filling the 64-pixel box (in the official code, the box is 1.1 times the extent of the face points). B's local focal length is 256, and the same 3.2 projects to 118 pixels.

Step one, scaling. A's tzt_z becomes 3.2×1120/128=28.03.2\times1120/128=28.0, and B's becomes 3.2×1120/256=14.03.2\times1120/256=14.0. The focal length changes from the box's width plus height to the whole image's width plus height, so the number gets bigger; for the face to stay the same size on screen, it has to be pushed further away. The appendix calls this step zoom-out. The smaller the box, the larger the factor tzt_z is multiplied by, and the further the face is pushed; the distance the head can't see in the features is made up by the box's size.

Step two, moving the principal point. KboxK_{box} has its principal point at the box center and KimgK_{img} at the image center, with the same focal length, so

Kimg−1Kbox=[10Δx/f01Δy/f001]K_{img}^{-1}K_{box} = \begin{bmatrix} 1 & 0 & \Delta_x/f \\ 0 & 1 & \Delta_y/f \\ 0 & 0 & 1 \end{bmatrix}

Δ\Delta is the box center minus the image center. Multiplying by tt gives tx′=tx+Δxtz/ft'_x = t_x + \Delta_x t_z/f. A's Δ=(192,−108)\Delta=(192, -108), giving tx′=192×28/1120=4.8t'_x = 192\times28/1120=4.8 and ty′=−108×28/1120=−2.7t'_y=-108\times28/1120=-2.7. B's Δ=(−120,60)\Delta=(-120, 60), giving (−1.5,0.75)(-1.5, 0.75).

As a check, A's global translation (4.8,−2.7,28)(4.8, -2.7, 28) is exactly the example from the projection section, and it projects right onto the box center (512,132)(512, 132).

The reverse direction, global to local (Algorithm 2), is the same operation run backward, with the scaling done last. During training the proposals change every iteration, and every proposal has to convert the ground-truth pose into its own local coordinates before it can be compared with the head's output.

Regressing in local coordinates has another benefit. No matter how big the face is in the photo or where it is, as long as the proposal frames it well, the local translation falls in roughly the same range. The official code also standardizes the six numbers with the mean and standard deviation of the training-set poses, so the range of values the head has to learn is even tidier.

Loss

The loss for each proposal is equation (6) of the paper:

L=Lcls(pi,pi∗)+pi∗ Lpose(hiprop,hiprop∗)+pi∗ Lcalib(Qic,Qic∗)\begin{aligned} L ={}& L_{cls}(p_i, p_i^*) + p_i^*\, L_{pose}(h_i^{prop}, h_i^{prop*})\\ &+ p_i^*\, L_{calib}(Q_i^c, Q_i^{c*}) \end{aligned}

pip_i is the probability that proposal ii is a face, and pi∗p_i^* is the label, decided by the IoU (intersection area divided by union area) between the proposal and the projected ground-truth box, with a threshold of 0.5 in the official code. Background boxes count only the binary cross-entropy LclsL_{cls}; only boxes that are faces count the other two terms.

The pose loss is the squared error over the six numbers, equation (7):

Lpose=∥hiprop−hiprop∗∥22L_{pose} = \left\| h_i^{prop} - h_i^{prop*} \right\|_2^2

hiproph_i^{prop} is the head's output, and hiprop∗h_i^{prop*} is the ground truth converted into the same proposal's coordinates.

The pose loss treats all six numbers alike, but rotation is in radians and translation in units of the 3D face model's length, so the same 0.1 error can mean very different displacements once projected onto the image. The paper adds a third term, the calibration point loss, which measures pose accuracy again directly on the image, equation (8):

Lcalib=∥Qic−Qic∗∥1L_{calib} = \left\| Q_i^c - Q_i^{c*} \right\|_1

The authors fix five points Pc∈R5×3P^c\in\mathbb R^{5\times3} on the 3D face, project them into the proposal's image once with the predicted pose and once with the ground-truth pose to get QicQ_i^c and Qic∗Q_i^{c*}, and compare the two sets of 2D points by L1 distance. This turns the error in the six numbers into a pixel error on the image.

Original Figure 5: photos of the same woman overlaid with a silver 3D face model. In the left image, (a), the pose is wrong, the 3D face is skewed to one side, and the green points (calibration points projected with the estimated pose) and blue points (projected with the ground-truth pose) are scattered over different parts of the face, clearly apart from each other. In the right image, (b), the pose is right, the 3D face coincides with the face, and the five pairs of green and blue points almost overlap, located on the forehead, both cheeks, the nose tip and the chin.
Original Figure 5, Albiero et al., from PDF page 6, arXiv license, scholarly quotation.

In the left image the pose is wrong, and the green points (predicted) and blue points (ground truth) scatter in different directions; in the right image the pose is right, and the two sets of points nearly overlap. LcalibL_{calib} measures exactly the distance between these green and blue points.

The paper says the five points can be chosen arbitrarily, as long as they don't all lie in one plane. The points in the figure are on the forehead, both cheeks, the nose tip and the chin; the five points used in the official code's loss are, judging by their coordinates, the two eyes, the nose tip and the two mouth corners. The nose tip sticks out, so both sets satisfy the non-coplanar condition.

The first-stage RPN keeps its own classification and box regression losses as usual, except that the boxes it learns are now B∗B^*. The official code simply adds all the losses together, each with a weight of 1.

Boxes Projected From Pose

At test time, once each proposal's pose has been converted to global, a standard 68-point 3D face is projected with it and the bounding rectangle of those points is taken, enlarged 1.1 times in width and height and then extended by 0.3 face heights toward the forehead. Which way it extends depends on the roll angle; for an upside-down face it extends downward. The official README says that without this extension, the box's top edge would stop at the start of the forehead.

So the tightness of the box is up to you; the same pose can draw a loose box, a very tight box, or a fairly tight box with the forehead added. The training targets B∗B^* are projected from the ground-truth pose with the same rules.

Pose Labels for WIDER FACE

WIDER FACE has only boxes. What the authors had on hand were the manual five-point labels the RetinaFace project added to the WIDER FACE training set, about 76,000 faces.

For the remaining faces, which have boxes but no points, the authors had RetinaFace detect them itself. The official annotation script uses InsightFace's RetinaFace R50 with five scales plus flipping and a confidence threshold of 0.8. For each ground-truth box, the prediction with the highest IoU is taken; below an IoU of 0.5 it's discarded. The five points and box of that prediction are used to solve 6DoF with PnP, which is then converted into a global pose. The boxes and points RetinaFace provides are used only to compute the pose and are thrown away afterward.

The final training set has 12,874 images and 138,722 faces, 62,827 of whose poses come from RetinaFace predictions. The validation set has 3,205 images and 34,294 faces, all from predictions.

That leaves about twenty thousand faces in the training set without pose labels. The paper says they're ignored during training. The official code does something more direct, painting those faces' boxes black in the image so they vanish from the frame and are never treated as background.

Training Setup

The backbone is an ImageNet-pretrained ResNet-18. SGD with two images per mini-batch, 256 samples per image for the RPN loss and 512 for the second-stage loss. The learning rate is 0.001, divided by 10 when the validation loss hasn't dropped for three epochs, with early stopping after five epochs without a drop; training actually ran for 35 epochs, about 4 days on a single Quadro RTX 6000. Data augmentation is random cropping, horizontal flipping and multi-scale, with the short side drawn from 640 to 800 and the long side at most 1,400.

Before pose is evaluated, the model gets one more round of training. WIDER FACE has many faces turned away with yaw beyond ±90°, and the model learned to answer for such angles; but AFLW2000-3D and BIWI score with Euler angles, and a prediction beyond 90° converted to Euler angles gets counted as a large error. So before evaluating pose, the authors first fine-tune on 300W-LP, 122,450 large-pose images that 3DDFA synthesized from 300-W, all with yaw within ±90°. The rotation labels are converted from its Euler angles, and the translation labels are computed from its landmarks with PnP; the learning rate is fixed at 0.001, and training runs for only 2 epochs.

Discussion

AFLW2000-3D

AFLW2000-3D is the first 2,000 faces of AFLW, with fitted 3D faces and 68 points. As is customary, the 31 images with angles beyond ±99° are removed, and the images are resized to 400×400400\times400. When an image has several faces, the one whose projected box has the highest IoU with the ground-truth box is taken. The rotation ground truth uses the Euler angles provided with the dataset, and the translation ground truth is obtained by solving PnP from the 68 ground-truth points with the authors' own 3D face.

MethodYawPitchRollMean
3DDFA5.4008.5308.2507.393
Hopenet6.4706.5605.4406.160
FSA-Caps-Fusion4.5016.0784.6445.074
QuatNet3.9735.6153.9204.503
TriNet4.1985.7674.0424.669
RetinaFace R-505.1019.6423.9246.222
img2pose3.4265.0343.2783.913

Excerpted from Table 1 of the paper, mean absolute error in degrees.

img2pose's mean error is 3.913°, and all three angles are the lowest in the table. For translation, only three methods have numbers, with mean errors of 0.099 for img2pose, 0.114 for RetinaFace and 0.446 for Dlib. On a single Titan Xp, it runs at 41 images per second on 400×400400\times400 images.

Three conditions apply when reading this table. First, apart from RetinaFace, every method in the table was tested on manually cropped face boxes, and the box itself tells them where the face is and how big; img2pose takes the whole photo. Second, the RetinaFace R-50 in the comparison is the very model that produced half of img2pose's training labels, so the student beat the teacher. Third, img2pose's numbers here come from the model after 300W-LP fine-tuning, and as we'll see later, that step has a large effect.

BIWI

BIWI is 15,678 frames of 20 people turning their heads indoors, with rotation ground truth only. The images are used at their original 933×700933\times700 size, and when an image has several faces, the one closest to the center with a score above 0.9 is taken.

MethodYawPitchRollMean
QuatNet4.0105.4922.9364.146
FSA-NET4.5605.2103.0704.280
TriNet3.0464.7584.1123.972
RetinaFace R-504.0706.4242.9744.490
img2pose4.5673.5463.2443.786

Excerpted from Table 2 of the paper, mean absolute error in degrees.

The mean error is the lowest in the table, but not when the three angles are taken separately. Yaw, at 4.567°, is the worst of these five methods, while TriNet has only 3.046°; img2pose wins on pitch, where its 3.546° is 1.2° below the runner-up. At this resolution it runs at 30 images per second.

Ablation

LossAFLW rot.AFLW trans.BIWI rot.
LposeL_{pose}5.3050.1144.375
LcalibL_{calib}4.7460.1184.023
Both4.6570.1253.856

Compiled from Table 4 of the paper, mean absolute error.

The calibration point loss alone does better than the pose loss alone; used together, they give the lowest rotation error, which drops from 4.375° to 3.856° on BIWI. Translation actually rises slightly, which the authors consider a small difference, possibly due to randomness in training.

The full version in this table scores 4.657°, while the main table says 3.913°; the numbers don't match, and the paper doesn't say which training setup the ablation used. This table can only be used to compare the three losses against one another.

WIDER FACE

Detection evaluation follows WIDER FACE convention, with the short side resized to five scales, 500, 800, 1100, 1400 and 1700, each with a horizontal flip, and all the projected boxes combined with box voting (boxes with IoU of at least 0.6 are grouped, and their coordinates averaged with weights from score and overlap). WIDER FACE splits faces by difficulty into Easy, Medium and Hard, depending on whether EdgeBox, a traditional proposal method, can find the face; Hard contains every face, many of them small. A detection box counts as correct if its IoU with a labeled box exceeds 0.5; sort all detections by score from high to low and count down the list, computing precision and recall at each step, which traces a PR curve, and the area under it is AP.

MethodEasyMediumHard
FaceBoxes0.8790.8570.771
LFFD0.9100.8810.780
RetinaFace-M0.9070.8820.738
ASFD-D00.9010.8750.744
img2pose0.9080.8990.847

Excerpted from Table 3 of the paper, the lightweight group on the WIDER FACE validation set. RetinaFace-M is RetinaFace with a MobileNet backbone.

img2pose is first in this group on Medium and Hard, 6.7 percentage points above the runner-up LFFD on Hard; on the test set it scores 0.900/0.891/0.839. The same table also lists detectors with heavy backbones, where ResNet-152 RetinaFace scores 0.920 on validation Hard, and the paper doesn't dodge this gap. The authors also stress that img2pose wasn't trained with box labels and used twenty thousand fewer faces than the others.

The RetinaFace-M row's 0.907/0.882/0.738 is identical to the MobileNet-0.25 "original image scale" row (90.70%/88.16%/73.82%) in the README of biubug6/Pytorch_Retinaface, the version the community uses most, and that's a single-scale result at original image size. In the same README, with the same test settings as the MXNet version, Hard is 80.99%; the RetinaFace paper itself reports 78.2% on Hard for its MobileNet-0.25 version.

Set the two sets of conditions side by side. img2pose's 0.847 used five scales, flipping and box voting; the table's 0.738 is a single forward pass at original size. The Hard group is mostly small faces, and multi-scale testing finds small faces precisely by enlarging them (part of those 10.9 percentage points belongs to the magnifying glass). The table's caption says img2pose "surpasses other light backbone detectors on Med. and Hard sets," without stating the conditions.

Original Figure 6: a 3D scatter plot with axes t_x, t_y and t_z. The blue points (Easy) cluster in a small patch closest to the origin; the green points (Medium) spread out a little around them; the red points (Hard) are the most widely spread, scattering farthest along the t_z axis and also widely up, down, left and right.
Original Figure 6, Albiero et al., from PDF page 8, arXiv license, scholarly quotation.

This figure plots the predicted global translation of every face in the WIDER FACE validation set as a point. The blue Easy points crowd into a small patch near the camera and in the middle of the frame, while the red Hard points spread out into the distance, most widely along the depth direction. The authors use it as evidence that the poses are reasonable, and it also shows why Hard is hard, since faces far away are small in the frame.

AFLW2000-3D Scores From v1 to v2

The 3.913° above only appears in the second version of the paper.

In v1, from December 2020, equation (1) is written in Euler angles, the AFLW2000-3D rotation ground truth is also computed by the authors themselves by solving PnP from the 68 ground-truth points, the model isn't fine-tuned on 300W-LP, and the mean error is 4.267° single-scale and 3.945° multi-scale.

In March 2021, the community started asking questions. Issue #15 first found that the evaluation notebook computed errors by treating rotation vectors directly as Euler angles; then someone pointed out that OpenCV's coordinate system differs from AFLW2000-3D's convention, with the Y and Z axes pointing the opposite way. Issue #17 put it more bluntly, saying that everyone else compares against the Euler angles provided with the dataset while img2pose compares against ground truth it made itself, so the two can't go in the same table; rerunning single-scale against the dataset's ground truth, the issue's author got errors above 7°. The authors replied the same day that switching to the dataset's ground truth gave similar results. Two weeks later, in issue #15, the authors announced the release of a new model "trained with constrained yaw poses," with evaluation switched to the dataset's ground truth, and said they would update the CVPR camera-ready version and arXiv.

v2, from May 2021, is the last version on arXiv. The representation changed to rotation vectors, the rotation ground truth switched to the Euler angles provided with the dataset, and the model gained 300W-LP fine-tuning.

How much the fine-tuning actually contributes wasn't measured until issue #59 at the end of that year. The issue's author tested the two officially released models on AFLW2000-3D. The model trained only on WIDER FACE has a mean error of 6.150°; with a different way of decoding the Euler angles, taking the better of the two for each image, it's 4.812°; the fine-tuned model is 3.913°. The authors' response was that the gap mainly comes from the Euler-angle problem, and that apart from evaluations using Euler angles, they recommend the model without fine-tuning.

Side by side, the best the un-fine-tuned img2pose manages is 4.812°, higher than both QuatNet's 4.503° and TriNet's 4.669° in the table; the abstract's claim that it "outperforms state of the art (SotA) face pose estimators" depends on those 2 epochs of 300W-LP. As for the 300W-LP annotations used for fine-tuning, the authors said in the same thread, "We have no plans on releasing these annotations at this time," and two weeks later in issue #61 changed that to "we may do so in the future" (maybe). The fine-tuned weights, on the other hand, are available; the authors said in the same thread that they had been put in the Model Zoo.

Limitations

It only sees faces. The training labels all come from five facial landmarks; heads turned away from the camera, showing only the back, have no pose labels on WIDER FACE and are painted black in the code. DirectMHP, which tackled multi-person head pose in 2023, treated img2pose as its most closely related prior work and pointed this out too, noting that its training design targets only visible faces and can't be extended directly to full-range head pose.

The camera is assumed. The focal length is fixed at the image's width plus height, regardless of whether the photo was taken with a wide-angle phone lens or a telephoto. The translation is therefore a relative quantity, in units of the 3D face model's length, not centimeters. In February 2024, someone asked in issue #79 how to plug in real camera intrinsics, and the next day issue #80 asked how the translation error was measured when AFLW2000-3D has no translation annotations; neither thread has any reply (the answer to the second is in Section 5.1 of the paper).

Fast, with conditions. 41 images per second is the figure for 400×400400\times400, single-scale, on a Titan Xp; the WIDER FACE results use five scales, with the short side enlarged up to 1,700, plus flipping. The released weights file is about 150 MB. In issue #65, a user took nearly two seconds per image, while BlazeFace on the same machine took only 15 milliseconds; the authors asked them to check whether the GPU was being used, and nothing more came of it.

Conclusion

img2pose drops the detector and the landmarks at inference, but training still needs both. The poses of its 130,000-plus training faces were all computed by solving PnP from five landmarks, 62,827 of them with five points from RetinaFace's detections and the rest from the RetinaFace project's manual annotations; the official README shows you how to train on your own data, and if you don't have boxes and landmarks, the first step is to run its annotation script, which contains from retinaface import RetinaFace. What you get in exchange is a ResNet-18 Faster R-CNN whose second stage regresses only six numbers and delivers both pose and face box; 0.847 on WIDER FACE validation Hard (five scales plus flipping), and mean errors of 3.913° and 3.786° on AFLW2000-3D and BIWI (after 300W-LP fine-tuning).

Pick the right weights. The model trained only on WIDER FACE can handle faces that are turned away, and the authors also recommend it for general use; the fine-tuned model squeezes poses to within ±90° yaw and suits comparing scores on Euler-angle benchmarks. The output is a rotation vector; to get yaw, pitch and roll, use the convert_to_aflw the authors gave in issue #17, because solving Euler angles directly with SciPy leaves the axis order and signs out of line with the AFLW2000-3D convention. How tight the box is depends on three parameters, bbox_x_factor, bbox_y_factor and expand_forehead; if the boxes are too tight, adjust them, with no retraining needed.