A method for training a face aging detection model and related device
By training the face aging detection model and using the convolutional neural network to combine the information in the real labels, the problem of being unable to accurately detect the characteristics and severity of facial aging in the existing technology is solved, and the refinement and accuracy of facial aging are achieved. detection.
Patent Information
- Application Number
- CN202110637569.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-08
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2041-06-08
AI Technical Summary
Existing skin measurement app software cannot accurately detect facial aging characteristics and severity, and cannot provide users with clear aging information.
By training the facial aging detection model, the convolutional neural network is used to combine the aging feature categories, location boxes and severity information in the real labels to learn multi-dimensional aging features and generate accurate aging detection results.
It achieves accurate detection of facial aging feature categories, locations and severity, provides clear-cut aging information, improves the refinement and accuracy of detection results, reduces model training time and improves accuracy.
Smart Images

Figure CN113343851B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of intelligent detection technology, and in particular to a method for training a face aging detection model and related devices. Background Art
[0002] As people's living standards continue to improve, men, women, young and old are increasingly pursuing younger skin. In addition, with the development of artificial intelligence, people are increasingly fond of using apps and other software to assist in skin testing, such as using skin testing apps to detect skin condition, degree of aging, etc.
[0003] However, current skin testing app software can only roughly estimate the user's age based on the facial skin to reflect the user's degree of aging. On the one hand, it cannot accurately determine the characteristics of aging and cannot provide specific improvement support for the user. On the other hand, the estimated age cannot accurately determine the degree of aging of the user's face, and thus, cannot provide the user with clearly defined aging information. Summary of the invention
[0004] The main technical problem solved by the embodiments of the present invention is to provide a method for training a face aging detection model and related devices, wherein the face aging detection model trained by the training method can accurately detect the category, position and severity of aging features, so that the degree of aging with clear boundaries can be accurately determined according to the category, position and severity of the aging features, so as to facilitate users to understand their own facial skin conditions.
[0005] To solve the above technical problems, in a first aspect, an embodiment of the present invention provides a method for training a face aging detection model, comprising:
[0006] Acquire an image sample set including human faces, wherein each image in the image sample set is annotated with a true label, and the true label includes a category, a position box, and a severity of an aging feature, wherein the aging feature is a reference feature reflecting aging of the human face, the category of the aging feature includes at least one aging feature, and the severity includes at least one degree level;
[0007] Acquire a position frame set, and determine the aspect ratios of a preset number of initial priori frames according to the position frame set, wherein the position frame set includes the position frame of each aging feature in each image in the image sample set;
[0008] The image sample set is input into a preset convolutional neural network for training. The preset convolutional neural network learns the image sample set with the preset number of initial prior frames to obtain a face aging detection model.
[0009] In some embodiments, the step of determining the aspect ratios of a preset number of initial a priori frames according to the position frame set includes:
[0010] For any target aging feature in the category of the aging feature, in the position frame set, randomly select a position frame from each position frame corresponding to the target aging feature as a standard position frame, and calculate the union-intersection ratios of the remaining position frames in each position frame corresponding to the target aging feature except the standard position frame and the standard position frame, so as to obtain each union-intersection ratio corresponding to each category of aging features;
[0011] Sorting the parallel-intersection ratios corresponding to the aging characteristics of each category together to generate a parallel-intersection ratio sequence;
[0012] According to the parallel-cross ratio sequence, the position frame set is divided into the preset number of position frame subsets;
[0013] According to a position frame subset, the aspect ratio of an initial a priori frame is determined to obtain the aspect ratios of the preset number of initial a priori frames.
[0014] In some embodiments, dividing the position frame set into the preset number of position frame subsets according to the parallel-cross ratio sequence includes:
[0015] Segmenting the parallel-crossover ratio sequence to obtain the preset number of parallel-crossover ratio subsequences;
[0016] For any target cross-ratio subsequence in the preset number of cross-ratio subsequences, a position frame for generating each cross-ratio in the target cross-ratio subsequence is obtained as a position frame subset.
[0017] In some embodiments, the step of determining the aspect ratio of an initial priori box according to a position box subset comprises:
[0018] Calculate the aspect ratio of the kth initial a priori frame among the preset number of initial a priori frames according to the following formula;
[0019]
[0020]
[0021] in, represents the average position box of each position box in the kth position box subset, |C k | represents the number of position boxes in the kth position box subset, x i represents the i-th position box in the K position box subset, R k represents the aspect ratio of the kth initial prior frame, represents the coordinates of the upper left corner of the average position box, represents the coordinates of the lower right corner of the average position frame, wherein the value range of k is from 1 to the preset number.
[0022] In some embodiments, the preset convolutional neural network includes a feature extraction network and a third preset number of convolution blocks, the third preset number is equal to the number of degree levels included in the severity level, the feature extraction network is used to extract features, the convolution blocks are used to learn features and output predicted labels, and a convolution block is configured with a level loss function, and the level loss function is used to calculate the error between the true label and the predicted label corresponding to each aging feature of the same level;
[0023] The step of inputting the image sample set into a preset convolutional neural network for training, wherein the preset convolutional neural network learns the image sample set with the preset number of initial prior frames to obtain a face aging degree detection model comprises:
[0024] Inputting a target image into the feature extraction network to obtain an initial feature map, wherein the target image is any image in the image sample set;
[0025] Copying the initial feature map by a preset number of copies to obtain the preset number of initial feature maps, wherein the preset number of copies is equal to the third preset number;
[0026] Inputting the preset number of initial feature maps into the third preset number of convolution blocks respectively, one initial feature map corresponds to one convolution block, so as to output the predicted label of the target image through a target convolution block, wherein the target convolution block is any one of the third preset number of convolution blocks;
[0027] Calculating the error between the predicted label output by the target convolution block and the true label corresponding to the target image according to the target level loss function, wherein the target level loss function is the level loss function configured by the target convolution block;
[0028] Sum the errors corresponding to the third preset number of convolution blocks to obtain a total error of the target image;
[0029] According to the total error sum, the model parameters of the preset convolutional neural network are adjusted until the preset convolutional neural network converges to obtain the face aging detection model, wherein the total error sum is the sum of the total errors corresponding to each image in the image sample set.
[0030] In some embodiments, a level loss function is configured with a level loss weight to form a corresponding relationship between the convolution block, the level loss function and the level loss weight;
[0031] The step of summing up the errors corresponding to the third preset number of convolution blocks to obtain a total error of the target image includes:
[0032] The errors corresponding to each of the third preset number of convolution blocks are weighted summed according to the corresponding level loss weights in the corresponding relationship to obtain the total error of the target image.
[0033] In order to solve the above technical problems, in a second aspect, an embodiment of the present invention provides a method for detecting face aging, comprising:
[0034] Obtain the face image to be tested;
[0035] The face image to be tested is input into the face aging detection model as described in the first aspect above to obtain the category, position and severity of the aging features of the face in the face image to be tested.
[0036] To solve the above technical problems, in a third aspect, an embodiment of the present invention provides a method for detecting the degree of aging of a face, comprising:
[0037] Obtain the face image to be tested;
[0038] Inputting the face image to be tested into the face aging detection model as described in the first aspect above to obtain the category, position and severity of the aging features of the face in the face image to be tested;
[0039] According to the category, position and severity of the aging features of the face in the face image to be tested, the aging degree of the face in the face image to be tested is determined according to a preset strategy.
[0040] In some embodiments, the severity level includes none, mild, moderate or severe.
[0041] The preset strategies include:
[0042] If the severity levels of the aging features are all zero, then it is determined that the aging degree of the face in the face image to be tested is zero;
[0043] If the severity levels of the aging characteristics do not include severe and moderate, then it is determined that the aging degree of the face in the face image to be tested is mild;
[0044] If the number of moderate severity levels in the severity levels of the aging characteristics is less than a preset threshold, it is determined that the aging degree of the face in the face image to be tested is moderate;
[0045] If the number of moderate severity levels of the aging characteristics is greater than or equal to the preset threshold, or if at least one severe severity level appears in the severity levels of the aging characteristics, it is determined that the aging level of the face in the face image to be tested is severe.
[0046] In order to solve the above technical problems, in a fourth aspect, an embodiment of the present invention provides an electronic device, including:
[0047] at least one processor, and
[0048] a memory communicatively coupled to the at least one processor, wherein:
[0049] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method described in the first aspect above.
[0050] To solve the above technical problems, in the fifth aspect, an embodiment of the present invention provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable an electronic device to execute the method described in the first aspect above.
[0051] Beneficial effects of the embodiments of the present invention: Different from the prior art, the method and related device for training a face aging detection model provided by the embodiments of the present invention, first, set an image sample set including a face as training data, each image in the image sample set is annotated with a real label, and the real label includes the category, position frame and severity of the aging feature, wherein the aging feature is a reference feature reflecting the aging of the face, for example, the category of the aging feature may include eye bags, cheek depression, sagging apple muscles or sagging corners of the mouth, etc. The category based on the aging feature includes at least one aging feature, so that the preset convolutional neural network can learn multiple dimensions of reference features that can reflect the aging of the face, compared with the learning of the reference feature of a single dimension, it can eliminate the error caused by the difference in the aging representation form of the user himself, and can improve the accuracy of the trained face aging detection model, and the real label also includes the severity of the aging feature, and the severity includes at least one degree level, for example, including four degree levels such as none, mild, moderate or severe, so that the preset convolutional neural network can learn aging features of different degrees of each category, that is, multiple aging features are learned by degree, which can make the detection result of the trained face aging detection model more refined. In addition, based on the fact that the position area of each aging feature on the human face is relatively fixed, the position boxes corresponding to an aging feature in the image sample set are similar. Therefore, the aspect ratio of each initial prior box determined by the statistical position box set is close to the aspect ratio of each position box in the real label, and can match the size of each aging feature in the real label. Therefore, during the training process, the adjustment of the aspect ratio of the prior box can be reduced, and attention can be paid to the adjustment of the center coordinates of the prior box, so that the prediction box (predicted position) generated by the prior box can be close to the position box in the real label. Therefore, the training time can be reduced, the model convergence can be effectively accelerated, and the accuracy of the model can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] One or more embodiments are exemplarily described by pictures in the corresponding drawings, and these exemplified descriptions do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings represent similar elements, and unless otherwise stated, the figures in the drawings do not constitute proportional limitations.
[0053] Figure 1 A schematic diagram of an operating environment of a related method in an embodiment of the present invention;
[0054] Figure 2 A schematic diagram of the hardware structure of an electronic device provided by one embodiment of the present invention;
[0055] Figure 3 A schematic diagram of a flow chart of a method for training a face aging detection model provided by one embodiment of the present invention;
[0056] Figure 4A schematic diagram of a true label of an image A provided by one embodiment of the present invention;
[0057] Figure 5 A schematic diagram of the structure of a preset convolutional neural network provided in one embodiment of the present invention;
[0058] Figure 6 A schematic diagram of a flow chart of a method for detecting facial aging provided by one embodiment of the present invention;
[0059] Figure 7 A schematic flow chart of a method for detecting the degree of aging of a human face provided in one embodiment of the present invention. DETAILED DESCRIPTION
[0060] The present invention is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those of ordinary skill in the art, several variations and improvements may be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.
[0061] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0062] It should be noted that, if there is no conflict, the various features in the embodiments of the present invention can be combined with each other, all within the scope of protection of the present application. In addition, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in a different order than the module division in the device or the flow chart. In addition, the words "first", "second", "third", etc. used herein do not limit the data and execution order, but only distinguish the same items or similar items with basically the same functions and effects.
[0063] Unless otherwise defined, all technical and scientific terms used in this specification have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in this specification and in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used in this specification includes any and all combinations of one or more of the related listed items.
[0064] In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0065] Figure 1is a schematic diagram of the operating environment of the relevant method in the embodiment of the present invention, wherein the relevant method includes a method for training a face aging detection model, a method for detecting face aging, or a method for detecting the degree of face aging. Figure 1 The operating environment includes an electronic device 10 and an image acquisition device 20, and the electronic device 10 and the image acquisition device 20 are communicatively connected.
[0066] The communication connection can be a wired connection, such as a fiber optic cable, or a wireless communication connection, such as a WIFI connection, a Bluetooth connection, a 4G wireless communication connection, a 5G wireless communication connection, and the like.
[0067] The image acquisition device 20 is used to acquire an image sample set including human faces, and can also be used to acquire a human face image to be tested. The image acquisition device 20 can be a terminal capable of capturing images, such as a mobile phone, tablet computer, video recorder or camera with a capturing function.
[0068] The electronic device 10 is a device that can run according to a program and automatically and quickly process massive amounts of data. It is usually composed of a hardware system and a software system, such as a computer, a smart phone, etc. The electronic device 10 can be a local device that is directly connected to the image acquisition device 20; it can also be a cloud device, such as a cloud server, a cloud host, a cloud service platform, a cloud computing platform, etc. The cloud device is connected to the image acquisition device 20 through a network, and the two are connected in communication through a predetermined communication protocol. In some embodiments, the communication protocol can be TCP / IP, NETBEUI, IPX / SPX, etc.
[0069] It is understandable that the image acquisition device 20 and the electronic device 10 may also be integrated together as an integrated device, such as a computer or smart phone with a camera.
[0070] The electronic device 10 receives an image sample set sent by the image acquisition device 20, each image in the image sample set includes a face, and the electronic device 10 trains the image sample set to obtain a face aging detection model, and uses the face aging detection model to detect the category, position and severity of the aging features of the face in the face image to be tested sent by the image acquisition device 20, or uses the face aging detection model to detect the aging degree of the face to be tested sent by the image acquisition device 20. It can be understood that the above-mentioned method of training a face aging detection model, the method of detecting face aging, or the method of detecting the aging degree of a face can be executed on the same electronic device or on different electronic devices.
[0071] In the above Figure 1 Based on this, another embodiment of the present invention provides an electronic device 10, see Figure 2 , is a hardware structure diagram of an electronic device 10 provided in an embodiment of the present invention, specifically, as Figure 2 As shown, the electronic device 10 includes at least one processor 11 and a memory 12 ( Figure 2 (a bus connection and a processor are used as an example).
[0072] Among them, the processor 11 is used to provide computing and control capabilities to control the electronic device 10 to perform corresponding tasks, for example, to control the electronic device 10 to execute any one of the methods for training a face aging detection model provided in the following invention embodiments, any one of the methods for detecting face aging provided in the following invention embodiments, or any one of the methods for detecting the degree of face aging provided in the following invention embodiments.
[0073] It can be understood that the processor 11 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0074] The memory 12 is a non-transitory computer-readable storage medium, which can be used to store non-transitory software programs, non-transitory computer executable programs and modules, such as the program instructions / modules corresponding to the method for training a face aging detection model in the embodiment of the present invention, or the program instructions / modules corresponding to the method for detecting face aging in the embodiment of the present invention, or the program instructions / modules corresponding to the method for detecting the degree of face aging in the embodiment of the present invention. The processor 11 can implement the method for training a face aging detection model in any of the following method embodiments by running the non-transitory software programs, instructions and modules stored in the memory 12, and can implement the method for detecting face aging in any of the following method embodiments, and can implement the method for detecting the degree of face aging in any of the following method embodiments. Specifically, the memory 12 may include a high-speed random access memory, and may also include a non-transitory memory, such as at least one disk storage device, a flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory 12 may also include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network and a combination thereof.
[0075] The following is a detailed description of the method for training a face aging detection model provided by an embodiment of the present invention. Figure 3 , the method S20 includes but is not limited to the following steps:
[0076] S21: Obtain an image sample set including faces.
[0077] Each image in the image sample set is annotated with a true label, and the true label includes a category, a position box and a severity of an aging feature, wherein the aging feature is a reference feature reflecting facial aging, the category of the aging feature includes at least one aging feature, and the severity includes at least one degree level.
[0078] S22: Acquire a position frame set, and determine the aspect ratios of a preset number of initial priori frames according to the position frame set, wherein the position frame set includes the position frame of each aging feature in each image in the image sample set.
[0079] S23: Inputting the image sample set into a preset convolutional neural network for training, wherein the preset convolutional neural network learns the image sample set with the preset number of initial prior frames to obtain a face aging detection model.
[0080] Several images in the image sample set all include human faces and can be acquired by the above-mentioned image acquisition device. For example, the image sample set can be a certificate photo or a selfie captured by the above-mentioned image acquisition device. It is understandable that the image sample set can also be data in an existing open source face database, wherein the open source face database can be a FERET face database, a CMU Multi-PIE face database, or a YALE face database. Here, there is no restriction on the source of the image sample set, as long as it includes human faces.
[0081] Each image in the image sample set is annotated with a corresponding true label, which includes the category, position frame and severity of the aging feature. The aging feature is a reference feature that reflects the aging of the face. For example, the category of aging features may include eye bags, sunken cheeks, sagging apple muscles or sagging corners of the mouth, etc., and may also include crow's feet or forehead wrinkles, etc., which may reflect the aging of the face. In this embodiment, eye bags, sunken cheeks, sagging apple muscles or sagging corners of the mouth may also be referred to as aging features.
[0082] The severity of the aging feature includes at least one degree level, for example, four degrees including none, mild, moderate or severe. It is understandable that the severity reflects the severity of the aging feature. For example, the severity of eye bags can be none, mild, moderate or severe, and the severity of sagging apple cheeks can be none, mild, moderate or severe.
[0083] The position box reflects the position area of the aging feature in the image. The position box can be a rectangular box represented by the center coordinates and width and height, for example (x, y, w, h), where (x, y) is the center coordinate, and w, h are the width and height respectively.
[0084] It can be understood that the true label of any image in the image sample set has at least one aging feature, and an aging feature corresponds to a position box and a severity. Figure 4 As shown, taking the real label of an image as an example, the real label of image A includes the position frames and severity of four types of aging characteristics, namely, eye bags, cheek depressions, sagging apple muscles, and sagging corners of the mouth. Among them, eye bags correspond to position frame 1#, the severity of eye bags is mild, cheek depressions correspond to position frame 2#, the severity of cheek depressions is none, sagging apple muscles correspond to position frame 3#, the severity of sagging apple muscles is mild, and sagging corners of the mouth correspond to position frame 4#, the severity of sagging corners of the mouth is none.
[0085] It is understandable that the true label of each image in the image sample set can be manually annotated using existing annotation tools, wherein the existing annotation tools may be LableBox or Labelmg, etc.
[0086] From the structure of the above-mentioned real labels, it can be seen that the category of aging features includes at least one aging feature, so that the preset convolutional neural network can learn multiple dimensions of reference features that can reflect the aging of the face. Compared with the learning of single-dimensional reference features, it can eliminate the errors caused by the differences in the representation forms of the users' own aging, and can improve the accuracy of the trained face aging detection model. For example, the aging of some users may be reflected in eye bags and full cheeks, the aging of other users may be reflected in sagging apple muscles without eye bags, and the aging of other users may be reflected in sagging corners of the mouth, sagging apple muscles, full cheeks, no eye bags, etc. If the single-dimensional reference features are used as aging features to evaluate aging, misjudgment will occur due to individual differences, and aging cannot be detected. Therefore, using multiple-dimensional reference features as aging features to evaluate aging can eliminate the errors caused by the differences in the representation forms of the users' own aging, and can improve the accuracy of the trained face aging detection model.
[0087] In addition, the true label also includes the severity of the aging feature, which includes at least one degree level, for example, four degrees including none, mild, moderate or severe, so that the preset convolutional neural network can learn aging features of various categories of different degrees, that is, learning multiple aging features by degree, which can make the detection results of the trained face aging detection model more refined.
[0088] Before using the image sample set as training data to train the preset convolutional neural network, by counting the position frames included in each real label, multiple initial a priori frames that meet the aspect ratio of the position frames in the real label are set, that is, multiple initial a priori frames can match the size of each aging feature in the real label. Specifically, a position frame set is obtained, and the position frame set includes the position frame of each aging feature in each image in the image sample set, that is, includes the position frame included in each real label. Then, according to the position frame set, the aspect ratio of the preset number of initial a priori frames is determined. It can be understood that the preset number is the same as the number of prediction frames generated by the preset convolutional neural network on the grid unit of the feature map during the learning process. Specifically, the preset number can be set by those skilled in the art according to the training requirements of the neural network. For example, in some embodiments, the preset number can be 9 or 3, etc.
[0089] Since the location area of each aging feature on the face is relatively fixed, the size of the location frame corresponding to the same aging feature in the image sample set is similar. For example, since the size and shape of eye bags in the face are similar, the aspect ratios of each location frame of the eye bags are relatively similar. For another example, since the size and shape of cheeks in the face are similar, the aspect ratios of each location frame of the cheek depression are relatively similar. Therefore, the aspect ratio of the initial prior frame determined by the statistical location frame set is similar to the aspect ratio of the location frame in the real label, and can match the size of each aging feature in the real label.
[0090] In the process of learning the image sample set, the preset convolutional neural network will continuously adjust the center coordinates and aspect ratio of the prior frame to generate a prediction frame, so that the prediction frame generated by the prior frame is constantly close to the position frame in the real label. Therefore, if multiple prior frames that match the aspect ratio of each position frame in the real label are used for learning at the beginning of training, the adjustment of the aspect ratio of the prior frame can be effectively reduced, saving the time required to adjust the aspect ratio. By paying attention to the adjustment of the center coordinates of the prior frame, the prediction frame (predicted position) generated by the prior frame can be close to the position frame in the real label, thereby reducing the training time, effectively accelerating the convergence of the model, and improving the accuracy of the model.
[0091] In the process of training the preset convolutional neural network using the image sample set as training data, the preset convolutional neural network will learn the image sample set with the above-mentioned preset number of initial prior frames to obtain a face aging detection model. Specifically, the initial prior frame continuously adjusts the center position and width and height to generate a prediction frame, so that the prediction frame is as close to the position frame in the real label as possible. The preset convolutional neural network in the training process will also predict the category and severity of the aging feature corresponding to each prediction frame, and the prediction frame, the category and severity of the aging feature constitute the prediction label. Then, the error sum between each predicted label and each real label is calculated by a preset loss function, and the model parameters of the preset convolutional neural network are reversely adjusted according to the error sum between each predicted label and each real label. After multiple iterative training, when the error sum between each predicted label and each real label fluctuates within a certain range or is less than a preset value, or when the iteration reaches a certain number of times, it means that the preset convolutional neural network after training converges. The corresponding network parameters after convergence are determined as the parameters of the model finally obtained, thereby obtaining a face aging detection model.
[0092] In summary, the method sets an image sample set including a human face as training data, and each image in the image sample set is annotated with a real label, and the real label includes the category, position frame and severity of the aging feature, wherein the aging feature is a reference feature reflecting the aging of the human face, for example, the category of the aging feature may include eye bags, cheek depression, sagging apple muscles or sagging corners of the mouth, etc. The category based on the aging feature includes at least one aging feature, so that the preset convolutional neural network can learn multiple dimensions of reference features that can reflect the aging of the human face. Compared with the learning of the reference feature of a single dimension, the error caused by the difference in the user's own aging representation form can be eliminated, and the accuracy of the trained human face aging detection model can be improved. In addition, the real label also includes the severity of the aging feature, and the severity includes at least one degree level, for example, including four degree levels such as none, mild, moderate or severe, so that the preset convolutional neural network can learn aging features of different degrees of each category, that is, multiple aging features are learned by degree, which can make the detection result of the trained human face aging detection model more refined. In addition, based on the fact that the position area of each aging feature on the human face is relatively fixed, the position boxes corresponding to an aging feature in the image sample set are similar. Therefore, the aspect ratio of each initial prior box determined by the statistical position box set is close to the aspect ratio of each position box in the real label, and can match the size of each aging feature in the real label. Therefore, during the training process, the adjustment of the aspect ratio of the prior box can be reduced, and attention can be paid to the adjustment of the center coordinates of the prior box, so that the prediction box (predicted position) generated by the prior box can be close to the position box in the real label. Therefore, the training time can be reduced, the model convergence can be effectively accelerated, and the accuracy of the model can be improved.
[0093] In some embodiments, step S22 specifically includes:
[0094] S221: For any target aging feature in the category of the aging feature, randomly select a position frame from the position frames corresponding to the target aging feature in the position frame set as a standard position frame, and calculate the union-intersection ratios of the remaining position frames except the standard position frame in the position frames corresponding to the target aging feature and the standard position frame, so as to obtain the union-intersection ratios corresponding to the aging features of each category.
[0095] S222: Sort the union-intersection ratios corresponding to the aging characteristics of each category together to generate a union-intersection ratio sequence.
[0096] S223: Divide the position frame set into the preset number of position frame subsets according to the parallel-cross ratio sequence.
[0097] S224: Determine the aspect ratio of an initial a priori frame according to a position frame subset, to obtain the aspect ratios of the preset number of initial a priori frames.
[0098] Specifically, an image sample set includes 100 images, and the true labels of each image include four types of aging features, namely, eye bags, sunken cheeks, sagging apple muscles, and sagging corners of the mouth. It can be understood that each image is marked with four position boxes, which correspond to the above four types of aging features, namely, eye bags, sunken cheeks, sagging apple muscles, and sagging corners of the mouth. Therefore, in this embodiment, there are 400 position boxes in the position box set. It can be understood that the above image sample set is only for illustration and does not constitute any limitation to the image sample set.
[0099] In this embodiment, the target aging feature is any one of the above four categories of aging features, for example, the target aging feature may be sagging of the apple muscles. It is understandable that in the position frame set, there are 100 position frames corresponding to the target aging feature. A position frame is randomly selected from the 100 position frames as the standard position frame, and the union-intersection ratios of the remaining 99 position frames and the standard position frame are calculated, thereby obtaining 99 union-intersection ratios corresponding to the target aging feature. For example, if from the position frame x1-x 100 In , the position frame x1 is randomly selected as the standard position frame, then the union-intersection ratio between the position frame x2 and the standard position frame is:
[0100]
[0101] Since the position area of each aging feature on the face is relatively fixed, the center coordinates and width and height of each position box corresponding to the same aging feature in the image sample set are similar. Therefore, for the same target aging feature, each intersection ratio (such as the 99 intersection ratios mentioned above) is relatively large, generally between 0.8 and 1.
[0102] Those skilled in the art can understand that, in this embodiment, since the target aging feature is any one of the above four categories of aging features, each of the aging features of eye bags, sunken cheeks, sagging apple muscles, and sagging corners of the mouth is calculated according to the above calculation method of the cross-over ratio, and 99*4=396 cross-over ratios can be obtained. Then, these 396 cross-over ratios are sorted to obtain a cross-over ratio sequence. The sorting can be in ascending order, for example, the 396 cross-over ratios are arranged from small to large, or in descending order, for example, the 396 cross-over ratios are arranged from large to small.
[0103] According to the intersection ratio sequence, the position frame set is divided into the preset number of position frame subsets. For example, 400 position frames are divided into 9 position frame subsets according to the intersection ratio sequence. Several intersection ratios are randomly selected at intervals in the intersection ratio sequence as an intersection ratio group. For any intersection ratio IoU(x1,x t ), we can use the intersection over Union (IoU) (x1, xt ) is used to calculate the intersection over Union (IoU) ratio (x1, x t ) standard position frame x1 and position frame x t , thereby obtaining the position frames corresponding to each cross-over ratio in the cross-over ratio group, and the position frames corresponding to each cross-over ratio in the cross-over ratio group constitute a position frame subset. Then, according to a position frame subset, determine the aspect ratio of an initial a priori frame, for example, take the aspect ratio of the position frame that appears most times in the position frame subset as the aspect ratio of the initial a priori frame. Finally, 9 position frame subsets obtain 9 initial a priori frames.
[0104] In this embodiment, the intersection-and-parallel ratios corresponding to the aging features of each category are sorted together so that the intersection-and-parallel ratios under each aging feature are roughly evenly distributed in the intersection-and-parallel ratio sequence, which is equivalent to dispersing the position frames under each aging feature, so that the position frame subset obtained according to the intersection-and-parallel ratio sequence can include the position frames under various aging features with a high probability. Therefore, each group of initial prior frames takes into account the shapes and sizes of various aging features, which is more reasonable and can match the sizes of each aging feature in the real label.
[0105] In some embodiments, step S223 specifically includes:
[0106] Step S2231: segmenting the parallel-crossover ratio sequence to obtain the preset number of parallel-crossover ratio subsequences;
[0107] Step S2232: For any parallel cross ratio subsequence in the preset number of parallel cross ratio subsequences, obtain a position frame for generating each parallel cross ratio in the target parallel cross ratio subsequence as a position frame subset.
[0108] For example, the parallel cross ratio sequence is roughly evenly divided into 9 segments, and 9 parallel cross ratio subsequences are obtained. For any target parallel cross ratio subsequence in the preset number of parallel cross ratio subsequences, the position frame for generating each parallel cross ratio in the target parallel cross ratio subsequence is indexed as a position frame subset. By analogy, 9 position frame subsets can be obtained.
[0109] Since the intersection-and-parallel ratios of various aging features are roughly evenly distributed in the intersection-and-parallel ratio sequence, based on the above segment division, it can be basically ensured that each position frame subset includes position frames corresponding to all categories of aging features.
[0110] In this embodiment, each cross-ratio subsequence is obtained by segmenting the cross-ratio sequence, and then the corresponding position frame subset is indexed according to the cross-ratio subsequence, so that each position frame subset can cover all aging features, which helps each initial prior frame to match the size of each aging feature in the real label, making each initial prior frame better.
[0111] In some embodiments, step S224 specifically includes:
[0112] Calculate the aspect ratio of the kth initial a priori frame among the preset number of initial a priori frames according to the following formula;
[0113]
[0114]
[0115] in, represents the average position box of each position box in the kth position box subset, |C k | represents the number of position boxes in the kth position box subset, x i represents the i-th position box in the k-th position box subset, R k represents the aspect ratio of the kth initial prior frame, represents the coordinates of the upper left corner of the average position box, represents the coordinates of the lower right corner of the average position frame, wherein the value range of k is from 1 to the preset number.
[0116] In the Calculate Average Position box When |C k The average value of the center coordinates (x, y) of | position frames is used to obtain the average position frame The center coordinates of |C k The average position box is obtained by taking the average coordinates of the upper left corners of the position boxes. The upper left corner coordinates Calculate|C k The average position box is obtained by taking the average coordinates of the lower right corners of the position boxes. The lower right corner coordinates
[0117] Thus, the average position frame The width is Gao Wei Thus, the aspect ratio R is obtained k .
[0118] In this implementation, the average position frame of each position frame in the position frame subset is used as the initial prior frame, and then the aspect ratio of the initial prior frame is calculated. Since the average position frame can reflect the overall size of each position frame in the position frame subset, the initial prior frame can reflect the overall size of each position frame in the position frame subset. The aspect ratio obtained by using this calculation formula is more reasonable and can match the size of each aging feature in the real label.
[0119] In some embodiments, the preset convolutional neural network includes a feature extraction network and a third preset number of convolutional blocks, the third preset number being equal to the number of degree levels included in the severity, for example, the severity includes four degree levels of none, mild, moderate, and severe, then the corresponding third preset number is 4, and the preset convolutional neural network includes 4 convolutional blocks. Among them, the feature extraction network is used to extract features, and the convolutional blocks are used to learn features and output predicted labels. A convolutional block is configured with a level loss function. The level loss function is used to calculate the error between the true label and the predicted label corresponding to each aging feature of the same level.
[0120] It can be understood that the convolution blocks correspond to the level loss functions one by one, and each convolution block has a corresponding level loss function. Therefore, the convolution block only learns the features of the level constrained by the corresponding level loss function. For example, Figure 5 As shown, if the level loss function corresponding to convolution block 2# is used to calculate the error between the true label and the predicted label of each mild aging feature, under the constraint of the loss function, convolution block 2# only learns the mild aging features, such as only learning the features of mild-eye bags, mild-cheek sunken, mild-apple muscle drooping, mild-mouth corner drooping, etc., and outputs the predicted labels corresponding to each aging feature with a severity level of mild.
[0121] Specifically, in this embodiment, step S23 specifically includes:
[0122] S231: Inputting a target image into the feature extraction network to obtain an initial feature map, wherein the target image is any image in the image sample set.
[0123] S232: Copy the initial feature map by a preset number of copies to obtain the preset number of initial feature maps, wherein the preset number of copies is equal to the third preset number.
[0124] S233: Input the preset number of initial feature maps into the third preset number of convolution blocks respectively, one copy of the initial feature map corresponds to one convolution block, so as to output the predicted label of the target image through the target convolution block, wherein the target convolution block is any one of the third preset number of convolution blocks.
[0125] S234: Calculate the error between the predicted label output by the target convolution block and the corresponding true label according to the target level loss function, where the target level loss function is the level loss function configured for the target convolution block.
[0126] S235: Sum the errors corresponding to the third preset number of convolution blocks to obtain a total error of the target image.
[0127] S236: Adjust the model parameters of the preset convolutional neural network according to the total error sum until the preset convolutional neural network converges to obtain the face aging detection model, wherein the total error sum is the sum of the total errors corresponding to each image in the image sample set.
[0128] The target image is any image in the image sample set. During the training process, each image in the image sample set is input into the preset convolutional neural network for training. The specific training process is described using the target image as an example, as follows:
[0129] Input the target image into the feature extraction network to obtain an initial feature map. The feature extraction network is used to perform convolution operations and pooling operations on the target image to reduce the dimension of the target image and extract features. In some embodiments, the feature extraction network can be an existing CSPDarknet53 network or Resnet network, etc. For example, if the size of the target image is 416*416, after the feature extraction network extracts the features, an initial feature map of size 52*52 can be output. It can be understood that the downsampling multiple of the initial feature map is 416 / 52=8, that is, the downsampling multiple is low, the extracted features are fewer, and it is similar to the original target image, and the initial feature map will not deviate from the original target image due to the downsampling multiple being too high.
[0130] After obtaining the initial feature map, the initial feature map is copied a preset number of times, where the preset number of copies is equal to the third preset number, that is, the number of the initial feature map is the same as the number of convolution blocks, and thus, the preset number of initial feature maps are respectively input into the third preset number of convolution blocks, that is, one initial feature map corresponds to one convolution block.
[0131] A level loss function is configured based on a convolution block, so that a target level loss function corresponding to the target convolution block can be determined according to the target convolution block. The target convolution block is any one of the third preset number of convolution blocks, and the target level loss function is the level loss function configured by the target convolution block. The target convolution block performs a convolution operation on the initial feature map and outputs a predicted label of the target image. Then, according to the target level loss function, the error between the predicted label output by the target convolution block and the corresponding true label is calculated.
[0132] It can be understood that since the level loss function is used to calculate the error between the real label and the predicted label corresponding to each aging feature of the same level, under the constraint of the target level loss function, the target convolution block only learns the aging features of the severity corresponding to the target level loss function. If the target level loss function is used to calculate the error between the real label and the predicted label corresponding to each moderate aging feature, then the target convolution block only learns the aging features of moderate severity, and the output predicted label is also the predicted label of moderate severity. Therefore, the target level loss function also only calculates the error between the predicted label of moderate severity and the corresponding real label.
[0133] Specifically, the initial feature map of size 52*52 is input into the target convolution block, and the initial feature map is further convolved to extract features and obtain a 13*13 feature map. The target convolution block divides the feature map into S*S grids, generates a preset number of initial prior verifications on each grid, and assigns the prediction task of the position of each aging feature to the initial prior box corresponding to the grid A where the center position of the aging feature is located. The initial prior box is used to predict the position of the aging feature. As the model parameters are adjusted, the initial prior box will slide on the grid A to adjust the center coordinates, adjust the width and height, and become a prediction box. In the next iterative training, the size and position of the previous prediction box are also continuously adjusted as the model parameters are adjusted, so that each adjusted prediction box continuously approaches the corresponding position box in the true label. The target convolution block also predicts the confidence of the prediction box and the probability of each aging feature to which the prediction box belongs. The prediction box, the confidence of the prediction box, and the probability of each aging feature to which the prediction box belongs constitute the predicted label of the aging feature. .
[0134] Then, the target level loss function is used to calculate the error between the predicted label of the target image output by the target convolution block and the true label of the target image. For example, if the target level loss function is used to calculate the error between the predicted label and the true label corresponding to each mild aging feature, then when calculating the error, only the labels with mild severity in the predicted label are involved in the error calculation.
[0135] It can be understood that the target level loss function can be set according to the structure of the target convolution block. When the target convolution block is a YOLOV3 network, the corresponding target level loss function can be the loss function of the YOLOV3 network. k (object) The calculation is done according to the following formula:
[0136]
[0137] Where k is the severity level, is the center coordinate loss of the prediction box with severity k, ρxy is the center coordinate loss weight, is the width and height loss of the prediction box with severity k, ρ wh is the wide loss weight, is the confidence loss, is the category loss of aging features, ρ cls is the class loss weight.
[0138] in,
[0139]
[0140]
[0141]
[0142]
[0143]
[0144] Among them, S*S represents the number of grids, σ(t x ) represents the horizontal distance of the center of the prediction box from the upper left corner of the grid where the prediction box is located, σ(t y ) represents the vertical distance of the center of the prediction box from the upper left corner of the grid where the prediction box is located, σ(t x * ) represents the horizontal distance of the center of the position box from the upper left corner of the grid where the position box is located, σ(t y * ) represents the vertical distance of the center of the position box from the upper left corner of the grid where the position box is located. and Respectively represent the width and height of the position box, σ(t w ) represents the distance from the center of the prediction box to the width of the upper left corner of the grid where the prediction box is located, σ(t w * ) represents the distance from the center of the position box to the width of the upper left corner of the grid where the real position box is located, σ(t h ) represents the distance from the center of the prediction box to the upper left corner of the grid where the prediction box is located, σ(t h * ) represents the distance that the center of the position box deviates from the height of the upper left corner of the grid where the real position box is located.
[0145] γ obj and γ noobj are the weights of predicting whether the box contains aging features. and They respectively represent whether the j-th prediction box of the i-th grid is responsible for predicting the aging feature. When the prediction box is responsible for predicting the aging feature, on the contrary, c i Represents the confidence of the prediction box, c i * represents the true confidence. When the prediction box of the i-th network unit is responsible for predicting the aging feature, c i * =1, otherwise c i * = 0. i Represents the probability of each aging feature to which the prediction box belongs, represents the true class probability.
[0146] In this embodiment, the target level loss function is the result of center coordinate loss, width and height loss, confidence loss and category loss. Among them, the center coordinate loss and width and height loss constrain the relationship between the prediction box and the position box in the real label, minimize the error between the two, so that the output prediction box is constantly close to the position box to optimize the model parameters. Among them, the category loss constrains the category of the aging feature output in the prediction label and the category in the real label, so that the category in the prediction label is constantly close to the category in the real label to optimize the model parameters. Among them, the confidence loss constrains the optimization model parameters by judging whether the prediction box includes aging features. In this target level loss function, the prediction box and the position box participate in error calculation, gradient backpropagation, and backpropagation when there is an intersection, so as to be trained. The prediction box and the position box can also perform gradient backpropagation and backpropagation with a certain weight when there is no intersection, so as to be trained to improve the accuracy of the model.
[0147] The above description is the error calculation corresponding to the convolution block with severity k. It can be understood that k can be any degree of severity. For the third preset number of convolution blocks, the above training process can be used to calculate the corresponding errors, and then the errors corresponding to the third predicted number of convolution blocks are summed to obtain the total error of the target image. The total error of the target image is calculated according to the following formula:
[0148]
[0149] Where M is the number of severity levels, Loss k (object) is the error corresponding to the convolution block with severity k, and Loss is the total error of the target image.
[0150] It can be understood that the target image is any image in the image sample set, and the total error of each image in the image sample set is calculated according to the above method. Therefore, when the preset convolutional neural network is trained using the image sample set as training data, the preset convolutional neural network in the training process processes the entire image sample set at the same time, and the total error of the entire model is the sum of the total errors corresponding to each image in the image sample set. According to the total error, the model parameters of the preset convolutional neural network are adjusted. After multiple iterations, when the total error fluctuates within a certain range or is less than the preset value, it means that the preset convolutional neural network after training has converged, and the corresponding model parameters after convergence are determined as the parameters of the model finally obtained, thereby obtaining a face aging detection model.
[0151] In this embodiment, the initial feature map is copied according to the number of severity levels, and then the initial feature maps are respectively input into the convolution blocks for learning to output predicted labels. Since one convolution block is configured with a level loss function, the level loss function is used to calculate the error between the true label and the predicted label corresponding to each aging feature of the same level, that is, the level loss function is used to constrain the corresponding convolution block to only learn each aging feature of a certain severity level, so that aging features of different severities are learned separately, thereby effectively reducing the impact of the difficulty in model training convergence due to the small difference in the severity of each aging feature.
[0152] In the image sample set, there is a data imbalance problem for various aging features of different severity. For example, there are more mild aging features and fewer severe aging features. In order to reduce the risk of inaccurate model classification caused by data imbalance, in some embodiments, a level loss function is configured with a level loss weight to form a corresponding relationship between convolution block-level loss function-level loss weight, for example, convolution block k-level loss function k-level loss weight τ k , where k represents the severity level.
[0153] In this embodiment, step S235 includes:
[0154] The errors corresponding to each of the third preset number of convolution blocks are weighted summed according to the corresponding level loss weights in the corresponding relationship to obtain the total error of the target image.
[0155] Specifically, the error corresponding to each convolution block is multiplied by the corresponding level loss weight, and then summed to obtain the total error of the target image. The specific calculation formula is as follows:
[0156]
[0157] Among them, τ kDenotes the convolutional block k-level loss function k corresponding to the degree loss weight, where k represents the degree of severity.
[0158] In this embodiment, corresponding level loss weights are set for convolution blocks of different severity levels to balance the imbalance of aging feature data. This can effectively reduce the risk of inaccurate model classification caused by data imbalance and improve the accuracy of the face aging detection model.
[0159] In summary, the method for training a face aging detection model provided by an embodiment of the invention first sets an image sample set including a face as training data, wherein each image in the image sample set is annotated with a true label, and the true label includes the category, position frame and severity of the aging feature, wherein the aging feature is a reference feature reflecting the aging of the face, for example, the category of the aging feature may include eye bags, cheek depression, sagging apple muscles or sagging corners of the mouth, etc. The category based on the aging feature includes at least one aging feature, so that the preset convolutional neural network can learn multiple dimensions of reference features that can reflect the aging of the face. Compared with the learning of the reference feature of a single dimension, the error caused by the difference in the aging representation form of the user himself can be eliminated, and the accuracy of the trained face aging detection model can be improved. In addition, the true label also includes the severity of the aging feature, and the severity includes at least one degree level, for example, including four degree levels such as none, mild, moderate or severe, so that the preset convolutional neural network can learn aging features of different degrees of each category, that is, multiple aging features are learned by degree, which can make the detection result of the trained face aging detection model more refined. In addition, based on the fact that the position area of each aging feature on the human face is relatively fixed, the position boxes corresponding to an aging feature in the image sample set are similar. Therefore, the aspect ratio of each initial prior box determined by the statistical position box set is close to the aspect ratio of each position box in the real label, and can match the size of each aging feature in the real label. Therefore, during the training process, the adjustment of the aspect ratio of the prior box can be reduced, and attention can be paid to the adjustment of the center coordinates of the prior box, so that the prediction box (predicted position) generated by the prior box can be close to the position box in the real label. Therefore, the training time can be reduced, the model convergence can be effectively accelerated, and the accuracy of the model can be improved.
[0160] The following is a detailed description of the method for detecting face aging provided by an embodiment of the present invention. Figure 6 The method S30 includes but is not limited to the following steps:
[0161] S31: Obtain a face image to be tested.
[0162] S32: Inputting the face image to be tested into the face aging detection model in any one of the above training method embodiments to obtain the category, position and severity of the aging features of the face in the face image to be tested.
[0163] The face image to be tested is a human face image, which can be obtained by the above-mentioned image acquisition device 20. For example, the face image to be tested can be a certificate photo or a selfie captured by the image acquisition device 20. Here, there is no restriction on the source of the face image to be tested, and it can be a human face image.
[0164] By inputting the face image to be tested into the face aging detection model in any of the above embodiments, the category, position and severity of the aging features of the face in the face image to be tested can be obtained.
[0165] It can be understood that the face aging detection model is trained by the method of training the face aging detection model in any of the above embodiments, and has the same structure and function as the face aging detection model in any of the above embodiments, which will not be elaborated here.
[0166] In this embodiment, the face image to be tested is tested through the face aging detection model, and the category, position and severity of each aging feature can be directly located, providing users with rich and refined aging detection results.
[0167] The following is a detailed description of the method for detecting the degree of aging of a face provided by an embodiment of the present invention. Figure 7 The method S40 includes but is not limited to the following steps:
[0168] S41: Obtain a face image to be tested.
[0169] S42: inputting the face image to be tested into the face aging detection model in any one of the training method embodiments to obtain the category, position and severity of the aging features of the face in the face image to be tested;
[0170] S43: Determine the aging degree of the face in the face image to be tested according to the category, position and severity of the aging features of the face in the face image to be tested and according to a preset strategy.
[0171] It is understandable that the face image to be tested is a human face image, which can be obtained by the above-mentioned image acquisition device 20. For example, the face image to be tested can be a certificate photo or a selfie captured by the image acquisition device 20. Here, there is no restriction on the source of the face image to be tested, and it can be a human face image.
[0172] By inputting the face image to be tested into the face aging detection model in any of the above embodiments, the category, position and severity of the aging features of the face in the face image to be tested can be obtained.
[0173] It can be understood that the face aging detection model is trained by the method of training the face aging detection model in any of the above embodiments, and has the same structure and function as the face aging detection model in any of the above embodiments, which will not be elaborated here.
[0174] After obtaining the category, position and severity of each aging feature in the face image to be tested, the aging degree of the face in the face image to be tested is determined according to a preset strategy.
[0175] Among them, the preset strategy stipulates the mapping relationship between different detection results and the degree of aging, so as to output the degree of aging that is more in line with the user's judgment of the aging of the face. The degree of aging as a recognition result has clear boundaries, which can help users understand the aging of their facial skin.
[0176] Since facial aging is determined by many factors and cannot be determined by a single feature, if the classification network is directly used to identify the degree of facial aging, inaccurate classification is likely to occur, and the classification boundaries of the degree of aging are not very clear.
[0177] Therefore, this embodiment detects the aging features that affect the degree of facial aging through a face aging detection model, and then identifies them through a matching method of a preset strategy. It can effectively integrate various aspects of aging features for judgment and improve the accuracy of aging degree detection.
[0178] It is understandable that the preset strategy can be set according to actual conditions. In some embodiments, the severity level includes none, mild, moderate or severe levels, and the aging level also includes none, mild, moderate or severe.
[0179] In this embodiment, the preset strategy includes:
[0180] If the severity levels of the aging features are all "none", then the aging degree of the face in the face image to be tested is determined to be "none". For example, if the severity levels of aging features such as eye bags, sunken cheeks, sagging apple muscles, or sagging corners of the mouth are all "none", then the aging degree of the face in the face image to be tested is determined to be "none", that is, no aging.
[0181] If severe and moderate severity levels do not appear in the severity levels of the aging features, the aging degree of the face in the face image to be tested is determined to be mild. For example, if the severity levels of aging features such as eye bags, sunken cheeks, sagging apple muscles, or sagging corners of the mouth are none or mild, and severe and moderate aging features do not appear, the aging degree of the face in the face image to be tested is determined to be mild.
[0182] If the number of moderate severity levels in the severity levels of the aging characteristics is less than a preset threshold, it is determined that the aging level of the face in the face image to be tested is moderate.
[0183] If the number of moderate severity levels of the aging characteristics is greater than or equal to the preset threshold, or if at least one severe severity level appears in the severity levels of the aging characteristics, it is determined that the aging level of the face in the face image to be tested is severe.
[0184] It is understandable that the preset threshold can be set according to actual conditions, for example, according to the user's cognitive requirements for aging. For example, if the preset threshold is 2, and the number of severe aging features such as eye bags, sunken cheeks, sagging apple muscles, or sagging corners of the mouth is less than 2, then it is determined that the aging degree of the face in the face image to be tested is moderate.
[0185] If two or more moderate aging features such as eye bags, sunken cheeks, sagging apple muscles or drooping corners of the mouth appear, or one severe aging feature appears, then the aging level of the face in the face image to be tested is determined to be severe.
[0186] In this embodiment, by setting a reasonable preset strategy, various aspects of aging characteristics can be effectively integrated for judgment, thereby improving the accuracy of aging degree detection.
[0187] Another embodiment of the present invention further provides a non-transitory computer-readable storage medium, which stores computer-executable instructions, and the computer-executable instructions are used to enable an electronic device to execute the method for training a face aging detection model, the method for detecting face aging, or the method for detecting the degree of face aging in any of the above-mentioned method embodiments.
[0188] An embodiment of the present invention provides a computer program product, including a computer program stored on a non-volatile computer-readable storage medium, wherein the computer program includes program instructions. When the program instructions are executed by a computer, the computer executes the method for training a face aging detection model, the method for detecting face aging, or the method for detecting the degree of face aging in any of the above-mentioned method embodiments.
[0189] It should be noted that the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0190] Through the description of the above implementation methods, ordinary technicians in this field can clearly understand that each implementation method can be implemented by means of software plus a general hardware platform, and of course, it can also be implemented by hardware. Ordinary technicians in this field can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0191] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them. Under the concept of the present invention, the technical features in the above embodiments or different embodiments may also be combined, the steps may be implemented in any order, and there are many other changes in different aspects of the present invention as described above, which are not provided in detail for the sake of simplicity. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they may still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for training a face aging detection model, It is characterized in that include: Acquire an image sample set including human faces, wherein each image in the image sample set is annotated with a true label, and the true label includes a category, a position box, and a severity of an aging feature, wherein the aging feature is a reference feature reflecting aging of the human face, the category of the aging feature includes at least one aging feature, and the severity includes at least one degree level; Acquire a position frame set, and determine the aspect ratios of a preset number of initial priori frames according to the position frame set, wherein the position frame set includes the position frame of each aging feature in each image in the image sample set; Inputting the image sample set into a preset convolutional neural network for training, wherein the preset convolutional neural network learns the image sample set with the preset number of initial prior frames to obtain a face aging detection model; The step of determining the aspect ratios of a preset number of initial a priori frames according to the position frame set includes: For any target aging feature in the category of the aging features, in the position frame set, a position frame is randomly selected from the position frames corresponding to the target aging feature as the standard position frame, and the intersection and parallel ratios of the remaining position frames except the standard position frame in the position frames corresponding to the target aging feature are calculated respectively with the standard position frame to obtain the intersection and parallel ratios corresponding to the aging features of each category; the intersection and parallel ratios corresponding to the aging features of each category are sorted together to generate an intersection and parallel ratio sequence; according to the intersection and parallel ratio sequence, the position frame set is divided into the preset number of position frame subsets; according to a position frame subset, the aspect ratio of an initial priori frame is determined to obtain the aspect ratio of the preset number of initial priori frames.
2. The method according to claim 1, It is characterized in that The step of dividing the position frame set into the preset number of position frame subsets according to the parallel-cross ratio sequence comprises: Segmenting the parallel-crossover ratio sequence to obtain the preset number of parallel-crossover ratio subsequences; For any target cross-ratio subsequence in the preset number of cross-ratio subsequences, a position frame for generating each cross-ratio in the target cross-ratio subsequence is obtained as a position frame subset.
3. The method according to claim 1, It is characterized in that The step of determining the aspect ratio of an initial priori frame according to a position frame subset comprises: Calculate the aspect ratio of the kth initial a priori frame among the preset number of initial a priori frames according to the following formula; in, represents the average position box of each position box in the kth position box subset, represents the number of position boxes in the kth position box subset, represents the i-th position box in the k-th position box subset, represents the aspect ratio of the kth initial prior frame, represents the coordinates of the upper left corner of the average position box, represents the coordinates of the lower right corner of the average position frame, wherein the value range of k is from 1 to the preset number.
4. The method according to claim 1, It is characterized in that The preset convolutional neural network includes a feature extraction network and a third preset number of convolution blocks, the third preset number is equal to the number of degree levels included in the severity level, the feature extraction network is used to extract features, the convolution blocks are used to learn features and output predicted labels, and a convolution block is configured with a level loss function, and the level loss function is used to calculate the error between the true label and the predicted label corresponding to each aging feature of the same level; The step of inputting the image sample set into a preset convolutional neural network for training, wherein the preset convolutional neural network learns the image sample set with the preset number of initial prior frames to obtain a face aging degree detection model comprises: Inputting a target image into the feature extraction network to obtain an initial feature map, wherein the target image is any image in the image sample set; Copying the initial feature map by a preset number of copies to obtain the preset number of initial feature maps, wherein the preset number of copies is equal to the third preset number; Inputting the preset number of initial feature maps into the third preset number of convolution blocks respectively, one initial feature map corresponds to one convolution block, so as to output the predicted label of the target image through a target convolution block, wherein the target convolution block is any one of the third preset number of convolution blocks; Calculating the error between the predicted label output by the target convolution block and the true label corresponding to the target image according to the target level loss function, wherein the target level loss function is the level loss function configured by the target convolution block; Sum the errors corresponding to the third preset number of convolution blocks to obtain a total error of the target image; According to the total error sum, the model parameters of the preset convolutional neural network are adjusted until the preset convolutional neural network converges to obtain the face aging detection model, wherein the total error sum is the sum of the total errors corresponding to each image in the image sample set.
5. The method according to claim 4, It is characterized in that A level loss function configures a level loss weight to form a corresponding relationship between the convolution block, the level loss function and the level loss weight; The step of summing up the errors corresponding to the third preset number of convolution blocks to obtain a total error of the target image includes: The errors corresponding to each of the third preset number of convolution blocks are weighted summed according to the corresponding level loss weights in the corresponding relationship to obtain the total error of the target image.
6. A method for detecting facial aging, It is characterized in that include: Obtain the face image to be tested; The face image to be tested is input into the face aging detection model as described in any one of claims 1 to 5 to obtain the category, position and severity of the aging features of the face in the face image to be tested.
7. A method for detecting the degree of aging of a face. It is characterized in that include: Obtain the face image to be tested; Inputting the face image to be tested into the face aging detection model as described in any one of claims 1 to 5 to obtain the category, position and severity of the aging features of the face in the face image to be tested; According to the category, position and severity of the aging features of the face in the face image to be tested, the aging degree of the face in the face image to be tested is determined according to a preset strategy.
8. The method according to claim 7, It is characterized in that The severity levels include none, mild, moderate or severe. The preset strategies include: If the severity levels of the aging features are all zero, then it is determined that the aging degree of the face in the face image to be tested is zero; If the severity levels of the aging characteristics do not include severe and moderate, then it is determined that the aging degree of the face in the face image to be tested is mild; If the number of moderate severity levels in the severity levels of the aging characteristics is less than a preset threshold, it is determined that the aging degree of the face in the face image to be tested is moderate; If the number of moderate severity levels of the aging characteristics is greater than or equal to the preset threshold, or if at least one severe severity level appears in the severity levels of the aging characteristics, it is determined that the aging level of the face in the face image to be tested is severe.
9. An electronic device, It is characterized in that include: at least one processor, and a memory communicatively coupled to the at least one processor, wherein: The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 8.
10. A non-transitory computer-readable storage medium, It is characterized in that The non-transitory computer-readable storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable an electronic device to execute the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Method and apparatus for annotation of medical imagery to facilitate patient identification, diagnosis, and treatment
CA2229630A1
Training method of human face impurity detection model and human face impurity detection method
CN111695463A
