AdaFace: Quality Adaptive Margin for Face Recognition
- Publication
- CVPR 2022Conference
- First submitted to arXiv
- arXiv:2204.00964
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{facerecognitionadaface2022,
title = {{AdaFace: Quality Adaptive Margin for Face Recognition}},
author = {Minchul Kim and Anil K. Jain and Xiaoming Liu},
year = {2022},
eprint = {2204.00964},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2204.00964}
}
Two training photos, and the model can't recognize either of them yet. One is a profile of someone in sunglasses, every feature clearly visible, just shot from an awkward angle; the other is a person blurred into a smudge in surveillance footage, where you can't even tell where the eyes are.
To the loss function, both are hard samples, with features far from the center of the correct class. Most loss designs of recent years hold that hard samples deserve extra effort. The first photo is worth it; with the second, however hard the model tries, about all it can learn is the color of the clothes and the background.
This paper comes from Michigan State University, by Minchul Kim, Anil K. Jain and Xiaoming Liu. They want the loss function to tell these two kinds of "hard" apart, and their approach rests on two observations. The first, a little counterintuitive, is that angular margins of the ArcFace kind already give smaller gradients to samples that sit farther from the class center. The second is that the length of the feature vector before normalization correlates to a fair degree with how clear the photo is.
Put the two together and you get AdaFace. It looks at a face's feature norm to decide the shape of the margin: clear photos get a negative angular margin, which emphasizes hard samples; blurry photos get a positive, ArcFace-style angular margin, which lets go of the ones that can't be learned no matter what.
Defining the Problem
Quality and difficulty are two different things

