Quantitative Study of Swin Transformer and Loss Function Combinations for Face Anti-Spoofing
Abstract
:1. Introduction
2. Related Work
2.1. Face Anti-Spoofing
2.2. Data Augmentations
2.3. Swin Transformer
3. Proposed Methods
3.1. Pre-Processing Work
3.2. Model Architecture
3.3. Loss Functions
4. Experiments
4.1. Datasets
4.2. Implementation Details
4.3. Ablation Test for Single Loss Function
4.4. Ablation Test for Loss Combination
4.5. Cross-Dataset Study
5. Conclusions and Future Work
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
References
- Ojala, T.; Pietikainen, M.; Maenpaa, T. Multiresolution gray-scale and rotation invariant texture classification with local binary patterns. IEEE Trans. Pattern Anal. Mach. Intell. 2002, 24, 971–987. [Google Scholar] [CrossRef]
- He, K.; Zhang, X.; Ren, S.; Sun, J. Deep Residual Learning for Image Recognition. In Proceedings of the 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Las Vegas, NV, USA, 27–30 June 2016; pp. 770–778. [Google Scholar] [CrossRef]
- Chollet, F. Xception: Deep Learning with Depthwise Separable Convolutions. In Proceedings of the 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Honolulu, HI, USA, 21–26 July 2017; pp. 1800–1807. [Google Scholar] [CrossRef]
- Schroff, F.; Kalenichenko, D.; Philbin, J. FaceNet: A unified embedding for face recognition and clustering. In Proceedings of the 2015 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Boston, MA, USA, 7–12 June 2015; pp. 815–823. [Google Scholar] [CrossRef]
- Yu, Z.; Qin, Y.; Li, X.; Zhao, C.; Lei, Z.; Zhao, G. Deep Learning for Face Anti-Spoofing: A Survey. IEEE Trans. Pattern Anal. Mach. Intell. 2023, 45, 5609–5631. [Google Scholar] [CrossRef]
- Xu, X.; Xiong, Y.; Xia, W. On Improving Temporal Consistency for Online Face Liveness Detection. In Proceedings of the IEEE/CVF International Conference on Computer Vision, Seattle, WA, USA, 13–19 June 2020. [Google Scholar]
- Liu, A.; Wan, J.; Escalera, S.; Escalante, H.J.; Tan, Z.; Yuan, Q.; Wang, K.; Lin, C.; Guo, G.; Guyon, I.; et al. Multi-Modal Face Anti-Spoofing Attack Detection Challenge at CVPR2019. In Proceedings of the 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops (CVPRW), Long Beach, CA, USA, 16–17 June 2019; pp. 1601–1610. [Google Scholar] [CrossRef]
- Liu, A.; Tan, Z.; Wan, J.; Liang, Y.; Lei, Z.; Guo, G.; Li, S.Z. Face Anti-Spoofing via Adversarial Cross-Modality Translation. IEEE Trans. Inf. Forensics Secur. 2021, 16, 2759–2772. [Google Scholar] [CrossRef]
- Khammari, M. Robust face anti-spoofing using CNN with LBP and WLD. IET Image Process. 2019, 13, 1880–1884. [Google Scholar] [CrossRef]
- Li, L.; Feng, X.; Boulkenafet, Z.; Xia, Z.; Li, M.; Hadid, A. An original face anti-spoofing approach using partial convolutional neural network. In Proceedings of the 2016 Sixth International Conference on Image Processing Theory, Tools and Applications (IPTA), Oulu, Finland, 12–15 December 2016; pp. 1–6. [Google Scholar] [CrossRef]
- Zhong, Z.; Zheng, L.; Kang, G.; Li, S.; Yang, Y. Random Erasing Data Augmentation. In Proceedings of the AAAI Conference on Artificial Intelligence, New York, NY, USA, 7–12 February 2020; Volume 34, pp. 13001–13008. [Google Scholar] [CrossRef]
- Vaswani, A. Attention is all you need. In Proceedings of the 31st International Conference on Neural Information Processing Systems, NIPS’17, Long Beach, CA, USA, 4–9 December 2017; Curran Associates Inc.: Red Hook, NY, USA, 2017; pp. 6000–6010. [Google Scholar]
- Liu, Z.; Lin, Y.; Cao, Y.; Hu, H.; Wei, Y.; Zhang, Z.; Lin, S.; Guo, B. Swin Transformer: Hierarchical Vision Transformer using Shifted Windows. In Proceedings of the 2021 IEEE/CVF International Conference on Computer Vision (ICCV), Montreal, QC, Canada, 10–17 October 2021; pp. 9992–10002. [Google Scholar]
- Guo, J.; Deng, J.; Lattas, A.; Zafeiriou, S. Sample and Computation Redistribution for Efficient Face Detection. arXiv 2021, arXiv:2105.04714. [Google Scholar]
- Zhang, Y.; Yin, Z.-f.; Li, Y.; Yin, G.; Yan, J.; Shao, J.; Liu, Z. CelebA-Spoof: Large-Scale Face Anti-Spoofing Dataset with Rich Annotations. In Proceedings of the European Conference on Computer Vision, Glasgow, UK, 23–28 August 2020. [Google Scholar]
- Boulkenafet, Z.; Komulainen, J.; Li, L.; Feng, X.; Hadid, A. OULU-NPU: A Mobile Face Presentation Attack Database with Real-World Variations. In Proceedings of the 2017 12th IEEE International Conference on Automatic Face and Gesture Recognition (FG 2017), Washington, DC, USA, 30 May–3 June 2017; pp. 612–618. [Google Scholar] [CrossRef]
- Zhang, Z.; Yan, J.; Liu, S.; Lei, Z.; Yi, D.; Li, S.Z. A face antispoofing database with diverse attacks. In Proceedings of the 2012 5th IAPR International Conference on Biometrics (ICB), New Delhi, India, 29 March–1 April 2012; pp. 26–31. [Google Scholar] [CrossRef]
- Chingovska, I.; Anjos, A.; Marcel, S. On the effectiveness of local binary patterns in face anti-spoofing. In Proceedings of the 2012 BIOSIG—Proceedings of the International Conference of Biometrics Special Interest Group (BIOSIG), Darmstadt, Germany, 6–7 September 2012; pp. 1–7. [Google Scholar]
- Lin, C.; Liao, Z.; Zhou, P.; Hu, J.; Ni, B. Live face verification with multiple instantialized local homographic parameterization. In Proceedings of the 27th International Joint Conference on Artificial Intelligence, Stockholm, Sweden, 13–19 July 2018. [Google Scholar]
- Liu, Y.; Jourabloo, A.; Liu, X. Learning Deep Models for Face Anti-Spoofing: Binary or Auxiliary Supervision. In Proceedings of the 2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition, Salt Lake City, UT, USA, 18–23 June 2018; pp. 389–398. [Google Scholar] [CrossRef]
- Jourabloo, A.; Liu, Y.; Liu, X. Face De-spoofing: Anti-spoofing via Noise Modeling. In Proceedings of the Computer Vision—ECCV 2018: 15th European Conference, Proceedings, Part XIII, Munich, Germany, 8–14 September 2018. [Google Scholar]
- Spoof in Wild. Available online: https://cvlab.cse.msu.edu/siw-spoof-in-the-wild-database.html (accessed on 10 November 2024).
Decoder Layers | Output Feature Size | Components |
---|---|---|
Decoder Conv1 | , stride = 2 | |
Decoder Basic Block1 | ||
Decoder Basic Block2 | ||
Decoder Basic Block3 | ||
Reshape | None |
Loss Functions | Accuracy (%) | APCER (%) | BPCER (%) | ACER (%) |
---|---|---|---|---|
CE loss | 84.35 | 6.444 | 15.672 | 11.058 |
Semi-hard triplet loss | 71.44 | 47.665 | 20.710 | 34.188 |
Focal loss | 86.73 | 4.365 | 12.703 | 8.534 |
Smooth L1 loss | 77.16 | 2.780 | 31.528 | 17.153 |
Loss Combination | Epoch | Accuracy (%) | APCER (%) | BPCER (%) | ACER(%) |
---|---|---|---|---|---|
CE loss | 18 | 84.35 | 6.444 | 15.672 | 11.508 |
CE + triplet | 22 | 89.75 | 8.401 | 12.494 | 10.448 |
CE + triplet + Smooth L1 | 17 | 93.52 | 2.184 | 8.773 | 5.479 |
Focal + triplet + Smooth L1 | 6 | 88.86 | 1.324 | 15.391 | 8.357 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Gong, L.Y.; Li, X.J. Quantitative Study of Swin Transformer and Loss Function Combinations for Face Anti-Spoofing. Electronics 2025, 14, 448. https://doi.org/10.3390/electronics14030448
Gong LY, Li XJ. Quantitative Study of Swin Transformer and Loss Function Combinations for Face Anti-Spoofing. Electronics. 2025; 14(3):448. https://doi.org/10.3390/electronics14030448
Chicago/Turabian StyleGong, Liang Yu, and Xue Jun Li. 2025. "Quantitative Study of Swin Transformer and Loss Function Combinations for Face Anti-Spoofing" Electronics 14, no. 3: 448. https://doi.org/10.3390/electronics14030448
APA StyleGong, L. Y., & Li, X. J. (2025). Quantitative Study of Swin Transformer and Loss Function Combinations for Face Anti-Spoofing. Electronics, 14(3), 448. https://doi.org/10.3390/electronics14030448