Dynamic Class Queue for Large Scale Face Recognition in the Wild

Bi Li, Teng Xi, Gang Zhang, Haocheng Feng, Junyu Han, Jingtuo Liu, Errui Ding, Wenyu Liu

Introduction

Modern face recognition systems face significant scaling challenges as datasets grow to include millions of identities. Presented at CVPR 2021, the Dynamic Class Queue (DCQ) framework introduces a novel training paradigm designed to mitigate computational overhead and address the inherent "long-tail" distribution of real-world facial data. By replacing the traditional, memory-intensive final classification layer with a dynamic queue of class weights generated on-the-fly, DCQ enables efficient training on massive scales while improving performance for underrepresented identities.

The Bottlenecks of Large-Scale Recognition

In standard face recognition pipelines, each identity is treated as a distinct class. This approach leads to two primary bottlenecks:

  1. Hardware Constraints: The final Fully Connected (FC) layer's size scales linearly with the number of identities. For datasets containing millions of people, the memory requirements for this single layer can exceed the capacity of high-end GPUs.
  2. The Long-Tail Problem: Real-world data is typically long-tailed; while a few "head" classes have thousands of images, the vast majority of "tail" classes have fewer than ten. During standard training, the overwhelming gradients from head classes cause the weights of tail classes to fluctuate wildly, preventing the model from learning stable, representative features for the majority of identities.

The Dynamic Class Queue (DCQ) Framework

To solve these issues, the authors propose the Dynamic Class Queue (DCQ). Instead of maintaining a static weight matrix for every class in the dataset, DCQ utilizes a dynamic subset of classes stored in a first-in, first-out (FIFO) queue.

Comparison between traditional FC-based training and the proposed DCQ-based framework.

As illustrated in the comparison above, DCQ shifts from using all classes in every iteration to using a small subset (e.g., 10%). Furthermore, it replaces standard Stochastic Gradient Descent (SGD) updates for class weights with a feedforward generation mechanism. This allows the model to focus on a manageable number of active classes at any given time, drastically reducing memory consumption.

System Architecture and Momentum Updates

The core innovation of DCQ lies in its Weight Generator. For a specific identity, the generator takes a "reference image" and produces a weight vector. This effectively transforms the large-scale classification task into a few-shot learning problem integrated directly into the training loop.

Detailed architecture of the DCQ training pipeline, showing the weight generation process.

To ensure consistency, the system employs a Momentum Update strategy. Because the model's feature extractor evolves during training, weights generated early in the queue could become incompatible with later features. To prevent this "feature drift," the weight generator is updated as a moving average of the feature extractor's parameters. This ensures that the generated class proxies remain synchronized with the current state of the model.

Experimental Evaluation

The authors evaluated DCQ on two major benchmarks: the balanced MS1MV2 (85K identities) and the massive, long-tailed MegaFace Challenge 2 (MF2) (672K identities).

Key Results:

  • Memory Efficiency: On the MF2 dataset, DCQ reduced GPU memory consumption from 18.6 GB to 8.4 GB compared to a standard CosFace baseline, while maintaining or improving training speed.
  • Long-Tail Performance: DCQ demonstrated superior accuracy on the long-tailed MF2 benchmark, outperforming CosFace by 0.75% in identification and 1.72% in verification. This success is attributed to the weight generator's ability to create robust class proxies even from a single image, bypassing the gradient imbalance that plagues tail classes in traditional FC layers.
  • General Robustness: On balanced datasets like MS1MV2, DCQ achieved performance parity with state-of-the-art methods like ArcFace and Partial FC, proving its effectiveness as a general-purpose framework.

Conclusion

The Dynamic Class Queue represents a significant step forward in making large-scale face recognition more accessible and accurate. By moving away from static, massive classification layers toward dynamic, instance-based weight generation, DCQ effectively handles the hardware and distributional challenges of "in-the-wild" data. Future work may involve exploring more complex meta-learning functions for weight generation to further enhance the model's representational power.

Summary updated

BibTeX
@inproceedings{li2021dynamic,
  author = {Bi Li and Teng Xi and Gang Zhang and Haocheng Feng and Junyu Han and Jingtuo Liu and Errui Ding and Wenyu Liu},
  title = {{Dynamic Class Queue for Large Scale Face Recognition in the Wild}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2021},
  doi = {10.1109/cvpr46437.2021.00376},
}
Figure