Face recognition method, face recognition model training method and related devices

By adjusting the aspect ratio of the face image to 1:1 and inputting it into the face recognition model, the problem of low face recognition accuracy in the existing technology is solved and higher face recognition accuracy is achieved.

CN112257504BActive Publication Date: 2024-09-06SHENZHEN SHULIAN TIANXIA INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010976638.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-16
Publication Date
2024-09-06
Estimated Expiration
2040-09-16

Smart Images

  • Figure CN112257504B
    Figure CN112257504B
Patent Text Reader

Abstract

The embodiment of the present invention discloses a face recognition method, a face recognition model training method and a related device. Since the face recognition model converts the input image into a feature image of 1:1 size and performs recognition, in the above method, after determining the minimum face rectangular area based on the key points of the face, the minimum face rectangular area is adjusted to a target face area with an aspect ratio of 1:1, and the corresponding target image is extracted, so that the size ratio of the target image is consistent with the size ratio of the feature image after the face recognition model is converted, so that after the target image is input into the face recognition model, the aspect ratio of the target image will not be changed, and further, the face contour in the target image will not be changed, which can effectively avoid the face recognition model from damaging the face contour and effectively improve the accuracy of face recognition for users.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of image processing, and in particular to a face recognition method, a face recognition model training method and related devices. Background Art

[0002] With the rapid development of mobile communication technology and the improvement of people's living standards, various smart terminals have been widely used in people's daily work and life, making people more and more accustomed to using smart terminals. Many different types of applications can be installed on smart terminals, such as applications for personal image design. One aspect of personal image design is to determine the user's face shape. By judging the face shape, it can help the user find a more suitable image style. However, there is currently no method that can accurately identify the user's face shape. Summary of the invention

[0003] The main purpose of the present invention is to provide a face shape recognition method, a face shape recognition model training method and related devices, which can effectively improve the accuracy of face shape recognition.

[0004] To achieve the above object, the present invention provides a face recognition method in a first aspect, the method comprising:

[0005] Obtain a facial image of the user whose face shape is to be recognized;

[0006] Performing facial key point detection on the facial image, and determining a minimum facial rectangular area in the facial image according to the detected facial key points;

[0007] Adjusting the minimum face rectangular area so that the adjusted length-to-width ratio of the target face area is 1:1, and extracting a target image corresponding to the target face area from the face image;

[0008] The target image is input into a face shape recognition model, and the face shape of the user is determined according to an output result of the face shape recognition model.

[0009] To achieve the above object, the second aspect of the present invention provides a face recognition model training method, the device comprising:

[0010] Acquire a facial image sample data set, wherein the facial image sample data set includes facial sample images and face shapes of the facial sample images;

[0011] Performing facial key point detection on the facial sample images in the facial image sample data set, and determining an initial facial sample area in the facial sample images according to the detected facial key points;

[0012] The initial face sample area is adjusted so that the adjusted aspect ratio of the target face sample area is 1:1, and a target sample image corresponding to the target face sample area is extracted from the face sample image to obtain a target face image sample data set, wherein the target face sample data set includes a target sample image and a face shape of the target sample image;

[0013] The face shape recognition model is iteratively trained using the target sample image data set until the face shape recognition model converges based on the face shape recognition model training output result and the face shape of the target sample image.

[0014] To achieve the above object, the present invention provides a face recognition device according to a third aspect, the device comprising:

[0015] An acquisition module is used to acquire a face image of a user whose face shape is to be recognized;

[0016] A determination module, configured to perform facial key point detection on the facial image, and determine a minimum facial rectangular area in the facial image according to the detected facial key points;

[0017] An adjustment module, used for adjusting the minimum face rectangular area so that the adjusted length-to-width ratio of the target face area is 1:1, and extracting a target image corresponding to the target face area from the face image;

[0018] The recognition module is used to input the target image into a face recognition model and determine the face shape of the user according to the output result of the face recognition model.

[0019] To achieve the above object, the fourth aspect of the present invention provides a face recognition model training device, the device comprising:

[0020] A sample acquisition module, used to acquire a face image sample data set, wherein the face image sample data set includes face sample images and face shapes of the face sample images;

[0021] A region determination module, configured to perform facial key point detection on the facial sample images in the facial image sample data set, and determine an initial facial sample region in the facial sample images according to the detected facial key points;

[0022] A sample adjustment module is used to adjust the initial face sample area so that the adjusted target face sample area has an aspect ratio of 1:1, and extract a target sample image corresponding to the target face sample area from the face sample image to obtain a target face image sample data set, wherein the target face sample data set includes a target sample image and a face shape of the target sample image;

[0023] The model training module is used to iteratively train the face shape recognition model using the target sample image until the face shape recognition model converges based on the output result of the face shape recognition model training and the face shape of the target sample image.

[0024] To achieve the above-mentioned objectives, the fifth aspect of the present invention provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor performs the various steps in the face recognition method as described in the first aspect, or performs the various steps in the face recognition model training method as described in the second aspect.

[0025] The embodiments of the present invention have the following beneficial effects:

[0026] The present invention provides a face shape recognition method. The method obtains a face image of a user whose face shape is to be recognized, performs face key point detection on the face image, determines a minimum face rectangular area in the face image according to the detected face key points, adjusts the minimum face rectangular area so that the adjusted length-to-width ratio of the target face area is 1:1, extracts a target image corresponding to the target face area from the face image, inputs the target image into a face shape recognition model, and determines the face shape of the user according to an output result of the face shape recognition model. Since the face recognition model will convert the input image into a feature image of 1:1 size and perform recognition, in the above method, after determining the minimum face rectangular area based on the face key points, the minimum face rectangular area is adjusted to a target face area with an aspect ratio of 1:1, and the corresponding target image is extracted, so that the size ratio of the target image is consistent with the size ratio of the feature image after conversion by the face recognition model, so that after the target image is input into the face recognition model, the aspect ratio of the target image will not be changed, and further, the face contour in the target image will not be changed, which can effectively avoid the face recognition model from damaging the face contour and effectively improve the accuracy of face recognition for users. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0028] in:

[0029] Figure 1 Schematic diagram of the face recognition method according to an embodiment of the present invention;

[0030] Figure 2For the present invention Figure 1 A schematic flow chart of the detailed steps of step 102 in the illustrated embodiment;