The paper's first figure pulls two axes apart. Image quality is about capture conditions such as brightness, contrast, sharpness, noise and resolution; recognizability is how many identity cues are left in the image. A high-quality photo can be very hard to recognize (sunglasses, a profile), and a low-quality photo can still be barely recognizable; only when quality gets bad enough does a photo fall into the "unrecognizable" cell at the lower right, the two with red backgrounds.
Why does this only matter now? On high-quality benchmarks such as LFW and CFP-FP, methods of the time already had verification accuracy above 98%, with the differences down to the decimals; the focus of evaluation had moved to datasets like IJB-B, IJB-C and IJB-S, full of surveillance and video frames. The training data, though, were still mostly high-quality celebrity photos, with low-quality images making up only a small share that has to be put to good use.
The side effect of emphasizing hard samples
Margin-based losses (margin-based softmax) make features more discriminative, and a batch of later methods added "adaptivity" on top: MV-Softmax emphasizes misclassified samples, and CurricularFace adjusts according to training progress, learning the easy samples first and emphasizing the hard ones later.
These methods share one premise: hard samples deserve more learning. Unrecognizable images are always hard samples, and the model can only guess on them; blindly emphasizing hard samples amounts to emphasizing these images again and again. The authors argue that, among hard samples, whether to emphasize one should depend on image quality.
That leaves two questions. How should the loss function adjust the weights of samples of different difficulty? And during training, where can each image's quality be obtained cheaply?
Solving the Problem
The margin changes the size of the gradient
First, write down the common form of margin-based losses, the paper's Eq. (1):
The feature and every class weight are normalized to unit length, is the angle between them, is the correct class, and is the scale (64 in the paper). The margin is added only to the correct class, and the three classic forms are:
- SphereFace: , a multiplicative angular margin (in AdaFace's unified notation; SphereFace itself uses the feature length instead of a fixed );
- CosFace: , an additive cosine margin;
- ArcFace: , an additive angular margin.
Earlier discussions of these margins mostly looked at where they push the decision boundary and what that means geometrically. AdaFace looks from another angle: how the gradient changes during backpropagation. Let be the probability of class after softmax, and take the derivative with respect to the weight (Eq. (10)):
The last term is the direction and doesn't depend on ; the first two are scalars, and only they are affected by . The authors combine these two into what they call the gradient scaling term (GST), Eq. (12):
The larger is, the more this sample influences the parameter update. Only the correct class needs to be considered, since the other classes have no margin.
CosFace and softmax without a margin: the derivative of with respect to is , so , exactly the same as softmax. Subtracting only shifts the decision boundary.
ArcFace: first expand with the angle-addition formula, then write as a function of :
Differentiate with respect to :
This term picks up a , so it changes with the angle. Plugging in ArcFace's (about 28.6°) and computing a few points, divided by :
| 30° | 60° | 90° | 120° | 150° | |
|---|---|---|---|---|---|
| 1.708 | 1.154 | 0.878 | 0.601 | 0.047 |
Computed for this note from Eq. (15) of the paper.
The farther from the center of the correct class, the smaller this term; a sample at 150° gets only about 3% of what a sample at 30° gets.
What about the other half, ? makes the softmax very steep. Take ArcFace with in a two-class example and assume the other class has : as the correct-class angle grows from 60° to 80°, drops from 0.82 to almost 0. For samples already past the decision boundary, is close to 0 and contributes almost no gradient; for those not yet past it, is almost always . So among the samples that "haven't been learned yet," which one gets the larger gradient is decided almost entirely by .
The upshot is that ArcFace's positive angular margin automatically lowers the weight of the hardest samples. Flip the sign of and changes sign, so the effect reverses as well: the farther the sample, the larger its gradient.

This figure draws the computation above in feature space. Each sector has the correct class at the upper left and another class at the lower right; the closer to , the harder the sample. The color is .
In CosFace on the far left, everything below the boundary is dark red, so all samples not yet learned get the same weight. In the second plot, ArcFace (), the red concentrates near the boundary and gradually turns yellow-green toward : the hardest samples get turned down. The third plot changes to , and the corner near becomes the reddest instead. The two middle plots, CurricularFace, move the boundary according to the training stage; MagFace gives high-norm features a larger angular margin, and its gradient distribution resembles ArcFace's, again without emphasizing hard samples.
So just by switching among a positive angular margin, zero and a negative angular margin, you can decide whether to emphasize easy samples or hard ones. The next question is what to switch on.
Using the feature norm as quality
Image quality assessment (IQA) already has plenty of methods, such as the no-reference BRISQUE and the face-specific SER-FIQ, but they are too expensive to run once per image inside the training loop. The authors add no module at all and directly use , the length of the backbone's output feature before normalization.

The authors randomly take 1,534 images from the MS1MV2 training set (including the data augmentation covered later), use 1 − BRISQUE as the quality score, and compute its Pearson correlation with the norm. The green line in (a) is 0.5235 at the last epoch, and it is already around 0.5 at the first epoch, so the norm is usable right from the start of training. The orange line is the correlation between quality and the correct-class probability , and it stays below the green line the whole way.
(c) has to be read against (b). can be seen as sample difficulty (the larger , the harder), and the dots crowd mostly at the two ends, 0 and 1, so its relationship with quality is nonlinear; images of different quality have different difficulty distributions. This is exactly why the authors want to treat quality and difficulty separately.
0.52 is a moderate correlation. In issue #24 of the official repo, someone pressed on what the relationship between norm and quality really is, and Minchul Kim replied (July 2022), agreeing that beyond the correlation there is no stronger connection.
Plotted out, each sample's trajectory during training looks like this.

The 1,536 samples are sorted by their final norm from small to large, and around sample 600 is where low norm turns into high norm. In the bottom row, many samples on the low-norm side never see their rise before training ends, meaning they are never learned; the corresponding images in the top row are faces mostly cropped away or blurred out. Among samples 0 to 600, about 62.0% carry at least one kind of data augmentation; after sample 600, only 38.5% do.
Turning the norm into a score in
The scale of the norm depends on the model; change the model or the training stage and the range of values shifts, so the norm is first standardized with batch statistics, Eq. (16):
and are the mean and standard deviation of the norms within the batch; means clipping to , with the gradient stopped.
controls how concentrated the score is. Dividing directly by , only about 68% of a standard normal falls within , and the rest would all be clipped; the authors want most samples to fall within range, so they take . That means the norm has to deviate from the mean by more than 3 standard deviations before the score reaches . For example, an image whose norm is 1 standard deviation below the mean gets a score of ; one that is 2 standard deviations above gets .
The stopped gradient is deliberate. The paper's explanation is that the authors don't want the features to be optimized toward low norms; AdaFace uses the norm only as an indicator and doesn't let it be optimized.
With small batches the statistics are unstable, so and use an exponential moving average. The official code gives the new batch a weight of 0.01 and the accumulated value 0.99 at each step (t_alpha=0.01). The supplementary material trains ResNet50 with batch sizes of 128, 256 and 512, and the TAR on IJB-B is 94.32%, 94.42% and 94.35%, almost unaffected by batch size.
The margin moves with the norm
With the quality score in hand, AdaFace's margin function is Eq. (18):
The other classes keep . The two adaptive terms are defined by Eq. (19):
Plug in three values, with :
- (low norm): and , giving , which is ArcFace with ;
- (average): and , giving , which is CosFace with ;
- (high norm): and , giving , a negative angular margin plus a downward shift.
Values in between vary continuously among the three. Replace the margin in the earlier ArcFace derivative with , and the margin-dependent half of the gradient scaling term is . The margins and this term for the three norms are plotted below.

Look at the top chart first. All three lines lie below the gray one, meaning the correct class always has points deducted. The green line deducts 0.4 everywhere; the blue line deducts little at both ends and more in the middle; the orange line deducts the most everywhere, leaving only at the easy end. The three lines nearly meet around 90°, and the difference lies in their slopes, which is the gradient multiplier in the bottom chart. A few points from the bottom chart:
| 30° | 60° | 90° | 120° | 150° | |
|---|---|---|---|---|---|
| Low norm (−1) | 1.596 | 1.146 | 0.921 | 0.696 | 0.247 |
| Average (0) | 1 | 1 | 1 | 1 | 1 |
| High norm (+1) | 0.247 | 0.696 | 0.921 | 1.146 | 1.596 |
Computed for this note from Eqs. (12) and (19) of the paper, .
For a low-norm image, a hard sample at 150° gets only about one sixth of what an easy sample at 30° gets; for a high-norm image it's the other way around, and the hard sample's multiplier is more than six times the easy sample's. If the norm really reflects quality, the profile in sunglasses from the opening gets emphasized, and the smudge in the surveillance footage gets let off.
The official implementation
The official repo's head.py writes the formulas above in a dozen or so lines. The version below follows AdaFace.forward, keeps the variable names of the original file and merges a few lines; the comments were added for this note:
# embeddings: L2-normalized features (B, 512); norms: their pre-normalization lengths (B, 1)
kernel_norm = l2_norm(self.kernel, axis=0)
cosine = torch.mm(embbedings, kernel_norm).clamp(-1 + self.eps, 1 - self.eps)
safe_norms = torch.clip(norms, min=0.001, max=100).clone().detach() # no gradient to the norm
with torch.no_grad(): # EMA of batch statistics
mean, std = safe_norms.mean(), safe_norms.std()
self.batch_mean = mean * self.t_alpha + (1 - self.t_alpha) * self.batch_mean
self.batch_std = std * self.t_alpha + (1 - self.t_alpha) * self.batch_std
margin_scaler = (safe_norms - self.batch_mean) / (self.batch_std + self.eps)
margin_scaler = torch.clip(margin_scaler * self.h, -1, 1) # Eq. (16)
# g_angle = -m * ||z||^, only on the ground-truth column
m_arc = torch.zeros(label.size()[0], cosine.size()[1], device=cosine.device)
m_arc.scatter_(1, label.reshape(-1, 1), 1.0)
m_arc = m_arc * (self.m * margin_scaler * -1)
theta_m = torch.clip(cosine.acos() + m_arc, min=self.eps, max=math.pi - self.eps)
cosine = theta_m.cos()
# g_add = m * ||z||^ + m, only on the ground-truth column
m_cos = torch.zeros(label.size()[0], cosine.size()[1], device=cosine.device)
m_cos.scatter_(1, label.reshape(-1, 1), 1.0)
cosine = cosine - m_cos * (self.m + self.m * margin_scaler)
return cosine * self.s # logits for CrossEntropyLoss
A few implementation points to watch. The backbone ends in a fully connected layer followed by BatchNorm1d(512, affine=False), and the norm is the length of this 512-dimensional vector before normalization, returned together with the normalized feature. This computation is not wrapped in no_grad, so the gradients of acos and cos flow back as usual. The README's example parameters are , , and t_alpha=0.01.
Showing the model more bad photos
Since AdaFace can let go of unrecognizable images, the authors go ahead and manufacture some on purpose. Three kinds of online augmentation are added during training, each applied with probability 0.2:
- Cropping: pick a random rectangle and black out everything outside it; there is no rescaling, so the face alignment isn't broken.
- Rescaling: shrink the image, then enlarge it back to the original size, which blurs it.
- Photometric: randomly adjust hue, saturation and brightness.
Face-recognition training usually leaves these augmentations out, because they usually don't help; part of the extra data they create gets blurred beyond recognition. The authors' argument is that AdaFace can ignore that part, which is why it gets to benefit from the augmentation.
Training setup
- Data: MS1MV2 (5.8M images), MS1MV3 (5.1M) and WebFace4M (4.2M).
- Preprocessing: five-landmark alignment, cropped to 112×112.
- Backbone: the ResNet as modified by ArcFace; ResNet18 and ResNet50 for the ablations, ResNet100 for the main results.
- Optimization: SGD with an initial learning rate of 0.1, decayed at epochs 10, 18 and 22, for 24 epochs in total; 2 more epochs when augmentation is used. , , .
- Cost: under the same settings, ArcFace takes 0.3193 seconds per iteration and AdaFace 0.3229 seconds, 1% more.
Discussion
Test sets and metrics
The authors split the test sets into three groups by image quality:
- High quality: LFW, CFP-FP, CPLFW, AgeDB and CALFW, reporting 1:1 verification accuracy.
- Mixed quality: IJB-B and IJB-C, which contain both high-quality photos and low-quality video frames, reporting TAR@FAR=0.01%. That means setting the threshold so that only one in ten thousand pairs of different people may be judged to be the same person, and at that threshold, seeing what fraction of same-person pairs pass.
- Low quality: IJB-S is surveillance video, and the probes of all three protocols are surveillance footage, matched respectively against a single high-quality enrollment photo (Surveillance-to-Single), a set of enrollment photos from multiple angles (Surveillance-to-Booking) and another surveillance video (Surveillance-to-Surveillance), reporting closed-set Rank-1/Rank-5 and open-set TPIR@FPIR=1%; TinyFace consists entirely of low-resolution faces, reporting Rank-1/Rank-5.
Ablations: , , quality proxy and augmentation
The ablations use ResNet18 and a random sixth of MS1MV2. HQ is the average accuracy over the five high-quality sets; LQ is the average of Rank-1 and TPIR@FPIR=1% over the three IJB-S protocols.
| Setting | HQ | LQ |
|---|---|---|
| CurricularFace | 93.43 | 32.92 |
| 93.67 | 34.92 | |
| , | 93.74 | 35.40 |
| 93.70 | 35.29 | |
| 93.56 | 35.23 | |
| 93.37 | 35.69 | |
| 1−BRISQUE as proxy | 93.43 | 34.55 |
| as proxy | 93.46 | 35.17 |
Compiled from Table 1 of the paper; unlisted parameters are , and the norm proxy.
Between 0.22 and 0.66, makes little difference, and every value beats CurricularFace. HQ falls steadily as grows, while LQ peaks at ( is actually a little lower than 0.4). The authors' explanation is that the larger is, the wider the range over which the angular margin varies with quality; in the end they take , where LQ does well and HQ isn't sacrificed. Swapping the norm for a precomputed BRISQUE drops LQ by 0.85; the authors' explanation is that BRISQUE was computed only on the original images and can't capture quality after online augmentation. Swapping in is also worse, showing that adapting to the norm and adapting to difficulty are two different things.
The augmentation experiments switch to ResNet50 and the full MS1MV2, with the probability of each augmentation:
| Method | HQ | LQ | |
|---|---|---|---|
| CurricularFace | 0.0 | 96.85 | 41.00 |
| CurricularFace | 0.2 | 96.75 | 40.84 |
| CurricularFace | 0.3 | 96.59 | 40.58 |
| AdaFace | 0.0 | 96.72 | 40.95 |
| AdaFace | 0.2 | 96.88 | 41.82 |
| AdaFace | 0.3 | 96.78 | 41.93 |
Compiled from Table 2 of the paper.
Augmentation makes CurricularFace worse on both metrics, while it adds nearly 1 percentage point to AdaFace's LQ, consistent with the authors' argument. Compare the first and fourth rows as well: without augmentation, AdaFace is slightly below CurricularFace on both HQ and LQ. In this same-setting comparison, AdaFace's advantage only shows up together with augmentation.
Against other methods
The main results use ResNet100; the table below lists only the part trained on MS1MV2 (%):
| Method | HQ avg. | IJB-B | IJB-C |
|---|---|---|---|
| CosFace | 96.82 | 94.80 | 96.37 |
| ArcFace | 96.78 | 94.25 | 96.03 |
| CurricularFace | 97.16 | 94.80 | 96.10 |
| BroadFace | 97.25 | 94.97 | 96.38 |
| MagFace | 97.10 | 94.51 | 95.97 |
| SCF-ArcFace | 97.16 | 94.74 | 96.09 |
| DAM-CurricularFace | – | 95.12 | 96.20 |
| URL | – | – | 96.60 |
| AdaFace | 97.19 | 95.67 | 96.89 |
Compiled from Table 3(a) of the paper; IJB-B and IJB-C are TAR@FAR=0.01%.
The five high-quality datasets are already saturated: AdaFace's average of 97.19 is a little below BroadFace's 97.25, and the authors also say these columns alone can hardly separate the methods. Mixed quality is where AdaFace pulls ahead. The runner-up on IJB-B is DAM-CurricularFace at 95.12, and the error rate drops from 4.88% to 4.33%, 11% fewer errors in relative terms; the runner-up on IJB-C is URL at 96.60, and the error rate drops from 3.40% to 3.11%, 9% fewer in relative terms. Against MagFace, the reductions are 21% and 23% respectively.
Trained on MS1MV3 and WebFace4M instead, AdaFace reaches 97.09% and 97.39% on IJB-C, against 96.76% for VPL-ArcFace and 97.16% for ArcFace.
On the low-quality IJB-S and TinyFace (Rank-1, %, trained on MS1MV2):
| Method | S→Single | S→Booking | S→Surv. | TinyFace |
|---|---|---|---|---|
| PFE | 50.16 | 53.60 | 9.20 | – |
| ArcFace | 57.35 | 57.36 | – | – |
| URL | 59.79 | 61.98 | – | 63.89 |
| CurricularFace | 62.43 | 63.81 | 19.54 | 63.68 |
| AdaFace | 65.26 | 66.27 | 23.74 | 68.21 |
Compiled from Table 3(b) of the paper; S stands for the surveillance-video probe.
Across the four Rank-1 columns, AdaFace beats the runner-up by 3.5 percentage points on average, and across the three protocols' TPIR@FPIR=1% by 2.4 percentage points on average. The exception is the hardest protocol, Surveillance-to-Surveillance, where its TPIR is only 2.50%, slightly below CurricularFace's 2.53%; when trained on WebFace4M, ArcFace's 5.32% in this column is also higher than AdaFace's 4.96%. When two surveillance videos are matched against each other, the open-set TPIR of every method is still in single digits.
Most of the baseline numbers in the table are taken from their own papers, trained without AdaFace's three augmentations; the only same-setting comparison is Table 2 above.
How it differs from MagFace and CurricularFace
All three adjust the margin, but they go by different things.
- CurricularFace goes by training progress. Early on it suppresses the weight of hard negative classes and later it emphasizes them, with every sample following the same schedule.
- MagFace also uses the feature norm, but learns the norm as recognizability. It lets the gradient flow through the norm so that "the larger the norm, the easier to recognize" holds, then pairs higher norms with larger angular margins. AdaFace's supplementary material points out that this design gives the loss an incentive to lower the norm in exchange for a smaller margin.
- AdaFace treats the norm as a proxy for image quality, stops its gradient, and doesn't try to shape the norm itself; what it changes is the shape of the margin function, emphasizing hard samples when quality is high. MagFace's gradient distribution, by contrast, is the same as ArcFace's and doesn't emphasize hard samples.
What the norm does at test time
The official IJB-B/IJB-C evaluation code uses flip testing by default, and before summing the features of one template (several photos or frames of the same person), it multiplies each feature back by its own norm, so that high-norm images weigh more in the fusion; the IJB-S evaluation does the same. The paper's related-work section mentions this practice of using the norm for quality-aware fusion. InsightFace's standard IJB evaluation code also keeps the norm by default, so on this point the methods are roughly on equal footing; when you need AdaFace for matching videos or sets of photos, you can use it the same way.
Community reports
The relationship between norm and quality doesn't necessarily hold for every model. In issue #6 (May 2022), someone who trained their own IR50 on MS1MV3 found that the low-norm images were actually the high-quality ones. The author first suggested flipping the sign of , then added that a high norm going with high quality is "somewhat common" in the models the author had trained, and that the L2-softmax paper mentions it too; as for why some models don't show this relationship, the guess was that it relates to model size, data scale and the margin settings.
In issue #25 (June 2022), a user also reported porting AdaFace together with the official augmentation into InsightFace: on MS1MV3 it beat ArcFace on IJB-C (97.17% vs. 96.85%), but on Glint360K it lost to CosFace (97.38% vs. 97.55%). This is a single run from a single user, and the author replied that they had never run it on Glint360K.
As for the ArcFace WebFace4M model marked with an asterisk in Table 3, issue #34 confirms that it is a checkpoint requested from the InsightFace authors, trained with augmentation different from AdaFace's.
There's also a very practical pitfall. AdaFace's released pretrained models take BGR color order, while InsightFace's models take RGB, and the README says so twice. In issue #17, someone tested both and felt ArcFace was more accurate; the author first said there was too little context, then pointed out that cosine values can't be compared directly across models, and in the third reply asked them to check exactly this.
As for larger datasets, in June 2022 someone asked in issue #22 why there were no WebFace42M results; the author replied that two million classes make the last layer enormous, that they were looking into training a WebFace42M model for release, and that "it may take some time" (to this day, the model tables in both the official repo and its successor CVLFace stop at WebFace12M). In June 2024, the author explained in issue #88 that PartialFC plus AdaFace had been added to the new CVLFace repo, and that anyone wanting to train on datasets with more than a million classes could start from there.
Limitations
AdaFace handles unrecognizable images but not label errors, a limitation the authors point out themselves. Mislabels are common in large face datasets, and AdaFace emphasizes high-quality hard samples; a clear photo labeled as the wrong person is, in its eyes, exactly the kind that most deserves emphasis. The asker in issue #22 reasoned from this that AdaFace might be more sensitive than CosFace and ArcFace to mislabeled and unseen identities.
Also, MS1MV2 and MS1MV3 both derive from MS-Celeb-1M, which Microsoft has taken down. The authors explain in the paper that they still use them for a fair comparison with prior work, and they also provide results on WebFace4M.
Conclusion
AdaFace first points out that angular margins scale the gradient according to sample difficulty, then uses the stop-gradient feature norm as a quality proxy, letting the margin move continuously among an ArcFace-style margin, a CosFace-style margin and a negative angular margin. For only 1% more training time, it cuts the relative error on IJB-B/IJB-C by 9% to 11% and adds an average of 3.5 percentage points of Rank-1 on IJB-S and TinyFace, while the high-quality benchmarks stay roughly flat. The same-setting comparison shows that these gains come together with data augmentation.
If you want to swap ArcFace's head for AdaFace, first run your own model on a batch of training images and check whether norm and sharpness are positively correlated; if they're reversed, flip the sign of as the author suggests. Remember to turn on all three augmentations together, and set , and t_alpha=0.01 as in the README; when running inference with the official pretrained models, convert the input to BGR. If your training labels are very dirty, clean the data first, and only then talk about emphasizing hard samples.
SphereFace left the feature norm in the logit, CosFace and ArcFace fixed it at 64, and AdaFace picked it back up, only this time it keeps it outside the computation graph.