FSFM: A Generalizable Face Security Foundation Model via Self-Supervised Facial Representation Learning

Gaojian Wang, Feng Lin, Tong Wu, Zhenguang Liu, Zhongjie Ba, Kui Ren

Abstract

Face security tasks, such as deepfake detection and anti-spoofing, currently rely on specialized models that often overfit to specific datasets and fail to generalize to unseen attacks. We present FSFM (Face Security Foundation Model), a self-supervised framework designed to learn robust facial representations from large-scale unlabeled data. By integrating a novel Covering a Random Facial Region followed by Proportional (CRFR-P) masking strategy with local-to-global self-distillation, FSFM captures both fine-grained textural consistency and structural coherency. Pretrained on 3.3 million face images, FSFM serves as a universal backbone that achieves state-of-the-art performance across multiple security benchmarks, demonstrating superior cross-dataset generalization compared to traditional supervised and general-purpose vision models.

Introduction

The landscape of face security is fragmented, with researchers typically developing isolated models for Deepfake Detection (DfD), Face Anti-Spoofing (FAS), and Diffusion Facial Forgery (DiFF). These models, often trained under full supervision on narrow datasets, struggle with domain shift and novel forgery techniques. There is a critical need for a "Foundation Model" for face security—one that understands the fundamental structural and textural "realness" of human faces through large-scale self-supervised pretraining. While general-purpose models like those trained on ImageNet exist, they lack the fine-grained sensitivity required to detect subtle security cues. FSFM addresses this gap by learning a task-agnostic representation of real faces.

Methodology

FSFM utilizes a "3C" learning strategy: Consistency, Coherency, and Correspondence.

CRFR-P Masking

Unlike standard random masking in Masked Image Modeling (MIM), FSFM introduces CRFR-P masking. This approach explicitly masks an entire facial component (e.g., the nose) to force the model to learn inter-region Coherency by inferring missing parts from surrounding features. Simultaneously, it applies proportional masking across other regions to enforce intra-region Consistency, capturing fine-grained skin and hair textures.

The FSFM framework overview, illustrating the integration of CRFR-P masking, Masked Image Modeling, and Instance Discrimination.

Instance Discrimination

To complement local reconstruction, FSFM employs a Siamese network architecture consisting of an "online" and a "target" encoder. The online view is masked, while the target view remains full. By aligning masked local features with global unmasked semantics, the model learns local-to-global Correspondence.

Comparison of different masking strategies, highlighting the unique approach of CRFR-P in FSFM compared to random or region-only masking.

Architecture

The framework utilizes a vanilla Vision Transformer (ViT-B/16) as the backbone. After pretraining on the VGGFace2 dataset (3.3M images), the ViT can be fine-tuned for specific security tasks with minimal labeled data. This approach avoids "forgery augmentation" (simulating deepfakes during training), which prevents the model from becoming blind to unseen forgery techniques.

Results and Evaluation

FSFM was evaluated across 10 public datasets covering DfD, FAS, and DiFF, demonstrating significant improvements in cross-dataset generalization.

  • Deepfake Detection: On the CelebDF-v2 dataset (cross-dataset testing from FF++), FSFM achieved a 91.44% AUC (video-level), outperforming specialized SOTA methods and significantly beating ImageNet-pretrained models.
  • Face Anti-Spoofing: In cross-domain "leave-one-out" tests, FSFM reached an average HTER of 4.81%, a marked improvement over standard ViT baselines which ranged from 6.5% to 24%.
  • Diffusion Forgery: The model demonstrated high robustness against unseen diffusion-based forgeries, where traditional detectors often fail due to severe overfitting to GAN-based patterns.

Conclusion

FSFM demonstrates that learning a "realness" representation solely from unlabeled real faces provides a powerful defense against diverse forgery attacks. By combining MIM and self-distillation, the model captures the essential synergy between texture and structure. While the model currently relies on an external face parser and focuses on static image features, future work will explore scaling to larger datasets and incorporating temporal modeling to address video-specific inconsistencies.

Summary updated

BibTeX
@inproceedings{wang2025fsfm,
  author = {Gaojian Wang and Feng Lin and Tong Wu and Zhenguang Liu and Zhongjie Ba and Kui Ren},
  title = {{FSFM: A Generalizable Face Security Foundation Model via Self-Supervised Facial Representation Learning}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.02269},
}
Figure