[0031] Figure 3 Schematic diagram of the structure of the feature fusion layer in an embodiment of the present invention;

[0032] Figure 4 Schematic diagram of the process of training a face recognition model in an embodiment of the present invention;

[0033] Figure 5 Schematic diagram of the structure of a face recognition device in an embodiment of the present invention;

[0034] Figure 6 Schematic diagram of the structure of the face recognition model training device in an embodiment of the present invention. DETAILED DESCRIPTION

[0035] 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.

[0036] Since there is a lack of accurate methods for identifying the user's face shape in the prior art, there is a problem of low accuracy in identifying the user's face shape.

[0037] In order to solve the above problems, the embodiments of the present invention provide a face shape recognition method, a face shape recognition model training method and related devices. In the face shape recognition method, since the face shape recognition model converts the input image into a feature image of 1:1 size and recognizes it, after determining the minimum face rectangular area based on the face key points, the minimum face rectangular area is adjusted to a target face area with an aspect ratio of 1:1, and the corresponding target image is extracted, so that the size ratio of the target image is consistent with the size ratio of the feature image converted by the face shape recognition model, so that after the target image is input into the face shape recognition model, the aspect ratio of the target image will not be changed, and further, the face contour of the target image will not be changed, which can effectively avoid the face recognition model from damaging the face contour and effectively improve the accuracy of face recognition of the user.

[0038] See also Figure 1 , is a flow chart of a face recognition method in an embodiment of the present invention, the method comprising:

[0039] Step 101, obtaining a face image of a user whose face shape is to be recognized;

[0040] Step 102: Detect facial key points on the facial image, and determine the minimum facial rectangular area in the facial image based on the detected facial key points;

[0041] Step 103, adjusting the minimum face rectangular area so that the adjusted length-to-width ratio of the target face area is 1:1, and extracting a target image corresponding to the target face area from the face image;

[0042] Step 104: input the target image into a face shape recognition model, and determine the user's face shape according to the output result of the face shape recognition model.

[0043] In an embodiment of the present invention, the face recognition method is implemented by a face recognition device, which is a program module and is stored in a readable storage medium of a computer device. The computer device also includes a processor, which can read and run the face recognition device from the readable memory to implement the above-mentioned face recognition method.

[0044] In an embodiment of the present invention, when it is necessary to perform face recognition on a user, a face image of the user's face to be recognized can be obtained first. The face image can be a frontal face image of the face, that is, the user's two eyes, eyebrows, nose, mouth, etc. can be clearly seen, and the height of the device for taking the face image can be at the same height as the face, so that the shooting direction can be as perpendicular to the plane where the face is located as possible. Furthermore, the face image of the user's face to be recognized can be obtained by taking a face image in real time, or the face image of the user's face to be recognized can be obtained by obtaining a face image uploaded by the user, or the face image of the user's face to be recognized sent by other devices can be received. In actual applications, there are many ways to obtain the face image of the face to be recognized, which will not be repeated here.

[0045] When performing face recognition, in order to avoid interference from irrelevant images, for example, objects such as trees, sky, buildings, etc. that appear in the face image and interfere with the face shape judgment, it is necessary to first extract the face area from the face image. Specifically, the face key points of the face image can be detected, and the minimum face rectangular area can be determined in the face image based on the detected face key points.

[0046] Among them, the facial key point detection can use a facial key point detection algorithm, which pre-sets the number of facial key points, for example, it can be 68 key points, and the facial key points are numbered in sequence, and the number and number of facial key points corresponding to each part are pre-divided, for example, it can be facial key points 0 to 20 for identifying the face shape. Therefore, the facial key points in the face image can be detected by using the facial key point detection method, and the minimum face rectangular area can be further determined in the face image according to the detected facial key points, wherein the minimum face rectangular area refers to the minimum area surrounding all facial key points.

[0047] Since there are many types of face shapes, according to the morphological method, they can be divided into round face shape, oval face shape, oval face shape, inverted oval face shape, square face shape, rectangular face shape, trapezoidal face shape, inverted trapezoidal face shape, diamond face shape and pentagonal face shape. The aspect ratios of different face shapes are different. Therefore, there are also many aspects of the aspect ratio of the minimum face rectangular area determined in the face image, for example, the length is greater than the width, the width is greater than the length, the length is equal to the width, etc.

[0048] It should be understood that in the embodiment of the present invention, a face recognition model will be used to recognize the face image of the user's face shape to be recognized, so as to determine the user's face shape. Since the feature of the face recognition model is to convert the input image into a feature image with an aspect ratio of 1:1, and process the feature image by means of convolution feature extraction, and no matter how it is processed, the aspect ratio of the feature image used in each layer of the face recognition model and the feature image output by each layer is 1:1. Therefore, no matter what the aspect ratio of the image is, after the image is input into the face recognition model, it will first be converted into an aspect ratio of 1:1 so that feature extraction can be performed. Therefore, for the smallest rectangular face area determined in the face image area, if the aspect ratio of the smallest rectangular face area is not 1:1, after the image corresponding to the smallest rectangular face area is input into the face shape recognition model, the face shape recognition model converts the image corresponding to the smallest rectangular face area into an image with an aspect ratio of 1:1, which must be a compression or stretching of the image in length or width. Regardless of the compression or stretching in the length or width direction, the shape of the face contour in the image corresponding to the smallest rectangular face area will change, making the recognition of the face shape less accurate.

[0049] In order to avoid the above problems, after determining the minimum face rectangular area in the face image, the minimum face rectangular area will be adjusted so that the adjusted target face area has an aspect ratio of 1:1, and a target image corresponding to the target face area will be extracted from the face image, and further, the target image will be input into the face shape recognition model, and the user's face shape will be determined based on the output result of the face shape recognition model. For example, if the face shape recognition model can recognize the aforementioned multiple face shapes, the face shape recognition model will output the probability values ​​of each recognized face shape, and select the face shape corresponding to the maximum probability value as the user's face shape.

