Face recognition anti-counterfeiting method, device, equipment, medium and program product
By performing background segmentation and face recognition on the input image, the interactive correlation between the character and the background is solved, and the problem of inability to effectively prevent background evasion detection in the prior art is solved, and the security and accuracy of face recognition are improved.
Patent Information
- Application Number
- CN202411853012.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-16
- Publication Date
- 2025-04-11
AI Technical Summary
The existing facial recognition anti-counterfeiting technology only focuses on the face part, making it difficult to effectively prevent the behavior of evading detection by simulating the background of actual users, resulting in the inability to guarantee the security and accuracy of facial recognition.
By using a preset background segmentation model to segment the input image, identify the characters and backgrounds, and use the preset face recognition model to perform face recognition images, enhancing the background environment detection and interactive relevance of the characters.
Effectively prevent the behavior of evading detection by simulating the background of actual users, enhance the security and accuracy of facial recognition, and ensure the authenticity of recognition results.
Smart Images

Figure CN119810885A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a face recognition anti-counterfeiting method, device, electronic equipment, computer-readable storage medium and computer program product. Background Art
[0002] Face recognition technology, especially methods based on pure image processing, has made significant progress in recent years, mainly due to breakthroughs in deep learning and computer vision. Its core lies in using convolutional neural networks to learn complex features of face images through multi-level structures to achieve efficient and accurate individual recognition. This type of technology covers multiple aspects from feature extraction, face alignment to deep metric learning.
[0003] In order to prevent the face recognition system from being deceived by photos or videos, the existing technology usually adopts face recognition anti-counterfeiting measures including liveness detection technology, dual cameras or multi-modal verification, 3D face recognition, etc. However, the face recognition anti-counterfeiting measures in the existing technology have the problem of only focusing on the face part for recognition, and it is difficult to effectively prevent various evasion detection behaviors, and it is impossible to ensure the security and accuracy of face recognition. Summary of the invention
[0004] The present invention provides a face recognition anti-counterfeiting method, device, equipment, medium and program product to solve the technical problem that the existing face recognition anti-counterfeiting technology can not ensure the security and accuracy of face recognition because it only focuses on the face part for recognition.
[0005] In order to solve the above technical problems, the first aspect of the embodiment of the present invention provides a face recognition anti-counterfeiting method, comprising:
[0006] Use a preset background segmentation model to segment the person and background in the input image to obtain an image to be recognized;
[0007] A preset face recognition model is used to perform face recognition on the image to be recognized to obtain a face recognition result of the input image.
[0008] As a preferred solution, the background segmentation model includes a depth separable convolution module, an image segmentation module and a segmentation edge processing module;
[0009] The method of using a preset background segmentation model to segment the person and background in the input image to obtain the image to be recognized specifically includes:
[0010] Performing convolution processing on the input image through the depthwise separable convolution module to obtain a feature map corresponding to the input image;
[0011] Identifying the person pixels and background pixels in the feature map by the image segmentation module, and performing image segmentation on the feature map based on the person pixels and the background pixels to obtain an initial segmented image;
[0012] The segmentation edge processing module performs refinement processing on the segmentation edge in the initial segmentation image to obtain the image to be recognized.
[0013] As a preferred solution, performing convolution processing on the input image by the depthwise separable convolution module to obtain a feature map corresponding to the input image specifically includes:
[0014] Performing deep convolution processing on each channel of the input image through the deep separable convolution module to obtain a feature map corresponding to each channel;
[0015] Each of the feature maps is subjected to point-by-point convolution processing through the depth-wise separable convolution module to merge the feature maps to obtain the feature map.
[0016] As a preferred solution, the face recognition model includes a local feature enhancement module, a global feature enhancement module, a multi-scale feature fusion module and an image classification module;
[0017] The step of using a preset face recognition model to perform face recognition on the image to be recognized to obtain a face recognition result of the input image specifically includes:
[0018] The local feature enhancement module uses a Transformer encoder to extract visual spatial information features of the image to be identified, and enhances the spatial information and channel information of the visual spatial information features to obtain local features associated with the enhanced feature information;
[0019] By using the global feature enhancement module, the Transformer encoder is used to iteratively encode the image to be identified to obtain global feature information of the image to be identified; the self-attention mechanism is used to enhance the global feature information to obtain global features associated with the enhanced feature information;
[0020] The local feature and the global feature are fused by the multi-scale feature fusion module to obtain a fused feature;
[0021] Performing image classification and recognition based on the fusion features through the image classification module to obtain an image classification result;
[0022] A face recognition result of the input image is obtained according to the image classification result.
[0023] As a preferred solution, the method performs feature enhancement on the spatial information and channel information of the visual spatial information feature through the local feature enhancement module to obtain local features associated with the enhanced feature information, specifically including:
[0024] Through the local feature enhancement module, the visual spatial information features are respectively subjected to global maximum pooling processing and global average pooling processing in the spatial dimension to obtain a first pooling feature map and a second pooling feature map;
[0025] Through the local feature enhancement module, the first pooling feature map and the second pooling feature map are respectively subjected to nonlinear transformation, addition and activation to generate a channel attention weight;
[0026] The visual space information feature is multiplied by the channel attention weight through the local feature enhancement module to obtain a local feature with channel feature enhancement;
[0027] By means of the local feature enhancement module, the local features enhanced by the channel features are respectively subjected to global maximum pooling processing and global average pooling processing in the channel dimension to obtain a third pooling feature map and a fourth pooling feature map;
[0028] Through the local feature enhancement module, the third pooling feature map and the fourth pooling feature map are respectively concatenated, convolved and activated to generate a spatial attention weight;
[0029] Through the local feature enhancement module, the local features enhanced by the channel features are multiplied by the spatial attention weights to obtain local features associated with the enhanced feature information.
[0030] As a preferred solution, the method uses the global feature enhancement module to iteratively encode the image to be identified using the Transformer encoder to obtain global feature information of the image to be identified, specifically including:
[0031] By using the global feature enhancement module, the image to be identified is iteratively encoded using the Transformer encoder to obtain a plurality of encoding feature vectors;
[0032] Several encoded feature vectors are concatenated to obtain the global feature information.
[0033] As a preferred solution, the method uses the global feature enhancement module to enhance the global feature information using a self-attention mechanism to obtain global features associated with the enhanced feature information, specifically including:
[0034] Through the global feature enhancement module, a self-attention mechanism is used to obtain different attention scores related to the importance of facial image information in the global feature information, and the attention scores are integrated through a weight matrix to obtain the global feature.
[0035] As a preferred solution, obtaining the face recognition result of the input image according to the image classification result specifically includes:
[0036] When the image classification result is a two-dimensional image, determining that the face recognition result is a face recognition failure;
[0037] When the image classification result is a three-dimensional image, the face recognition result is determined to be a successful face recognition.
[0038] As a preferred solution, the method specifically obtains the background segmentation model through training through the following steps:
[0039] Collecting a plurality of images containing characters and backgrounds, and preprocessing the plurality of images to obtain a plurality of images to be labeled;
[0040] Annotating the segmentation labels of the person and the background on a plurality of the images to be annotated to obtain image segmentation training samples;
[0041] According to a preset loss function and Adam optimization algorithm, an untrained background segmentation model is trained using the image segmentation training samples to obtain the background segmentation model; wherein the loss function is a weighted sum of a pixel-level cross entropy loss and an edge-sensitive loss.
[0042] A second aspect of an embodiment of the present invention provides a face recognition anti-counterfeiting device, comprising:
[0043] The background segmentation module is used to segment the person and background in the input image using a preset background segmentation model to obtain an image to be recognized;
[0044] The face recognition module is used to perform face recognition on the image to be recognized using a preset face recognition model to obtain a face recognition result of the input image.
[0045] A third aspect of an embodiment of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the face recognition anti-counterfeiting method described in any one of the first aspects when executing the computer program.
[0046] A fourth aspect of an embodiment of the present invention provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the face recognition anti-counterfeiting method described in any one of the first aspects.
[0047] A fifth aspect of an embodiment of the present invention provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the face recognition anti-counterfeiting method described in any one of the first aspects.
[0048] Compared with the prior art, the beneficial effect of the embodiments of the present invention is that it fully considers that the background environment will affect the facial features so that there is a certain interactive correlation between the background environment and the person. By performing background segmentation on the input image to identify the person image information and background image information therein, the background environment detection of the person can be enhanced in the process of face recognition, and the interactive correlation between the person in the input image and its background environment can be identified, thereby effectively preventing the behavior of evading detection by simulating the background of the actual user, achieving the purpose of anti-counterfeiting, and ensuring the security and accuracy of face recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 is a schematic diagram of the process of the face recognition anti-counterfeiting method in an embodiment of the present invention;
[0050] Figure 2 is a schematic diagram of the architecture of a local feature enhancement module in an embodiment of the present invention;
[0051] Figure 3 is a schematic structural diagram of a face recognition anti-counterfeiting device in an embodiment of the present invention;
[0052] Figure 4 Schematic diagram of the structure of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION
[0053] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0054] See also Figure 1 The first aspect of the embodiment of the present invention provides a face recognition anti-counterfeiting method, comprising the following steps S1 to S2:
[0055] Step S1, using a preset background segmentation model to segment the person and background in the input image to obtain an image to be recognized;
[0056] Step S2: performing face recognition on the image to be recognized using a preset face recognition model to obtain a face recognition result of the input image.
[0057] Specifically, this embodiment fully considers the impact of the background environment on facial features. For example, the shadows and light on the face will be different due to different background environments. Therefore, for a real image with both a person and a background environment, the person and the background environment are interactively correlated. In some face recognition scenarios, such as office attendance scenarios, the background of user attendance is basically fixed, such as offices, workshops and other workplaces. Some cheaters attempt to circumvent face recognition detection by simulating the background of actual users. However, in this false image, the simulated background and the person are not interactively correlated. Therefore, by identifying the interactive correlation between the person and the background environment, this behavior of circumventing face recognition detection can be effectively prevented.
[0058] In order to enhance the detection of the background environment of the person, the present embodiment first uses a background segmentation model to segment the person and the background in the input image to identify the person image information and the background image information, such as the person outline and the background outline, the person area and the background area, etc. Further, the face recognition model is used to perform face recognition on the image to be recognized with the person image information and the background image information, which can enhance the detection of the person's background environment during the face recognition process, and identify the interactive correlation between the person in the input image and its background environment, so as to prevent cheaters from evading detection by simulating the background of the actual user, thereby achieving the purpose of anti-counterfeiting.
[0059] As a preferred solution, the background segmentation model includes a depth separable convolution module, an image segmentation module and a segmentation edge processing module;
[0060] The method of using a preset background segmentation model to segment the person and background in the input image to obtain the image to be recognized specifically includes:
[0061] Performing convolution processing on the input image through the depthwise separable convolution module to obtain a feature map corresponding to the input image;
[0062] Identifying the person pixels and background pixels in the feature map by the image segmentation module, and performing image segmentation on the feature map based on the person pixels and the background pixels to obtain an initial segmented image;
[0063] The segmentation edge processing module performs refinement processing on the segmentation edge in the initial segmentation image to obtain the image to be recognized.
[0064] Specifically, this embodiment first performs convolution processing on each channel of the input image through a deep separable convolution module to extract the features of each channel and output a feature map corresponding to the input image. Furthermore, the image segmentation module in this embodiment is specifically a U-Net model, and its encoder-decoder structure can achieve accurate image segmentation, which is particularly suitable for image segmentation tasks that require fine local information recovery. Specifically, the U-Net model combines shallow position information with deep semantic information through a U-shaped network structure with jump connections for the generation of the final semantic segmentation image. In the image segmentation task, the semantic information of the image refers to the meaning or category of different regions or pixels in the image. The goal of image segmentation is to assign a semantic category to each pixel in the image, thereby decomposing the image into different objects or regions. The encoder of the U-Net model can be understood as a feature extraction network, which uses convolutional layers to continuously extract image features and uses the maximum pooling layer to continuously reduce the size of the image. In essence, it uses less and less code to describe the original information and obtain task-oriented high-level information. After the input image has been pooled multiple times, each feature map obtained is low-resolution, which reflects pixel-level semantic information, so that the character pixels and background pixels in the feature map can be identified. The decoder of the U-Net model can be understood as a feature fusion network, which is used to present pixel-level semantic information in the original image, that is, to fuse the original shallow position information (the position of each pixel corresponding to the image) and the deep semantic information (the category of each pixel) to obtain the final image with pixel-level semantic information. In the decoder, since deconvolution can only expand the image but not restore it, in order to reduce data loss, the method of cropping the downsampled image to the same size and then directly splicing it together is adopted to increase the feature layer, and then convolution is performed to extract features. Through skip connections, the shallow position information is fused with the deep semantic information, which not only retains more spatial information, but also promotes the effective transmission of context information. Furthermore, in order to make the segmentation result closer to the actual situation, especially in the segmentation edge area, the segmentation edge processing module in this embodiment specifically adopts a conditional random field model to refine the segmentation edges in the initial segmented image output by the image segmentation module to further improve the segmentation accuracy.
[0065] As a preferred solution, performing convolution processing on the input image by the depthwise separable convolution module to obtain a feature map corresponding to the input image specifically includes:
[0066] Performing deep convolution processing on each channel of the input image through the deep separable convolution module to obtain a feature map corresponding to each channel;
[0067] Each of the feature maps is subjected to point-by-point convolution processing through the depth-wise separable convolution module to merge the feature maps to obtain the feature map.
[0068] Specifically, the depth-wise separable convolution module in this embodiment first uses a depth-wise convolution layer to perform depth convolution processing on each channel of the input image to obtain a feature map of the input image after independent convolution processing of each channel, and then uses a convolution layer with a size of 1×1 to perform point-by-point convolution processing on each feature map to merge the feature maps and obtain the final feature map.
[0069] As a preferred solution, the face recognition model includes a local feature enhancement module, a global feature enhancement module, a multi-scale feature fusion module and an image classification module;
[0070] The step of using a preset face recognition model to perform face recognition on the image to be recognized to obtain a face recognition result of the input image specifically includes:
[0071] The local feature enhancement module uses a Transformer encoder to extract visual spatial information features of the image to be identified, and enhances the spatial information and channel information of the visual spatial information features to obtain local features associated with the enhanced feature information;
[0072] By using the global feature enhancement module, the Transformer encoder is used to iteratively encode the image to be identified to obtain global feature information of the image to be identified; the self-attention mechanism is used to enhance the global feature information to obtain global features associated with the enhanced feature information;
[0073] The local feature and the global feature are fused by the multi-scale feature fusion module to obtain a fused feature;
[0074] Performing image classification and recognition based on the fusion features through the image classification module to obtain an image classification result;
[0075] A face recognition result of the input image is obtained according to the image classification result.
[0076] Specifically, this embodiment adopts a pre-trained visual Transformer model, retains the MLP Head therein, and imitates the image classification task to finally identify whether the input image is a two-dimensional image or a three-dimensional image to achieve the purpose of face recognition. During the training process, a data set containing two-dimensional images, three-dimensional images and their corresponding image labels is used, and the Adam optimization algorithm is selected to train the MLP Head classifier. Furthermore, after distinguishing the person and the background, the corresponding face contour and background contour can be clearly identified based on the segmentation edges of the person and the background, and the face contour and the background contour contain a lot of noise information, and the correlation between the features needs to be considered. Therefore, the local feature enhancement module in this embodiment is designed as a dual-channel feature association module based on the CBAM (Convolutional Block Attention Module) hybrid attention mechanism, and the visual spatial information features of the image to be identified output by the Transformer encoder of the visual Transformer model are enhanced in terms of its spatial information and channel information. At the same time, in order to enhance the ability to distinguish between two-dimensional images and three-dimensional images, the global feature enhancement module in this embodiment is designed as a weight feature integration module based on the self-attention mechanism. The self-attention mechanism is used to enhance the feature information of the global feature information obtained by each iterative encoding process of the Transformer encoder, so as to enhance the feature information association. The local features and global features processed by the local feature enhancement module and the global feature enhancement module are feature fused to achieve the effect of feature enhancement. Finally, after being processed by the MLP Head of the visual Transformer model, the output image classification result is a two-dimensional image or a three-dimensional image.
[0077] As a preferred solution, the method performs feature enhancement on the spatial information and channel information of the visual spatial information feature through the local feature enhancement module to obtain local features associated with the enhanced feature information, specifically including:
[0078] Through the local feature enhancement module, the visual spatial information features are respectively subjected to global maximum pooling processing and global average pooling processing in the spatial dimension to obtain a first pooling feature map and a second pooling feature map;
[0079] Through the local feature enhancement module, the first pooling feature map and the second pooling feature map are respectively subjected to nonlinear transformation, addition and activation to generate a channel attention weight;
[0080] The visual space information feature is multiplied by the channel attention weight through the local feature enhancement module to obtain a local feature with channel feature enhancement;
[0081] By means of the local feature enhancement module, the local features enhanced by the channel features are respectively subjected to global maximum pooling processing and global average pooling processing in the channel dimension to obtain a third pooling feature map and a fourth pooling feature map;
[0082] Through the local feature enhancement module, the third pooling feature map and the fourth pooling feature map are respectively concatenated, convolved and activated to generate a spatial attention weight;
[0083] Through the local feature enhancement module, the local features enhanced by the channel features are multiplied by the spatial attention weights to obtain local features associated with the enhanced feature information.
[0084] Specifically, Figure 2 As shown, it is a schematic diagram of the architecture of the local feature enhancement module in this embodiment. Since the output features of the last layer of encoder have rich visual spatial information after the image to be recognized has been iterated by the Transformer encoder for many times, the local feature enhancement module in this embodiment is specifically composed of a channel attention module and a spatial attention module in series. First, the visual spatial information features are subjected to global maximum pooling and global average pooling in the spatial dimension, and then the first pooling feature map of size C×1×1 and the second pooling feature map of size C×1×1 after pooling are respectively input into the two-layer fully connected network with shared parameters to generate two channel attention vectors to capture more complex inter-channel relationships, where C represents the number of channels; then the two channel attention vectors are added and normalized by the sigmoid function to generate the final channel attention weight, and then the visual spatial information features are multiplied by the channel attention weights channel by channel to obtain the local features with enhanced channel features.
[0085] Furthermore, the local features enhanced by the channel features obtained above are respectively subjected to global maximum pooling processing and global average pooling processing in the channel dimension, so as to obtain a third pooling feature map of size 1×H×W and a fourth pooling feature map of size 1×H×W, where H represents height and W represents width; the third pooling feature map and the fourth pooling feature map are then spliced in the channel dimension to obtain a feature map with two channels, that is, the size is 2×H×W; the spliced feature map is then convolved with a convolution kernel of size 7×7 to convert the feature map of size 2×H×W into a feature map of size 1×H×W, and normalized using the sigmoid function to generate the final spatial attention weight, and then the local features enhanced by the channel features are element-by-element multiplied by the spatial attention weight to obtain local features associated with the enhanced feature information.
[0086] As a preferred solution, the method uses the global feature enhancement module to iteratively encode the image to be identified using the Transformer encoder to obtain global feature information of the image to be identified, specifically including:
[0087] By using the global feature enhancement module, the image to be identified is iteratively encoded using the Transformer encoder to obtain a plurality of encoding feature vectors;
[0088] Several encoded feature vectors are concatenated to obtain the global feature information.
[0089] Specifically, in this embodiment, the number of iterations of the given Transformer encoder is 4. After 4 iterations, the encoded feature vectors in each output of the Transformer encoder are collected, and then the collected encoded feature vectors are concatenated to obtain global feature information.
[0090] As a preferred solution, the method uses the global feature enhancement module to enhance the global feature information using a self-attention mechanism to obtain global features associated with the enhanced feature information, specifically including:
[0091] Through the global feature enhancement module, a self-attention mechanism is used to obtain different attention scores related to the importance of facial image information in the global feature information, and the attention scores are integrated through a weight matrix to obtain the global feature.
[0092] Specifically, this embodiment uses a self-attention mechanism to automatically emphasize important areas related to the face image and suppress irrelevant information, so that the focus of attention in the feature map can be automatically adjusted, thereby effectively enhancing the key features. This mechanism helps the face recognition model to maintain high robustness when facing noise interference or target occlusion, and improves the recognition accuracy in complex scenes. By reducing unnecessary information processing, the allocation of computing resources is further optimized, and the operating efficiency of the system is improved.
[0093] As a preferred solution, obtaining the face recognition result of the input image according to the image classification result specifically includes:
[0094] When the image classification result is a two-dimensional image, determining that the face recognition result is a face recognition failure;
[0095] When the image classification result is a three-dimensional image, the face recognition result is determined to be a successful face recognition.
[0096] As a preferred solution, the method specifically obtains the background segmentation model through training through the following steps:
[0097] Collecting a plurality of images containing characters and backgrounds, and preprocessing the plurality of images to obtain a plurality of images to be labeled;
[0098] Annotating the segmentation labels of the person and the background on a plurality of the images to be annotated to obtain image segmentation training samples;
[0099] According to a preset loss function and Adam optimization algorithm, an untrained background segmentation model is trained using the image segmentation training samples to obtain the background segmentation model; wherein the loss function is a weighted sum of a pixel-level cross entropy loss and an edge-sensitive loss.
[0100] Specifically, this embodiment can obtain images containing people and backgrounds from public data sets (such as COCO data sets, VOC data sets, etc.), or can take or collect pictures with diverse backgrounds and foreground people by yourself to increase the diversity of the data, and can also use web crawlers to collect relevant images from the Internet to ensure sufficient data volume. In this embodiment, the preprocessing of the collected images includes data cleaning and data enhancement, wherein data cleaning includes: removing duplicate and low-quality images to ensure the clarity and representativeness of the data set; filtering blurred and distorted images manually or using image quality assessment algorithms (such as SSIM algorithms). Data enhancement includes: geometric transformations, such as rotation, flipping, scaling, translation, etc., to increase the diversity of data; color transformations, such as adjusting brightness, contrast, saturation, etc., to make the background segmentation model more robust; noise addition, such as adding Gaussian noise, salt and pepper noise, etc., to enhance the resistance of the background segmentation model to noise. Furthermore, for the preprocessed images to be annotated, tools (such as LabelMe tool and Labelbox tool) can be used for manual annotation to generate segmentation masks of foreground characters and backgrounds as segmentation labels for characters and backgrounds. Semi-automatic annotation tools can also be used to improve annotation efficiency and ensure label accuracy.
[0101] Furthermore, according to the preset loss function and Adam optimization algorithm, a dynamic learning rate adjustment mechanism is introduced, that is, the initial learning rate is high, and the learning rate is gradually reduced during the training process to avoid overfitting. The untrained background segmentation model is trained using the image segmentation training samples to obtain the final background segmentation model. Among them, the loss function is specifically: L seg =α·CE(S,S true )+β·ES(S,S true ), this loss function combines pixel-level cross entropy loss and edge-sensitive loss. Pixel-level cross entropy loss ensures classification accuracy, while edge-sensitive loss is used to enhance the model's ability to identify edge areas, especially at the junction of background and foreground. segrepresents the loss function, CE represents the pixel-level cross entropy loss, ES represents the edge-sensitive loss, S represents the predicted segmentation result, S true represents the true segmentation label, α and β represent the weight of the pixel-level cross entropy loss and the weight of the edge-sensitive loss, respectively.
[0102] The face recognition anti-counterfeiting method provided in the embodiment of the present invention fully takes into account that the background environment will affect the facial features so that there is a certain interactive correlation between the background environment and the person. By performing background segmentation on the input image to identify the person image information and background image information therein, the background environment detection of the person can be enhanced in the face recognition process, and the interactive correlation between the person in the input image and its background environment can be identified, thereby effectively preventing the behavior of circumventing detection by simulating the background of the actual user, achieving the purpose of anti-counterfeiting, and ensuring the security and accuracy of face recognition.
[0103] See also Figure 3 According to a second aspect of an embodiment of the present invention, a face recognition anti-counterfeiting device 100 is provided, comprising:
[0104] The background segmentation module 11 is used to segment the person and background in the input image using a preset background segmentation model to obtain an image to be recognized;
[0105] The face recognition module 12 is used to perform face recognition on the image to be recognized by using a preset face recognition model to obtain a face recognition result of the input image.
[0106] As a preferred solution, the background segmentation model includes a depth separable convolution module, an image segmentation module and a segmentation edge processing module;
[0107] The background segmentation module 11 is used to segment the person and background in the input image using a preset background segmentation model to obtain an image to be recognized, specifically including:
[0108] Performing convolution processing on the input image through the depthwise separable convolution module to obtain a feature map corresponding to the input image;
[0109] Identifying the person pixels and background pixels in the feature map by the image segmentation module, and performing image segmentation on the feature map based on the person pixels and the background pixels to obtain an initial segmented image;
[0110] The segmentation edge processing module performs refinement processing on the segmentation edge in the initial segmentation image to obtain the image to be recognized.
[0111] As a preferred solution, the background segmentation module 11 is used to perform convolution processing on the input image through the depth-separable convolution module to obtain a feature map corresponding to the input image, specifically including:
[0112] Performing deep convolution processing on each channel of the input image through the deep separable convolution module to obtain a feature map corresponding to each channel;
[0113] Each of the feature maps is subjected to point-by-point convolution processing through the depth-wise separable convolution module to merge the feature maps to obtain the feature map.
[0114] As a preferred solution, the face recognition model includes a local feature enhancement module, a global feature enhancement module, a multi-scale feature fusion module and an image classification module;
[0115] The face recognition module 12 is used to perform face recognition on the image to be recognized using a preset face recognition model to obtain a face recognition result of the input image, specifically including:
[0116] The local feature enhancement module uses a Transformer encoder to extract visual spatial information features of the image to be identified, and enhances the spatial information and channel information of the visual spatial information features to obtain local features associated with the enhanced feature information;
[0117] By using the global feature enhancement module, the Transformer encoder is used to iteratively encode the image to be identified to obtain global feature information of the image to be identified; the self-attention mechanism is used to enhance the global feature information to obtain global features associated with the enhanced feature information;
[0118] The local feature and the global feature are fused by the multi-scale feature fusion module to obtain a fused feature;
[0119] Performing image classification and recognition based on the fusion features through the image classification module to obtain an image classification result;
[0120] A face recognition result of the input image is obtained according to the image classification result.
[0121] As a preferred solution, the face recognition module 12 is used to enhance the spatial information and channel information of the visual spatial information feature through the local feature enhancement module to obtain local features associated with the enhanced feature information, specifically including:
[0122] Through the local feature enhancement module, the visual spatial information features are respectively subjected to global maximum pooling processing and global average pooling processing in the spatial dimension to obtain a first pooling feature map and a second pooling feature map;
[0123] Through the local feature enhancement module, the first pooling feature map and the second pooling feature map are respectively subjected to nonlinear transformation, addition and activation to generate a channel attention weight;
[0124] The visual space information feature is multiplied by the channel attention weight through the local feature enhancement module to obtain a local feature with channel feature enhancement;
[0125] By means of the local feature enhancement module, the local features enhanced by the channel features are respectively subjected to global maximum pooling processing and global average pooling processing in the channel dimension to obtain a third pooling feature map and a fourth pooling feature map;
[0126] Through the local feature enhancement module, the third pooling feature map and the fourth pooling feature map are respectively concatenated, convolved and activated to generate a spatial attention weight;
[0127] Through the local feature enhancement module, the local features enhanced by the channel features are multiplied by the spatial attention weights to obtain local features associated with the enhanced feature information.
[0128] As a preferred solution, the face recognition module 12 is used to perform iterative encoding processing on the image to be recognized by using the Transformer encoder through the global feature enhancement module to obtain the global feature information of the image to be recognized, specifically including:
[0129] By using the global feature enhancement module, the image to be identified is iteratively encoded using the Transformer encoder to obtain a plurality of encoding feature vectors;
[0130] Several encoded feature vectors are concatenated to obtain the global feature information.
[0131] As a preferred solution, the face recognition module 12 is used to enhance the global feature information by using the self-attention mechanism through the global feature enhancement module to obtain global features associated with the enhanced feature information, specifically including:
[0132] Through the global feature enhancement module, a self-attention mechanism is used to obtain different attention scores related to the importance of facial image information in the global feature information, and the attention scores are integrated through a weight matrix to obtain the global feature.
[0133] As a preferred solution, the face recognition module 12 is used to obtain the face recognition result of the input image according to the image classification result, specifically including:
[0134] When the image classification result is a two-dimensional image, determining that the face recognition result is a face recognition failure;
[0135] When the image classification result is a three-dimensional image, the face recognition result is determined to be a successful face recognition.
[0136] As a preferred solution, the device further includes a model training module, which is used to:
[0137] Collecting a plurality of images containing characters and backgrounds, and preprocessing the plurality of images to obtain a plurality of images to be labeled;
[0138] Annotating the segmentation labels of the person and the background on a plurality of the images to be annotated to obtain image segmentation training samples;
[0139] According to a preset loss function and Adam optimization algorithm, an untrained background segmentation model is trained using the image segmentation training samples to obtain the background segmentation model; wherein the loss function is a weighted sum of a pixel-level cross entropy loss and an edge-sensitive loss.
[0140] The face recognition anti-counterfeiting device 100 provided in the embodiment of the present invention fully considers that the background environment will affect the facial features so that there is a certain interactive correlation between the background environment and the person. By performing background segmentation on the input image to identify the person image information and background image information therein, the background environment detection of the person can be enhanced in the process of face recognition, and the interactive correlation between the person in the input image and its background environment can be identified, thereby effectively preventing the behavior of evading detection by simulating the background of the actual user, achieving the purpose of anti-counterfeiting and ensuring the security and accuracy of face recognition.
[0141] See also Figure 4 A third aspect of an embodiment of the present invention provides an electronic device 200, comprising a memory 22, a processor 21, and a computer program stored in the memory 22 and executable on the processor 21, wherein the processor 21 implements the face recognition anti-counterfeiting method described in any embodiment of the first aspect when executing the computer program.
[0142] Exemplarily, the computer program may be divided into one or more modules / units, which are stored in the memory 22 and executed by the processor 21 to implement the present invention. The one or more modules / units may be a series of computer program instruction segments capable of implementing specific functions, which are used to describe the execution process of the computer program in the electronic device 200.
[0143] The electronic device 200 may include, but is not limited to, a processor 21 and a memory 22. Those skilled in the art will appreciate that the schematic diagram is merely an example of the electronic device 200 and does not limit the electronic device 200. The electronic device 200 may include more or fewer components than shown in the figure, or may combine certain components, or different components. For example, the electronic device 200 may also include input and output devices, network access devices, buses, etc.
[0144] The processor 21 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor 21 may also be any conventional processor 21, etc. The processor 21 is the control center of the electronic device 200, and uses various interfaces and lines to connect various parts of the entire electronic device 200.
[0145] The memory 22 can be used to store the computer program and / or module. The processor 21 realizes various functions of the electronic device 200 by running or executing the computer program and / or module stored in the memory 22 and calling the data stored in the memory 22. The memory 22 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 22 can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0146] A fourth aspect of an embodiment of the present invention provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the face recognition anti-counterfeiting method described in any embodiment of the first aspect.
[0147] A fifth aspect of an embodiment of the present invention provides a computer program product, including a computer program / instruction, which, when executed by a processor, implements the steps of the face recognition anti-counterfeiting method described in any embodiment of the first aspect.
[0148] Wherein, if the module / unit integrated in the electronic device 200 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc.
[0149] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A face recognition anti-counterfeiting method, characterized in that: include: Use a preset background segmentation model to segment the person and background in the input image to obtain an image to be recognized; A preset face recognition model is used to perform face recognition on the image to be recognized to obtain a face recognition result of the input image.
2. The face recognition anti-counterfeiting method according to claim 1, characterized in that: The background segmentation model includes a depth separable convolution module, an image segmentation module and a segmentation edge processing module; The method of using a preset background segmentation model to segment the person and background in the input image to obtain the image to be recognized specifically includes: Performing convolution processing on the input image through the depthwise separable convolution module to obtain a feature map corresponding to the input image; Identifying the person pixels and background pixels in the feature map by the image segmentation module, and performing image segmentation on the feature map based on the person pixels and the background pixels to obtain an initial segmented image; The segmentation edge processing module performs refinement processing on the segmentation edge in the initial segmentation image to obtain the image to be recognized.
3. The face recognition anti-counterfeiting method according to claim 2, characterized in that: The step of performing convolution processing on the input image by the depthwise separable convolution module to obtain a feature map corresponding to the input image specifically includes: Performing deep convolution processing on each channel of the input image through the deep separable convolution module to obtain a feature map corresponding to each channel; Each of the feature maps is subjected to point-by-point convolution processing through the depth-wise separable convolution module to merge the feature maps to obtain the feature map.
4. The face recognition anti-counterfeiting method according to claim 1, characterized in that: The face recognition model includes a local feature enhancement module, a global feature enhancement module, a multi-scale feature fusion module and an image classification module; The step of using a preset face recognition model to perform face recognition on the image to be recognized to obtain a face recognition result of the input image specifically includes: The local feature enhancement module uses a Transformer encoder to extract visual spatial information features of the image to be identified, and enhances the spatial information and channel information of the visual spatial information features to obtain local features associated with the enhanced feature information; By using the global feature enhancement module, the Transformer encoder is used to iteratively encode the image to be identified to obtain global feature information of the image to be identified; the self-attention mechanism is used to enhance the global feature information to obtain global features associated with the enhanced feature information; The local feature and the global feature are fused by the multi-scale feature fusion module to obtain a fused feature; Performing image classification and recognition based on the fusion features through the image classification module to obtain an image classification result; A face recognition result of the input image is obtained according to the image classification result.
5. The face recognition anti-counterfeiting method according to claim 4, characterized in that: The method performs feature enhancement on the spatial information and channel information of the visual spatial information feature through the local feature enhancement module to obtain local features associated with the enhanced feature information, specifically including: Through the local feature enhancement module, the visual spatial information features are respectively subjected to global maximum pooling processing and global average pooling processing in the spatial dimension to obtain a first pooling feature map and a second pooling feature map; Through the local feature enhancement module, the first pooling feature map and the second pooling feature map are respectively subjected to nonlinear transformation, addition and activation to generate a channel attention weight; The visual space information feature is multiplied by the channel attention weight through the local feature enhancement module to obtain a local feature with channel feature enhancement; By means of the local feature enhancement module, the local features enhanced by the channel features are respectively subjected to global maximum pooling processing and global average pooling processing in the channel dimension to obtain a third pooling feature map and a fourth pooling feature map; Through the local feature enhancement module, the third pooling feature map and the fourth pooling feature map are respectively concatenated, convolved and activated to generate a spatial attention weight; Through the local feature enhancement module, the local features enhanced by the channel features are multiplied by the spatial attention weights to obtain the local features associated with the enhanced feature information.
6. The face recognition anti-counterfeiting method according to claim 4, characterized in that: The method uses the global feature enhancement module and the Transformer encoder to iteratively encode the image to be identified to obtain global feature information of the image to be identified, specifically including: By using the global feature enhancement module, the Transformer encoder is used to iteratively encode the image to be identified to obtain a plurality of encoding feature vectors; Several encoded feature vectors are concatenated to obtain the global feature information.
7. The face recognition anti-counterfeiting method according to claim 4, characterized in that: The method uses the global feature enhancement module to enhance the global feature information using a self-attention mechanism to obtain global features associated with the enhanced feature information, specifically including: Through the global feature enhancement module, a self-attention mechanism is used to obtain different attention scores related to the importance of facial image information in the global feature information, and the attention scores are integrated through a weight matrix to obtain the global feature.
8. The face recognition anti-counterfeiting method according to claim 4, characterized in that: The obtaining, according to the image classification result, a face recognition result of the input image, specifically comprises: When the image classification result is a two-dimensional image, determining that the face recognition result is a face recognition failure; When the image classification result is a three-dimensional image, the face recognition result is determined to be a successful face recognition.
9. The face recognition anti-counterfeiting method according to claim 1, characterized in that: The method specifically obtains the background segmentation model through training by the following steps: Collecting a plurality of images containing characters and backgrounds, and preprocessing the plurality of images to obtain a plurality of images to be labeled; Annotating the segmentation labels of the person and the background on a plurality of the images to be annotated to obtain image segmentation training samples; According to a preset loss function and Adam optimization algorithm, an untrained background segmentation model is trained using the image segmentation training samples to obtain the background segmentation model; wherein the loss function is a weighted sum of a pixel-level cross entropy loss and an edge-sensitive loss.
10. A face recognition anti-counterfeiting device, characterized in that: include: The background segmentation module is used to segment the person and background in the input image using a preset background segmentation model to obtain an image to be recognized; The face recognition module is used to perform face recognition on the image to be recognized using a preset face recognition model to obtain a face recognition result of the input image.
11. An electronic device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the face recognition anti-counterfeiting method according to any one of claims 1 to 9 when executing the computer program.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the face recognition anti-counterfeiting method according to any one of claims 1 to 9.
13. A computer program product, characterized in that The method comprises a computer program / instruction, which, when executed by a processor, implements the steps of the face recognition anti-counterfeiting method according to any one of claims 1 to 9.