Liveness score-based regression neural networks for face anti-spoofing
Previous anti-spoofing methods have used either pseudo maps or user-defined
labels, and the performance of each approach depends on the accuracy of the
third party networks generating pseudo maps and the way in which the users
define the labels. In this paper, we propose a liveness score-based regression
network for overcoming the dependency on third party networks and users. First,
we introduce a new labeling technique, called pseudo-discretized label encoding
for generating discretized labels indicating the amount of information related
to real images. Secondly, we suggest the expected liveness score based on a
regression network for training the difference between the proposed supervision
and the expected liveness score. Finally, extensive experiments were conducted
on four face anti-spoofing benchmarks to verify our proposed method on both
intra-and cross-dataset tests. The experimental results show our approach
outperforms previous methods.
Youngjun Kwak, Minyoung Jung, Hunjae Yoo, JinHo Shin, Changick Kim
# Liveness Score-Based Regression Neural Networks for Face Anti-Spoofing

###### Abstract

Previous anti-spoofing methods have used either pseudo maps or user-defined labels, and the performance of each approach depends on the accuracy of the third party networks generating pseudo maps and the way in which the users define the labels. In this study, we propose a liveness score-based regression network for overcoming the dependency on third party networks and users. First, we introduce a new labeling technique, called pseudo-discretized label encoding for generating discretized labels indicating the amount of information related to real images. Secondly, we suggest the expected liveness score based on a regression network for training the difference between the proposed supervision and the expected liveness score. Finally, extensive experiments were conducted on four face anti-spoofing benchmarks to verify our proposed method on both intra-and cross-dataset tests. The experimental results denote our approach outperforms previous methods.

Machine Learning, ICML, ICML

## 1 Introduction

Face anti-spoofing (FAS) systems have been successfully established in face authentication, and widely used in online banking, electronic payments, and securities as a crucial technique. Despite its substantial success, FAS still shows vulnerability to various presentation attacks (PAs) such as printed materials, replay-videos, and 3D-masks. To alleviate such vulnerability, previous deep learning-based FAS methods (Liu et al., 2018; Yu et al., 2020) learn discriminative features for distinguishing real faces against PAs, and such methods mostly treat the FAS problem as a binary classification of whether a given face is real or a spoof, as shown in Fig. 1(a). However, such binary classification-based approaches suffer from non-trivial attacks because they are prone to an over-fitting to the training data, resulting in poor generalization (Liu et al., 2018). To mitigate the over-fitting problem, regression-based methods (Feng et al., 2018; Bian et al., 2022; Yu et al., 2021, 2020) have been proposed, which find sparse evidence for known spoof types and generalize to unseen attacks. For regression-based neural networks, two approaches are considered: First, pseudo-define based supervision (Jiang and Sun, 2022; Bian et al., 2022; Yu et al., 2021, 2020; Liu et al., 2018; Fang et al., 2021) is designed for context-agnostic discrimination describing the local cues from the pixel level, such as the depth and reflection. For example, a pseudo-map based CNN (Feng et al., 2018) utilizes pseudo-depth supervision using the mean square error (MSE) to reconstruct a sparse depth-map and a flattened-map for a real and spoof image, respectively, as illustrated in Fig. 1(a). And PAL-RW (Fang et al., 2021) is the first approach that utilizes partial pixel-wise labels with face masks to train FAS models. Secondly, user-define based supervision (Jiang and Fangling; Wang et al., 2022) is designed for constrained learning using the relative distances among real and PAs to improve the generalization ability. For instance, ordinal regression (Jiang and Fangling) introduces user-defined ordinal labels. Based on the user-defined labels, the model is trained to finely constrain the relative distances among the features of different spoof categories within the latent space. Another example is PatchNet (Wang et al., 2022), which subdivides binary labels (a real or a spoof) into fine-grained labels (reals or spoofs). Despite previous efforts, we found that the pseudo-define based