[0050] In the embodiment of the present invention, since the face recognition model converts the input image into a feature image of 1:1 size and performs recognition, in the above method, after determining the minimum face rectangular area based on the face key points, the minimum face rectangular area is adjusted to a target face area with an aspect ratio of 1:1, and the corresponding target image is extracted, so that the size ratio of the target image is consistent with the size ratio of the feature image after conversion by the face recognition model, so that after the target image is input into the face recognition model, the aspect ratio of the target image will not be changed, and further, the face contour in the target image will not be changed, which can effectively avoid the face recognition model from damaging the face contour and effectively improve the accuracy of face recognition for users.

[0051] For further information, see Figure 2 , is a flowchart of detailed steps of the above step 102 in an embodiment of the present invention, including:

[0052] Step 201, performing facial key point detection on a facial image, and selecting a first minimum value and a first maximum value on a first direction component, and a second minimum value and a second maximum value on a second direction component from position information of facial key points contained in the detected facial image;

[0053] Step 202: take the position determined by the first minimum value and the second minimum value as the first position, take the position determined by the first maximum value and the second maximum value as the second position, take the first position and the second position as the two opposite vertices of the first rectangle, determine the first rectangle in the face image, and take the area enclosed by the first rectangle as the minimum face rectangle area.

[0054] In an embodiment of the present invention, a standard coordinate system is pre-set, and the standard coordinate system includes a first straight line and a second straight line, wherein the first straight line and the second straight line are perpendicular to each other, and the perpendicular intersection is the origin of the standard coordinate system, the direction pointed by the first straight line is the first direction, the direction pointed by the second straight line is the second direction, and the first direction and the second direction are perpendicular to each other.

[0055] After the facial key points of the face image are detected, the face image is placed in the above-mentioned standard coordinate system, and the vertex of the upper left corner of the face image coincides with the origin of the standard coordinate system, and the upper edge of the face image coincides with the first straight line of the standard coordinate system, and the left edge of the face image coincides with the second straight line of the standard coordinate system, so that the position information of each facial key point in the face image can be determined in the standard coordinate system, and the position information includes the value in the first direction component and the value in the second direction component. It can be understood that the above-mentioned standard coordinate system can be an XY coordinate system, the first straight line can be the X-axis, the second straight line can be the Y-axis, and the intersection of the X-axis and the Y-axis is the origin.

[0056] In the embodiment of the present invention, after determining the position information of the key points of the human face in the standard coordinate system, the first minimum value and the first maximum value on the first direction component, and the second minimum value and the second maximum value on the second direction component are selected. Specifically, the values ​​of the key points of the human face on the first direction component can be put into a set, and the maximum value and the minimum value are selected from the set as the first maximum value and the first minimum value, respectively. Similarly, the second minimum value and the second maximum value can be obtained.

[0057] It can be understood that the above-mentioned first minimum value and first maximum value can determine the minimum length of the face area, and the above-mentioned second minimum value and second maximum value can determine the minimum width of the face area. By combining the minimum length and the minimum width, the minimum face rectangular area can be determined.

[0058] Specifically, the position determined by the first minimum value and the second minimum value can be used as the first position, the position determined by the first maximum value and the second maximum value can be used as the second position, the first position and the second position can be used as the two opposite vertices of the first rectangle, and the first rectangle can be determined in the face image. The area enclosed by the first rectangle can be used as the minimum face rectangle area.

[0059] For example, taking the XY coordinate axis as an example, if the first minimum value in the X-axis direction component is Xmin and the first maximum value is Xmax, and the second minimum value in the Y-axis direction component is Ymin and the second maximum value is Ymax, therefore, the coordinate value of the first position can be determined to be (Xmin, Ymin), and the coordinate value of the second position can be determined to be (Xmax, Ymax). Then, based on (Xmin, Ymin) and (Xmax, Ymax) as the two vertices of the first rectangle, the first rectangle can be determined in the face image, and the area enclosed by it can be used as the minimum face rectangle area.

[0060] In an embodiment of the present invention, by determining the first minimum value and the first maximum value on the first direction component, and determining the second minimum value and the second maximum value on the second direction component, the first position and the second position for determining the first rectangle can be obtained, thereby effectively realizing the determination of the minimum face rectangular area.

[0061] Furthermore, for Figure 1 In step 103 of the illustrated embodiment, the minimum face area can be adjusted in the following manner, including:

[0062] When a first difference between the first maximum value and the first minimum value is greater than a second difference between the second maximum value and the second minimum value, a third difference obtained by subtracting the second difference from the first difference is calculated, the second maximum value in the second position is added to the third difference to obtain an adjusted second position, and the minimum face rectangular area is updated based on the first position and the adjusted second position to obtain a target face area; or, the second minimum value in the first position is subtracted from the third difference to obtain an adjusted first position, and the minimum face rectangular area is updated based on the adjusted first position and the second position to obtain the target face area.

[0063] For better understanding, the first minimum value is Xmin, the first maximum value is Xmax, the second minimum value is Ymin, and the second maximum value is Ymax. When Xmax-Xmin>Ymax-Ymin, it means that the length of the smallest face rectangular area is greater than the width. In order to achieve the requirement of 1:1 aspect ratio, the width needs to be increased. Specifically, the first difference (Xmax-Xmin) minus the second difference (Ymax-Ymin) can be calculated to get the third difference. The third difference represents the difference between the length and the width. In order to increase the width, there are two adjustment methods, one is to adjust the first position, and the other is to adjust the second position. They are explained below.

[0064] Subtracting the third difference from the second minimum value Ymin is equivalent to reducing the second minimum value to increase the difference between the second minimum value and the second maximum value to increase the width and obtain a new Ymin. The new Ymin and the re-determined position of Xmin are used as the adjusted first position. The minimum face rectangular area is updated based on the adjusted (Xmin, new Ymin) and (Xmax, Ymax) to obtain the target face area.

[0065] Alternatively, the difference between Ymin and Ymax can also be increased by increasing Ymax to achieve the purpose of increasing the width. Specifically, add a third difference to Ymax to obtain a new Ymax, and get the adjusted second position (Xmax, new Ymax). Then, update the minimum face rectangle area based on (Xmin, Ymin) and (Xmax, new Ymax) to obtain the target face area.

[0066] The above describes the method for adjusting the width when the length of the minimum face rectangle area is greater than the width. Next, the method for adjusting the length when the width of the minimum face rectangle area is greater than the length will be described, which specifically includes:

