Back to paper library
arXiv 2020CVPR 2020Face anti-spoofingPaper notes

CDCN

Between Truth and Falsehood

Original paper

Searching Central Difference Convolutional Networks for Face Anti-Spoofing

Paper authors

Zitong Yu · Chenxu Zhao · Zezheng Wang …

Show all 8 authors

Zitong Yu · Chenxu Zhao · Zezheng Wang · Yunxiao Qin · Zhuo Su · Xiaobai Li · Feng Zhou · Guoying Zhao

Publication
CVPR 2020Conference
First submitted to arXiv
arXiv:2003.04092
Cite this paper · BibTeX

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

@misc{faceantispoofingcdcn2020,
  title = {{Searching Central Difference Convolutional Networks for Face Anti-Spoofing}},
  author = {Zitong Yu and Chenxu Zhao and Zezheng Wang and Yunxiao Qin and Zhuo Su and Xiaobai Li and Feng Zhou and Guoying Zhao},
  year = {2020},
  eprint = {2003.04092},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2003.04092}
}
On this page

People tend to believe that as long as the model is deep enough and data is abundant, the system can naturally distinguish between "real" and "fake."

But perhaps we have overlooked a more fundamental problem.

This time, let's look at a very famous classic paper: CDCN.

Problem Definition

In an era where face recognition has become the standard, Face Anti-Spoofing (FAS) gradually turns into a critical checkpoint in identity verification workflows. Attack methods have evolved from high-resolution printing, video replay, to sophisticated 3D masks, and continue to emerge.

Facing such opponents, the technical community once pinned hopes on handcrafted features: local descriptors like LBP, DoG, HOG, SIFT, which once captured subtle patterns, noise, and printing residuals hard for the human eye to detect.

Unfortunately, these methods are sensitive to scene changes and lack robustness, failing to meet modern application demands.

Thus, we turned to deep learning, entrusting Convolutional Neural Networks (CNNs) to discriminate the boundary between real and fake.

But CNN’s strength is also its blind spot.

Deep architectures excel at abstract semantics but can weaken low-level details if the design does not preserve them, especially those lattice textures, moiré patterns, or reflective edges only visible under specific lighting and angles. When the environment shifts slightly or the camera changes, these models not only fail to generalize but may even mistake background textures or screen borders for live features.

To compensate for the semantic gap, some began introducing depth maps as auxiliary supervision signals, aiming to teach the model finer spatial perception. However, most of these architectures remain expert-designed and rely on classification backbones (e.g., ResNet, VGG, DenseNet) not originally created for FAS, so their generalization remains limited.

The problem boils down to a fundamental point: if the convolution itself is insensitive to details, higher-level designs cannot compensate for its visual foundation’s distortion.

Could convolution itself be the unopened door?

Solution

Before we start, let's review how convolution operates.

We know standard 2D convolution can be written as:

y(p0)=∑pn∈Rw(pn)⋅x(p0+pn)y(p_0) = \sum_{p_n \in R} w(p_n) \cdot x(p_0 + p_n)

where p0p_0 identifies the output position and its corresponding input center, and RR is the receptive field (e.g., 3×3).

This "local weighted sum" approach has become the cornerstone of vision tasks but proves insufficient against attacks, because those extremely subtle spoof traces often don't exist in pixel intensity alone, but hide in the differences between pixels.

Central Difference Convolution (CDC)

Inspired by LBP, the authors introduced "central difference" into convolution, so each computation includes a "variation amount":

y(p0)=∑pn∈Rw(pn)⋅(x(p0+pn)−x(p0))y(p_0) = \sum_{p_n \in R} w(p_n) \cdot \bigl(x(p_0 + p_n) - x(p_0)\bigr)

Compared with traditional convolution, the focus here is no longer on the "magnitude of the value" but on "how much it differs from the center."

Just like detecting fine lines or protrusions, what matters more might be the "edges," not the "overall brightness."

However, pure central difference sometimes loses the absolute information of the image itself.

So the authors further proposed a hybrid form:

y(p0)=θ∑pn∈Rw(pn)⋅(x(p0+pn)−x(p0))  +  (1−θ)∑pn∈Rw(pn)⋅x(p0+pn)y(p_0) = \theta \sum_{p_n \in R} w(p_n) \cdot \bigl(x(p_0 + p_n) - x(p_0)\bigr) \;+\; (1 - \theta) \sum_{p_n \in R} w(p_n) \cdot x(p_0 + p_n)

where θ∈[0,1]\theta \in [0,1] is a balancing coefficient:

  • When θ=0\theta=0, it reverts to the original convolution;
  • When θ=1\theta=1, it focuses entirely on the difference term.

The authors named this mixed operation CDC (Central Difference Convolution), which preserves both "intensity" and "difference" information sources.

For practical implementation, it can be rearranged as:

