Back to paper library
ACM Multimedia 2024Face anti-spoofingPaper notes

FM-CLIP

Guidance from Language

Original paper

FM-CLIP: Flexible Modal CLIP for Face Anti-Spoofing

Paper authors

Ajian Liu · Hui Ma · Junze Zheng …

Show all 9 authors

Ajian Liu · Hui Ma · Junze Zheng · Haocheng Yuan · Xiaoyuan Yu · Yanyan Liang · Sergio Escalera · Jun Wan · Zhen Lei

Publication
ACM Multimedia 2024Conference
Cite this paper · BibTeX

The citation identifies the linked source version. It cites the original paper and its authors.

@inproceedings{faceantispoofingfmclip2024,
  title = {{FM-CLIP: Flexible Modal CLIP for Face Anti-Spoofing}},
  author = {Ajian Liu and Hui Ma and Junze Zheng and Haocheng Yuan and Xiaoyuan Yu and Yanyan Liang and Sergio Escalera and Jun Wan and Zhen Lei},
  year = {2024},
  booktitle = {ACM Multimedia},
  url = {https://doi.org/10.1145/3664647.3680856},
  doi = {10.1145/3664647.3680856}
}
On this page

In the field of Face Anti-Spoofing (FAS), the term "multimodal" typically refers to different sensors such as RGB, depth, and infrared.

However, in recent years, another kind of "modality" has become popular: natural language.

Problem Definition

The original battlefield of Face Anti-Spoofing (FAS) is the image itself.

Researchers designed convolutional networks to extract features like texture, depth, and reflectance to distinguish between genuine and fake faces.

However, as attack methods evolve—such as high-resolution printing, replay attacks, and 3D masks—the defense relying on a single modality has gradually fractured.

To cope with this escalation, the FAS community introduced multimodal fusion. RGB captures color, IR records infrared light, Depth measures structure; by interleaving signals from different sensors, they attempt to piece together a more realistic picture.

Yet this approach has its cracks.

Many fusion models depend on having all modalities available during both training and testing. Once sensor data is missing, recognition can deteriorate sharply; some architectures cannot run without adapting their input path. Hardware costs for deployment and variable scene conditions make "modality consistency" a luxury.

The concept of Flexible Modal emerged in response.

Its goal is to design a model that learns multimodal features during training but does not rely on the presence of all modalities during testing. However, past research on Flexible Modal still focused on traditional modalities such as spectral, thermal, or geometric signals.

The rise of natural language offers another possibility.

Language does not directly capture the world's light and shape; instead, it describes, interprets, and aligns experiences.

It provides an alignment mechanism beyond the sensor level, enabling heterogeneous observations to find commonality at the semantic level.

Perhaps, through natural language as a bridge, we can reconstruct the cognition of authenticity within the gaps of these fragmented modalities.

Solution

Model Architecture

The authors propose FM-CLIP, a multimodal alignment model based on CLIP, specifically designed for Face Anti-Spoofing (FAS).

The CLIP image and text encoders are frozen; the visual CMSE adapters and text prompt context vectors are trained. In Figure 2, first follow the two upper branches, then locate the adapters inside the ViT blocks at lower left. Cross-sensor interaction occurs during training; only one sensor is required at test time.

As shown in the figure above, FM-CLIP can be divided into two main branches:

  • Visual branch: Uses paired RGB, Depth, and IR data during training; CMS-Enhancer inside the ViT reinforces spoofing cues.
  • Language branch: Learns prompts for real/fake text features, used in both CLS and patch classification supervision.

Next, we examine each component in the order of signal flow.

CMS-Enhancer

ViT can combine global information, but it has no explicit convolutional path for local textures or frequency cues. Such cues may help with print and replay attacks.

The authors therefore insert trainable CMSE adapters into ViT blocks. Their core module is the Cross-Modal Spoofing Enhancer (CMS-Enhancer).

The input features are decomposed into two parallel streams:

  • Spatial Features: Fine-grained texture extraction by the Spatial Extractor (SE).
  • Frequency features: The Frequency Extractor (FE) applies a DCT to input features and produces gating weights. It does not reconstruct a directly interpretable image.

The Spatial Extractor (SE) operates as:

FSE_output(j)=Conv1(GELU(Conv3(GELU(Conv1(Finput(j))))))F_{\text{SE\_output}}^{(j)} = \text{Conv1}(\text{GELU}(\text{Conv3}(\text{GELU}(\text{Conv1}(F_{\text{input}}^{(j)})))))

This is a simple convolutional structure with GELU activation to obtain local image features.

A residual connection is added:

F^spatial(j)=FSE_output(j)⊕Finput(j)\hat{F}_{\text{spatial}}^{(j)} = F_{\text{SE\_output}}^{(j)} \oplus F_{\text{input}}^{(j)}

The Frequency Extractor (FE) is defined as:

FFE_output(j)=σ(Conv1(GELU(Conv1(DCT(Finput(j))))))F_{\text{FE\_output}}^{(j)} = \sigma(\text{Conv1}(\text{GELU}(\text{Conv1}(\text{DCT}(F_{\text{input}}^{(j)})))))

The DCT acts on the input features, followed by convolution, GELU, and sigmoid to produce weights. The spatial branch examines local neighborhoods; the frequency branch uses frequency information to decide which input features to emphasize or suppress.

The weights are multiplied element-wise with the input features:

F^frequency(j)=FFE_output(j)⊗Finput(j)\hat{F}_{\text{frequency}}^{(j)} = F_{\text{FE\_output}}^{(j)} \otimes F_{\text{input}}^{(j)}

Cross-Modal Interactor

Different sensor images can look very different. The authors hypothesize that their frequency representations still contain shared spoofing cues. The Cross-Modal Interactor (CMI) lets paired modalities exchange information during training; Figure 2 illustrates RGB and Depth.

  • A gate map controls how much of each modality's frequency feature passes through.
  • Its inverse, 1−M1-M, weights features borrowed from the other modality. These are learned weights, not human-verified maps of information density.

Gate maps are computed as:

Mfreq.RGB=σ(Conv3(Ffreq.RGB))M_{\text{freq.RGB}} = \sigma(\text{Conv3}(F_{\text{freq.RGB}})) Mfreq.Depth=σ(Conv3(Ffreq.Depth))M_{\text{freq.Depth}} = \sigma(\text{Conv3}(F_{\text{freq.Depth}}))

Sigmoid puts gate values between 0 and 1. Figure 2 applies the gate to the current modality and its inverse to the other; the result controls feature flow, not a direct pixel-level real/fake judgment.

The interaction and supplementation process is:

eFfreq.RGB-Depth=(1−Mfreq.RGB)⊗eFfreq.DeptheF_{\text{freq.RGB-Depth}} = (1 - M_{\text{freq.RGB}}) \otimes eF_{\text{freq.Depth}} eFfreq.Depth-RGB=(1−Mfreq.Depth)⊗eFfreq.RGBeF_{\text{freq.Depth-RGB}} = (1 - M_{\text{freq.Depth}}) \otimes eF_{\text{freq.RGB}}

For RGB, a lower gate value gives the enhanced Depth features more weight through 1−Mfreq.RGB1-M_{\text{freq.RGB}}; the other direction works the same way.

Finally, the original features, enhanced features, and supplemented features are fused:

FEfreq.RGB=Ffreq.RGB⊕eFfreq.RGB⊕eFfreq.RGB-DepthF_{E_\text{freq.RGB}} = F_{\text{freq.RGB}} \oplus eF_{\text{freq.RGB}} \oplus eF_{\text{freq.RGB-Depth}} FEfreq.Depth=Ffreq.Depth⊕eFfreq.Depth⊕eFfreq.Depth-RGBF_{E_\text{freq.Depth}} = F_{\text{freq.Depth}} \oplus eF_{\text{freq.Depth}} \oplus eF_{\text{freq.Depth-RGB}}

These are then combined with the corresponding spatial features to form enhanced representations.

During training, the visual branch keeps each modality's spatial clues and can draw on another modality's frequency features. At single-modal test time, it does not conjure up readings from a missing sensor.

Language-Guided Patch Alignment

After processing visual signals, the authors introduce the natural language modality to further guide each patch to focus on spoofing cues.

In the text branch, prompt learning trains context vectors v={v1,v2,...,vM}\mathbf{v} = \{v_1, v_2, ..., v_M\} followed by a real/fake class token cic_i:

ti={v1,v2,...,vM,ci}t_i = \{v_1, v_2, ..., v_M, c_i\}

The technique itself is not the paper's invention. Learnable prompts reuse CLIP without hand-tuning a sentence for every case, although the learned tokens are hard to translate into ordinary language.

After passing through the text encoder g(⋅)g(\cdot), text features ftextf_{\text{text}} are obtained.

From the visual branch, we have the CLS token fimg(0)f_{\text{img}}^{(0)} and Patch tokens fimg(1 N)f_{\text{img}}^{(1\:N)}.

The authors adopt dual alignment:

  1. CLS token alignment: Compute cosine similarity between the image CLS token and real/fake text features for global classification.
  2. Patch Token Alignment (LGPA): Calculate similarity matrix between each Patch token and text features:
S=fimg(1:N)⋅(ftext)TS = f_{\text{img}}^{(1:N)} \cdot (f_{\text{text}})^T

Then perform weighted fusion:

f^img(1:N)=softmax(S)⋅ftext+fimg(1:N)\hat{f}_{\text{img}}^{(1:N)} = \text{softmax}(S) \cdot f_{\text{text}} + f_{\text{img}}^{(1:N)}

Each row of SS refers to a patch and each column to a text class. Softmax weights determine how much of each text feature is added to a patch; the resulting patch probabilities are averaged for classification. This supplies local supervision, not a validated spoof-region map.

Loss Function Design

To supervise both global and local alignment, the authors introduce two loss terms:

  • CLS Loss (Global Alignment):

    LC=CrossEntropy(pcls_token,y)L_C = \text{CrossEntropy}(p_{\text{cls\_token}}, y)
  • Patch Loss (Local Alignment):

    LP=CrossEntropy(ppatch_token,y)L_P = \text{CrossEntropy}(p_{\text{patch\_token}}, y)

The total loss is:

Ltotal=LC+LPL_{\text{total}} = L_C + L_P

Both the global CLS token and local patches receive real/fake supervision. The losses are added so the decision does not rely solely on one global vector.

Discussion

The authors evaluated their method on three commonly used multimodal FAS datasets:

  • CASIA-SURF (SURF): RGB, Depth, and IR data.
  • CASIA-SURF CeFA (CeFA): Covers different demographic, modality, and attack conditions; the paper uses Protocols 1, 2, and 4.
  • WMCA: Covers multiple physical presentation attacks with seen and unseen attack protocols.

Experiments were conducted under two testing settings:

  • Fixed modal: Test inputs match the modalities expected by the training setup.
  • Flexible modal: Training uses paired RGB/Depth/IR samples; testing supplies only one of these modalities.

APCER measures accepted attacks, BPCER rejected bona fide faces, and ACER averages the two; lower is better. Comparisons must keep the dataset, protocol, input modality, and training setup in view.

Fixed Modal Results

Start with SURF in Table 1; fixed-modal WMCA and CeFA results are in Tables 2 and 3 of the paper.

Look at the last three rows: within the ViT/FM-ViT family, the added modules slightly lower SURF ACER. But VisionLabs reaches 0.08% in the first group of rows, so FM-CLIP's 0.43% is not the best result in this table.

  • SURF (Table 1): FM-ViT scores 0.45%, CMS-Enhancer 0.44%, and FM-CLIP 0.43%. Each step changes the last column by only 0.01 percentage points.
  • WMCA dataset (unseen protocol): Table 2 reports mean ACER of 2.49±4.37% for FM-ViT, 2.36±4.08% for CMS-Enhancer, and 2.29±4.00% for FM-CLIP across seven unseen attack categories. The standard deviations show substantial variation among attacks.
  • CeFA dataset: In Table 3, ACER changes from 0.98% to 0.95% on Protocol 1 and 0.90% to 0.87% on Protocol 4. Protocol 2 lists 0.30% for both models, but those ACER values do not equal the average of the APCER and BPCER values in the same rows. Treat that row cautiously; not every metric improves on every protocol.

On WMCA seen attacks, FM-CLIP's ACER of 1.05% is slightly higher than FM-ViT's 1.00%. Table 9 reports fewer trainable parameters, 5.34M versus 22.77M, but higher FLOPs, 26.51G versus 3.85G. Parameter count alone cannot explain the error difference or establish cheaper inference.

Flexible Modal Results

The middle section, “Flexible modal testing,” is the main test of the paper's claim. R, D, and I stand for RGB, Depth, and IR. “R&D&I” in the training column means paired tri-modal data, whereas each test row uses one modality.

In the more challenging flexible modal tests, FM-CLIP exhibits clear advantages.

  • SURF: Against FM-ViT trained on the same three modalities, RGB ACER changes from 12.38% to 10.21%, Depth from 3.49% to 3.02%, and IR from 2.59% to 2.01%. The largest gain is 2.17 percentage points on RGB. An RGB error rate of 10.21% is still consequential.
  • CeFA Protocol 4: RGB changes from 21.06±4.90% to 11.87±3.14%, a 9.19-point gain. IR changes from 2.88±2.23% to 2.07±1.36%, a 0.81-point gain. Depth slightly worsens from 2.25±0.36% to 2.29±0.68%. The large RGB gain should not be attributed to IR.
  • WMCA (seen protocol): RGB, Depth, and IR ACER fall from 2.87/2.32/2.13% with FM-ViT to 1.68/1.92/1.70%. These rows support single-modal improvements under this protocol, not automatic compatibility with any new sensor.

Core Components Analysis

Ablation studies on FM-CLIP’s two main modules—CMS-Enhancer and VLA (Vision-Language Alignment)—were conducted on WMCA (seen), SURF, and CeFA (Protocol 4) datasets under the flexible modal setting.

The three columns summarize ACER by dataset; they are not the single-modal rows of Table 4. On SURF, for example, the baseline is 9.78%, CMS-Enhancer alone 5.24%, VLA alone 5.58%, and both together 1.47%. Specifically:

  • CMS-Enhancer alone lowers WMCA/SURF/CeFA ACER by 1.07/4.54/5.32 percentage points.
  • VLA alone lowers them by 1.27/4.20/4.73 points. VLA includes both text prompting and LGPA, so this result cannot be credited solely to patch alignment.
  • Both together lower them by 1.39/8.31/8.85 points. The combined effect is strongest on SURF and CeFA; WMCA sees a smaller additional gain. This ablation does not explain every individual error it corrects.

Conclusion

Introducing Vision-Language Models (VLMs) into the FAS domain has become a popular trend in recent years.

Given the heterogeneity of data sources and diversity of attack types, relying solely on single sensors or handcrafted features is increasingly inadequate for maintaining stable recognition systems. Natural language, as a high-level alignment mechanism, offers potential links across sensors and attack modes, making it a promising direction many researchers are exploring.

From this study, two key directions emerge:

  1. When physical-layer observations inevitably fragment, semantic-level alignment and repair may become an important pillar of recognition systems.
  2. Pure language guidance alone is insufficient to fully replace sensor-level information enhancement; frequency domain, local structures, and semantic relations still need to be tightly integrated.

FM-CLIP demonstrates the potential of cross-modal alignment with fewer trainable parameters, leaving room for further exploration in deeper structural modeling and active perceptual repair. Its higher FLOPs in Table 9 mean the actual deployment cost still needs separate evaluation.