[0067] When the first difference between the first maximum value and the first minimum value is less than the second difference between the second maximum value and the second minimum value, calculate the fourth difference obtained by subtracting the first difference from the second difference. Add the fourth difference to the first maximum value in the second position to obtain the adjusted second position, and update the minimum face rectangle area based on the first position and the adjusted second position to obtain the target face area; or subtract the fourth difference from the first minimum value in the first position to obtain the adjusted first position, and update the minimum face rectangle area based on the adjusted first position and the second position to obtain the target face area.

[0068] For better understanding, take the first minimum value as Xmin, the first maximum value as Xmax, the second minimum value as Ymin, and the second maximum value as Ymax as an example. When Xmax - Xmin < Ymax - Ymin, it indicates that the width of the minimum face rectangle area is greater than the length. To meet the requirement of an aspect ratio of 1:1, the length needs to be increased. Specifically, the fourth difference can be calculated by subtracting the first difference (Xmax - Xmin) from the second difference (Ymax - Ymin). This fourth difference represents the gap between the width and the length. To increase the length, there are two adjustment methods, one is to adjust the first position, and the other is to adjust the second position. The following will explain them separately.

[0069] Subtract the fourth difference from the first minimum value Xmin, which is equivalent to reducing the first minimum value to increase the difference between the first minimum value and the first maximum value, thereby increasing the length to obtain a new Xmin. Use the new Xmin and Ymin to re - determine the position as the adjusted first position, and update the minimum face rectangle area based on the adjusted (new Xmin, Ymin) and (Xmax, Ymax) to obtain the target face area.

[0070] Alternatively, the purpose of increasing the length can be achieved by increasing Xmax to increase the difference between Xmin and Xmax. Specifically, Xmax is added to the fourth difference to obtain a new Xmax, and the adjusted second position (new Xmax, Ymax) is obtained. The minimum face rectangular area is updated based on (Xmin, Ymin) and (new Xmax, Ymax) to obtain the target face area.

[0071] In the embodiment of the present invention, the above method can effectively adjust the minimum face rectangular area to obtain the target face area, so as to achieve the purpose of the aspect ratio of the target face area being 1:1.

[0072] In a feasible implementation, in order to avoid the influence of images not related to facial contour on the facial recognition results, before step 104, the facial features area in the target image may be mosaic processed to obtain an updated target image, and when executing step 104, the updated target image is input into the facial recognition model, and the user's face shape is determined according to the output result of the facial recognition model.

[0073] Among them, the facial features areas in the target image, including eyes, eyebrows, nose and mouth, etc., are mosaic-processed, which allows the face recognition model to pay more attention to the contour of the face, and can well preserve the smooth transition between the contour of the face and the facial features information, avoiding the face recognition model from identifying too much facial features information and affecting the accuracy of face recognition.

[0074] Among them, the mosaic method can be: divide the target image into several small grids, for each small grid, determine whether the grid contains the facial key points of the face contour, if it contains the facial key points of the face contour, then the grid is not processed, if it does not contain the facial key points of the face contour, then calculate the average value of the pixels in the grid, and use the average value to replace the pixel value of each pixel in the grid, so as to form a smooth transition between the face contour and the facial features.

[0075] It should be noted that in the above-mentioned face recognition method, the face recognition model used can be a commonly used existing face recognition model, or can be a face recognition model set up based on the needs of face recognition. In actual applications, you can choose a commonly used existing face recognition model or a face recognition model set up based on the needs of face recognition. There is no limitation here.

[0076] Furthermore, in a feasible implementation method, a face recognition model can be set up. Specifically, the face recognition model includes: a first convolutional layer, a first feature extraction layer, a second convolutional layer, a second feature extraction layer, a third convolutional layer, a third feature extraction layer, a fourth convolutional layer, a fourth feature extraction layer, a fifth convolutional layer, a sixth convolutional layer, a pooling layer and a seventh convolutional layer, which are cascaded in sequence.

[0077] Among them, the first feature extraction layer, the second feature extraction layer, the third feature extraction layer and the fourth feature extraction layer each include at least two feature fusion layers cascaded in sequence.

[0078] To better understand the structure of the face recognition model in the embodiment of the present invention, please refer to the following table, which is a feasible grid structure of the face recognition model in the embodiment of the present invention:

[0079]

[0080] In the above table, there are 5 3*3 convolutional layers, 14 Res_block structures, one pooling layer (Avgpooling) and 2 1*1 convolutional layers, and c represents the number of output channels, n represents the number of times the layer is repeated, s represents the step size, and k represents the number of face types. Specifically, layer 1 represents the first convolutional layer, layer 2 represents the first feature extraction layer, layer 3 represents the second convolutional layer, layer 4 represents the second feature extraction layer, layer 5 represents the third convolutional layer, layer 6 represents the third feature extraction layer, layer 7 represents the fourth convolutional layer, layer 8 represents the fourth feature extraction layer, layer 9 represents the fifth convolutional layer, layer 10 represents the sixth convolutional layer, layer 11 represents the pooling layer, and layer 12 represents the seventh convolutional layer. Therefore, the layers with the function of the Res_block structure are all feature extraction layers, and the feature extraction layer contains at least two cascaded feature fusion layers.

[0081] In a feasible implementation, the Res_block structure is mainly composed of a convolutional layer and a Dwise layer (depth-level separable convolutional layer).

[0082] For details, please refer to Figure 3, is a schematic diagram of the structure of the feature fusion layer in an embodiment of the present invention, the feature fusion layer includes a first sub-convolution layer, a depth-level separable convolution layer, and a second sub-convolution layer cascaded in sequence, and further includes an input node, a fusion module, and an output node, wherein the input node is used to connect with the previous layer and receive the feature image output by the previous layer, and the output node is used to connect with the next layer and send the processed feature image to the next layer. The input node has two branches, one branch is directly connected to the fusion module, and the other branch is the input node, the first sub-convolution layer, the depth-level separable convolution layer, the second sub-convolution layer, and then to the fusion module. If the input node inputs the feature image A, the feature image A will be copied to obtain two copies of the feature image A, and one copy of the feature image A is transmitted to the fusion module, and the other copy of the feature image passes through the first sub-convolution layer, the depth-level separable convolution layer, and the second sub-convolution layer to obtain the feature image A1, and the fusion module fuses the feature image A with the feature image A1, and outputs the fused feature image from the output node. Therefore, the feature image output by the feature fusion layer is: the feature image obtained by fusing the input feature image of the input feature fusion layer with the output feature image of the second sub-convolutional layer. Optionally, the convolution kernels of the first sub-convolutional layer and the second sub-convolutional layer are 1*1, and the convolution kernel of the depth-level separable convolutional layer is 3*3.