y(p0)=∑pn∈Rw(pn)⋅x(p0+pn)  −  θ⋅x(p0)∑pn∈Rw(pn)y(p_0) = \sum_{p_n \in R} w(p_n) \cdot x(p_0 + p_n) \;-\;\theta \cdot x(p_0) \sum_{p_n \in R} w(p_n)

Thus, in common deep learning frameworks (PyTorch, TensorFlow), CDC can be integrated into networks with just a few lines of code, without adding extra parameters.

Here is an educational implementation. To align the sampled centers of the two branches, it requires odd kernels and centered zero padding, such as kernel_size=3, padding=1; it is not a replacement for every possible Conv2d configuration:

python
import torch.nn as nn
import torch.nn.functional as F


class Conv2dCD(nn.Module):
    """CDC for odd kernels with centered, zero-padded sampling."""

    def __init__(self, *, theta=0.7, bias=False, **conv_kwargs):
        super().__init__()
        if not 0 <= theta <= 1:
            raise ValueError("theta must be between 0 and 1")
        self.theta = theta
        self.conv = nn.Conv2d(bias=bias, **conv_kwargs)
        expected_padding = tuple(
            d * (k - 1) // 2
            for k, d in zip(self.conv.kernel_size, self.conv.dilation)
        )
        if (any(k % 2 == 0 for k in self.conv.kernel_size)
                or self.conv.padding != expected_padding
                or self.conv.padding_mode != "zeros"):
            raise ValueError("Use an odd kernel with centered zero padding")

    def forward(self, x):
        out = self.conv(x)
        if self.theta == 0:
            return out
        # Same sampled centers and output shape as the regular convolution.
        kernel_sum = self.conv.weight.sum(dim=(2, 3), keepdim=True)
        difference = F.conv2d(
            x, kernel_sum, stride=self.conv.stride, groups=self.conv.groups
        )
        return out - self.theta * difference

CDC Networks

Previous studies mostly attempted to use depth maps as auxiliary supervision signals, strengthening live detection through pixel-level contrast.

The authors followed this idea by building a network backbone based on DepthNet, replacing all convolutions with CDC to form Central Difference Convolutional Networks (CDCN).

  • Network Input/Output:

    • Input: single-frame RGB face image (3×256×256).
    • Output: predicted grayscale depth map (32×32).
  • Feature Fusion: low-, mid-, and high-level features are concatenated to enhance capturing facial texture and spatial structure.

  • Hyperparameter: θ=0.7\theta=0.7 is set in experiments, emphasizing difference signals while retaining some original intensity information.

For the loss function, to supervise spoof traces more finely, two losses are introduced:

  1. MSE loss LMSEL_{\text{MSE}}: measures mean squared error between the prediction and the supervisory pseudo-depth map.
  2. Contrastive Depth Loss LCDLL_{\text{CDL}}: assists in capturing finer depth differences, enabling the model to distinguish real facial edge contours from fake textures caused by printing.

The overall loss is:

Loverall=LMSE+LCDL.L_{\text{overall}} = L_{\text{MSE}} + L_{\text{CDL}}.

CDCN++

However, the overall CDCN architecture is still manually designed and may not be optimal for the task.

Therefore, the authors combined Neural Architecture Search (NAS) to find an architecture suited to FAS within a specified search space and data setting, resulting in an advanced version: CDCN++, shown above.

Traditionally, NAS is used for image classification or detection; here it is introduced for depth-supervised FAS tasks. Through bi-level optimization, weights and architecture parameters are alternately tuned on training and validation sets, as illustrated below:

The search space is divided into multiple cells, each containing candidate operations such as skip-connect, CDC with different channel expansion ratios, or none. A node attention strategy learns weights for intermediate node outputs.

The result is a backbone selected under this search setting, not a guaranteed global optimum over all possible architectures.

Multiscale Attention Fusion Module

Even with a NAS-discovered backbone, simply concatenating low-, mid-, and high-level features may still overlook which spatial regions deserve more focus.

To address this, the authors introduced the Multiscale Attention Fusion Module (MAFM):

Fi′=Fi  ⊙  [σ(Ci([A(Fi), M(Fi)]))],i∈{low, mid, high},F'_i = F_i \;\odot\; \Bigl[\sigma\Bigl(C_i\bigl(\bigl[\mathrm{A}(F_i),\,\mathrm{M}(F_i)\bigr]\bigr)\Bigr)\Bigr] ,\quad i \in \{\text{low},\,\text{mid},\,\text{high}\},

where ⊙\odot denotes Hadamard (element-wise) multiplication, A\mathrm{A} and M\mathrm{M} represent average and max pooling along the channel axis, preserving spatial dimensions, σ\sigma is the sigmoid function, and CiC_i is an ordinary convolution with 7×7, 5×5, or 3×3 kernels for the low-, mid-, and high-level features, respectively.

