A face detection method, device and related products
The multi-scale features of the image are extracted through the face detection model, and the positive and negative sample allocation and model updates are dynamically adjusted, which solves the problem of low face detection accuracy in the prior art and improves the accuracy of face detection.
Patent Information
- Application Number
- CN202510437679.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-09
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2045-04-09
AI Technical Summary
When processing difficult face samples, the prior art causes the model to be overfitted or insufficient learning through static difficulty evaluation, resulting in low accuracy of face detection.
Multi-scale features of the image are extracted through the face detection model, the face density distribution is determined, and the results are divided easily according to the comparison results of the real and predicted density distributions, dynamically adjust the positive and negative sample allocation and model updates, and improve the training effectiveness of the face detection model.
Accurate evaluation and dynamic adjustment of the difficulty of face samples is achieved, and the accuracy of face detection is improved.
Smart Images

Figure CN119942624B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer vision technology, and in particular, to a face detection method, device, and related products. Background Art
[0002] Face detection is a key task in the field of computer vision and is a basic prerequisite for various tasks such as face recognition, face attribute classification, face alignment, and face tracking. The quality of face detection deeply affects the performance of subsequent tasks, thus having a significant impact on fields such as security monitoring, human-computer interaction, and virtual reality.
[0003] With the development of deep learning technology, general object detection based on neural networks, such as SSD, YOLO, and RetinaNet, has greatly promoted the development of the face detection field. However, there are still the following challenges in general face detection: 1) complex environmental factors, such as lighting and face background objects; 2) shooting distance and hardware configuration of image acquisition devices, such as resolution, shutter speed, etc.; 3) variability of facial poses and occlusion between multiple faces. In real-world applications, these challenges often coexist, and for faces with important features such as small size, low resolution, and pose changes, recent methods often fail to achieve satisfactory results. Generally, a face with one or more of these features is called a difficult example face.
[0004] In the prior art, when dealing with challenging face samples such as difficult example faces, the prior art usually distinguishes face samples of different difficulty levels through label assignment. However, after predefined anchor points, these methods assign fixed labels to all faces in the image, which means that the difficulty assessment of each face remains unchanged throughout the training process. This static difficulty assessment method is not ideal because continuously increasing the loss weight or the number of positive samples of a specific face sample during training may cause the model to overfit to these faces and under-learn other faces, thereby resulting in low accuracy of face detection.
[0005] In summary, how to improve the accuracy of face detection is an urgent problem for those skilled in the art. Summary of the Invention
[0006] In view of this, this application provides a face detection method, device, and related products, aiming to improve the accuracy of face detection.
[0007] In a first aspect, this application provides a face detection method, including:
[0008] Extracting features of images in a training set by using a face detection model to obtain multi-scale features of the images;
[0009] Determine the face density distribution in the image according to the multi-scale features of the image; the face density distribution includes a predicted face density distribution and a ground-truth face density distribution;
[0010] Divide the face samples into easy and difficult ones according to the comparison result between the ground-truth face density distribution and the predicted face density distribution;
[0011] Perform positive and negative sample assignment for face detection according to the division of the face samples into easy and difficult ones;
[0012] Update the face detection model according to the assignment of positive and negative samples for face detection;
[0013] Perform face detection using the updated face detection model.
[0014] Optionally, the determining the face density distribution in the image according to the multi-scale features of the image includes:
[0015] Pass each scale feature in the multi-scale features of the image through multiple layers of convolution to obtain a predicted face density map; the predicted face density map is used to indicate the predicted face density distribution;
[0016] When supervising the face density map branch, give a fully zero input mask;
[0017] Set the position of the face center point in the fully zero input mask to 1;
[0018] Generate a ground-truth face density map using a Gaussian filter; the ground-truth face density map is used to indicate the ground-truth face density distribution.
[0019] Optionally, after determining the face density distribution in the image according to the multi-scale features of the image, the method further includes:
[0020] Classify and regress the multi-scale features of the image to obtain a face confidence and a face position; the face confidence is used for face judgment;
[0021] Determine the face size according to the result of the face judgment;
[0022] Perform pre-assignment of positive and negative samples for face detection according to the face position and the face size.
[0023] Optionally, after determining the face density distribution in the image according to the multi-scale features of the image, the method further includes:
[0024] Store the predicted face density map into a prediction result list;
[0025] Assign an index number in the prediction result list to the predicted face density map;
[0026] Store the ground-truth face density map in the ground-truth result list;
[0027] Assign an index number in the ground-truth result list to the ground-truth face density map.
[0028] Optionally, the dividing the face samples into easy and difficult ones according to the comparison result between the ground-truth face density distribution and the predicted face density distribution includes:
[0029] Index the target predicted face density map from the prediction result list;
[0030] Index the target ground-truth face density map from the ground-truth result list;
[0031] Calculate the predicted regional average density according to the target predicted face density map;
[0032] Calculate the ground-truth regional average density according to the target ground-truth face density map;
[0033] Divide the face samples into easy and difficult ones according to the simple difference index between the predicted regional average density and the ground-truth regional average density.
[0034] In a second aspect, the present application provides a face detection device, including:
[0035] A feature extraction module, configured to extract features from the images in the training set by using a face detection model to obtain multi-scale image features;
[0036] A first determination module, configured to determine the face density distribution in the image according to the multi-scale image features; the face density distribution includes a predicted face density distribution and a ground-truth face density distribution;
[0037] A division module, configured to divide the face samples into easy and difficult ones according to the comparison result between the ground-truth face density distribution and the predicted face density distribution;
[0038] A first assignment module, configured to perform positive and negative sample assignment for face detection according to the division of the face samples into easy and difficult ones;
[0039] An update module, configured to update the face detection model according to the assignment of the positive and negative samples for face detection;
[0040] A face detection module, configured to perform face detection by using the updated face detection model.
[0041] Optionally, the first determination module includes:
[0042] A multi-layer convolutional sub-module, which is used to perform multi-layer convolution on each scale feature in the multi-scale features of the image to obtain a predicted face density map; the predicted face density map is used to indicate the predicted face density distribution;
[0043] A given sub-module, which is used to give a completely zero input mask when supervising the face density map branch;
[0044] A setting sub-module, which is used to set the position of the face center point in the completely zero input mask to 1;
[0045] A generation sub-module, which is used to generate a real face density map by using a Gaussian filter; the real face density map is used to indicate the real face density distribution.
[0046] Optionally, the device further includes:
[0047] A classification and regression module, which is used to classify and regress the multi-scale features of the image to obtain a face confidence and a face position; the face confidence is used for face judgment;
[0048] A second determination module, which is used to determine the face size according to the result of the face judgment;
[0049] A pre-allocation module, which is used to pre-allocate positive and negative face detection samples according to the face position and the face size.
[0050] Optionally, the device further includes:
[0051] A first storage module, which is used to store the predicted face density map into a prediction result list;
[0052] A second allocation module, which is used to allocate an index number in the prediction result list for the predicted face density map;
[0053] A second storage module, which is used to store the real face density map into a real result list;
[0054] A third allocation module, which is used to allocate an index number in the real result list for the real face density map.
[0055] Optionally, the division module includes:
[0056] A first index sub-module, which is used to index a target predicted face density map from the prediction result list;
[0057] A second index sub-module, which is used to index a target real face density map from the real result list;
[0058] A first calculation sub-module, which is used to calculate the predicted regional average density according to the target predicted face density map;
[0059] A second calculation sub-module, configured to calculate a true regional average density according to the target true face density map;
[0060] A division sub-module, configured to divide the face samples into easy and difficult levels according to the predicted regional average density and the simple difference index of the true regional average density.
[0061] In a third aspect, an embodiment of the present application provides a computer device, including: a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the face detection method introduced in any one of the first aspects of the embodiments of the present application is implemented.
[0062] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium. Instructions are stored in the computer-readable storage medium. When the instructions are run on a terminal device, the terminal device is caused to execute the face detection method introduced in any one of the first aspects of the embodiments of the present application.
[0063] The present application provides a face detection method. When executing the method, first use a face detection model to extract features from the images in the training set to obtain image multi-scale features, and then determine the face density distribution in the images according to the image multi-scale features, where the face density distribution includes a predicted face density distribution and a true face density distribution. Then, according to the comparison result between the true face density distribution and the predicted face density distribution, divide the face samples into easy and difficult levels. Next, according to the division of the face samples into easy and difficult levels, perform positive and negative sample allocation for face detection, and update the face detection model according to the allocation of positive and negative samples for face detection. Finally, use the updated face detection model to perform face detection. In this way, by comparing the predicted face density distribution and the true face density distribution, the difficulty level of face samples can be accurately evaluated, and positive and negative samples for face detection are allocated according to the difficulty level, thereby improving the effectiveness of face detection model training and further improving the accuracy of face detection. Description of the Drawings
[0064] To more clearly illustrate the technical solutions in the embodiments or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.
[0065] Figure 1 It is a flowchart of a face detection method provided by an embodiment of the present application;
[0066] Figure 2 A structural schematic diagram of a face detection device provided by an embodiment of the present application;
[0067] Figure 3 A structural schematic diagram of a computer device provided by an embodiment of the present application. Detailed implementation manners
[0068] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. A face detection method, device and related products provided by the present application are used in the field of computer vision technology. The above is only an example and does not limit the application fields of the method and device names provided by the present application.
[0069] Face detection is a key task in the field of computer vision and is a basic prerequisite for various tasks such as face recognition, face attribute classification, face calibration, and face tracking. The quality of face detection deeply affects the performance of subsequent tasks, thus having a significant impact on fields such as security monitoring, human-computer interaction, and virtual reality.
[0070] With the development of deep learning technology, general object detection based on neural networks, such as SSD, YOLO, and RetinaNet, has greatly promoted the development of the face detection field. However, there are still the following challenges in general face detection: 1) complex environmental factors, such as lighting and face background objects; 2) shooting distance and hardware configuration of the image acquisition device, such as resolution, shutter speed, etc.; 3) variability of facial poses and occlusion between multiple faces. In real applications, these challenges often coexist, and for faces with important features such as small size, low resolution, and pose changes, recent methods often fail to achieve satisfactory results. Generally, a face with one or more of these features is called a difficult example face.
[0071] In the prior art, when dealing with challenging face samples such as difficult example faces, the prior art usually distinguishes different difficulty levels of faces through label assignment. However, after predefined anchor points, these methods will assign fixed labels to all faces in the image, which means that the difficulty assessment of each face remains unchanged throughout the training process. This static difficulty assessment method is not ideal because continuously increasing the loss weight or the number of positive samples of a specific face sample during training may cause the model to overfit to these faces and under-learn other faces, thereby resulting in low accuracy of face detection.
[0072] The inventor proposed the technical solution of this application through research. First, use a face detection model to extract features from the images in the training set to obtain multi-scale features of the images. Then, based on the multi-scale features of the images, determine the face density distribution in the images, where the face density distribution includes the predicted face density distribution and the true face density distribution. Then, according to the comparison result between the true face density distribution and the predicted face density distribution, divide the face samples into easy and difficult ones. Next, according to the division of the face samples into easy and difficult ones, allocate positive and negative samples for face detection, and update the face detection model according to the allocation of positive and negative samples for face detection. Finally, use the updated face detection model to perform face detection. In this way, by comparing the predicted face density distribution and the true face density distribution, the difficulty level of the face samples can be accurately evaluated, and positive and negative samples for face detection can be allocated according to the difficulty level, thereby improving the effectiveness of the training of the face detection model and further improving the accuracy of face detection.
[0073] In order to enable those skilled in the art to better understand the solution of this application, the following further elaborates on this application in conjunction with the accompanying drawings and specific implementation manners. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all of them. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of this application. It should be noted that, for the sake of convenience of description, only the parts related to the invention are shown in the accompanying drawings. Without conflict, the embodiments in this application and the features in the embodiments can be combined with each other.
[0074] See Figure 1 , Figure 1 is a flowchart of a face detection method provided by an embodiment of this application, including:
[0075] S101: Use a face detection model to extract features from the images in the training set to obtain multi-scale features of the images.
[0076] Use a face detection model to extract features from the images in the training set. Among them, the face detection model is a deep learning model, and multi-scale features of the images can be obtained. The scales of the multi-scale features of the images are divided according to different downsampling ratios, such as downsampling by 4 times, 8 times, 16 times, 32 times, etc.
[0077] S102: Determine the face density distribution in the images according to the multi-scale features of the images.
[0078] After obtaining the multi-scale features of the image in S101, first, through the face density map branch of the face detection model, the predicted face density map is obtained by performing multi-layer convolution on each scale. Then, the intermediate features of the face density map branch are given to the face detection branch corresponding to the corresponding scale. After feature alignment, the prediction of the face confidence and position results is obtained through multi-layer convolution. Among them, the face confidence is used to determine whether the image is a face. Among them, when supervising the face density map branch, first, a full-zero input mask of a specific size is given, then the position of the face center point in the full-zero input mask is set to 1, and finally, a Gaussian filter is applied to generate the true face density map. Among them, the face center point is determined based on the face annotation rectangle on the detection scale, and these rectangles are obtained when performing face detection according to the corresponding scale. The specific calculation method of the true face density map D(x) corresponding to the image is as follows:
[0079] ;
[0080] Among them, D(x) is the true face density map corresponding to the image, δ is the Dirac function, x is the image coordinate, x i is the face center point coordinate, n is the number of faces, G σ is a two-dimensional Gaussian kernel.
[0081] The optimization objective function Loss dm for the face density map prediction task is:
[0082] ;
[0083] Among them, X is the predicted face density map, and Y is the true face density map.
[0084] Through the supervision of the face detection branch, the optimization objective function of the multi-task is:
[0085] ;
[0086] Among them, Loss dm is the optimization objective function of the face density map prediction, Loss det is the optimization objective function of the face detection. λ1 and λ2 are the weighting coefficients of the two optimization objectives. Among them, λ1 and λ2 are preset by those skilled in the art according to experience. In some implementation cases, it can be set[[ID=....]] ,[[]] .
[0087] S103: According to the comparison result between the true face density distribution and the predicted face density distribution, the face samples are divided into easy and difficult ones.
[0088] Before performing step S103, it is necessary to first store the predicted face density map obtained in step S102 into the prediction result list and assign an index number in the prediction result list to the predicted face density map; first store the obtained true face density map in step S102 into the true result list and assign an index number in the true result list to the true face density map.
[0089] Specifically, the face samples are divided into easy and difficult as follows:
[0090] First, obtain the corresponding predicted face density map pred_density from the prediction result list Pred according to the index i. This map represents the prediction of the face density on a certain hierarchical feature map. Here, i is the scale index. If there are 3 scales, then there are 3 predicted face density maps in the prediction pred list, and i represents the i-th predicted face density map, that is, the i-th scale. Obtain the corresponding true face density map gt_density from the true face density map list according to the index i. This map reflects the actual face distribution.
[0091] Next, for each true face rectangle, calculate its average density on the predicted face density map respectively through the Region of Interest Align (RoIAlign) operation, that is, the predicted regional average density pred_avg_rois, and calculate the average density on the true face density map, that is, the true regional average density gt_avg_rois.
[0092] Then, calculate the simple difference index diff between the predicted regional average density pred_avg_rois and the true regional average density gt_avg_rois:
[0093] ;
[0094] Calculate the weight gt_weights of each face rectangle according to the difference index diff. Among them, in order to ensure that the weight can reflect the importance of the difference and remain positive, it is necessary to use the softmax function to transform the difference value. The temperature coefficient T can adjust the smoothness of the softmax output. The larger the T value, the closer the output is to a uniform distribution; the smaller the T value, the more the output tends to highlight the maximum value:
[0095] ;
[0096] Finally, normalize the weight gt_weights. Normalization is a process to ensure that the scale of the weight is appropriate, which is achieved by dividing by the average value of the weights. In this way, even on datasets of different scales, the weights can maintain a certain comparability:
[0097] ;
[0098] The weights of the finally obtained different samples can be used to adjust the distribution of samples and the loss function during the training process, and this evaluation method can more accurately reflect the gap between the predictions and the truths of different samples.
[0099] S_{104}: According to the classification of the difficulty of face samples, perform the allocation of positive and negative samples for face detection.
[0100] Model training is a dynamic process. As the training progresses, difficult example samples may change. Therefore, it is necessary to evaluate the sample weights in real time and adjust the allocation of positive and negative samples according to the latest training results. This dynamic adjustment can help the model continuously improve and better adapt to the constantly changing data distribution. First, calculate the mean and variance of the weights of all face samples at a certain scale respectively, denoted as m and v, where both m and v are real numbers. Then, denote the set of samples with weights greater than m + v as S, and the remaining sample set as T. Both S and T are real numbers. Next, calculate the mean of the number of pre-allocated positive samples in set T, denoted as k, where k is a real number. Then, supplement the faces in set S with the number of pre-allocated positive samples less than k to k positive samples.
[0101] Finally, for the weights gt_weights of different face samples, perform loss weight weighting on the positive samples allocated to each face according to the following formula:
[0102] ;
[0103] S_{105}: Update the face detection model according to the allocation of positive and negative samples for face detection.
[0104] According to the allocation of positive and negative samples for face detection, update the weights of face positive samples during loss calculation. Before updating the weights of face positive samples during loss calculation, the weights of all face positive samples are 1. After updating the weights of face positive samples during loss calculation, the weights of some positive samples, such as simple samples, are less than 1, and the weights of some positive samples, such as difficult example samples, are greater than 1. Then, use the model after positive and negative sample reallocation and positive sample re-weighting for training to obtain the updated face detection model. By specifically increasing the number of positive sample allocations and loss weights of face samples with larger weights, this can make the model more focused on difficult example samples, thereby improving its overall performance.
[0105] S_{106}: Perform face detection using the updated face detection model.
[0106] In the embodiments of the present application, first, a face detection model is used to extract features from the images in the training set to obtain multi-scale features of the images. Then, based on the multi-scale features of the images, the face density distribution in the images is determined, where the face density distribution includes the predicted face density distribution and the real face density distribution. Then, according to the comparison result between the real face density distribution and the predicted face density distribution, the face samples are divided into easy and difficult samples. Next, according to the division of the face samples into easy and difficult samples, positive and negative samples for face detection are allocated, and according to the allocation of positive and negative samples for face detection, the face detection model is updated. Finally, the updated face detection model is used for face detection. In this way, by comparing the predicted face density distribution and the real face density distribution, the difficulty level of the face samples can be accurately evaluated, and positive and negative samples for face detection are allocated according to the difficulty level, thereby improving the effectiveness of the training of the face detection model and further improving the accuracy of face detection.
[0107] The above are some specific implementation manners of the face detection method provided by the embodiments of the present application. Based on this, the present application also provides a corresponding device. Next, the device provided by the embodiments of the present application will be introduced from the perspective of functional modularization.
[0108] See Figure 2 , Figure 2 FIG. 240 is a schematic structural diagram of a face detection device provided by an embodiment of the present application. The face detection device 200 includes:
[0109] A feature extraction module 210, configured to extract features from the images in the training set by using a face detection model to obtain multi-scale features of the images;
[0110] A first determination module 220, configured to determine the face density distribution in the images according to the multi-scale features of the images; the face density distribution includes a predicted face density distribution and a real face density distribution;
[0111] A division module 230, configured to divide the face samples into easy and difficult samples according to the comparison result between the real face density distribution and the predicted face density distribution;
[0112] A first allocation module 240, configured to allocate positive and negative samples for face detection according to the division of the face samples into easy and difficult samples;
[0113] An update module 250, configured to update the face detection model according to the allocation of positive and negative samples for face detection;
[0114] A face detection module 260, configured to perform face detection by using the updated face detection model.
[0115] Optionally, the first determination module 220 includes:
[0116] The multi-layer convolution sub-module is used to perform multi-layer convolution on each scale feature in the multi-scale features of the image to obtain a predicted face density map; the predicted face density map is used to indicate the predicted face density distribution;
[0117] The given sub-module is used to give a completely zero input mask when supervising the face density map branch;
[0118] The setting sub-module is used to set the position of the face center point in the completely zero input mask to 1;
[0119] The generation sub-module is used to generate a true face density map by using a Gaussian filter; the true face density map is used to indicate the true face density distribution.
[0120] Optionally, the face detection device 200 further includes:
[0121] The classification and regression module is used to classify and regress the multi-scale features of the image to obtain a face confidence and a face position; the face confidence is used for face judgment;
[0122] The second determination module is used to determine the face size according to the result of the face judgment;
[0123] The pre-allocation module is used to pre-allocate positive and negative face detection samples according to the face position and the face size.
[0124] Optionally, the face detection device 200 further includes:
[0125] The first storage module is used to store the predicted face density map into a prediction result list;
[0126] The second allocation module is used to allocate an index number in the prediction result list for the predicted face density map;
[0127] The second storage module is used to store the true face density map into a true result list;
[0128] The third allocation module is used to allocate an index number in the true result list for the true face density map.
[0129] Optionally, the 230 includes:
[0130] The first index sub-module is used to index the target predicted face density map from the prediction result list;
[0131] The second index sub-module is used to index the target true face density map from the true result list;
[0132] The first calculation sub-module is configured to calculate the predicted regional average density according to the target predicted face density map;
[0133] The second calculation sub-module is configured to calculate the true regional average density according to the target true face density map;
[0134] The division sub-module is configured to divide the face samples into easy and difficult ones according to the simple difference index between the predicted regional average density and the true regional average density.
[0135] The embodiments of the present application also provide corresponding devices and computer storage media for implementing the solutions provided by the embodiments of the present application.
[0136] As Figure 3 shown, the computer device 01 is presented in the form of a general-purpose computing device. The components of the computer device 01 may include, but are not limited to: one or more processors or processor units 03, a system memory 08, and a bus 04 connecting different system components (including the system memory 08 and the processor unit 03).
[0137] The bus 04 represents one or more of several types of bus structures, including a memory bus or a memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the multiple bus structures. For example, these architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
[0138] The computer device 01 typically includes a variety of computer system-readable media. These media can be any available media accessible by the computer device 01, including volatile and non-volatile media, removable and non-removable media.
[0139] The system memory 08 may include computer system-readable media in the form of volatile memory, such as random access memory (RAM) 09 and / or cache memory 10. The computer device 01 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 11 can be used to read and write non-removable, non-volatile magnetic media ( Figure 3 not shown, commonly referred to as a "hard disk drive"). Although Figure 3Not shown in the figure, a disk drive for reading and writing a removable non-volatile disk (such as a "floppy disk") and an optical disk drive for reading and writing a removable non-volatile optical disk (such as a CD-ROM, DVD-ROM or other optical medium) can be provided. In these cases, each drive can be connected to the bus 04 through one or more data medium interfaces. The system memory 08 may include at least one program product having a set (such as at least one) of program modules configured to perform the functions of the embodiments of the present invention.
[0140] A program / utility 12 having a set (at least one) of program modules 13 can be stored, for example, in the system memory 08. Such program modules 13 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include the implementation of a network environment. The program modules 13 generally perform the functions and / or methods in the embodiments described in the present invention.
[0141] The computer device 01 can also communicate with one or more external devices 02 (such as a keyboard, a pointing device, a display 07, etc.), and can also communicate with one or more devices that enable a user to interact with the computer device 01, and / or communicate with any device that enables the computer device 01 to communicate with one or more other computing devices (such as a network card, a modem, etc.). Such communication can be carried out through the input / output (I / O) interface 06. In addition, the computer device 01 can also communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through the network adapter 05. As Figure 3 shown, the network adapter 05 communicates with other modules of the computer device 01 through the bus 04. It should be understood that although Figure 3 not shown in the figure, other hardware and / or software modules can be used in combination with the computer device 01, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0142] The processor unit 03 executes various functional applications and data processing by running the programs stored in the system memory 08, such as implementing a face detection method provided by the embodiments of the present application.
[0143] It should be noted that in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprising", "including" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising one..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the said element.
[0144] From the description of the above embodiments, those skilled in the art can clearly understand that all or part of the steps in the above method embodiments can be implemented by means of software plus a general hardware platform. Based on such an understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a storage medium, such as a read-only memory (ROM) / RAM, magnetic disk, optical disk, etc., including several instructions for causing a computer device (which can be a personal computer, a server, or a network communication device such as a router) to execute the methods described in various embodiments or certain parts of the embodiments of the present application.
[0145] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the device embodiments, since they are basically similar to the method embodiments, they are described relatively simply, and the relevant parts can be referred to the partial description of the method embodiments. One can select some or all of the modules according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art can understand and implement it without creative effort.
[0146] The above description is only an exemplary embodiment of the present application and is not used to limit the protection scope of the present application.
Claims
1. A face detection method, characterized in that, Including: Using a face detection model to extract features from the images in the training set to obtain multi-scale image features; According to the multi-scale image features, determining the face density distribution in the image; the face density distribution includes a predicted face density distribution and a true face density distribution; According to the comparison result between the true face density distribution and the predicted face density distribution, dividing the face samples into easy and difficult ones; According to the division of the face samples into easy and difficult ones, performing positive and negative sample allocation for face detection; The performing positive and negative sample allocation for face detection according to the division of the face samples into easy and difficult ones includes: Increasing the allocation quantity and loss weight of the positive samples of the difficult example samples; According to the allocation of the positive and negative samples for face detection, updating the face detection model; Using the updated face detection model to perform face detection.
2. The method according to claim 1, wherein The determining the face density distribution in the image according to the multi-scale image features includes: Passing each scale feature in the multi-scale image features through multiple layers of convolution to obtain a predicted face density map; the predicted face density map is used to indicate the predicted face density distribution; When supervising the face density map branch, giving a full-zero input mask; Setting the position of the face center point in the full-zero input mask to 1; Using a Gaussian filter to generate a true face density map; the true face density map is used to indicate the true face density distribution.
3. The method according to claim 1, wherein After determining the face density distribution in the image according to the multi-scale image features, the method further includes: Classifying and regressing the multi-scale image features to obtain a face confidence and a face position; the face confidence is used for face judgment; According to the result of the face judgment, determining the face size; According to the face position and the face size, pre-allocating positive and negative samples for face detection.
4. The method according to claim 2, wherein After determining the face density distribution in the image according to the multi-scale image features, the method further includes: Storing the predicted face density map into a prediction result list; Assigning an index number in the prediction result list to the predicted face density map; Storing the true face density map into a true result list; Assigning an index number in the true result list to the true face density map.
5. The method according to claim 4, wherein The dividing the face samples into easy and difficult ones according to the comparison result between the true face density distribution and the predicted face density distribution includes: Indexing a target predicted face density map from the prediction result list; Indexing a target true face density map from the true result list; Calculating the predicted regional average density according to the target predicted face density map; Calculating the true regional average density according to the target true face density map; Dividing the face samples into easy and difficult ones according to the simple difference index between the predicted regional average density and the true regional average density.
6. A face detection device, characterized in that, Including: A feature extraction module, configured to use a face detection model to extract features from the images in the training set to obtain multi-scale image features; A first determination module, configured to determine the face density distribution in the image according to the multi-scale features of the image; the face density distribution includes a predicted face density distribution and a true face density distribution; A division module, configured to divide face samples into easy and difficult ones according to the comparison result between the true face density distribution and the predicted face density distribution; An allocation module, configured to perform positive and negative sample allocation for face detection according to the division of the face samples into easy and difficult ones; The allocation module is specifically configured to: Increase the allocation quantity and loss weight of positive samples of difficult example samples; An update module, configured to update the face detection model according to the allocation of the positive and negative samples for face detection; A face detection module, configured to perform face detection by using the updated face detection model.
7. The device according to claim 6, characterized in that, The first determination module includes: A multi-layer convolution sub-module, configured to obtain a predicted face density map by performing multi-layer convolution on each scale feature in the multi-scale features of the image; the predicted face density map is used to indicate the predicted face density distribution; A given sub-module, configured to give a completely zero input mask when supervising a face density map branch; A setting sub-module, configured to set the position of the face center point in the completely zero input mask to 1; A generation sub-module, configured to generate a true face density map by using a Gaussian filter; the true face density map is used to indicate the true face density distribution.
8. The device according to claim 6, characterized in that, The apparatus further includes: A classification and regression module, configured to perform classification and regression on the multi-scale features of the image to obtain a face confidence level and a face position; the face confidence level is used for face judgment; Determine the face size according to the result of the face judgment; A pre-allocation module, configured to pre-allocate positive and negative samples for face detection according to the face position and the face size.
9. A computer device, characterized in that, including: A memory, a processor, and a computer program stored on the memory and executable on the processor, where when the processor executes the computer program, the face detection method according to any one of claims 1-5 is implemented.
10. A computer-readable storage medium, characterized in that, Instructions are stored in the computer-readable storage medium, and when the instructions are run on a terminal device, the terminal device is caused to execute the face detection method according to any one of claims 1-5.
Citation Information
Patent Citations
Face recognition method and device, electronic equipment and computer readable storage medium
CN116152870A