Figure 1: Comparison between previous methods and our method for face anti-spoofing. (a) Previous methods utilize either binary supervision to detect spoof cues, or pseudo depth supervision, or both. (b) Our method discretizes binary labels and exchanges real and spoof images for our expected liveness score. The discretized label \(\lambda\) indicates the ratio of a real image over an image.
supervisions depend on the accuracy of additional works (e.g., depth- (Feng et al., 2018) and texture-based (Zhang et al., 2018)), and that user-define based supervision relies on that user-specified guides, and the correctness is not guaranteed. In this paper, as described in Fig. 1(b), we introduce a discretized label encoding for increasing data distribution and generating data relationships, which has no dependencies on the prior works. For our proposed label encoding, we present a novel pre-processing method, called the pseudo-discretized label encoding (PDLE) scheme, in which an image is randomly selected in a mini-batch, then the opposite labeled image is also arbitrarily chosen from the whole batch, and then parts of the images are exchanged to generate a new image and its discretized dense label.

Our contributions are as follows:

* We re-formulate face anti-spoofing as a value regression problem that directly optimizes a deep neural network with mean square error for improving performance, instead of using binary cross-entropy.
* We propose a simple yet effective pseudo-discretized label encoding (PDLE), which enforce the regression network to represent the ratio of information of the real image to that of the given input image for a prediction of the liveness score.
* We conduct extensive experiments, and obtain the state-of-the-art and outstanding performance on the intra- and cross-dataset respectively.

## 2 Proposed Method

### Overview

For an expansion of the training image and label distribution without an information corruption, we introduce a discretized label encoding schema to preserve the spoof and real cues in the images, and indicate the amount of a real image information over that of the input image. To leverage the PDLE, we propose learning a value regression neural network using the MES between the expected liveness scores and the pseudo-labels. In addition, we apply a domain-invariant learning scheme (GRL) (Ganin and Lempitsky, 2015) as an adversarial training to our regression neural network using the domain labels. The framework of our method is illustrated in Fig. 2.

### Pseudo-Discretized Label Encoding

We assume that \(X=\{x_{s},x_{r}\}\in\mathbb{R}^{H\times W\times 3}\) and \(Y=\{y_{s}=0.0,y_{r}=1.0\}\) denote the spoof and real color image space and the class label space in each. To sample the discretized labels between \(y_{s}\) and \(y_{r}\), we use the following formula:

\[u\sim\mathcal{U}\{1,K\};\quad\lambda=\frac{u}{K}, \tag{1}\]

where \(u\) is sampled from the discrete uniform distribution (1, \(K\)), and \(K\) is a pre-defined discretized level, a cardinality of an encoding label \(\tilde{Y}\) set, and a number of outputs for the last \(FC\) in Fig. 2. \(\lambda\) implies a pseudo-discretized label presenting the amount of a partial real image over a whole image. Inspired by CutMix (Yun et al., 2019), we first exchange a real image and a spoof image through a random rectangular box as follows:

\[\tilde{x} =M\odot x_{a}+(1-M)\odot x_{b},\text{where }y_{a}\neq y_{b} \tag{2}\] \[\tilde{y} =\begin{cases}1-\lambda,&\text{if }x_{a}=x_{r}\\ \lambda,&\text{otherwise},\end{cases}\]

where \(M\in\{0,1\}^{H\times W}\) is a random rectangular mask based on \(\lambda\), with \(0\) and \(1\) indicating inside and outside the mask. \(\odot\) is an element-wise multiplication operator, and \(x_{a}\) is an anchor to choose a sample from a mini-batch, whereas \(x_{b}\) is the opposite sample selected from the entire training set. \(\tilde{x}\) indicates the exchanged image, and \(\tilde{y}\) is the pseudo-discretized label determined based on whether \(x_{a}\) is a real image or not. We exchange between images with different labels (\(y_{a}\neq y_{b}\)) to expand data and label distribution. As shown in Fig. 2, we use \(\tilde{X}\in(x_{s},\tilde{x},x_{r})\) and \(\tilde{Y}\in(y_{s},\tilde{y},y_{r})\)

Figure 2: Overview of our approach for a value regression neural network. Our framework consists of a label encoding (PDLE) for the data and label expansion, a encoder network for the feature extractor, an expected liveness score estimator for the regression network learning, and a discriminator for the domain-invariant feature learning.
as the training data and the supervision for the regression network to learn the liveness score.

### Expected Liveness Score

