A face recognition method and system based on AI intelligence
Through adaptive processing and attention feature classification model, high-dimensional face feature vectors are extracted, which solves the problem of insufficient face recognition accuracy and generalization ability in the prior art, and realizes efficient recognition of diverse face images and Identity matching.
Patent Information
- Application Number
- CN202410901321.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2044-07-05
AI Technical Summary
Existing facial recognition technology is difficult to fully capture the unique features of the face and cannot effectively deal with the diverse changes in facial images, resulting in insufficient recognition accuracy and generalization capabilities.
Using AI intelligence-based face recognition method, high-dimensional face feature vectors are extracted through adaptive image denoising processing and histogram equalization, and the attention feature classification model is used to perform identity tags and confidence scores, combined with employee matching templates library for identification.
It improves the accuracy and generalization ability of face recognition, can effectively deal with the diverse changes in face images, and ensures high accuracy and reliability of identity matching.
Smart Images

Figure CN118430054B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of face recognition technology, and more specifically, to an AI-based face recognition method and system. Background Art
[0002] The patent with application publication number CN110705419A discloses an emotion recognition method, an early warning method, a model training method and related devices, which relate to the field of biometric recognition technology, including: extracting a face area image from an image to be recognized, performing feature extraction on the face area image using a convolution layer and a pooling layer to obtain an emotion feature vector of the face in the face area image, processing the emotion feature vector using a GAP layer to obtain the confidence of the face in the face area image under each emotion label, and identifying the emotion reflected by the face in the face area image based on the confidence of each emotion label, thereby improving the efficiency of identifying facial emotions.
[0003] First, traditional methods can only capture part of the visual information of the face image locally and cannot fully describe the unique features of the face, which brings many difficulties and limitations to the subsequent recognition tasks. Due to the lack of full expression of the rich features of the face, the recognition accuracy and generalization ability are often unsatisfactory; secondly, in the feature extraction process, fixed parameter settings are usually used, and it is impossible to dynamically adjust according to the actual quality and complexity of the image, which may lead to distortion or over-enhancement of the feature extraction effect. In addition, the lack of synchronous grasp of the overall and local information of the face makes it difficult to fully describe the unique recognition mode of the face, and the recognition accuracy and generalization ability are naturally limited to a certain extent. Finally, the existing methods cannot effectively cope with the diverse changes in facial images in posture, expression, lighting, etc., resulting in more errors in the subsequent identity matching process, reducing the accuracy and reliability of the matching. In general, the existing technology has certain deficiencies in capturing facial information, feature extraction, model construction, identity matching and other links, which directly restricts the performance and practical value of the face recognition system.
[0004] In view of this, the present invention proposes an AI-based face recognition method and system to solve the above problems. Summary of the invention
[0005] In order to overcome the above-mentioned defects of the prior art and to achieve the above-mentioned purpose, the present invention provides the following technical solution: a face recognition method based on AI intelligence, comprising: S1, collecting face image data, and preprocessing the face image data to obtain a face area image;
[0006] S2, extracting high-dimensional face feature vector from the face area image;
[0007] S3, inputting the high-dimensional face feature vector into the pre-built attention feature classification model to obtain n identity tags and confidence scores corresponding to the n identity tags;
[0008] S4. Preset an employee matching template library, and identify the employee identity from the employee matching template library based on the high-dimensional face feature vector, n identity tags, and confidence scores corresponding to the n identity tags.
[0009] Furthermore, the method of preprocessing the facial image data includes:
[0010] Performing adaptive image denoising on the face image data to obtain denoised image data, and performing adaptive histogram equalization on the denoised image data to obtain equalized image data;
[0011] The equalized image data is processed using a face detection and segmentation method to obtain a face region image;
[0012] The method for performing adaptive image denoising processing includes:
[0013] The face image data is initially divided into N fixed-size image blocks, and the gradient of the image blocks is calculated to obtain the horizontal gradient and vertical gradient , based on the horizontal gradient and vertical gradient Calculate the gradient amplitude of the image block ;
[0014] And count the gradient amplitude of the image block The mean and variance of , as statistical features;
[0015] The size of the image block is adjusted according to the variance value. The size of the image block is , calculate the threshold range of variance [T min , T max ], if the variance is less than T min , then adjust the size of the image block to ;
[0016] , ;
[0017] in, is the width increment of the image block size, is the height increment of the image block size;
[0018] If the variance is greater than T max , then adjust the size of image block B0 to ;
[0019] , ;
[0020] in, is the width of the image block size minus the width, is the height decrement of the image block size, The lower width limit of the image block size, is the lower limit of the height of the image block size;
[0021] in, ,in, The current image block The gradient amplitude variance is The current image block The variance of the wavelet coefficients is is the average trade-off parameter;
[0022] After resizing the image block Perform gradient calculation to obtain the gradient amplitude of the resized image block ,statistics The mean and variance , as Statistical characteristics of ;
[0023] For image blocks Perform wavelet transform to obtain wavelet coefficients at each scale, and count the wavelet coefficients at the smallest scale. The mean and variance , as the wavelet coefficients Statistical characteristics of ;
[0024] The most matching noise type is obtained based on the statistical characteristics; the noise types include Gaussian noise and salt and pepper noise, and the corresponding noise types are repeatedly obtained for all image blocks; for Gaussian noise, denoising is performed using soft threshold or hard threshold filtering in the wavelet domain or Fourier domain, and for salt and pepper noise, denoising is performed using adaptive threshold filtering or median filtering in the wavelet domain, thus completing the adaptive image denoising process.
[0025] Furthermore, the method of obtaining the most matching noise type includes:
[0026] Defining the Gradient Magnitude Statistics Model and wavelet coefficient statistics model , calculate the statistical characteristics and and The distance metric value is calculated as follows:
[0027] ;
[0028] in, for The mean of for The variance of is the wavelet coefficient distance function; is the distance metric;
[0029] Wavelet coefficient distance function ,in, for The mean of for The variance of
[0030] Find the noise type with the smallest distance metric value, which is the most matching noise type.
[0031] Furthermore, the method of performing adaptive histogram equalization processing includes:
[0032] Divide the denoised image data into m1×n1 overlapping sub-regions ,in is a positive integer in the interval [1, m1], is a positive integer in the interval [1, n1], and the calculation formula for the size of the sub-region is: , among which, among which, is the initial width of the sub-region, is the initial height of the subregion, For sub-region The local contrast, For sub-region The texture features of and is the adjustment parameter;
[0033] For sub-region The width of For sub-region The height of the sub-area is the width multiplied by the height.
[0034] For each sub-region , calculate the gray level In sub-area The number of pixels in ,in For the interval Positive integers within is the number of gray levels;
[0035] based on Calculate the value of the cumulative distribution function, the calculation formula is:
[0036] ,in, For the sub-area Gray level calculated in The cumulative distribution probability is the value of the cumulative distribution function;
[0037] For sub-region The total number of pixels in is the gray level sum index;
[0038] For denoised image data Each pixel in , its gray value Mapped to the enhanced grayscale value , the mapping formula is: ;
[0039] in, For the sub-area Calculated in The cumulative distribution probability of
[0040] The sub-regions containing the enhanced grayscale values are spliced back to the size of the original denoised image data to form balanced image data.
[0041] Furthermore, the method of processing the equalized image data using the face detection and segmentation method to obtain the face area image includes:
[0042] The fast face detection method based on Haar features and AdaBoost classifier is used to equalize the image data, and the bounding box coordinates of the detected face area are output;
[0043] Collect N2 groups of face images, manually mark the coordinates of the face key points in the face images, and normalize the coordinates of the marked face key points to obtain the face shape vector;
[0044] Calculate average face shape based on face shape vector and the principal component matrix , and obtain the statistical shape model ;
[0045] in, is the shape parameter;
[0046] Input the bounding box coordinates of the detected face area, and search for the shape parameters that best match the statistical shape model with the actual face area in the face area, which are recorded as the best matching parameters. ;
[0047] This is the final face area segmentation result;
[0048] Limit the best matching parameters The value range of is limited by the formula:
[0049] ,in, is the regularization parameter used to balance the fitting error and parameter complexity;
[0050] The final face region segmentation result is used to extract the face region image from the equalized image data.
[0051] Furthermore, the method of extracting the high-dimensional face feature vector includes:
[0052] Using the face key point detection algorithm, a series of key points are detected from the face area image;
[0053] Calculate the distance and angle between key points as geometric features and concatenate them into geometric feature vectors ;
[0054] The face area image is divided into M2×N2 non-overlapping small blocks. For each small block, the variance of the gradient amplitude is calculated as the local texture complexity.
[0055] Initially define the intrinsic parameters of the Gabor filter, based on each small block The local texture complexity , adaptively adjust the intrinsic parameters of the Gabor filter, which include wavelength, direction, Gaussian kernel standard deviation and aspect ratio;
[0056] Adopting the adaptively adjusted Gabor filter to filter the face area image, and obtaining Gabor feature maps of different scales;
[0057] wavelength ,direction , Gaussian kernel standard deviation , aspect ratio ;
[0058] in, Initially defined wavelength, is the direction initially defined, is the standard deviation of the initially defined Gaussian kernel, is the initially defined aspect ratio;
[0059] is the wavelength adjustment coefficient, is the direction adjustment coefficient, is the Gaussian kernel standard deviation adjustment coefficient, is the aspect ratio adjustment factor;
[0060] Calculate statistical features for each Gabor feature map, including mean, variance and entropy, and concatenate the statistical feature groups into a preliminary texture feature vector;
[0061] Input the face region image into the convolution layer of the VGGFace2 or FaceNet model, extract the local feature vector output by the middle convolution layer; concatenate the local feature vector with the preliminary texture feature vector to form a texture feature vector; define the identity label, calculate the mutual information value between each texture feature vector and the identity label, sort the mutual information values corresponding to all texture feature vectors in descending order, select the texture feature vectors corresponding to the first N3 mutual information values to form a comprehensive texture feature vector; concatenate the comprehensive texture feature vector and the geometric feature vector to obtain a high-dimensional face feature vector;
[0062] The mutual information value is calculated by:
[0063] ;
[0064] in, Represents the texture feature vector The marginal probability distribution of Indicates identity tag The marginal probability distribution of express and The joint probability distribution of is the set of all texture feature vectors, is the set of all identity tags.
[0065] Furthermore, the construction method of the attention feature classification model includes:
[0066] Define the basic structure of the attention feature classification model, which includes input layer, feature transformation layer, hierarchical attention structure, feature fusion layer, fully connected layer and output layer; the hierarchical attention structure includes global attention sublayer and local attention sublayer;
[0067] The hierarchical attention structure is repeatedly stacked N4 times;
[0068] The fully connected layer maps the last output fusion feature vector to the classification space and outputs n neurons corresponding to n identity labels;
[0069] The output layer uses the Softmax activation function to convert the output of the fully connected layer into a probability distribution in the interval [0, 1] as the confidence score of each identity tag;
[0070] Collect historical data, which are N5 groups of high-dimensional face feature vectors and corresponding identity labels, use the historical data as training data for the attention feature classification model, and define the loss function and optimizer of the attention feature classification model;
[0071] If the value of the loss function no longer decreases during PL consecutive trainings on the training data, the training is stopped and the parameters of the attention feature classification model are retained, thus completing the construction of the attention feature classification model.
[0072] Furthermore, the input layer is used to receive a high-dimensional face feature vector as input, and the feature transformation layer linearly maps the input high-dimensional face feature vector to a low-dimensional feature space vector through a fully connected layer or a convolutional layer;
[0073] The global attention sublayer uses the structure of the SENet network and uses convolution kernels instead of the fully connected layer of the SENet network. Get the global attention weight vector ,in, is the Sigmoid activation function; is the ReLU activation function, is a two-dimensional convolution operation, is the weight of the first convolution kernel, is the weight of the second convolution kernel;
[0074] The global attention weight vector is combined with the feature space vector Multiply element by element to get the weighted global eigenvector ;
[0075] The local attention sublayer uses a self-attention mechanism to calculate the query vector , key vector Sum value vector ;
[0076] in, To query the projection matrix, is the key projection matrix, is the value projection matrix;
[0077] Calculate the attention weight matrix based on the query vector and key vector ;
[0078] in, is the key vector The transpose of is the relative position encoding matrix, is the dimension of the key vector;
[0079] The local feature vector is calculated based on the value vector and the attention weight matrix ;
[0080] The feature fusion layer uses gated fusion to weight the global feature vector and the local eigenvector Fusion on the channel dimension to obtain the fused feature vector ;
[0081] ;
[0082] in, ;
[0083] is the global convolution kernel weight, is the local convolution kernel weight.
[0084] Furthermore, the preset method of the employee matching template library includes:
[0085] Collect the identity information and facial image data of all employees of the company. The identity information includes name, position and department. Take standardized facial photos of employees as facial image data. Based on the collected facial image data, calculate the high-dimensional facial feature vector of each employee. Cluster the B high-dimensional facial feature vectors of each employee and use the cluster center as the representative feature vector of the employee. Based on the representative feature vector obtained by clustering, build a template entry for each employee. The template entry includes employee ID, employee basic information, representative feature vector and facial image data, thus completing the preset of the employee matching template library.
[0086] The employee identification methods include:
[0087] Calculate high-dimensional facial feature vectors The similarity between the representative feature vector corresponding to each employee in the employee matching template library,
[0088] The similarity calculation formula is:
[0089] ,in, Match the employee in the template library The representative feature vector corresponding to each employee is is the bandwidth parameter, which is used to control the smoothness and influence range;
[0090] is a high-dimensional face feature vector The normalized vector of for The normalized vector of For , Weight vector of the same dimension;
[0091] Constructing an employee match score based on confidence score and similarity ;
[0092] in, For the confidence score, is the balance weight parameter;
[0093] The maximum value of all employee matching scores obtained is taken as the optimal matching value, and the template entry of the employee corresponding to the optimal matching value is extracted as the identification result of the employee identity.
[0094] An AI-based face recognition system, which is used to implement the AI-based face recognition method, includes: an image acquisition and processing module, which is used to acquire face image data and pre-process the face image data to obtain a face area image;
[0095] A vector extraction module is used to extract high-dimensional facial feature vectors from facial region images;
[0096] A model fitting module is used to input the high-dimensional face feature vector into the pre-built attention feature classification model to obtain n identity tags and the confidence scores corresponding to the n identity tags;
[0097] The matching module is used to preset an employee matching template library, and identify the employee identity from the employee matching template library based on a high-dimensional face feature vector, n identity tags, and confidence scores corresponding to the n identity tags; each module is connected by wire and / or wireless means.
[0098] The technical effects and advantages of the AI-based face recognition method and system of the present invention are as follows:
[0099] The present invention can efficiently capture the rich visual information contained in facial images, comprehensively depict the unique features of the face, and lay the foundation for subsequent recognition tasks. At the same time, it has the ability of adaptive optimization, and can dynamically adjust the processing flow according to the actual quality and complexity of the image, ensuring the accuracy and robustness of feature extraction, and effectively avoiding the distortion or over-enhancement problems commonly found in traditional methods. Secondly, it can pay attention to the overall structure and local detail information of the face at the same time, comprehensively grasp the unique recognition mode of the face, and greatly improve the recognition accuracy and generalization ability. Finally, it can effectively cope with the diverse changes of facial images, and ensure the high accuracy and reliability of subsequent identity matching. BRIEF DESCRIPTION OF THE DRAWINGS
[0100] Figure 1 A schematic diagram of a face recognition method based on AI intelligence of the present invention;
[0101] Figure 2The figure is a schematic diagram of a face recognition system based on AI intelligence of the present invention. DETAILED DESCRIPTION
[0102] 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.
[0103] Example 1
[0104] See also Figure 1 As shown, the face recognition method based on AI intelligence described in this embodiment includes:
[0105] S1, collecting face image data, and preprocessing the face image data to obtain a face area image;
[0106] S2, extracting high-dimensional face feature vector from the face area image;
[0107] S3, inputting the high-dimensional face feature vector into the pre-built attention feature classification model to obtain n identity tags and confidence scores corresponding to the n identity tags;
[0108] S4. Preset an employee matching template library, and identify the employee identity from the employee matching template library based on the high-dimensional face feature vector, n identity tags, and confidence scores corresponding to the n identity tags.
[0109] By using a camera or a camera to collect face image data in real time;
[0110] Furthermore, the method of preprocessing the face image data includes:
[0111] Performing adaptive image denoising on the face image data to obtain denoised image data, and performing adaptive histogram equalization on the denoised image data to obtain equalized image data;
[0112] The equalized image data is processed using the face detection and segmentation method to obtain the face area image.
[0113] The method for performing adaptive image denoising processing includes:
[0114] The face image data is initially divided into N image blocks of fixed size, for example, 8×8 or 16×16 pixels;
[0115] Calculate the gradient of the image block to get the horizontal gradient and vertical gradient , based on the horizontal gradient and vertical gradient Calculate the gradient amplitude of the image block ;
[0116] And count the gradient amplitude of the image block The mean and variance of are used as statistical features.
[0117] The size of the image block is adjusted according to the variance value. The size of the image block is , calculate the threshold range of variance [T min , T max ], if the variance is less than T min , it means that the image block is too flat and needs to be enlarged to include more detailed information. Then adjust the size of image block B0 to ;
[0118] , ;
[0119] in, is the width increment of the image block size, Height increment for image block size.
[0120] If the variance is greater than T max , it means that the image block is too complex and the block size needs to be reduced to reduce noise interference;
[0121] Then adjust the size of image block B0 to ;
[0122] , ;
[0123] in, is the width of the image block size minus the width, is the height decrement of the image block size, The lower width limit of the image block size, The lower limit of the height of the image block size; the lower limit of the width and height to prevent over-scaling.
[0124] in, ,in, The current image block The gradient amplitude variance is The current image block The variance of the wavelet coefficients is is the average trade-off parameter used to balance the weight between the gradient amplitude and the wavelet coefficient. A number greater than 0 and less than 1.
[0125] After resizing the image block Perform gradient calculation to obtain the gradient amplitude of the resized image block ,statistics The mean and variance , as Statistical characteristics of ;
[0126] The noise type used for detection is Gaussian noise.
[0127] For image blocks Perform wavelet transform to obtain wavelet coefficients at each scale, and count the wavelet coefficients at the smallest scale. The mean and variance , as the wavelet coefficients Statistical characteristics of ;
[0128] The type of noise used for detection is salt and pepper noise;
[0129] Obtain the most matching noise type based on statistical characteristics;
[0130] Noise types include Gaussian noise and salt and pepper noise.
[0131] Defining the Gradient Magnitude Statistics Model and wavelet coefficient statistics model , for different types of noise (such as Gaussian noise, salt and pepper noise, etc.), obtain their and ;
[0132] For example, for Gaussian noise, is the Gaussian distribution parameter of the gradient amplitude, is the Gaussian distribution parameter of the wavelet coefficients.
[0133] Calculate statistical characteristics and and The distance metric value is calculated as follows:
[0134] ;
[0135] in, for The mean of for The variance of is the wavelet coefficient distance function;
[0136] is the distance metric;
[0137] Wavelet coefficient distance function ,in, for The mean of for The variance of
[0138] Find the noise type with the smallest distance metric value, which is the most matching noise type, and repeat for all image blocks to obtain the corresponding noise type.
[0139] For Gaussian noise, denoising is performed using soft threshold or hard threshold filtering in the wavelet domain or Fourier domain. For salt and pepper noise, denoising is performed using adaptive threshold filtering or median filtering in the wavelet domain, thus completing adaptive image denoising processing.
[0140] It should be noted that the width increment, height increment, width decrement and height decrement can first set a smaller initial block size (such as 8x8), and then appropriately increase or decrease the block size according to the change in variance. The specific values of the increment and decrement can be fixed (such as 2, 4, etc.) or adaptive (such as dynamically adjusted according to the variance size).
[0141] Furthermore, the method of performing adaptive histogram equalization processing includes:
[0142] Divide the denoised image data into m1×n1 overlapping sub-regions ,in is a positive integer in the interval [1, m1], is a positive integer in the interval [1, n1], and the calculation formula for the size of the sub-region is: , among which, among which, is the initial width of the sub-region, is the initial height of the subregion, For sub-region The local contrast, For sub-region The texture features of and is the adjustment parameter; For sub-region The width of For sub-region The height of the sub-area is the width multiplied by the height.
[0143] The texture features are described using the statistical characteristics of the gray-level co-occurrence matrix, and the local contrast is obtained by calculating the standard deviation of the pixel values in the sub-region or other contrast metrics. Specifically, each pixel in the sub-region is traversed, the difference between it and the neighboring pixels is calculated, and then the standard deviation of these differences is counted as the local contrast.
[0144] For each sub-region , calculate the gray level In sub-area The number of pixels in ,in For the interval Positive integers within is the number of gray levels.
[0145] based on Calculate the value of the cumulative distribution function, the calculation formula is:
[0146] ,in, For the sub-area Gray level calculated in The cumulative distribution probability is the value of the cumulative distribution function;
[0147] For sub-region The total number of pixels in Gray level sum index.
[0148] For denoised image data Each pixel in , is the horizontal coordinate of the pixel point in the image coordinate system, The vertical coordinate of the pixel point in the image coordinate system is its gray value Mapped to the enhanced grayscale value , the mapping formula is: ;
[0149] in, For the sub-area Calculated in The cumulative distribution probability of .
[0150] splicing the sub-regions containing the enhanced grayscale values back to the size of the original denoised image data to form balanced image data;
[0151] In the overlapping area, weighted averaging is used for fusion to ensure smooth transition.
[0152] The size and overlap of the sub-regions are adaptively adjusted according to the local features of the image, thereby obtaining a more natural enhancement effect and avoiding over-enhancement or distortion problems.
[0153] Furthermore, the method of processing the equalized image data using the face detection and segmentation method to obtain the face area image includes:
[0154] The fast face detection method based on Haar features and AdaBoost classifier is used to equalize the image data, and the bounding box coordinates of the detected face area are output;
[0155] Collect N2 groups of face images, manually mark the coordinates of the face key points in the face images, and normalize the coordinates of the marked face key points to obtain the face shape vector.
[0156] Calculate average face shape based on face shape vector and the principal component matrix , and obtain the statistical shape model ;
[0157] in, is the shape parameter.
[0158] Specifically, the mean vector of all face shape vectors is calculated as the average face shape, each face shape vector is subtracted from the average face shape to obtain a special matrix, the special matrix is subjected to singular value decomposition to obtain a column orthogonal matrix, and the first KL (such as KL=20) columns of the column orthogonal matrix are taken as the principal component matrix.
[0159] Input the bounding box coordinates of the detected face area, and search for the shape parameters that best match the statistical shape model with the actual face area in the face area, which are recorded as the best matching parameters. ; This is the final face region segmentation result.
[0160] Limit the best matching parameters The value range of is limited by the formula:
[0161] ,in, is the regularization parameter used to balance the fitting error and parameter complexity;
[0162] The final face region segmentation result is used to extract the face region image from the equalized image data.
[0163] Furthermore, the method of extracting the high-dimensional face feature vector includes:
[0164] Using the facial key point detection algorithm, a series of key points are detected from the face area image, such as the corners of the eyes, the tip of the nose, and the corners of the mouth.
[0165] Calculate the distance and angle between key points as geometric features and concatenate them into geometric feature vectors ;
[0166] The face area image is divided into M2×N2 non-overlapping small blocks. For each small block, the variance of the gradient amplitude is calculated as the local texture complexity.
[0167] Initially define the intrinsic parameters of the Gabor filter, based on each small block The local texture complexity , adaptively adjust the intrinsic parameters of the Gabor filter, which include wavelength, direction, Gaussian kernel standard deviation and aspect ratio;
[0168] The face area image is filtered using the adaptively adjusted Gabor filter to obtain Gabor feature maps of different scales.
[0169] wavelength ,direction , Gaussian kernel standard deviation , aspect ratio ;
[0170] in, Initially defined wavelength, is the direction initially defined, is the standard deviation of the initially defined Gaussian kernel, is the initially defined aspect ratio; is the wavelength adjustment coefficient, is the direction adjustment coefficient, is the Gaussian kernel standard deviation adjustment coefficient, is the aspect ratio adjustment factor.
[0171] Calculate statistical features for each Gabor feature map, including mean, variance and entropy, and concatenate the statistical feature groups into a preliminary texture feature vector;
[0172] Input the face region image into the convolution layer of the VGGFace2 or FaceNet model, and extract the local feature vector output by the middle convolution layer;
[0173] The local feature vector not only contains rich texture information, but also has strong discriminative ability and robustness.
[0174] The local feature vector is concatenated with the preliminary texture feature vector to form a texture feature vector;
[0175] The dimension of the final texture feature vector will be higher in order to improve computational efficiency and generalization performance;
[0176] Define the identity label, calculate the mutual information value between each texture feature vector and the identity label, sort the mutual information values corresponding to all texture feature vectors in descending order, select the texture feature vectors corresponding to the first N3 mutual information values, and form the optimized texture feature vector, that is, the comprehensive texture feature vector.
[0177] The mutual information value is calculated by:
[0178] ;
[0179] in, Represents the texture feature vector The marginal probability distribution of Indicates identity tag The marginal probability distribution of express and The joint probability distribution of is the set of all texture feature vectors, is the set of all identity tags, , and It is obtained by the sample frequency in the training data set, which is a training set of collected texture feature vectors and identity labels;
[0180] The comprehensive texture feature vector and the geometric feature vector are concatenated to obtain a high-dimensional face feature vector.
[0181] Comprehensive features including geometry and texture are extracted from the face area image and fused to form a high-dimensional face feature vector. This high-dimensional feature vector can well represent the various visual features of the face and provide richer and more robust input data for subsequent face recognition tasks.
[0182] Furthermore, the construction method of the attention feature classification model includes:
[0183] Define the basic structure of the attention feature classification model, which includes input layer, feature transformation layer, hierarchical attention structure, feature fusion layer, fully connected layer and output layer; the hierarchical attention structure includes global attention sublayer and local attention sublayer.
[0184] The input layer is used to receive a high-dimensional face feature vector as input. The feature transformation layer linearly maps the input high-dimensional face feature vector to a low-dimensional feature space vector through a fully connected layer or a convolutional layer to reduce the complexity of subsequent calculations.
[0185] The global attention sublayer uses the structure of the SENet network and uses convolution kernels instead of the fully connected layer of the SENet network. Get the global attention weight vector ,in, Sigmoid activation function limits the output to the interval [0, 1];
[0186] is the ReLU activation function, used to increase nonlinearity, is a two-dimensional convolution operation, is the weight of the first convolution kernel, is the weight of the second convolution kernel;
[0187] The global attention weight vector is combined with the feature space vector Multiply element by element to get the weighted global eigenvector .
[0188] The local attention sublayer uses a self-attention mechanism to calculate the query vector , key vector Sum value vector ;
[0189] in, To query the projection matrix, is the key projection matrix, are value projection matrices, which are all trainable parameters and are automatically learned during the training process.
[0190] Calculate the attention weight matrix based on the query vector and key vector ;
[0191] in, is the key vector The transpose of is the relative position encoding matrix, which is used to capture the relative position relationship between features;
[0192] is the dimension of the key vector, used to scale the dot product result;
[0193] The relative position encoding matrix encodes the relative position information between each pair of input features. The encoding method uses trigonometric functions, which has a certain smoothness and periodicity and can better capture the sequence information of the position.
[0194] The local feature vector is calculated based on the value vector and the attention weight matrix ;
[0195] The feature fusion layer uses gated fusion to weight the global feature vector and the local eigenvector Fusion on the channel dimension to obtain the fused feature vector ;
[0196] ;
[0197] in, ;
[0198] is the global convolution kernel weight, is the local convolution kernel weight.
[0199] The hierarchical attention structure is repeatedly stacked N4 times to form a deep attention module to capture attention features at different levels of abstraction;
[0200] The fully connected layer maps the last output fused feature vector to the classification space and outputs n neurons corresponding to n identity labels.
[0201] The output layer uses the Softmax activation function to convert the output of the fully connected layer into a probability distribution in the interval [0, 1] as the confidence score of each identity label.
[0202] Collect historical data, which is N5 groups of high-dimensional facial feature vectors and corresponding identity tags. The identity tag can be a unique ID or other feature data that reflects the identity.
[0203] The historical data is used as the training data of the attention feature classification model, and the loss function and optimizer of the attention feature classification model are defined. The optimizer is used to optimize the parameters of the attention feature classification model. If the value of the loss function no longer decreases during PL consecutive training times on the training data, the training is stopped and the parameters of the attention feature classification model are retained, thus completing the construction of the attention feature classification model.
[0204] Through the hierarchical attention mechanism, the model can simultaneously focus on the global information and local details of the input facial features. The global attention weight guides the model's selection of overall features, while the local attention captures the correlation and interaction between different local features. The combination of the two can better simulate the discriminative patterns of faces and improve recognition accuracy and robustness.
[0205] Furthermore, the preset method of the employee matching template library includes:
[0206] Collect the identity information and facial image data of all company employees. The identity information includes name, position and department;
[0207] The company's human resources management system is used to obtain employee information and to take standardized facial photos of employees as facial image data.
[0208] Based on the collected facial image data, the high-dimensional facial feature vector of each employee is calculated using the feature extraction method mentioned above.
[0209] Since the collection conditions of facial image data may be different (such as posture, expression, lighting, etc.), there may be certain differences in multiple facial images of the same employee. The B high-dimensional facial feature vectors of each employee are clustered, and the cluster center is used as the representative feature vector of the employee. The clustering algorithm for clustering selects K-Means or spectral clustering. Based on the representative feature vector obtained by clustering, a template entry is constructed for each employee. The template entry includes employee ID (unique identifier), employee basic information (name, position and department), representative feature vector and facial image data (optional, for visual display), thus completing the preset of the employee matching template library.
[0210] Build a high-quality, robust and scalable employee matching template library to provide a reliable basic support for subsequent identity recognition and matching tasks.
[0211] Furthermore, the employee identification method includes:
[0212] Calculate high-dimensional facial feature vectors The similarity between the representative feature vector corresponding to each employee in the employee matching template library;
[0213] The similarity calculation formula is:
[0214] ,in, Match the employee in the template library The representative feature vector corresponding to each employee is is the bandwidth parameter, which is used to control the smoothness and influence range;
[0215] is a high-dimensional face feature vector The normalized vector of for The normalized vector of For , A weight vector of the same dimension.
[0216] Constructing an employee match score based on confidence score and similarity ;
[0217] in, For the confidence score, The weight parameter is used to balance the importance of confidence score and similarity, and the optimal value is determined by cross-validation.
[0218] The maximum value among all employee matching scores is taken as the optimal matching value, and the template entry of the employee corresponding to the optimal matching value is extracted as the identification result of the employee identity.
[0219] This embodiment can efficiently capture the rich visual information contained in facial images, comprehensively characterize the unique features of the face, and lay the foundation for subsequent recognition tasks. At the same time, it has the ability of adaptive optimization and can dynamically adjust the processing flow according to the actual quality and complexity of the image to ensure the accuracy and robustness of feature extraction, and effectively avoid the distortion or over-enhancement problems commonly found in traditional methods. Secondly, it can pay attention to the overall structure and local detail information of the face at the same time, comprehensively grasp the unique recognition mode of the face, and greatly improve the recognition accuracy and generalization ability. Finally, it can effectively cope with the diverse changes of facial images, and ensure the high accuracy and reliability of subsequent identity matching.
[0220] Example 2
[0221] See also Figure 2 As shown, the part not described in detail in this embodiment is described in Example 1, which provides a face recognition system based on AI intelligence, including:
[0222] The image acquisition and processing module is used to acquire face image data and pre-process the face image data to obtain a face area image;
[0223] A vector extraction module is used to extract high-dimensional facial feature vectors from facial region images;
[0224] A model fitting module is used to input the high-dimensional face feature vector into the pre-built attention feature classification model to obtain n identity tags and the confidence scores corresponding to the n identity tags;
[0225] A matching module is used to preset an employee matching template library, and identify the employee identity from the employee matching template library based on a high-dimensional face feature vector, n identity tags, and confidence scores corresponding to the n identity tags;
[0226] The modules are connected to each other via wired and / or wireless means to achieve data transmission between modules.
[0227] Example 3
[0228] This embodiment discloses an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the operation mode of the above-mentioned AI-based face recognition method is implemented.
[0229] Since the electronic device introduced in this embodiment is an electronic device used to implement an AI-based face recognition method in the embodiment of this application, based on the AI-based face recognition method introduced in the embodiment of this application, the technical personnel in this field can understand the specific implementation of the electronic device in this embodiment and its various variations, so how the electronic device implements the method in the embodiment of this application is not described in detail here. As long as the technical personnel in this field implement the electronic device used in the AI-based face recognition method in the embodiment of this application, it belongs to the scope of protection of this application.
[0230] The above formulas are all dimensionless and numerical calculations. The formula is a formula for the most recent real situation obtained by collecting a large amount of data and performing software simulation. The preset parameters and thresholds in the formula are set by technicians in this field according to actual conditions.
[0231] The above is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technical users in this technical field, some improvements and modifications without departing from the principle of the present invention should also be regarded as the protection scope of the present invention.
Claims
1. A face recognition method based on AI intelligence, characterized in that: include: S1, collecting face image data, and preprocessing the face image data to obtain a face area image; S2, extracting high-dimensional face feature vector from the face area image; S3, inputting the high-dimensional face feature vector into the pre-built attention feature classification model to obtain n identity tags and confidence scores corresponding to the n identity tags; S4, presetting an employee matching template library, identifying the employee identity from the employee matching template library based on the high-dimensional face feature vector, n identity tags and the confidence scores corresponding to the n identity tags; The method of preprocessing the facial image data includes: Performing adaptive image denoising on the face image data to obtain denoised image data, performing adaptive histogram equalization on the denoised image data to obtain balanced image data; and processing the balanced image data using a face detection and segmentation method to obtain a face region image; The method for performing adaptive image denoising processing includes: The face image data is initially divided into N image blocks of fixed size, and the gradient of the image blocks is calculated to obtain the horizontal gradient Gx and the vertical gradient Gy. The gradient amplitude of the image block is calculated based on the horizontal gradient Gx and the vertical gradient Gy. And count the mean and variance of the gradient amplitude G of the image block as statistical features; The size of the image block is adjusted according to the variance value. The initial image block size is w0×h0. The threshold range of the variance is calculated [T min , T max ], if the variance is less than T min , then adjust the size of the image block to w×h; w=w0+Δw, h=h0+Δh; where Δw is the width increment of the image block size, and Δh is the height increment of the image block size; If the variance is greater than T max , then adjust the size of the initial image block to w2×h2; w2=[max(w0-w1,wmin)], h2=[max(h0-h1,hmin)]; where w1 is the width reduction of the image block size, h1 is the height reduction of the image block size, wmin is the lower limit of the width of the image block size, and hmin is the lower limit of the height of the image block size; in, in, is the gradient amplitude variance of the current image block B, is the variance of the wavelet coefficients of the current image block B, and λ is the average weight parameter; Perform gradient calculation on the resized image block B' to obtain the gradient amplitude G' of the resized image block, and calculate the mean value μ of G' G' (B') and variance As the statistical characteristics of G'; Perform wavelet transform on the image block B' to obtain the wavelet coefficients of each scale. At the smallest scale, the mean value μ of the wavelet coefficient R is calculated. R (B') and variance As the statistical characteristics of the wavelet coefficient R; The most matching noise type is obtained based on the statistical features; the noise types include Gaussian noise and salt and pepper noise, and the corresponding noise types are repeatedly obtained for all image blocks; for Gaussian noise, denoising is performed using soft threshold or hard threshold filtering in the wavelet domain or Fourier domain, and for salt and pepper noise, denoising is performed using adaptive threshold filtering or median filtering in the wavelet domain, thus completing the adaptive image denoising process; The method of obtaining the most matching noise type includes: Define the gradient amplitude statistics model GF and the wavelet coefficient statistics model WF, calculate the distance metric between the statistics feature and GF and WF, and the calculation formula of the distance metric is: Among them, μ G0 is the mean value of GF, is the variance of GF, FL is the wavelet coefficient distance function; D is the distance metric; Wavelet coefficient distance function Among them, μ R0 is the mean value of WF, is the variance of WF; find the noise type with the smallest distance metric value, which is the most matching noise type; The method of performing adaptive histogram equalization processing includes: The denoised image data is divided into m1×n1 overlapping sub-regions E(i,j), where i is a positive integer in the interval [1, m1], j is a positive integer in the interval [1, n1], and the calculation formula for the size of the sub-region is: Where, W0 is the initial width of the sub-region, H0 is the initial height of the sub-region, C(i,j) is the local contrast of the sub-region E(i,j), T(i,j) is the texture feature of the sub-region E(i,j), k1 and k2 are adjustment parameters; W(i,j) is the width of the sub-region E(i,j), H(i,j) is the height of the sub-region E(i,j), and the width multiplied by the height is the size of the sub-region; For each sub-region E(i,j), calculate the number of pixels g(i,j,l) with gray level l in the sub-region E(i,j), where l is a positive integer in the interval [0,L-1] and L is the number of gray levels; The value of the cumulative distribution function is calculated based on g(i,j,l). The calculation formula is: Wherein, CL(i,j,l) is the cumulative distribution probability of gray level l calculated in sub-region E(i,j), that is, the value of the cumulative distribution function; N(i,j) is the total number of pixels in sub-region E(i,j), and d is the gray level sum index; For each pixel (x, y) in the denoised image data I, its grayscale value I(x, y) is mapped to the enhanced grayscale value I'(x, y), and the mapping formula is: Where CL(i,j,I(x,y)) is the cumulative distribution probability of I(x,y) calculated in the sub-region E(i,j); splicing the sub-regions containing the enhanced grayscale values back to the size of the original denoised image data to form balanced image data; The method of processing the equalized image data using the face detection and segmentation method to obtain the face area image includes: The fast face detection method based on Haar features and AdaBoost classifier is used to equalize the image data, and the bounding box coordinates of the detected face area are output; Collect N2 groups of face images, manually mark the coordinates of the face key points in the face images, and normalize the coordinates of the marked face key points to obtain the face shape vector; Calculate average face shape based on face shape vector and the principal component matrix Get the statistical shape model Where b is the shape parameter; Input the bounding box coordinates of the detected face area, and search for the shape parameters that best match the statistical shape model with the actual face area in the face area, which is recorded as the best matching parameter b * ; b * This is the final face area segmentation result; Limit the best matching parameter b * The value range of is limited by the formula: Among them, γ is the regularization parameter, which is used to balance the fitting error and parameter complexity; The final face region segmentation result is used to extract the face region image from the equalized image data.
2. The AI-based face recognition method according to claim 1, characterized in that: The method for extracting the high-dimensional face feature vector includes: Using the face key point detection algorithm, a series of key points are detected from the face area image; the distance and angle between the key points are calculated as geometric features and spliced into a geometric feature vector RF; The face area image is divided into M2×N2 non-overlapping small blocks. For each small block, the variance of the gradient amplitude is calculated as the local texture complexity. Initially define the intrinsic parameters of the Gabor filter, and adaptively adjust the intrinsic parameters of the Gabor filter based on the local texture complexity FT(u) of each small block u. The intrinsic parameters include wavelength, direction, Gaussian kernel standard deviation and aspect ratio. Use the adaptively adjusted Gabor filter to filter the face area image to obtain Gabor feature maps of different scales. wavelength Direction θ u =θ0+k θ FT(u), Gaussian kernel standard deviation ηu=η0+k η FT(u), aspect ratio δu=δ0+k δ FT(u); where The initially defined wavelength, θ0 is the initially defined direction, η0 is the initially defined Gaussian kernel standard deviation, and δ0 is the initially defined aspect ratio; is the wavelength adjustment coefficient, k θ is the direction adjustment coefficient, k η is the Gaussian kernel standard deviation adjustment coefficient, k δ is the aspect ratio adjustment factor; Calculate statistical features for each Gabor feature map, including mean, variance and entropy, and concatenate the statistical feature groups into a preliminary texture feature vector; Input the face region image into the convolution layer of the VGGFace2 or FaceNet model, extract the local feature vector output by the middle convolution layer; concatenate the local feature vector with the preliminary texture feature vector to form a texture feature vector; define the identity label, calculate the mutual information value between each texture feature vector and the identity label, sort the mutual information values corresponding to all texture feature vectors in descending order, select the texture feature vectors corresponding to the first N3 mutual information values to form a comprehensive texture feature vector; concatenate the comprehensive texture feature vector and the geometric feature vector to obtain a high-dimensional face feature vector; The mutual information value is calculated by: Among them, p(C) represents the marginal probability distribution of the texture feature vector C, p(Q) represents the marginal probability distribution of the identity label Y, p(C,Q) represents the joint probability distribution of C and Y, χ is the set of all texture feature vectors, and τ is the set of all identity labels.
3. The AI-based face recognition method according to claim 2, characterized in that: The construction method of the attention feature classification model includes: Define the basic structure of the attention feature classification model, which includes input layer, feature transformation layer, hierarchical attention structure, feature fusion layer, fully connected layer and output layer; the hierarchical attention structure includes global attention sublayer and local attention sublayer; The hierarchical attention structure is repeatedly stacked N4 times; the fully connected layer maps the last output fusion feature vector to the classification space and outputs n neurons corresponding to n identity labels; The output layer uses the Softmax activation function to convert the output of the fully connected layer into a probability distribution in the interval [0, 1] as the confidence score of each identity tag; Collect historical data, which are N5 groups of high-dimensional facial feature vectors and corresponding identity labels, and use the historical data as training data for the attention feature classification model. Define the loss function and optimizer of the attention feature classification model. If the value of the loss function no longer decreases during PL consecutive training times on the training data, stop training and retain the parameters of the attention feature classification model at this time, thus completing the construction of the attention feature classification model.
4. The AI-based face recognition method according to claim 3, characterized in that: The input layer is used to receive a high-dimensional face feature vector as input, and the feature transformation layer linearly maps the input high-dimensional face feature vector to a low-dimensional feature space vector through a fully connected layer or a convolutional layer; The global attention sublayer uses the structure of the SENet network and uses convolution kernels instead of the fully connected layer of the SENet network. Based on the feature space vector X', the global attention weight vector wg = σ(Conv2d(φ(Conv2d(X',W1)),W2)) is obtained, where σ is the Sigmoid activation function; φ is the ReLU activation function, Conv2d is a two-dimensional convolution operation, W1 is the weight of the first convolution kernel, and W2 is the weight of the second convolution kernel; Multiply the global attention weight vector by the feature space vector X' element by element to obtain the weighted global feature vector Xg; The local attention sublayer uses the self-attention mechanism to calculate the query vector Q'=X'·Wq, the key vector K'=X'·Wk and the value vector V'=X'·Wv; where Wq is the query projection matrix, Wk is the key projection matrix, and Wv is the value projection matrix; Calculate the attention weight matrix based on the query vector and key vector Among them, K' T is the transpose of the key vector K', R' is the relative position encoding matrix, and dk is the dimension of the key vector; Based on the value vector and the attention weight matrix, the local feature vector Xl=A'·V' is calculated; The feature fusion layer uses gated fusion to fuse the weighted global feature vector Xg and the local feature vector Xl in the channel dimension to obtain the fused feature vector X fused ; Among them, X hier =Concat(Xg,Xl);W f1 is the global convolution kernel weight, W f2 is the local convolution kernel weight.
5. The AI-based face recognition method according to claim 4, characterized in that: The preset methods of the employee matching template library include: Collect the identity information and facial image data of all employees of the company. The identity information includes name, position and department. Take standardized facial photos of employees as facial image data. Based on the collected facial image data, calculate the high-dimensional facial feature vector of each employee. Cluster the B high-dimensional facial feature vectors of each employee and use the cluster center as the representative feature vector of the employee. Based on the representative feature vector obtained by clustering, build a template entry for each employee. The template entry includes employee ID, employee basic information, representative feature vector and facial image data, thus completing the preset of the employee matching template library. The employee identification methods include: Calculate the similarity between the high-dimensional face feature vector GW and the representative feature vector corresponding to each employee in the employee matching template library, The similarity calculation formula is: Among them, DH q is the representative feature vector corresponding to the qth employee in the employee matching template library, ε is the bandwidth parameter used to control the smoothness and influence range; GW no is the normalized vector of the high-dimensional face feature vector GW, DH q,no For DH q The normalized vector of , we is the same as DH q , weight vector of the same dimension as GW; Construct the employee matching score FG(GW,DHq)=t1·ZXt+(1-t1)·Sim(GW,DHq) based on the confidence score and similarity; where ZXt is the t-th confidence score and t1 is the balance weight parameter; The maximum value among all employee matching scores is taken as the optimal matching value, and the template entry of the employee corresponding to the optimal matching value is extracted as the identification result of the employee identity.
6. An AI-based face recognition system, used to implement the AI-based face recognition method according to any one of claims 1 to 5, characterized in that: include: The image acquisition and processing module is used to acquire face image data and pre-process the face image data to obtain a face area image; A vector extraction module is used to extract high-dimensional facial feature vectors from facial region images; A model fitting module is used to input the high-dimensional face feature vector into the pre-built attention feature classification model to obtain n identity tags and the confidence scores corresponding to the n identity tags; The matching module is used to preset an employee matching template library, and identify the employee identity from the employee matching template library based on a high-dimensional face feature vector, n identity tags, and confidence scores corresponding to the n identity tags; each module is connected by wire and / or wireless means.
Citation Information
Patent Citations
Emotion recognition method, early warning method, model training method and related device
CN110705419A
Personnel flow statistics method and device and computer device
CN110263703A
Face recognition method and device and electronic equipment
CN112597941A
Insurance instant matching method based on face edge point recognition
CN115631525A
Intelligent work reporting and quality inspection method and system based on computer vision technology
CN118037091A
