Inter-class angular margin loss for face recognition

Jingna Sun, Wenming Yang, Riqiang Gao, Jing-Hao Xue, Qingmin LiaoSignal Process. Image Commun 2020 · DOI

Abstract

Face recognition systems rely on mapping facial images into a discriminative feature space where intra-class compactness and inter-class variance are maximized. While existing methods like ArcFace and CosFace focus on intra-class margins, they often treat inter-class separation as a secondary effect or use constant margins. This paper introduces the Inter-class Angular Margin (IAM) loss, a novel regularization term that adaptively penalizes small angles between different class clusters. By focusing on the "empty space" between classes, IAM pushes identities further apart in the feature space. Experimental results on benchmarks like LFW and MegaFace demonstrate that IAM consistently improves the performance of various base loss functions, particularly in large-scale identification tasks.

Introduction

The primary objective of deep face recognition is to learn a feature embedding where images of the same individual are clustered closely (intra-class compactness) and images of different individuals are separated by a significant margin (inter-class variance). Recent advancements have introduced angular margin-based loss functions such as SphereFace, CosFace, and ArcFace to enhance discriminative power. However, these methods typically apply a fixed margin to all classes, regardless of their proximity in the feature space.

The authors argue that a more effective strategy involves adaptively penalizing classes that are too close to one another. This approach forces the model to distribute identities more efficiently across the available hypersphere. To address this, they propose the Inter-class Angular Margin (IAM) loss, which serves as a plug-and-play regularization term to boost the performance of existing loss functions.

Methodology

The proposed framework utilizes a standard deep learning pipeline for face recognition, typically employing an Inception-ResNet-V1 backbone to extract facial features.

A typical pipeline for training a face recognition model, where the penultimate layer serves as the facial feature representation.

The IAM Loss Function

The IAM loss is designed to be integrated with a base loss function ($L_{base}$), such as Softmax or ArcFace. The total loss is defined as:

$$L = L_{base} + \beta L_{IAM}$$

Where $\beta$ is a hyperparameter controlling the regularization strength. The $L_{IAM}$ term calculates the average similarity between a feature vector and the weights of all "incorrect" classes. Specifically, it penalizes small angles between a feature and different class centers, thereby increasing inter-class variance.

A critical aspect of the methodology is the gradient analysis of $\beta$. The authors found that $\beta$ must be carefully tuned (generally $< 1$) to ensure that the drive to push classes apart does not compromise the intra-class compactness maintained by $L_{base}$.

Experiments and Results

The model was trained on the CASIA-WebFace dataset and evaluated across several standard benchmarks.

Performance on Benchmarks

The addition of IAM loss consistently yielded improvements across various datasets:

  • LFW: Adding IAM to a scaled Softmax loss improved accuracy from 98.567% to 99.117%.
  • MegaFace: The most significant gains were observed here. For a basic scaled Softmax, IAM boosted Rank-1 identification accuracy from 48.779% to 76.825%. Even for high-performing losses like ArcFace, IAM provided a lift from 72.975% to 73.911%.
  • Other Datasets: Improvements were also noted on CFP (Celebrities in Frontal-Profile) and YTF (YouTube Faces).

Visualizing Feature Distribution

Using a toy example on the MNIST dataset, the authors visualized feature distributions on a 3D sphere. The results showed that IAM leads to a more uniform and separated distribution of class centers compared to standard Softmax, confirming its ability to maximize the utilization of the feature space.

Discussion and Conclusion

The Inter-class Angular Margin loss offers a flexible and effective way to enhance the discriminative power of face recognition models. By adaptively focusing on the hardest-to-distinguish classes, it complements existing margin-based losses.

However, the method requires careful tuning of the $\beta$ hyperparameter, which varies depending on the base loss function used. Additionally, as the number of classes grows into the millions, the computational cost of calculating the IAM term may increase. Future work could explore applying this adaptive inter-class penalty to other metric learning tasks, such as person re-identification or image retrieval.

Summary updated

BibTeX
@article{sun2020inter,
  author = {Jingna Sun and Wenming Yang and Riqiang Gao and Jing-Hao Xue and Qingmin Liao},
  title = {{Inter-class angular margin loss for face recognition}},
  journal = {Signal Process. Image Commun.},
  year = {2020},
  doi = {10.1016/j.image.2019.115636},
}
Figure