The specification discloses a method and device for training an
anomaly detection model, obtaining real face images as positive samples, obtaining synthetic face images as negative samples, and taking each
positive sample and
negative sample as a training sample. The sample features of each training sample are extracted through a
feature extraction layer, the detection results of each training sample are obtained through a classification layer, and the representative features for representing the commonality of the positive samples are determined based on the sample features of each
positive sample. Then, the
anomaly detection model is trained according to the differences between the sample features of each
positive sample and the representative features, the differences between the sample features of each
negative sample and the representative features, and the differences between the detection results of each training sample and the labels thereof. This method can learn an accurate
feature extraction method based on the representative features, so as to accurately extract the face features of the face images for accurate
anomaly detection in the subsequent process, thereby ensuring the accuracy of the anomaly detection.