Domain Generalization via Shuffled Style Assembly for Face Anti-Spoofing
- Publication
- CVPR 2022Conference
- First submitted to arXiv
- arXiv:2203.05340
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{faceantispoofingssan2022,
title = {{Domain Generalization via Shuffled Style Assembly for Face Anti-Spoofing}},
author = {Zhuo Wang and Zezheng Wang and Zitong Yu and Weihong Deng and Jiahong Li and Tingting Gao and Zhongyuan Wang},
year = {2022},
eprint = {2203.05340},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2203.05340}
}
Let’s take a look at a famous paper.
This paper introduces the concept of "style," combining it with contrastive learning to emphasize live-related cues. This marks an important breakthrough in style-aware Domain Generalization (DG) design.
Defining the Problem
Face Anti-Spoofing (FAS) has always been in an invisible battle.
Traditional FAS methods rely on handcrafted features, such as LBP and SIFT, to extract texture details from images. In the deep learning era, CNN-based methods have been used to train binary classifiers for distinguishing between live and spoofed faces, incorporating various auxiliary information such as depth maps, reflection maps, and rPPG signals to enrich the recognition cues.
However, even though these methods are stable, they often only perform well under "laboratory conditions."
Once we step out of the boundaries of the original training data, performance drops significantly, especially when faced with different devices, lighting conditions, or spoofing techniques. The model's predictions start to fluctuate and may even result in severe misclassifications.
This phenomenon is known as the Cross-Domain Generalization dilemma, which stems primarily from the following three points:
- Data Bias: Training data has a narrow coverage, unable to encompass all potential variations;
- Feature Overfitting: The model learns surface patterns from a particular domain rather than the essence of liveness;
- Insufficient Model Generalization Design: Most models still follow traditional CNN processes, neglecting subtle differences between samples.
To improve generalization capability, researchers have invested considerable effort into Domain Adaptation (DA) and Domain Generalization (DG):
- DA normally uses target-domain data during training or adaptation. MMD and adversarial alignment are possible tools, but also appear in DG; access to target data is the key distinction.
- DG aims to learn generalizable representations without involving target data, using strategies like feature disentangling and meta-learning.
While these methods have indeed improved model stability under certain settings, they also reveal a deeper issue:
Our understanding of "what constitutes a key feature" is still incomplete.
FAS can be formulated as image classification, but useful signals often reside in texture and reflection details. Video can also carry pulse information; this single-image RGB method does not directly estimate rPPG.
Here, Normalization Layers become a key observation:
- Batch Normalization (BN) focuses on global statistics across samples, reinforcing semantic consistency;
- Instance Normalization (IN), on the other hand, focuses on individual samples, capturing unique patterns and style representations.
BN computes channel statistics over mini-batch and spatial dimensions; IN normalizes spatially within each image and channel. Content and style are architectural roles here, not guarantees that BN intrinsically isolates semantics or IN directly outputs style.
The authors move a prior generate-then-train style-transfer pipeline into feature space, enabling end-to-end learning without separately producing augmented images.
In other words, in the absence of a unified perspective, multi-domain validation, and semantic distinction, we are still in the exploratory phase of "how to make the model learn to ignore unimportant style features and focus on the essence of liveness."
The authors of this paper try to address this core gap:
We already know that style can mislead the model, so is it possible to reverse the approach and make style the key to uncovering spoofing?
The problem of cross-domain generalization is not over, but the issue of style analysis has already quickly emerged.
As one wave settles, another rises.
Solving the Problem
The authors train on several labeled source domains, aiming to recognize live faces in a domain excluded from training while recombining styles in feature space.
The proposed Shuffled Style Assembly Network (SSAN) combines content-domain adversarial learning, style assembly, and contrastive learning in a cross-domain FAS framework.
The core architecture is shown in the figure above, and we can break the entire process down into three stages:
- Feature Disentangling: Decompose the image into content and style
- Style Reassembly: Use AdaIN to self-organize and shuffle combinations
- Contrastive Learning: Compare style semantics with liveness labels to adjust the spatial structure
Dual-Stream Disentangling of Content and Style
The input image first enters the Feature Generator, which extracts low-level semantic and texture information, then feeds it into two branches for further processing:
-
The Content Stream uses Batch Normalization (BN) to extract global semantics and applies a Gradient Reversal Layer (GRL) for adversarial learning, forcing the model to learn domain-invariant representations.
The objective function for adversarial learning is:
- : Content feature generator
- : Domain discriminator
- : Set of domain labels for the data
- GRL reverses gradients, making learn domain-invariant semantic representations.
-
The Style Stream, based on Instance Normalization (IN), extracts style statistics from multi-level feature maps, including brightness, texture, and other style factors. These will play a crucial role in the subsequent reassembly phase.
Style Reassembly and Shuffling
Once the content feature and style feature are obtained, the model performs style reassembly through the Style Assembly Layer (SAL).
The core of SAL comes from Adaptive Instance Normalization (AdaIN):
Here, and are the channel statistics, and are parameters generated from the style input through an MLP.
The overall SAL operation is as follows:
Here, are 3×3 convolution kernels, and the final output is added to the original content residual, preserving the semantic backbone while introducing the style tonalities.
To introduce variability, SSAN designs two combination strategies:
-
Self-Assembly:
Combine the content and style from the same sample to create anchor features.
-
Shuffle-Assembly:
The style comes from another randomly shuffled sample while the content remains from , adding variation from the mixed source domains. The paper describes the random operation as a uniformly chosen permutation; a particular pairing is not guaranteed to cross domains.
Contrastive Learning in Style
As shown in the figure above, SSAN incorporates a contrastive learning mechanism, allowing the model to learn to distinguish in the style space:
- Which style variations are irrelevant to liveness (should be ignored)
- Which style differences contain attack features (should be reinforced)
Specifically:
- The self-assembled feature is the anchor. Stop-gradient fixes its position for this contrastive-loss calculation; classification loss and later parameter updates can still change the feature.
- The shuffled features are used as contrastive samples. Based on whether their labels match, the cosine similarity loss is calculated:
The contrastive loss is then further defined as:
Where:
This loss draws shuffled assemblies with the same live/spoof label toward the self-assembled anchor and pushes those with different labels away. It uses labels from the source domains.
Overall Loss
The final training loss for SSAN is integrated as follows:
The three losses correspond to:
- Classification accuracy
- Content semantic adversarial alignment
- Style space semantic separation
Classification, domain adversarial, and contrastive losses constrain live/spoof prediction, content features, and the assembled features, respectively. Their effects still need to be checked through ablation.
At inference, classification uses the input image's self-assembled content and style features. SSAN-M scores by the mean predicted depth map; SSAN-R uses the sigmoid output for the live class.
Discussion
Comparison with Other Methods
As is customary, this paper also uses the OCIM test to validate the model’s cross-domain generalization ability.
The test uses four datasets: OULU-NPU (O), CASIA-MFSD (C), Replay-Attack (I), and MSU-MFSD (M) for Leave-One-Out cross-validation. The specific strategy is to select three datasets for training and leave one for testing, performing four rounds of testing.
From the table, we can observe:
- SSAN-M's HTER on the first three splits is 10.42%, 16.47%, and 14.00%; on I&C&M → O it is 19.51%, higher than NAS-FAS's 13.80%;
- In some protocols it outperforms earlier methods such as SSDG and CDCN;
- SSAN-M's rank varies across the four settings.
The authors also report that SSAN-R, with a ResNet-18 backbone, beats SSDG-R on HTER and AUC in all four splits. This is a comparison under similar backbones.
Large-Scale Testing
The authors combined twelve public datasets to construct training and testing data, creating a large-scale learning and inference scenario. The datasets used vary in format (images and videos) and cover various attack types. The detailed configurations are shown in the table below:
This benchmark defines two test scenarios:
-
Protocol 1: Intra-Dataset Evaluation
- All twelve datasets contribute training and test data, evaluated using their respective splits.
- Primarily used to simulate model learning ability when data volume is sufficient.
-
Protocol 2: Cross-Dataset Evaluation
- The datasets are split into two groups:
- P1: {D3, D4, D5, D10, D11, D12}
- P2: {D1, D2, D6, D7, D8, D9}
- Sub-protocols are as follows:
- Protocol 2-1: Train on P1, test on P2
- Protocol 2-2: Train on P2, test on P1
Compared to Protocol 1, this setting includes more unseen attacks and scenarios, making it more challenging and closer to real-world application risks.
- The datasets are split into two groups:
Based on the above settings, the experimental results are as follows:
The authors train the compared methods using their listed default settings. At evaluation, they pool all live test samples as negatives and use some attack samples from the current dataset as positives. They calculate true-positive rate (TPR) at specified false-positive rates (FPR); the table reports the mean and variation across datasets.
From the results, we can observe that:
- SSAN-R has the highest mean TPR at all three FPR thresholds in each of the three protocols shown. The table has no model-size or latency measurements;
- Some methods that previously performed well in academic benchmarks showed significant degradation in the large-scale, multi-dataset tests;
- Model rankings change with the protocol and dataset mix. This merged dataset is still an offline evaluation.
The authors stress the need to assess real-world reliability separately from academic performance.
These experiments support higher average TPR for SSAN-R in the tested large-scale protocols. The standard deviations in the table are still wide.
Feature Visualization
To further observe the feature space structure learned by SSAN, the authors use t-SNE to visualize three types of features, corresponding to the three projection maps in the figure above:
-
Content Features: Consistency of Cross-Domain Semantics
Although they come from different datasets and include live and attack samples, the content features appear more compact and points from different sources mix in this t-SNE projection, consistent with the domain-adversarial design.
-
Style Features: Semantic Boundaries of Style Information
The style features show a rough live/spoof boundary in the t-SNE plot. The style branch has no separate classification loss, but receives label-related supervision through the full network. This figure cannot identify whether material, lighting, or reflection produces the boundary.
The picture is consistent with the goal of using contrastive learning to emphasize live/spoof information, but a single projection cannot isolate the contrastive loss's contribution.
-
Stylized Features: The Classification Space of Semantics and Style
Once content and style features are assembled, the stylized features show some live/spoof separation in the projection, along with remaining overlap. Target-domain samples are included, but the projection alone cannot quantify generalization.
Generalization needs to be judged with the preceding HTER, AUC, and TPR@FPR results; these points do not explain individual predictions.
Together, these plots illustrate differences among content, style, and assembled features under one protocol. They help explain the design; complete disentanglement or stability across other domains needs further evidence.
Conclusion
SSAN proposes more than an architecture name. It offers a clear design idea: treat "style" as information that can be manipulated, learned, and even transformed.
This was uncommon in FAS papers at the time. Many designs still focused on aligning domains and smoothing away variation, rather than drawing useful liveness signals out of style.
SSAN turns that approach around:
- It distinguishes content from style and supports that distinction with an architecture;
- It uses Instance Normalization for style extraction alongside Batch Normalization for steadier content features;
- It builds a training process around style assembly and contrastive learning, using style differences to adjust the learned representation;
- It uses a stop-gradient anchor to control the contrastive gradient path. This does not permanently freeze the feature space.
The design may look like a stack of techniques, but it has a consistent logic: to selectively tame style rather than erase it.
More complex approaches to style control and distribution adaptation have since appeared. The design philosophy of this paper still deserves another reading.