KeyPoint Relative Position Encoding for Face Recognition

Minchul Kim, Yiyang Su, Feng Liu, Anil Jain, Xiaoming Liu · DOI

TL;DR

This paper introduces KeyPoint Relative Position Encoding (KP-RPE), a novel method to make Vision Transformers (ViTs) more robust to affine transformations in image recognition tasks like face recognition. By leveraging facial landmarks, KP-RPE dynamically adjusts how the model perceives spatial relationships, significantly improving performance on unaligned and low-quality images without sacrificing accuracy on well-aligned data.

What Problem Does This Paper Address?

Computer vision models, especially those based on Vision Transformers (ViTs), often struggle with variations in image scale, rotation, and translation – collectively known as affine transformations. This is particularly problematic in real-world applications like face recognition, where images can be of low quality, poorly lit, or imperfectly aligned. Traditional methods rely on geometric alignment to standardize images, but this process can fail, leading to a sharp drop in recognition accuracy. The authors aim to make ViTs inherently more resilient to these alignment failures by incorporating keypoint information into their self-attention mechanism.

Methods

The core innovation is KeyPoint Relative Position Encoding (KP-RPE). This method builds upon existing Relative Position Encoding (RPE) techniques used in ViTs. While standard RPE encodes relationships based on pixel distance, KP-RPE extends this by making the positional encoding dependent on specific keypoints (like facial landmarks) within the image.

Here's a breakdown of the approach:

  • RPE Foundation: The paper starts with the observation that RPE helps ViTs generalize better to affine transformations by encoding relative positional information between image patches.
  • KP-RPE Extension: KP-RPE introduces a keypoint-dependent bias term ($B_{ij}$) into the self-attention calculation. This bias is not static but dynamically computed based on the positions of predefined keypoints in the image.
  • Dynamic Bias Calculation: The authors propose several ways to compute this bias, with the "Relative f(P)" and "Multihead Relative f(P)" variants showing the most promise. These methods involve calculating the difference between a mesh grid of image locations and the keypoint locations, then projecting this difference to generate the bias. This allows the model to learn how keypoint positions influence the attention weights.
  • Efficiency: KP-RPE is designed to be computationally efficient, with the keypoint-dependent bias computed only once per forward pass. It's also noted to be significantly faster than another relative position encoding method, iRPE.

Datasets

The authors used a variety of datasets for training and evaluation:

  • Training Datasets: MS1MV2, MS1MV3, WebFace4M, and WebFace12M were used for training face recognition models. WiderFace was used for training the landmark detector.
  • Evaluation Datasets:
    • Aligned Datasets: CFPFP, AgeDB, IJB-C (high quality); TinyFace, IJB-S (low quality).
  • Unaligned Datasets: Raw CFPFP and IJB-C images were used to simulate alignment failures.
  • Gait Recognition: Gait3D was used for gait recognition experiments.

Key Insights and Ideas

  • Keypoints as Spatial Anchors: The central idea is that keypoints (like facial landmarks) act as stable anchors that can help the model understand spatial relationships even when the overall image is distorted by affine transformations.
  • Dynamic RPE is Crucial: Simply using static RPE is insufficient for robust affine transformation handling. The ability to dynamically adjust positional encodings based on image content (specifically, keypoints) is key.
  • KP-RPE's Versatility: The method shows promise not only for face recognition but also for other tasks that rely on keypoints, such as gait recognition.
  • Robustness vs. Accuracy Trade-off: KP-RPE achieves improved robustness on unaligned datasets without significantly compromising performance on aligned datasets, suggesting a favorable trade-off.
  • Landmark Error Sensitivity: While KP-RPE is dependent on landmark predictions, the study indicates that it's relatively robust to small landmark errors, though significant errors do impact performance.

Key Results

  • Face Recognition: KP-RPE significantly improves performance on unaligned and low-quality face datasets. For example, on the unaligned CFPFP dataset, ViT+KP-RPE achieved 91.85% accuracy, a substantial jump from the baseline ViT's 77.27% (as shown in Figure 1). It also shows strong results on datasets like TinyFace and IJB-S.
  • Gait Recognition: KP-RPE demonstrated improvements in gait recognition metrics (Rank-1, Rank-5, mAP, mINP) when applied to the SwinGait-2D baseline.
  • Computational Efficiency: KP-RPE introduces a minimal increase in computational cost (FLOPs) and parameters, making it an efficient addition to ViT models. It is also significantly faster than iRPE.
  • Ablation Studies: Different formulations of KP-RPE were tested, with "Relative f(P)" and "Multihead f(P)" showing superior performance, particularly on unaligned datasets.

Limitations and Future Work

  • Keypoint Supervision: KP-RPE requires keypoint supervision, which might not be available for all datasets or tasks, especially those lacking consistent topology.
  • Future Work: The authors suggest exploring methods for "self-discovery of keypoints" to reduce the reliance on explicit supervision, thereby enhancing the model's flexibility. They also mention that the inverse relationship observed between feature magnitude and image quality in their model warrants further investigation.

Summary updated

BibTeX
@inproceedings{kim2024keypoint,
  author = {Minchul Kim and Yiyang Su and Feng Liu and Anil Jain and Xiaoming Liu},
  title = {{KeyPoint Relative Position Encoding for Face Recognition}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2024},
  doi = {10.1109/cvpr52733.2024.00031},
}
Figure