Let \(\mathbb{P}:\mathbb{R}^{H\times W\times 3}\rightarrow\mathbb{R}^{K}\) denote the probability of the liveness evidence estimated using \(SoftMax\), \(FC_{k}\), and \(Encoder(\tilde{X})\), as illustrated in Fig. 2. We employ \(K\) in Eq. 1 to formulate a random variable \(C\) with a finite list \(\{c_{0},...,c_{K}\}\) whose the \(i^{th}\) element \(c_{i}\) is denoted as follows:

\[c_{i}=\begin{cases}0.0,&\text{if }i=0\\ interval\times i,&\text{if }i>0\text{ and }i<K\\ 1.0,&\text{if }i=K\end{cases} \tag{3}\]

where \(interval=\lceil\frac{y_{i}-y_{s}}{K}\rceil\). The random variable \(c_{i}\) and its probability \(p_{i}\) are exploited to calculate the expected liveness score as follows:

\[\mathbb{E}[C]=\rho=\sum_{i=0}^{K}c_{i}*p_{i}, \tag{4}\]

where \(p_{i}\) is the \(i^{th}\) element of \(P\) which is the predicted probability vector of real cues from the input \(\tilde{X}\). We write \(\mathbb{E}[C]\) with \(\rho\), which is calculated using the sum over the element-wise multiplication between the random variables and their corresponding probabilities.

### Objective Function

Our objective function is defined as follows:

\[L^{\rho}_{mse}=-\frac{1}{N}\sum_{j=1}^{N}(\rho_{j}-\tilde{Y}_{j})^{2}, \tag{5}\]

where \(N\) is a mini-batch size, and \(\tilde{Y}_{j}\) and \(\rho_{j}\) are the \(j^{th}\) supervision and expected liveness score in the mini-batch. We calculate the distance between \(\tilde{Y}_{j}\) and \(\rho_{j}\) for our main objective function \(L^{\rho}_{mse}\).

To further improve the performance, we exploit not only a regression network but also an adversarial learning technique GRL (Ganin & Lempitsky, 2015). Finally, our overall loss function can be formulated as follows:

\[L_{final}=\alpha*L^{\rho}_{mse}+(1-\alpha)*L_{adv}, \tag{6}\]

where \(L^{\rho}_{mse}\) is a liveness score-based regression training loss and \(L_{adv}\) is an adversarial training loss for jointly learning our livensss score-based regression neural network. \(\alpha\) is a non-negative parameter to balance the importance of two losses, and we empirically set \(\alpha\) to \(0.5\).

## 3 Experiments

We demonstrate the effectiveness of the proposed approach on an intra- and cross-dataset. Based on the experimental results, the characteristics of our algorithm will be discussed in this section.

### Datasets and Metrics

**Datasets.** We employed four public datasets, OULU-NPU (labeled O) (Boulkenafet et al., 2017), CASIA-FASD (labeled C) (Zhang et al., 2012), Replay-Attack (labeled I) (Chingovska et al., 2012), and MSU-MFSD (labeled M) (Wen et al., 2015) for our experiments. OULU-NPU is a high-resolution database with four protocols for validating the improved performance on the intra-dataset. The videos of each dataset are recorded under different scenarios with various cameras and subjects, and they are used for cross-dataset testing to validate the generalization ability for testing data with unconstrained distribution shifts.

**Evaluation Metrics.** We utilized average classification error rate (ACER) for the intra-dataset testing on OULU-NPU. The half total error rate (HTER) and area under curve (AUC) are measured for the cross-dataset testing protocols.

### Implementation Details

**Primitive Data Preparation and Augmentation.** Because the four FAS datasets are in video format, we extracted images at certain intervals. After obtaining the images, we used RetinaFace (Deng et al., 2019) to detect faces, and then cropped and resized the color image to a resolution of 256\(\times\)256. Data augmentation, including horizontal flipping and random cropping, was used for training, and center cropping was employed for testing. And we empirically set \(K\) to 10 for our approach after testing variant \(K\) as depicted in Fig. 3.

**Experimental Setting.** To train the FAS task, we used ResNet18 (He et al., 2015) as the encoder with the Adam optimizer under an initial learning rate and weight decay of 1e-4 and 2e-4, respectively, for all testing protocols. We trained the models with a batch size of 32 and a max epoch of 200, whereas decreasing the learning rate through an exponential LR with a gamma of 0.99. For the domain labels on the intra-dataset, we used the number of sessions in each protocol.

