Rethinking Domain Generalization for Face Anti-spoofing: Separability and Alignment
- Publication
- CVPR 2023Conference
- First submitted to arXiv
- arXiv:2303.13662
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{faceantispoofingsafas2023,
title = {{Rethinking Domain Generalization for Face Anti-spoofing: Separability and Alignment}},
author = {Yiyou Sun and Yaojie Liu and Xiaoming Liu and Yixuan Li and Wen-Sheng Chu},
year = {2023},
eprint = {2303.13662},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2303.13662}
}
For the topic of Face Anti-Spoofing (FAS), we first explored solutions based on Domain Generalization (DG) such as SSDG, and then adaptive DG solutions like D²AM.
So, is DG truly the correct direction?
Defining the Problem
DG indeed works well, but it has its limitations.
First, most of these past methods are built on an idealized premise:
We can learn a feature space that is "domain-invariant."
This sounds beautiful, but in practice, it often cannot hold up.
Limited source domains and variation can lead to overfitting. Changes in devices, resolution, or lighting may then cause misclassification; this is a classification failure, not generative-model hallucination.
The situation can get worse: When data from different domains is forced into the same feature space, the originally well-separated live and spoof data get mixed up.
So, how would the model judge this? Simple—it would learn some irrelevant "false correlations," such as:
"Low resolution means an attack, high resolution means a real person."
But when the domain changes, this correlation doesn’t exist anymore, and the result is disastrous.
Since the domain-invariant path seems unfeasible, let's think of a different direction:
Rather than eliminating domain signals, let's "preserve them" and redesign the feature space.
Solving the Problem
The starting point of SA-FAS is actually quite simple:
We no longer try to eliminate the influence of domains, but instead acknowledge and make good use of these differences, and redesign the feature space.
This space needs to have two core properties:
- Separability: The live/spoof distinction should be clear, and different domains should retain their structure.
- Alignment: For the print and replay attacks studied here, the transition from live to spoof should point in the same direction across domains.
This might seem contradictory: we want separation but also consistency?
In fact, these two are complementary: Separation ensures we are not confused by the domain, and Alignment allows us to classify using a single decision boundary.
Separability
To ensure that data from the same category and domain can "cluster together," SA-FAS employs Supervised Contrastive Learning (SupCon). Each training sample produces two augmented views before the -normalized features are extracted.
The loss function is defined as:
In simple terms:
- Each of images yields two augmented views, giving L2-normalized embeddings. contains other indices with the anchor’s label and domain and excludes itself; the other augmented view supplies a positive.
- Bring these positive samples closer together, and push negative samples farther apart.
- Use the temperature coefficient to control the degree of contrast.
If you've read about contrastive learning, this should seem familiar: Yes, this is essentially the Supervised version of InfoNCE, also known as Multi-positive InfoNCE.
Let’s look at a diagram to get a sense of how these three methods impact the feature space:
- (a) ERM: The schematic allows low source-domain classification loss, while the global boundary may rely on correlations that fail in a new domain. It does not say ERM cannot classify its training data.
- (b) ERM + SupCon: The data has clustered, but the boundary directions for each domain are still messy.
- (c) SA-FAS: Not only is the data separable, but the transformation directions are consistent, and the classification is stable.
Alignment
Having clustering alone is not enough; if each domain has its own boundary direction, it becomes impossible to generalize.
To address this issue, SA-FAS introduces the concept of Invariant Risk Minimization (IRM).
The ideal of IRM is:
There exists a classifier that works for all domains.
The formula is as follows:
For a fixed intermediate representation, optimal classifiers across domains may have no common intersection. Jointly changing representation and classifier also creates a difficult bilevel optimization problem.
Projected Gradient IRM (PG-IRM)
Therefore, the authors propose an improved version: PG-IRM.
The core logic is:
Each domain first finds the best boundary for itself, and then gradually pulls everyone in the same direction.
This turns the problem into:
And an additional "nearness condition" is added to ensure that each cannot be too far from the others:
Where:
- is the set of minimum loss solutions for that domain.
- is an α-neighborhood set: the projected classifier's greatest distance to another domain's optimum is at most times the corresponding distance before projection.
The entire alignment process can be imagined as follows:
- (a) The original IRM tries to directly find , but may have no solution.
- (b) PG-IRM allows each domain to find its own best .
- (c) After a gradient update, is interpolated toward the "farthest" classifier while the feature extractor is also updated.
- (d) In the diagram, the domain hyperplanes nearly coincide after convergence.
α-adjacency is the Key
Why does PG-IRM work, while IRM often fails?
PG-IRM moves domain classifiers closer during optimization, but the paper’s ideal objective remains equivalent to IRM. For , substituting itself into the adjacency constraint gives a nonnegative distance , requiring at an ideal feasible solution. It is not merely a fixed nonzero tolerance at convergence.
This "closeness" concept is called α-adjacency, as shown in the diagram below:
The gray region is the α-adjacency set; the black point is the classifier projected toward the farthest one. Here α is a relative distance-contraction factor, not an absolute distance threshold.
The paper describes this as a projected-gradient update. Separate its ideal optimal-set formulation from finite-step SGD in practice:
- The experiment warms up for 20 epochs and then interpolates with α=0.995; this is the explicit implementation rule.
- Nonempty adjacency sets for arbitrary optimal-set arrangements and arbitrary α, or global convergence of a deep model, do not follow automatically. Classifier alignment is examined empirically.
Finally, we combine these two loss functions to form the total loss of SA-FAS:
Inference averages source-domain classifiers, equivalently averaging their linear scores. The expression is a score, not a calibrated probability; binary decisions still require a threshold:
In the four cross-dataset tests, the model trained this way performs well. The appendix's classifier cosine-similarity results also show the domain classifiers moving closer together.
Discussion
The most common cross-domain evaluation setting is used here: Training on three datasets from four options (CASIA, Idiap Replay, MSU, Oulu) and leaving the one that wasn’t seen during training for testing. For example:
- OCI → M: Train on Oulu, CASIA, Idiap, test on MSU
- OMI → C: Train on Oulu, MSU, Idiap, test on CASIA
- And so on, resulting in four possible directions.
This is essentially a FAS exam, testing who can avoid failure when tested on a set that was never seen during training.
Comparison with Other Methods
Here, the authors compare SA-FAS with other methods to see which performs best.
In Table 1, SA-FAS has the lowest listed HTER in all four directions. OCM→I improves from SSAN-R’s 8.88% to 6.58%, a 2.30-percentage-point or approximately 25.9% relative reduction. Its AUC is nevertheless lower than SSAN-R’s on OCI→M and OMI→C.
This is a historical comparison from the paper, useful for understanding strengths and protocol limits rather than a current leaderboard.
Evaluation Metric Analysis
The authors define two custom metrics:
- : , the angular separation of the two test-domain class centers, not ordinary Euclidean distance.
- : Mean cosine similarity between source classifier normals and test-domain . The equation points from live to spoof; the paper’s adjacent prose reverses this description, so we follow the formula.
Each point represents a training snapshot, with the X-axis showing the metric and the Y-axis showing the AUC score.
Across the four settings, the chart reports correlation coefficients of 0.68 for and 0.46 for . Both are positively associated with AUC, though to different degrees.
- With PG-IRM → ↑ → AUC ↑
- With SupCon → ↑ → AUC ↑
These correlations and ablations support the geometric interpretation without proving causation. Both metrics use test-domain live/spoof labels, so they are retrospective diagnostics, not label-free model-selection criteria for deployment in an unknown domain.
Feature Distribution
The OMI → C visualization uses UMAP as a qualitative view of feature distributions. Lines in a nonlinear projection should not be treated as exact images of the original high-dimensional decision boundaries:
- Each point is a live/spoof sample.
- The color represents the domain, and the dashed line is the classifier boundary.
Observations show:
- The boundary roughly separates live/spoof on the unseen domain (CASIA) in this projection.
- Domains with different resolutions exhibit different distributions, but the classification direction remains consistent.
This illustrates how retaining domain structure can coexist with classification. Original-space test metrics remain necessary to assess unseen-domain error.
Comparison with DANN and SSDG
In this visualization, DANN still shows a domain gap, especially between the unseen domain and the training domains.
With SSDG, the spoof transition directions are closer, but the training domains' live samples still show gaps. The authors use this example to motivate classifier-direction constraints, not to prove that SSDG cannot handle any domain gap.
Conclusion
In the past, we always tried to eliminate the influence of domains, like combating some kind of noise.
But SA-FAS offers a more pragmatic direction:
Rather than pretending domains don’t exist, design a feature space that allows them to exist reasonably.
From generalization capability and stability to interpretability, SA-FAS provides strong and convincing answers.