Fast and Interpretable Face Identification for Out-Of-Distribution Data Using Vision Transformers

Hai Phan, Cindy X. Le, Vu Le, Yihui He, Anh Totti Nguyen · DOI

Abstract

Face identification (FI) systems frequently encounter out-of-distribution (OOD) challenges, such as facial occlusions from masks or sunglasses, which significantly degrade the performance of standard Siamese networks. While existing patch-based comparison methods like DeepFace-EMD improve robustness, their high computational complexity limits real-time application. We present a novel Hybrid Vision Transformer (Hybrid-ViT) architecture designed for fast and interpretable face matching. By utilizing cross-attention to compare image patches directly, our model achieves state-of-the-art accuracy on OOD datasets while operating at twice the speed of previous benchmarks. Additionally, the model generates human-readable attention maps that significantly improve human accuracy in identity verification tasks, bridging the gap between automated systems and human-in-the-loop requirements.

Introduction

Modern face identification systems typically rely on compressing facial images into global embeddings. While effective for high-quality, in-distribution data, these "black-box" models often fail when faced with occlusions—such as masks, sunglasses, or adversarial perturbations—that characterize real-world OOD scenarios. Existing solutions that attempt patch-wise comparison, such as those using Earth Mover’s Distance (EMD), suffer from high computational complexity, making them unsuitable for large-scale or real-time deployment. Furthermore, the lack of interpretability in these systems hinders their adoption in high-stakes environments like law enforcement, where human verification is critical.

Methods: The Hybrid-ViT Architecture

To address these challenges, we propose the Hybrid-ViT (Model H2L). This architecture combines the spatial feature extraction capabilities of Convolutional Neural Networks (CNNs) with the relational modeling strengths of Vision Transformers.

The proposed Hybrid-ViT architecture (H2L) utilizes a CNN backbone for feature extraction followed by a Transformer Encoder with cross-attention for patch-level comparison.

The model operates in several key stages:

  1. Feature Extraction: A pre-trained ArcFace CNN extracts spatial feature maps from the input images.
  2. Cross-Attention Mechanism: Unlike standard ViTs that process images independently, our model feeds patches from two images into a single Transformer encoder. This allows the self-attention mechanism to function as "cross-attention," enabling the model to directly compare specific facial regions (e.g., the forehead or eyes) across the query and gallery images.
  3. Optimized Output Head: Instead of relying on a standard [CLS] token, we employ two separate linear layers to extract features from the Transformer's output. These features are then compared using cosine similarity, optimized via the ArcFace loss function.
  4. Two-Stage Inference: For efficiency, the system employs a re-ranking strategy. A standard CNN performs an initial rapid search (Stage 1), and the Hybrid-ViT re-ranks the top 100 candidates (Stage 2), ensuring both speed and high precision.

Experimental Evaluation

The model was trained on 2 million image pairs from the CASIA Webface dataset and evaluated across several benchmarks, including LFW for in-distribution data and modified versions of CALFW and AgeDB for OOD/occlusion scenarios. Our findings revealed that a shallow Transformer (depth of 1 layer) was sufficient for high-accuracy matching, significantly reducing computational overhead compared to deeper models.

Results and Interpretability

The Hybrid-ViT (H2L) demonstrated a significant performance leap over the current state-of-the-art, DeepFace-EMD, in both efficiency and interpretability.

Performance and Speed

H2L achieved a 2x speedup compared to DeepFace-EMD across all evaluation datasets. In terms of accuracy, it reached 99.28% P@1 on the masked AgeDB dataset during the re-ranking stage, matching or exceeding the performance of more computationally expensive models.

Visual Explanations and Human Impact

A core contribution of this work is the interpretability provided by the cross-attention maps. These maps allow users to see exactly which parts of the face the model is prioritizing for its decision.

Attention maps demonstrate how the Hybrid-ViT model ignores occlusions like masks and sunglasses, focusing on visible facial features to provide interpretable identity verification.

As shown in the visualizations, the model effectively ignores occluded regions (like the mask or sunglasses) and focuses on the unmasked, informative areas. In a user study involving 21 participants, these visual explanations improved human verification accuracy from 54.60% (without explanations) to 73.97%, demonstrating the value of the model as a collaborative tool for human-in-the-loop systems.

Conclusion

The Hybrid-ViT architecture provides a fast, accurate, and interpretable solution for face identification under challenging OOD conditions. By leveraging cross-attention and a two-stage re-ranking approach, it overcomes the speed limitations of previous patch-based methods. Future work will focus on optimizing hyperparameter settings and exploring sparse attention mechanisms for further acceleration.

Summary updated

BibTeX
@inproceedings{phan2024fast,
  author = {Hai Phan and Cindy X. Le and Vu Le and Yihui He and Anh Totti Nguyen},
  title = {{Fast and Interpretable Face Identification for Out-Of-Distribution Data Using Vision Transformers}},
  booktitle = {IEEE/CVF Winter Conference on Applications of Computer Vision},
  year = {2024},
  doi = {10.1109/wacv57701.2024.00618},
}
Figure