[0083] It should be noted that the above-mentioned face recognition model is lightweight and can be applied on the user side to facilitate the recognition of face shapes on the user side without occupying too much memory on the user side. When constructing the above-mentioned lightweight face recognition model, considering the limitations of the number of convolution kernels and the network depth, a network structure including a feature fusion layer is proposed. The feature fusion layer first uses a 1*1 convolution kernel to perform a dimensionality reduction operation to reduce the input feature map, thereby reducing the number of parameters of the 3*3 Dwise operation, and then uses a 1*1 convolution kernel to perform a dimensionality increase operation to provide more feature information for subsequent feature extraction. Since the features of the facial contour are not very obvious, the model may easily lose shallow texture contour feature information during the convolution operation, resulting in the model being unable to recognize the facial contour well. Therefore, a fusion feature layer is used in the above-mentioned face recognition model. By setting two branches, the input feature image is retained and fused with the feature image after convolution, thereby ensuring that the output feature image contains shallow texture features. In addition, by setting feature fusion layers at different layers, feature images of different sizes can effectively enhance the network depth without increasing the model parameters, so as to achieve the purpose of lightweight.

[0084] In addition, in the above-mentioned face recognition model, the average pooling layer and the 1*1 convolution layer are used instead of the fully connected layer, which can also reduce the parameters of the overall model, thereby further constructing a lightweight face recognition model.

[0085] In the embodiment of the present invention, by setting the above-mentioned face shape recognition model, the face shape can be effectively recognized, and the above-mentioned model is a lightweight model, which realizes targeted model construction.

[0086] For further information, see Figure 4 , is a flow chart of a face recognition model training method in the implementation of the present invention, comprising:

[0087] 401. Obtain a face image sample data set, where the face image sample data set includes face sample images and face shapes of the face sample images;

[0088] 402. Perform facial key point detection on the face sample images in the face image sample data set, and determine an initial face sample area in the face sample images according to the detected facial key points;

[0089] 403. Adjust the initial face sample area so that the adjusted aspect ratio of the target face sample area is 1:1, and extract the target sample image corresponding to the target face sample area from the face sample image to obtain a target face image sample data set, wherein the target face sample data set includes the target sample image and the face shape of the target sample image;

[0090] 404. Iteratively train the face shape recognition model using the target sample image data set until the face shape recognition model converges based on the face shape recognition model training output result and the face shape of the target sample image.

[0091] In the embodiment of the present invention, a face image sample data set is first obtained, and the face image sample data set includes face sample images and face shapes of the face sample images. Face key points are detected for the face sample images in the face sample data set, and an initial face sample area is determined in the face sample images according to the detected face key points.

[0092] Specifically, the method includes: selecting the first minimum sample value and the first maximum sample value on the first direction component, and the second minimum sample value and the second maximum sample value on the second direction component from the position information of the facial key points contained in the detected facial sample image; taking the position determined by the first minimum sample value and the second minimum sample value as the first sample position, taking the position determined by the first maximum sample value and the second maximum sample value as the second sample position, taking the first sample position and the second sample position as the two opposite vertices of the second rectangle, determining the second rectangle in the facial sample image, and taking the area enclosed by the second rectangle as the initial facial sample area.

[0093] It should be noted that the method for determining the initial face sample area is similar to the principle and method of determining the minimum face rectangular area in the aforementioned method embodiment. For detailed description, please refer to the relevant content of the minimum face rectangular area in the aforementioned method embodiment, which will not be repeated here.

[0094] Furthermore, the initial face sample area is adjusted so that the aspect ratio of the adjusted target face sample area is 1:1, including:

[0095] When the fifth difference between the first maximum sample value and the first minimum sample value is greater than the sixth difference between the second maximum sample value and the second minimum sample value, a seventh difference obtained by subtracting the sixth difference from the fifth difference is calculated, the second maximum sample value in the second sample position is added to the seventh difference to obtain an adjusted second sample position, and the initial face sample area is updated based on the first sample position and the adjusted second sample position to obtain a target face sample area; or, the second minimum sample value in the first sample position is subtracted from the seventh difference to obtain an adjusted first sample position, and the initial face sample area is updated based on the adjusted first sample position and the second sample position to obtain a target face sample area;

[0096] When the fifth difference between the first maximum sample value and the first minimum sample value is less than the sixth difference between the second maximum sample value and the second minimum sample value, an eighth difference obtained by subtracting the fifth difference from the sixth difference is calculated, the first maximum sample value in the second sample position is added to the eighth difference to obtain an adjusted second sample position, and the initial face sample area is updated based on the first sample position and the adjusted second sample position to obtain a target face sample area; or, the first minimum sample value in the first sample position is subtracted from the eighth difference to obtain an adjusted first sample position, and the initial face sample area is updated based on the adjusted first sample position and the second sample position to obtain a target face sample area.

[0097] It should be noted that the adjustment method for the initial face sample area here is similar to the adjustment method for the minimum face rectangular area in the aforementioned method embodiment. For details, please refer to the relevant content of the adjustment of the minimum face rectangular area described above, which will not be repeated here.

[0098] Furthermore, the face recognition model includes a first convolution layer, a first feature extraction layer, a second convolution layer, a second feature extraction layer, a third convolution layer, a third feature extraction layer, a fourth convolution layer, a fourth feature extraction layer, a fifth convolution layer, a sixth convolution layer, a pooling layer and a seventh convolution layer, which are cascaded in sequence; the first feature extraction layer, the second feature extraction layer, the third feature extraction layer and the fourth feature extraction layer each include at least two feature fusion layers cascaded in sequence; the feature fusion layer includes a first sub-convolution layer, a depth-level separable convolution, and a second sub-convolution layer, which are cascaded in sequence, and the feature image output by the feature fusion layer is: a feature image obtained by fusing the input feature image of the input feature fusion layer with the output feature image of the second sub-convolution layer.