### Intra-Dataset Testing on OULU-NPU

OULU-NPU has four protocols for evaluating the generalization ability under mobile scenarios with previously unseen sensors and spoof types. As shown in Table. 1, our PDLE approach presents the best performance for all protocols, and the expected liveness scores clearly validate the ability to generalize better latent embedding features. In particular, our proposed PDLE achieves the significant performance im

\begin{table}
\begin{tabular}{|c||c|c|c|c|} \hline \multirow{2}{*}{Method} & Protocol 1 & Protocol 2 & Protocol 3 & Protocol 4 \\ \cline{2-5}  & ACER(\%) & ACER(\%) & ACER(\%) & ACER(\%) \\ \hline \hline Auxiliary (Liu et al., 2018) & 1.6 & 2.7 & 2.941.5 & 5.964.0 \\ \hline CDCN (Yu et al., 2020) & 1.0 & 1.45 & 2.841.4 & 6.924.9 \\ \hline Facebook (Amin Iourabov, 2018) & 1.5 & 4.3 & 3.616.5 & 5.645.7 \\ \hline DC-CDN (Yu et al., 2021) & 0.4 & 1.3 & 1.941.1 & 4.343.1 \\ \hline LMFD-PAD (Fang et al., 2022) & 1.5 & 2.0 & 3.423.1 & 3.343.1 \\ \hline NAS-FAS (Yu et al., 2020) & 0.2 & **1.2** & 1.720.6 & 2.942.8 \\ \hline PeakNet (Wang et al., 2022) & **0.2** & **1.2** & 1.184.26 & 2.943.0 \\ \hline
**Uns** & **0** & **1.2** & **0.961.03** & **0.962.04** \\ \hline \end{tabular}
\end{table}
Table 1: Evaluation results for ACER (%) in comparison with the previous methods and the proposed **PDLE** approach within the intra-dataset (OULU-NPU protocols).
provement for protocol 4 (unseen lighting, spoof type, and sensor type). The results demonstrate that the effectiveness to train a liveness score-based regression neural network using the amount of swapping as pseudo-discrete labels. Note that our proposed PDLE improves the overall ACER performance over the previous SOTA (PatchNet (Wang et al., 2022a)) approach.

### Cross-Dataset Testing

To evaluate our proposed method, we select three out of four datasets to train and use the remaining one for testing, denoted by \(\{\cdot\&\&\cdot\}\) to \(\{\bullet\}\). We compare our proposed method with the latest methods as shown in Table. 2. Among ResNet-18 based methods, we found that our method shows outstanding performance on testing the O&C&I to M, O&C&M to I, and I&C&M to O protocols, and the other protocol O&M&I to C displays the very competitive performance. When comparing to the ResNet-50 based method HFN+MP (Cai et al., 2022), our approach shows competitive performance on testing datasets O&C&I to M and O&M&I to C which contain a variety of image resolutions, and superior performance on testing O&C&M to I and I&C&M to O whose images are collected from various capture devices unlike other datasets. By split testing on each capture device in the dataset C, we found that our method show relatively the low performance on low quality images (93.73% AUC) compared to normal (94.79% AUC) and high quality (96.47% AUC) images. This result proves that the proposed method achieves satisfactory performance on all protocols because our liveness score-based regression network estimates probabilities of the real cues under various presentation attacks.

### Ablation Study

We conducted ablation studies on cross-dataset testing to explore the contribution of each component in our method, as depicted in Table 2. To analyze the effect of discretization, we separated the proposed PDLE into patch exchange (PE) and label encoding (LE). And we confirmed that each of them is the essential element for improving performance, and also observed the best performance when both were used. In addition, we verified the influence of the pre-defined \(K\) in PDLE for determining the representation power of the liveness against an input image. As shown in Fig. 3, we tested various values of \(K\) on the O&C&M to I protocol to investigate the impact of \(K\) on AUC. With \(K\) between \(2\) and \(17\), our method outperforms the baseline.

## 4 Conclusion