In summary, CDCN++ integrates central difference convolution + NAS-discovered backbone + multiscale attention fusion, driven by depth supervision, achieving both high accuracy and strong generalization.

Discussion

The authors evaluated their method on six public datasets, including high-resolution sets (OULU-NPU, SiW) and low-resolution ones (CASIA-MFSD, Replay-Attack, MSU-MFSD), as well as cross-testing with unknown attack types on SiW-M.

Depending on the dataset and scenario, metrics such as ACER, HTER, AUC, and EER were used to assess model recognition performance and generalization ability in unseen environments.

During training, PyTorch was used with Adam optimizer. PRNet produces pseudo-depth maps for genuine faces, normalized to [0,1], while attack targets are set to zero. These are classification-oriented supervision targets, not a claim that 3D masks have no physical depth. The model outputs depth predictions for single frames, whose mean is taken as the final classification score. Unless otherwise specified, all experiments kept θ=0.7\theta=0.7 as the CDC default setting.

Impact of CDC Parameter

  1. Importance of θ\theta

    As shown in figure (a), the relationship between θ\theta and model performance is nonlinear. On OULU-NPU Protocol-1, ACER is 3.8% at θ=0\theta=0 and 3.6% at θ=0.3\theta=0.3; increasing the difference weight does not continually improve the result.

    The best performance occurs at θ=0.7\theta=0.7, with ACER as low as 1.0%. This experiment covers changes in lighting and scene, and supports moderate weighting of central difference for recognizing subtle textures. The figure does not isolate changes in camera device.

  2. Comparison with other convolution operations

    In the same Protocol-1 setting, figure (b) reports 1.0% ACER for CDC, below Local Binary Convolution at 3.2% and Gabor Convolution at 5.3%. LBConv is also slightly better than ordinary convolution at 3.8%. These results support using local difference information for this anti-spoofing task.

Contributions of NAS and MAFM

In this NAS ablation, enabling both varied cells and node attention reduces test ACER from the 1.7% baseline to 1.3%.

The authors' design lets the low-, mid-, and high-level cells search for their own structures, then weights intermediate nodes at the output with node attention. The ablation supports the two design choices under this setting.

Directly fusing the searched backbone features across multiple levels already surpasses the baseline without NAS, yet still leaves room for improvement, as shown below:

Further adding MAFM with ordinary 7×7, 5×5, and 3×3 convolutions reduces ACER from 0.7% to 0.2%, a decrease of 0.5 percentage points. Replacing these with three 3×3 CDC kernels raises ACER to 1.2% in the same table.

Performance on OULU-NPU

Results on OULU-NPU show CDCN++ achieves the lowest ACER across four protocols (min 0.2%, max 5.0%) and outperforms the compared earlier methods on SiW. However, on SiW Protocol 3, CDCN at 1.71% still outperforms CDCN++ at 1.90%; the upgraded version is not better in every setting.

Compared to advanced methods requiring multi-frame dynamic features (e.g., STASN, Auxiliary), CDCN++ attains or surpasses top performance with single-frame inputs, highlighting its potential for real-time deployment.

Cross-Dataset Generalization

When facing unseen attack types (13 in SiW-M) and cross-dataset scenarios, the CDC architecture maintains excellent generalization.

For CASIA-MFSD → Replay-Attack, CDCN++ reaches 6.5% HTER, 11 percentage points below FAS-TD at 17.5%. In the reverse direction, however, CDCN++ reaches 29.8%, worse than FAS-TD at 24.0%. Generalization gains are directional, so one result cannot summarize every unseen environment.

Analysis and Visualization

The above shows results from OULU-NPU Protocol-1.

The ordinary convolution model has a lower ACER on the development set, but its error rises markedly on the test set under different lighting and scenes. The gap between the two sets is smaller for the CDC model. These are development and test curves; the figure does not plot training error.

Using t-SNE visualization of features before and after CDC, the authors found CDC yields clearer clustering of genuine and fake face representations, supporting the observation of more distinguishable features in this experiment.

Conclusion

At its core, the paper starts with a strikingly simple hypothesis:

Spoof traces may leave anomalies in local gradients.

That is both a simplification in the design and an intuitive observation.

If a real face has continuous texture and physical depth, a reproduced one may reveal some difference along its edges, textures, or reflections.

What CDC does is draw out those differences and embed them in convolution itself through a controllable, interpretable operation. In that sense, it is a hand-designed bias toward spoof traces: more rudimentary than architectures that explicitly separate latent factors, but also deliberate about what visual evidence the network should attend to.

The impulse to separate useful cues before recognition also appears in later work on feature separation and domain generalization. The methods differ, with their research lineage requiring separate evidence; the engineering question remains familiar.

And CDC is one of the early tools that tried to trace the “shape of difference.”