[0099] It should be noted that the face recognition model in the embodiment of the present invention may be a lightweight model. For details, please refer to the aforementioned method for the description of the face recognition model in the embodiment, which will not be elaborated here.

[0100] In the embodiment of the present invention, step 404 specifically includes the following steps:

[0101] Input the target sample image into the face recognition model to obtain the face recognition model training output result;

[0102] The loss value is obtained by using the training output result, the face shape of the target sample image and the preset weight coefficient corresponding to the face shape of the target sample image;

[0103] Determine whether the face recognition model converges based on the loss value.

[0104] In the embodiment of the present invention, taking into account that facial micro-expressions, such as pursing the lips, will cause deformation of the facial contour, the recognition result is easy to be inaccurate. Therefore, a weight coefficient is set, and different weights are set for different face types to reduce the model's excessive focus on changes in facial contours caused by facial expressions during the training process.

[0105] During the training process, if the face recognition model training output is Z(z1,z2,…,zk), the loss function of the face recognition model is as follows:

[0106]

[0107] Among them, Loss represents the loss value, k represents the number of face types, α i represents the weight coefficient of the i-th face shape, zi represents the i-th value in the output structure, Y i Indicates the face shape category.

[0108] The weight coefficient may be a constant, and the value may be a coefficient set manually.

[0109] In an embodiment of the present invention, if it is determined based on the loss value that the face recognition model converges, the converged face recognition model is used as the trained face recognition model; if it is determined based on the loss value that the face recognition model does not converge, the parameters of the face recognition model are optimized to obtain the optimized face recognition model, and the step of inputting the target sample image into the face recognition model to obtain the training output result of the continuous recognition model is returned.

[0110] When optimizing the parameters of the face recognition model, the number of iterative training i can be determined first, and the learning rate of the adaptive moment estimation (ADAM) algorithm can be updated using the value of i to obtain an updated learning rate. The total loss value, the updated learning rate and the ADAM algorithm can be used to optimize the parameters of the current face recognition module to obtain an optimized face recognition model.

[0111] It should be noted that the use of the Adam algorithm requires pre-configured parameters, including the number of iterations, the initial learning rate, the weight decay of the learning rate, etc. The learning rate of the Adam algorithm needs to be updated for each iterative training. For example, the number of iterations can be set to 500, the initial learning rate is set to 0.001, and the weight decay of the learning rate is set to 0.0005. After 50 iterations, the learning rate will decay to 1 / 10 of the original. The learning rate and total loss value can be input into the Adam algorithm to obtain the adjustment parameters of the Adam output, and the adjustment parameters are used to optimize the parameters of the face recognition model.

[0112] In an embodiment of the present invention, by using a target sample image with an aspect ratio of 1:1 to train a face recognition model, it is possible to effectively prevent the face contour from being changed by the face recognition model, so that the face recognition model can better learn the contour information of different face shapes, and the trained face recognition model has a higher accuracy in recognizing face shapes. Furthermore, by mosaic processing the target sample image, the focus on facial features during model training can be reduced, so that a smooth transition between the face contour and the facial features can be better achieved, and the face recognition model can be reduced from excessively focusing on non-face contours during training. Furthermore, by constructing a lightweight face recognition model, targeted model settings can be achieved, which is more in line with demand. Furthermore, by setting weight coefficients, different weight coefficients can be set for different face shapes, reducing the situation where the face recognition model pays too much attention to facial expressions during training, causing changes in facial contours.

[0113] See also Figure 5 , is a schematic diagram of the structure of a face recognition device in an embodiment of the present invention, the device comprising:

[0114] An acquisition module 501 is used to acquire a face image of a user whose face shape is to be recognized;

[0115] A determination module 502 is used to detect facial key points on the facial image and determine the minimum facial rectangular area in the facial image according to the detected facial key points;

[0116] An adjustment module 503 is used to adjust the minimum face rectangular area so that the adjusted length-to-width ratio of the target face area is 1:1, and extract a target image corresponding to the target face area from the face image;

[0117] The recognition module 504 is used to input the target image into the face shape recognition model and determine the user's face shape according to the output result of the face shape recognition model.

[0118] In the embodiment of the present invention, the above-mentioned face recognition device is similar to the contents described in the embodiments related to the above-mentioned face recognition method. For details, please refer to the relevant contents in the above-mentioned method, which will not be repeated here.

[0119] In an embodiment of the present invention, in a face recognition device, since the face recognition model converts the input image into a feature image of 1:1 size and performs recognition, after determining the minimum face rectangular area based on the face key points, the minimum face rectangular area is adjusted to a target face area with an aspect ratio of 1:1, and the corresponding target image is extracted, so that the size ratio of the target image is consistent with the size ratio of the feature image converted by the face recognition model, so that after the target image is input into the face recognition model, the aspect ratio of the target image will not be changed, and further, the face contour of the target image will not be changed, which can effectively avoid the face recognition model from damaging the face contour and effectively improve the accuracy of face recognition of the user.

[0120] See also Figure 6 , is a schematic diagram of the structure of a face recognition model training device in an embodiment of the present invention, the device comprising:

[0121] The sample acquisition module 601 is used to acquire a face image sample data set, where the face image sample data set includes face sample images and face shapes of the face sample images;

[0122] The region determination module 602 is used to perform facial key point detection on the facial sample images in the facial image sample data set, and determine the initial facial sample region in the facial sample images according to the detected facial key points;

[0123] The sample adjustment module 603 is used to adjust the initial face sample area so that the adjusted aspect ratio of the target face sample area is 1:1, and extract the target sample image corresponding to the target face sample area from the face sample image to obtain a target face image sample data set, wherein the target face sample data set includes the target sample image and the face shape of the target sample image;

[0124] The model training module 604 is used to iteratively train the face shape recognition model using the target sample image until the face shape recognition model converges based on the face shape recognition model training output result and the face shape of the target sample image.

[0125] In the embodiment of the present invention, the above-mentioned face recognition model training device is similar to the contents described in the embodiments related to the above-mentioned face recognition model training method. For details, please refer to the relevant contents in the above-mentioned method, which will not be repeated here.