In this paper, we have proposed the PDLE approach for training a face anti-spoofing regression model. The regression model allows the probability to estimate our liveness score. Our approach not only has the effect of a data augmentation because different labels and domains are densely exchanged, new data combinations are also created, which results in the improved domain generalization. Through our experiments, we confirm the effectiveness, robustness, and generalization of the proposed PDLE and expected liveness score.

## 5 Acknowledgements

This work was supported by KakaoBank Corp., and IITP grant funded by the Korea government (MSIT) (No. 2022-0-00320).

\begin{table}
\begin{tabular}{|c||c|c|c||c|c||c||c||c|} \hline \multirow{2}{*}{Method} & \multirow{2}{*}{Network} & \multicolumn{2}{c||}{O\&C\&I to M} & \multicolumn{2}{c||}{O\&M\&I to C} & \multicolumn{2}{c||}{O\&C\&M to I} & \multicolumn{2}{c||}{I\&C\&M to O} \\ \cline{3-10}  & & HTER(\%) & AUC(\%) & HTER(\%) & AUC(\%) & HTER(\%) & AUC(\%) & HTER(\%) & AUC(\%) \\ \hline \hline NAS-FAS (Yu et al., 2020a) & NAS & 19.53 & 88.63 & 16.54 & 90.18 & 14.51 & 93.84 & 13.80 & 93.43 \\ \hline NAS-FAS w/ D-Meta (Yu et al., 2020a) & NAS & 16.85 & 90.42 & 15.21 & 92.64 & 11.63 & 96.98 & 13.16 & 94.18 \\ \hline DRDG (George and Marcel, 2021) & DenseNet & 12.43 & 95.81 & 19.05 & 88.79 & 15.56 & 91.79 & 15.63 & 91.75 \\ \hline ANRL (Liu et al., 2021) & - & 10.83 & 96.75 & 17.83 & 89.26 & 16.03 & 91.04 & 15.67 & 91.90 \\ \hline LMFD-PAD (Wang et al., 2022) & Res-50 & 10.48 & 94.55 & 12.50 & 94.17 & 18.49 & 84.72 & 12.41 & 94.95 \\ \hline DBEI (Jiang and Sun, 2022) & Res-50 & 8.57 & 95.01 & 20.26 & 85.80 & _13.52_ & _93.22_ & 20.22 & 88.48 \\ \hline HFN+MP (Cai et al., 2022) & Res-50 & 5.24 & 97.28 & _9.17_ & 96.09 & 15.35 & 90.67 & _12.04_ & 94.26 \\ \hline \hline CAPD (Huang et al., 2022) & Res-18 & 11.64 & 95.27 & 17.51 & 89.98 & 15.08 & 91.92 & 14.27 & 93.04 \\ \hline SSDG-R (Ria et al., 2020) & Res-18 & 7.38 & 97.17 & 10.44 & 95.94 & 11.71 & 96.59 & 15.61 & 91.54 \\ \hline SSAN-R (Wang et al., 2022b) & Res-18 & 6.67 & 98.75 & **10.00** & **96.67** & 8.88 & 96.79 & 13.72 & 93.63 \\ \hline PatchNet (Wang et al., 2022a) & Res-18 & 7.10 & 98.46 & 11.33 & 94.58 & 13.40 & 95.67 & 11.82 & 95.07 \\ \hline Ours w/o PE\& Res-18 & 10.83 & 94.58 & 15.08 & 91.14 & 14.50 & 93.55 & 13.88 & 93.16 \\ \hline Ours w/o PE & Res-18 & 10.41 & 94.93 & 13.59 & 91.04 & 11.17 & 93.92 & 12.50 & 94.35 \\ \hline Ours w/o LE & Res-18 & 9.58 & 94.47 & 12.47 & 92.28 & 12.25 & 94.55 & 13.29 & 93.62 \\ \hline
**Ques** & Res-18 & **5.41** & **98.85** & **10.05** & **94.27** & **8.62** & **97.60** & **11.42** & **95.82** \\ \hline \end{tabular}
\end{table}
Table 2: Comparison results of cross-domain testing on MSU-MFSD (M), CASIA-MFSD (C), Replay-Attack (I), and OULU-NPU (O). PE and LE mean patch-exchange and label-encoding, respectively. **Bold** and _italic_ denote the best results among Res-18 and Res-50 based methods in each.

Figure 3: Ablation study on the discretized level \(K\).