  Face recognition has achieved unprecedented results, surpassing human
capabilities in certain scenarios. However, these automatic solutions are not
ready for production because they can be easily fooled by simple identity
impersonation attacks. And although much effort has been devoted to develop
face anti-spoofing models, their generalization capacity still remains a
challenge in real scenarios. In this paper, we introduce a novel approach that
reformulates the Generalized Presentation Attack Detection (GPAD) problem from
an anomaly detection perspective. Technically, a deep metric learning model is
proposed, where a triplet focal loss is used as a regularization for a novel
loss coined "metric-softmax", which is in charge of guiding the learning
process towards more discriminative feature representations in an embedding
space. Finally, we demonstrate the benefits of our deep anomaly detection
architecture, by introducing a few-shot a posteriori probability estimation
that does not need any classifier to be trained on the learned features. We
conduct extensive experiments using the GRAD-GPAD framework that provides the
largest aggregated dataset for face GPAD. Results confirm that our approach is
able to outperform all the state-of-the-art methods by a considerable margin.