[0126] In an embodiment of the present invention, by using a target sample image with an aspect ratio of 1:1 to train a face recognition model, it is possible to effectively prevent the face contour from being changed by the face recognition model, so that the face recognition model can better learn the contour information of different face shapes, and the trained face recognition model has a higher accuracy in recognizing face shapes. Furthermore, by mosaic processing the target sample image, the focus on facial features during model training can be reduced, so that a smooth transition between the face contour and the facial features can be better achieved, and the face recognition model can be reduced from excessively focusing on non-face contours during training. Furthermore, by constructing a lightweight face recognition model, targeted model settings can be achieved, which is more in line with demand. Furthermore, by setting weight coefficients, different weight coefficients can be set for different face shapes, reducing the situation where the face recognition model pays too much attention to facial expressions during training, causing changes in facial contours.

[0127] In one embodiment, a computer-readable storage medium is proposed, storing a computer program. When the computer program is executed by a processor, the processor executes each step in the above-mentioned face recognition method, or causes the processor to execute each step in the above-mentioned face recognition model training method.

[0128] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0129] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0130] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A face recognition method, characterized in that: The method comprises: Obtain a facial image of the user whose face shape is to be recognized; Performing facial key point detection on the facial image, and determining a minimum facial rectangular area in the facial image according to the detected facial key points; Adjusting the minimum face rectangular area so that the adjusted length-to-width ratio of the target face area is 1:1, and extracting a target image corresponding to the target face area from the face image; Inputting the target image into a face shape recognition model, and determining the face shape of the user according to an output result of the face shape recognition model; Wherein, determining the minimum face rectangular area in the face image according to the detected face key points includes: Selecting a first minimum value and a first maximum value on a first direction component and a second minimum value and a second maximum value on a second direction component from the position information of the facial key points contained in the detected facial image, wherein the first direction component and the second direction component are perpendicular to each other and form a standard coordinate system; The position determined by the first minimum value and the second minimum value is used as the first position, the position determined by the first maximum value and the second maximum value is used as the second position, the first position and the second position are used as two opposite vertices of a first rectangle, the first rectangle is determined in the face image, and the area enclosed by the first rectangle is used as the minimum face rectangle area; The step of adjusting the minimum face rectangular area so that the adjusted target face area has a length-to-width ratio of 1:1 includes: When a first difference between the first maximum value and the first minimum value is greater than a second difference between the second maximum value and the second minimum value, a third difference obtained by subtracting the second difference from the first difference is calculated, the second maximum value in the second position is added to the third difference to obtain an adjusted second position, and the minimum face rectangular area is updated based on the first position and the adjusted second position to obtain the target face area; or, the second minimum value in the first position is subtracted from the third difference to obtain an adjusted first position, and the minimum face rectangular area is updated based on the adjusted first position and the second position to obtain the target face area; When a first difference between the first maximum value and the first minimum value is less than a second difference between the second maximum value and the second minimum value, a fourth difference obtained by subtracting the first difference from the second difference is calculated, the first maximum value in the second position is added to the fourth difference to obtain an adjusted second position, and the minimum face rectangular area is updated based on the first position and the adjusted second position to obtain the target face area; or, the first minimum value in the first position is subtracted from the fourth difference to obtain an adjusted first position, and the minimum face rectangular area is updated based on the adjusted first position and the second position to obtain the target face area.

2. The method according to claim 1, characterized in that Before inputting the target image into a face shape recognition model and determining the face shape of the user according to an output result of the face shape recognition model, the method further includes: Mosaic processing is performed on the facial features area in the target image to obtain an updated target image.

3. The method according to claim 1, characterized in that The face recognition model includes a first convolution layer, a first feature extraction layer, a second convolution layer, a second feature extraction layer, a third convolution layer, a third feature extraction layer, a fourth convolution layer, a fourth feature extraction layer, a fifth convolution layer, a sixth convolution layer, a pooling layer and a seventh convolution layer, which are cascaded in sequence; The first feature extraction layer, the second feature extraction layer, the third feature extraction layer and the fourth feature extraction layer each include at least two feature fusion layers cascaded in sequence; The feature fusion layer includes a first sub-convolution layer, a depth-level separable convolution, and a second sub-convolution layer that are cascaded in sequence. The feature image output by the feature fusion layer is: a feature image obtained by fusing an input feature image of the feature fusion layer with an output feature image of the second sub-convolution layer.

4. A face recognition model training method, characterized in that: The method comprises: Acquire a facial image sample data set, wherein the facial image sample data set includes facial sample images and face shapes of the facial sample images; Performing facial key point detection on the facial sample images in the facial image sample data set, and determining an initial facial sample area in the facial sample images according to the detected facial key points; The initial face sample area is adjusted so that the adjusted aspect ratio of the target face sample area is 1:1, and a target sample image corresponding to the target face sample area is extracted from the face sample image to obtain a target face image sample data set, wherein the target face sample data set includes a target sample image and a face shape of the target sample image; Iteratively training a face shape recognition model using the target sample image data set until the face shape recognition model converges based on the face shape recognition model training output result and the face shape of the target sample image; Wherein, determining the initial face sample area in the face sample image according to the detected face key points includes: From the position information of the facial key points contained in the detected facial sample image, select a first minimum sample value and a first maximum sample value on a first direction component, and a second minimum sample value and a second maximum sample value on a second direction component, the first direction component and the second direction component are perpendicular to each other and form a standard coordinate system; take the position determined by the first minimum sample value and the second minimum sample value as the first sample position, take the position determined by the first maximum sample value and the second maximum sample value as the second sample position, take the first sample position and the second sample position as two opposite vertices of a second rectangle, determine the second rectangle in the facial sample image, and take the area surrounded by the second rectangle as the initial facial sample area; The adjusting the initial face sample area so that the adjusted target face sample area has a length-to-width ratio of 1:1 includes: When a fifth difference between the first maximum sample value and the first minimum sample value is greater than a sixth difference between the second maximum sample value and the second minimum sample value, a seventh difference obtained by subtracting the sixth difference from the fifth difference is calculated, the second maximum sample value in the second sample position is added to the seventh difference to obtain an adjusted second sample position, and the initial face sample area is updated based on the first sample position and the adjusted second sample position to obtain the target face sample area; or, the second minimum sample value in the first sample position is subtracted from the seventh difference to obtain an adjusted first sample position, and the initial face sample area is updated based on the adjusted first sample position and the second sample position to obtain the target face sample area; When the fifth difference between the first maximum sample value and the first minimum sample value is less than the sixth difference between the second maximum sample value and the second minimum sample value, an eighth difference obtained by subtracting the fifth difference from the sixth difference is calculated, the first maximum sample value in the second sample position is added to the eighth difference to obtain an adjusted second sample position, and the initial face sample area is updated based on the first sample position and the adjusted second sample position to obtain the target face sample area; or, the first minimum sample value in the first sample position is subtracted from the eighth difference to obtain an adjusted first sample position, and the initial face sample area is updated based on the adjusted first sample position and the second sample position to obtain the target face sample area.

