Method, device and computer storage medium for human race recognition based on SE-ResNet network
Through the race recognition method based on the SE-ResNet network, combined with the VGG network for feature positioning and data preprocessing, the problem of low accuracy of the four major race recognition in the existing technology is solved, and high accuracy and high efficiency are achieved. kind of identification.
Patent Information
- Application Number
- CN202111305054.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-05
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2041-11-05
AI Technical Summary
The existing technology does not have high accuracy in classifying and identifying individual subtypes among the four major ethnic groups, especially the recognition of non-European and American ethnic groups.
A race recognition method based on the SE-ResNet network is adopted. By acquiring and preprocessing face image data, the VGG network is used to locate features and remove inferior data, and is combined with the SE-ResNet network for multi-layer convolution and residual module training to increase Data diversity and optimization of the training process, setting reasonable confidence thresholds to improve recognition accuracy.
It significantly improves the recognition accuracy of individual subtypes among the four major races, increases the recognition speed and reduces manual intervention. The recognition accuracy reaches 99.9% and the recall rate reaches 85%.
Smart Images

Figure CN114155573B
Abstract
Description
Technical Field
[0001] The present invention relates to a method for identifying human race, and in particular to a method, a device and a computer storage medium for identifying human race based on a SE-ResNet network. Background Art
[0002] The existing technology focuses on distinguishing the four major races. For example, the two patents with application numbers 202010996916.2 and 201811372085.0 solve the problem that the existing face dataset contains mostly European and American data, so the recognition results for other races are poor. There are also multiple types within a race, and the existing recognition methods are not accurate enough for this specific subtype. Summary of the invention
[0003] In view of the above-mentioned defects of the prior art, the present invention provides a method for identifying human race based on the SE-ResNet network to solve the problem of low accuracy in classification and identification of a single subtype among the four major races.
[0004] The technical solution of the present invention is as follows: A method for identifying human race based on SE-ResNet network, comprising the following steps:
[0005] S1. Acquire real human race image data as original data and detect human faces, rotate and fill the faces according to their facial features and scale them to a uniform size;
[0006] S2, removes featureless images with side faces, lowered heads, and large areas of facial features blocked;
[0007] S3, randomly adjusting the brightness, contrast, clarity, and sharpness of the image data to increase the diversity of the image data, and then performing Gaussian blur processing on the image;
[0008] S4, performing decrement processing on the RGB channels of the image data respectively, and then labeling the data set by classification to distinguish between the faces of type A race and the faces of type B race, where the type A race is the other races except the type B race;
[0009] S5. Establish an SE-ResNet network, wherein the SE-ResNet network sequentially includes a first convolution module, a second convolution module, a first pooling layer, a first SE residual module, a third convolution module, a second pooling layer, a second SE residual module, a third SE residual module, a fourth convolution module, a third pooling layer, fifth to ninth SE residual modules, a fifth convolution module, a fourth pooling layer, tenth to twelfth SE residual modules, a first fully connected layer, a second fully connected layer and a softmax layer, wherein the first to fifth convolution modules respectively include a convolution layer + an activation layer, and the SE residual module includes a main path and a side path respectively connected to an eltwise layer, wherein the main path sequentially includes a first convolution layer + an activation layer, a second convolution layer + an activation layer, an average pooling layer, a fully connected layer, an activation function, a fully connected layer and a Sigmoid, and then connected to the eltwise layer, and the side path is directly connected to the eltwise layer;
[0010] S6. Using the data set obtained in step S4 to train the SE-ResNet network;
[0011] S7, select the image to be identified and input it into the SE-ResNet network trained in step S6 for classification and identification to obtain the result.
[0012] Furthermore, in step S4, the labeled data set is divided into a test set and a training set, and step S6 includes S6-1, using the training set to train the SE-ResNet network, and then using the original data corresponding to the test set to test the SE-ResNet network trained in step S6-1, and the test set data corresponding to the original data with correct results and incorrect results in the test results are combined into an optimized training set; S6-2, using the optimized training set to optimize the training of the SE-ResNet network trained in step S6-1.
[0013] Furthermore, during the training of step S6-1, the optimizer is SGD, the loss function is the cross entropy loss function, the initial learning rate is 0.001, the training is set to 100,000 epochs, the learning strategy is multistep, the learning rate decays to 0.0001 after 20,000 epochs, and the learning rate decays to the previous 0.00001 after 40,000 epochs, and the momentum is 0.99; during the optimization training of step S6-2, the optimizer is Adam, the loss function is the cross entropy loss function, the initial learning rate is 0.0001, the training is set to 50,000 epochs, the learning strategy is step, the learning rate decays to 50% of the previous rate every 5,000 epochs, and the momentum is 0.99. The learning rate and bias learning rate of the second fully connected layer in the SE-ResNet network are respectively increased by 10 times to optimize the generated network model; the result confidence is set to 0.8 when performing classification and recognition in step S7.
[0014] Furthermore, during the optimization training in step S6-2, the proportion of test set data corresponding to the original data with erroneous test results in step S6-1 in the optimized training set is 40% to 50%.
[0015] Furthermore, the data ratio of the A-type human race category to the B-type human race category in the test set, the training set, and the optimized training set is 1:1.
[0016] Furthermore, the specific steps of step S2 include: S2-1, using a first neural network to classify and locate the original data, the classification includes front face, side face, and lowered head, and the positioning is the coordinate points of the eyebrow head, eyebrow middle, and eyebrow tail of the left and right eyebrows, the coordinate points of the inner corners, middle, and outer corners of the left and right eyes, the coordinate points of the nose tip, both sides of the nose wings, and the tail of the nose, the coordinate points of the two ends of the mouth, the upper lip, the middle, and the lower lip, and the coordinate points of the left and right ears connecting the upper and lower parts of the face contour; S2-2, comparing the distance from the left ear to the left eye with the distance from the right ear to the right eye to calculate the front and side face angles of the face, and comparing the y value coordinates of the two ears with the y value coordinates of the two eyes to calculate the face pitch angle; S2-3, using a second neural network to identify whether the original data is blocked in a large area of the facial features; S2- 4. Remove featureless images judged as 90-degree side faces, 70-degree or above bowed heads, and large-area occlusion of facial features; the first neural network structure is a modified VGG network, the basic layer is a convolution layer with a convolution kernel of 5 and a step size of 1 + an activation layer, a pooling layer, three convolution layers with a step size of 3 and a step size of 1 + an activation layer + a pooling layer, and a fully connected layer to calculate the classification results, and the segmentation layer slice is used to divide the calculation results into the classification and coordinate points; the second neural network structure is a modified VGG network, the basic layer is a convolution layer with a convolution kernel of 7 and a step size of 4 + an activation layer, a pooling layer, a convolution layer with a convolution kernel of 3 and a step size of 1 + an activation layer, a pooling layer, two convolution layers with a convolution kernel of 3 and a step size of 1 + an activation layer, a pooling layer, and a fully connected layer to calculate the classification results.
[0017] Furthermore, the random adjustment in step S3 is to randomly select whether to adjust the brightness, contrast, clarity, and sharpness, and randomly select positive adjustment or negative adjustment for the parameters selected for adjustment, and the adjustment amplitudes of the positive adjustment and the negative adjustment are the same.
[0018] The present invention also provides a human race identification device based on the SE-ResNet network, comprising a processor and a memory, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the above-mentioned human race identification method based on the SE-ResNet network is implemented.
[0019] The present invention also provides a computer storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the above-mentioned method for ethnicity recognition based on the SE-ResNet network is implemented.
[0020] The advantages of the technical solution provided by the present invention are: the present invention constructs a SE-ResNet network for the actual needs of image-based ethnic recognition, improves recognition speed and reduces manual work. In the early stage, the face in the image data is detected, and the inferior data with special angles and facial features blocked are eliminated to form training data, which can reduce the impact on the training results. The VGG network is used to classify and locate the image, and the calculation of the angle is combined to improve the efficiency and accuracy of data elimination. Through preliminary training and optimization training, an ideal recognition network model is obtained and a reasonable confidence threshold is set, which improves the accuracy of recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 The figure is a schematic diagram of the training process of the SE-ResNet network adopted by the human race recognition method based on the SE-ResNet network of the present invention.
[0022] Figure 2 Schematic diagram of SE-ResNet network structure.
[0023] Figure 3 Schematic diagram of the SE residual module structure in the SE-ResNet network structure. DETAILED DESCRIPTION
[0024] The present invention is further described below in conjunction with examples. It should be understood that these examples are only used to illustrate the present invention and are not used to limit the scope of the present invention. After reading this description, various equivalent modifications to this description by those skilled in the art fall within the scope defined by the claims attached to this application.
[0025] Please combine Figure 1 As shown, the steps of the method for ethnicity recognition based on the SE-ResNet network in this embodiment are as follows:
[0026] S1. Obtain real ethnic image data and generate a data set: Specifically, the ethnic data sets used in the present invention are all captured in the company's actual projects, with a total of 60,000 Class A faces and 60,000 Class B faces. Almost all images of different cameras, different imaging time periods, different lighting, different scenes, different genders and different age groups are covered. MTCNN is used for face detection, and the coordinates of the five coordinate points of the eyes, nose tip and both sides of the mouth are located, which are matched one by one with the preset coordinates of the facial features (left eye 30.2946, 51.6963, right eye 65.5318, 51.5014, nose tip 48.0252, 71.7366, left corner of the mouth 33.5493, 92.3655, right corner of the mouth 62.7299, 92.2041), so as to rotate and scale to correct the facial features, so that the facial features of each picture are in the same position, and the blank areas after the image is rotated are filled with black pixels to complete the rotation and filling correction of the face, and uniformly scaled to 96*112 size;
[0027] S2. Remove face data that does not meet the requirements: Faces are divided into Class A faces and other Class B faces according to the requirements, with a ratio of 1:1. If there is a mixed-race phenomenon, the face is classified according to the bias. The modified VGG network trained by calibration, the base layer of the modified VGG network is a convolution layer with a convolution kernel of 5 and a step length of 1 + an activation layer, a pooling layer, three convolution kernels with a step length of 3 and a convolution layer + an activation layer + a pooling layer, and a fully connected layer to calculate the classification results. The segmentation layer slice is used to divide the calculation results into 3 categories and 50 values. The 3 categories are 0-frontal face, 1-90 degree side face, and 2-75 degrees or more bowing. The 50 values form 25 coordinate points, which are the coordinate points of the eyebrow head, eyebrow middle, and eyebrow tail of the left and right eyebrows, and the inner and outer corners of the left and right eyes. The coordinate points of the corners of the eyes, the middle of the eyes, and the outer corners of the eyes; the coordinate points of the nose tip, the sides of the nose wings, and the tail of the nose; the coordinate points of the two ends of the mouth, the upper lip, the middle, and the lower lip; and the coordinate points of the left and right ears connecting the upper and lower parts of the face contour. The input image size is a grayscale image of 40*40. In the early stage, 50,000 faces of various postures were selected to mark the coordinate points of the eyebrows, the middle of the eyebrows, and the tail of the eyebrows on both sides, the coordinate points of the inner corners of the eyes, the middle of the eyes, and the outer corners of the eyes on both sides, the coordinate points of the nose tip, the sides of the nose wings, and the tail of the nose; the coordinate points of the two ends of the mouth, the upper lip, the middle, and the lower lip The network is trained with 25 coordinate points, and then the trained network is used to obtain the coordinate points of the facial features of the input face image. The right eye to right ear x-axis distance / (left eye to left ear x-axis distance + right eye to right ear x-axis distance) is used to calculate the proportion of the right eye width to the width of both eyes. The result range is [0,1]. The value is subtracted by 0.5 and multiplied by 2 to normalize the result range to [-1,1]. It is calculated that [-1,0) is the right side of the face, (0,1) is the left side of the face, and the square of the square multiplied by 90 is used to calculate the deviation. The angle is used to count the left and right directions and the angle of the face. Use y=kx+b and two points above the ears on both sides to calculate the corresponding k1 and b1. Similarly, use two points below the ears on both sides to calculate the corresponding k2 and b2. Set x=x-axis coordinate point in the left eye to calculate y1 and y2 respectively, and take the average value y0 of y1 and y2. Set y=y-axis coordinate point in the left eye, use n*(y-y0 / |y2-y1|), n is set to 30, and calculate the face pitch angle by comparing the maximum and minimum values to normalize the value range to [-90, 90]. If the value is greater than 0, it means looking up, and less than 0 means looking down.Through another modified VGG network trained, the network base layer is a convolution layer with a convolution kernel of 7 and a stride of 4 + an activation layer, a pooling layer, a convolution layer with a convolution kernel of 3 and a stride of 1 + an activation layer, a pooling layer, two convolution layers with a convolution kernel of 3 and a stride of 1 + an activation layer, a pooling layer, and a fully connected layer as the calculation classification result, the input image size is a three-channel image of 96*60, the image is a face detected and corrected by the mtcnn open source network and uniformly scaled to a size of 96*112, the face is cropped from a height of 62 to the end of the image into a 96*60 partial face with only the part below the nose, and 50,000 of each are used for training, totaling 100,000 faces obtained in the above manner are marked as 0-occluded 1-normal person recognition whether the facial features are largely occluded. In the original data set, remove the face data that is judged as 90-degree side faces and 70-degree or above lowered heads by the above two networks, and remove the face data with large areas of facial features blocked and without obvious features;.
[0028] S3. Perform data enhancement on the image. Use OpenCV to adjust the brightness, contrast, clarity, and sharpness of the image. Use four [0,1] random numbers to adjust the above four dimensions. For example, if the contrast random number is 0, the contrast is not adjusted, and if the random number is 1, the contrast is adjusted. Then set the random number as the adjustment range, the brightness adjustment range is [0.5, 1.5], the contrast adjustment range is [0.5, 1.5], the clarity adjustment range is [0.5, 1.5], and the sharpness adjustment range is [0.5, 1.5] to increase sample diversity.
[0029] Then, using Gauss's formula
[0030]
[0031] The value of σ is set. The specific value of this embodiment is 3. The image weight matrix is calculated, and each pixel is multiplied by the weight value to obtain the value of the Gaussian blur of the center point. In this way, Gaussian blur processing is performed on each image after the brightness, contrast, clarity, and sharpness are adjusted to enhance the sample generalization ability.
[0032] S4, preprocess the image, unify the image into a three-channel color image, and brighten the image. Specifically, subtract the mean of each channel 104, 117, and 123 from the BGR channel. The mean is calculated by the average value of each BGR channel through the face image in S2. Subtracting the mean from the image is convenient to eliminate the commonality of the image and highlight individual differences. Eliminating the commonality of the image also includes removing the average brightness value of the image, thereby reducing the impact of illumination on the data to a certain extent. The data set is labeled by category. The label format is (n, l), n is the image path, l = 0 represents the face of the A-type race, and l = n-1 represents the face of the B-type race. 10% is randomly selected as the test set and 90% as the training set, and the data set is randomly shuffled.
[0033] S5. Please combine Figure 2 and Figure 3 As shown, the SE-ResNet network constructed based on the ResNet50 network and the SE residual module includes, in sequence, a first convolution module, a second convolution module, a first pooling layer, a first SE residual module, a third convolution module, a second pooling layer, a second SE residual module, a third SE residual module, a fourth convolution module, a third pooling layer, fifth to ninth SE residual modules, a fifth convolution module, a fourth pooling layer, tenth to twelfth SE residual modules, a first fully connected layer, a second fully connected layer and a softmax layer. The SE-ResNet network inserts different numbers of SE residual modules after the last four modules of the five convolution modules of the ResNet50 network, respectively, and all the convolution modules of the ResNet50 network include convolution layers + activation layers. The SE residual module includes a main path that is the first convolution layer + activation layer, the second convolution layer + activation layer, the average pooling layer, the fully connected layer, the activation function (ReLU), the fully connected layer and the Sigmoid, and then connected to the eltwise layer. The SE residual module includes a side path that is directly connected to the eltwise layer. The training set is trained based on this newly built SE-ResNet network.
[0034] S6-1. The training parameters are as follows: data input size is 96*112, batchsize=64, optimizer SGD, loss function uses cross entropy loss function, initial learning rate is 0.001, training is set to 100,000 epochs, learning strategy is multistep, learning rate decays to 10% of the previous value after 20,000 epochs, and learning rate decays to 10% of the previous value after 40,000 epochs, and momentum is 0.99.
[0035] S6-2. If it is found in actual use that the accuracy of the newly set up scene is lower than 80%, select the new sample obtained by the camera of the scene trained in the model generated in step S6-1, and select 2W samples by category from the test results, of which 40% are wrong samples and 60% are correct samples, and the ratio of the number of categories is 1:1. These images are processed in the same way as steps S1 to S4, and then optimized based on the model generated by training in step S6-1. At this time, the input size is 96*112, batchsize=64, the optimizer is Adam, the loss function uses the cross entropy loss function, the initial learning rate is 0.0001, and the training is set to 50,000 epochs. The learning strategy is step, and the learning rate decays to 50% of the previous one every 5,000 epochs. The momentum is 0.99, and the learning rate and bias learning rate of the last fully connected layer (the second fully connected layer) in the network are respectively increased by 10 times to optimize the generated model.
[0036] S8. In actual use, select the pictures collected by the camera, use MTCNN for face detection and face angle correction, and use two modified VGG networks to calculate and filter out 90-degree side faces and faces without obvious features that are blocked by a large area. Perform [104, 117, 123] minus mean processing on the RGB channels of the face, send the face to the SE-ResNet network optimized in step S6-2, set the result confidence to 0.8, and you can get the race classification result. The race accuracy (i.e., the number of samples matched by the race model / the number of samples separated by the race model) is 99.9%, and the recall rate (i.e., the number of samples matched by the race model / the total number of race samples) is 85%.
[0037] It should be noted that the specific methods of the above embodiments can form a computer program product. Therefore, the computer program product implemented by the present application can be stored on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.). In addition, the present application can be implemented in the form of hardware, software, or a combination of hardware and software, or constitute a computer device including at least one processor and a memory, the memory storing a computer program for implementing the above process steps, and the processor executing the computer program on the memory to form the method steps of the above embodiments.
Claims
1. A method for ethnicity recognition based on SE-ResNet network, characterized in that: The following steps are involved: S1. Obtain real ethnic image data as raw data and use the MTCNN model to detect faces, rotate and fill the faces according to their facial features and scale them to a uniform size; S2, remove the featureless images of the side face, the lowered head and the facial features with large areas blocked, the specific steps include: S2-1, use the first neural network to classify and locate the original data, the classification includes front face, side face, lowered head, the positioning is the coordinate points of the eyebrow head, eyebrow middle and eyebrow tail of the left and right eyebrows, the coordinate points of the inner corners, middle and outer corners of the eyes on the left and right sides, the coordinate points of the nose tip, both sides of the nose wings and the tail of the nose, the coordinate points of the two ends of the mouth, the upper lip, the middle and the lower lip, and the coordinate points of the left and right ears connecting the upper and lower parts of the face contour; S2-2, compare the distance from the left ear to the left eye with the distance from the right ear to the right eye to calculate the front and side face angles of the face, compare the y value coordinates of the two ears with the y value coordinates of the two eyes to calculate the face pitch angle; S2-3, use the second neural network to identify whether the original data is facial features Large area occlusion; S2-4, remove featureless images judged as 90-degree side face, 70-degree or above bowing, and large-area occlusion of facial features; the first neural network structure is a modified VGG network, the base layer is a convolution layer with a convolution kernel of 5 and a step size of 1 + an activation layer, a pooling layer, three convolution kernels with a step size of 3 and a step size of 1 + an activation layer + a pooling layer, a fully connected layer to calculate the classification result, and the segmentation layer slice is used to divide the calculation result into the classification and coordinate points; the second neural network structure is a modified VGG network, the base layer is a convolution layer with a convolution kernel of 7 and a step size of 4 + an activation layer, a pooling layer, a convolution layer with a convolution kernel of 3 and a step size of 1 + an activation layer, a pooling layer, two convolution layers with a convolution kernel of 3 and a step size of 1 + an activation layer, a pooling layer, and a fully connected layer to calculate the classification result; S3, adjusting the brightness, contrast, clarity and sharpness of the image data, increasing the diversity of the image data and then performing Gaussian blur processing on the image; S4, performing decrement processing on the RGB channels of the image data respectively, and then labeling the data set by classification to distinguish between Class A race faces and Class B race faces, where Class A race refers to other races except Class B race, and dividing the labeled data set into a test set and a training set; S5. Establish an SE-ResNet network, wherein the SE-ResNet network sequentially includes a first convolution module, a second convolution module, a first pooling layer, a first SE residual module, a third convolution module, a second pooling layer, a second SE residual module, a third SE residual module, a fourth convolution module, a third pooling layer, fifth to ninth SE residual modules, a fifth convolution module, a fourth pooling layer, tenth to twelfth SE residual modules, a first fully connected layer, a second fully connected layer and a softmax layer, wherein the first to fifth convolution modules respectively include a convolution layer + an activation layer, and the SE residual module includes a main path and a side path respectively connected to an eltwise layer, wherein the main path sequentially includes a first convolution layer + an activation layer, a second convolution layer + an activation layer, an average pooling layer, a fully connected layer, an activation function, a fully connected layer and a Sigmoid, and then connected to the eltwise layer, and the side path is directly connected to the eltwise layer; S6, using the data set obtained in step S4 to train the SE-ResNet network, including S6-1, using the training set to train the SE-ResNet network, and then using the original data corresponding to the test set to test the SE-ResNet network trained in step S6-1, and the test set data corresponding to the original data with correct results and incorrect results in the test results are used to form an optimized training set. During training, the optimizer is SGD, the loss function is the cross entropy loss function, the initial learning rate is 0.001, and the training is set to 100,000 epochs. The learning strategy is multistep, and the learning rate decays to 0 after 20,000 epochs. 0001, the learning rate decays to the previous 0.00001 after 40,000 epochs, and the momentum is 0.99; S6-2, the SE-ResNet network trained in step S6-1 is optimized and trained using the optimized training set. During the optimization training, the optimizer is Adam, the loss function is the cross entropy loss function, the initial learning rate is 0.0001, and the training is set to 50,000 epochs. The learning strategy is step, and the learning rate decays to 50% of the previous rate every 5,000 epochs. The momentum is 0.99, and the learning rate and bias learning rate of the second fully connected layer in the SE-ResNet network are respectively increased by 10 times to optimize the generated network model; S7, select the image to be identified and input it into the SE-ResNet network trained in step S6 for classification and identification to obtain the result.
2. The method for ethnicity recognition based on SE-ResNet network according to claim 1, characterized in that: During the optimization training in step S6-2, the proportion of test set data corresponding to the original data with erroneous test results in step S6-1 in the optimized training set is 40% to 50%.
3. The method for ethnicity recognition based on SE-ResNet network according to claim 1, characterized in that: The data ratio of the A-type human race category to the B-type human race category in the test set, the training set, and the optimized training set is 1:
1.
4. The method for ethnicity recognition based on SE-ResNet network according to claim 1, characterized in that: The adjustment in step S3 is to randomly select whether to adjust the brightness, contrast, clarity, and sharpness, and randomly select positive adjustment or negative adjustment for the parameters selected for adjustment, and the adjustment amplitudes of the positive adjustment and the negative adjustment are the same.
5. A human race identification device based on a SE-ResNet network, comprising a processor and a memory, wherein a computer program is stored in the memory, characterized in that: When the computer program is executed by the processor, the method for ethnicity recognition based on the SE-ResNet network described in any one of claims 1 to 4 is implemented.
6. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for ethnicity recognition based on the SE-ResNet network described in any one of claims 1 to 4 is implemented.