5. The method according to claim 4, characterized in that The face recognition model includes a first convolution layer, a first feature extraction layer, a second convolution layer, a second feature extraction layer, a third convolution layer, a third feature extraction layer, a fourth convolution layer, a fourth feature extraction layer, a fifth convolution layer, a sixth convolution layer, a pooling layer and a seventh convolution layer, which are cascaded in sequence; The first feature extraction layer, the second feature extraction layer, the third feature extraction layer and the fourth feature extraction layer each include at least two feature fusion layers cascaded in sequence; The feature fusion layer includes a first sub-convolution layer, a depth-level separable convolution, and a second sub-convolution layer that are cascaded in sequence. The feature image output by the feature fusion layer is: a feature image obtained by fusing an input feature image of the feature fusion layer with an output feature image of the second sub-convolution layer.

6. A face recognition device, characterized in that: The device comprises: An acquisition module is used to acquire a face image of a user whose face shape is to be recognized; A determination module, configured to perform facial key point detection on the facial image, and determine a minimum facial rectangular area in the facial image according to the detected facial key points; An adjustment module, used for adjusting the minimum face rectangular area so that the adjusted length-to-width ratio of the target face area is 1:1, and extracting a target image corresponding to the target face area from the face image; A recognition module, used for inputting the target image into a face shape recognition model, and determining the face shape of the user according to an output result of the face shape recognition model; The determination module is specifically used to: select a first minimum value and a first maximum value on a first direction component, and a second minimum value and a second maximum value on a second direction component from the position information of the facial key points contained in the detected facial image, wherein the first direction component and the second direction component are perpendicular to each other and form a standard coordinate system; use the position determined by the first minimum value and the second minimum value as the first position, use the position determined by the first maximum value and the second maximum value as the second position, use the first position and the second position as two opposite vertices of a first rectangle, determine the first rectangle in the facial image, and use the area enclosed by the first rectangle as the minimum facial rectangle area; The adjustment module is specifically used to: when a first difference between the first maximum value and the first minimum value is greater than a second difference between the second maximum value and the second minimum value, calculate a third difference obtained by subtracting the second difference from the first difference, add the third difference to the second maximum value in the second position to obtain an adjusted second position, and update the minimum face rectangular area based on the first position and the adjusted second position to obtain the target face area; or subtract the third difference from the second minimum value in the first position to obtain an adjusted first position, and update the minimum face rectangular area based on the adjusted first position and the second position to obtain the target face area. a target face area; when a first difference between the first maximum value and the first minimum value is less than a second difference between the second maximum value and the second minimum value, a fourth difference obtained by subtracting the first difference from the second difference is calculated, the first maximum value in the second position is added to the fourth difference to obtain an adjusted second position, and the minimum face rectangular area is updated based on the first position and the adjusted second position to obtain the target face area; or, the first minimum value in the first position is subtracted from the fourth difference to obtain an adjusted first position, and the minimum face rectangular area is updated based on the adjusted first position and the second position to obtain the target face area.

7. A face recognition model training device, characterized in that: The device comprises: A sample acquisition module, used to acquire a face image sample data set, wherein the face image sample data set includes face sample images and face shapes of the face sample images; A region determination module, configured to perform facial key point detection on the facial sample images in the facial image sample data set, and determine an initial facial sample region in the facial sample images according to the detected facial key points; A sample adjustment module is used to adjust the initial face sample area so that the adjusted target face sample area has an aspect ratio of 1:1, and extract a target sample image corresponding to the target face sample area from the face sample image to obtain a target face image sample data set, wherein the target face sample data set includes a target sample image and a face shape of the target sample image; A model training module, used for iteratively training a face shape recognition model using the target sample image, until the face shape recognition model converges based on the face shape recognition model training output result and the face shape of the target sample image; Wherein, the area determination module is specifically used to: select the first minimum sample value and the first maximum sample value on the first direction component, and the second minimum sample value and the second maximum sample value on the second direction component from the position information of the facial key points contained in the detected facial sample image, the first direction component and the second direction component are perpendicular to each other and form a standard coordinate system; use the position determined by the first minimum sample value and the second minimum sample value as the first sample position, use the position determined by the first maximum sample value and the second maximum sample value as the second sample position, use the first sample position and the second sample position as the two opposite vertices of the second rectangle, determine the second rectangle in the facial sample image, and use the area surrounded by the second rectangle as the initial facial sample area; The sample adjustment module is specifically used for: when the fifth difference between the first maximum sample value and the first minimum sample value is greater than the sixth difference between the second maximum sample value and the second minimum sample value, calculating a seventh difference obtained by subtracting the sixth difference from the fifth difference, adding the seventh difference to the second maximum sample value in the second sample position to obtain an adjusted second sample position, and updating the initial face sample area based on the first sample position and the adjusted second sample position to obtain the target face sample area; or subtracting the seventh difference from the second minimum sample value in the first sample position to obtain an adjusted first sample position, and updating the initial face sample area based on the adjusted first sample position and the second sample position to obtain the target face sample area. the target face sample area; when the fifth difference between the first maximum sample value and the first minimum sample value is less than the sixth difference between the second maximum sample value and the second minimum sample value, an eighth difference obtained by subtracting the fifth difference from the sixth difference is calculated, the first maximum sample value in the second sample position is added to the eighth difference to obtain an adjusted second sample position, and the initial face sample area is updated based on the first sample position and the adjusted second sample position to obtain the target face sample area; or, the first minimum sample value in the first sample position is subtracted from the eighth difference to obtain an adjusted first sample position, and the initial face sample area is updated based on the adjusted first sample position and the second sample position to obtain the target face sample area.

8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the processor executes each step of the face recognition method as described in any one of claims 1 to 3, or executes each step of the face recognition model training method as described in claim 4.