A face detection method and device based on YOLOv8 target detection model

By improving the YOLOv8 target detection model, introducing deformable convolution DCNv2 and large-scale separable convolution attention mechanism LSKA, and combining it with the EMASlideLoss optimization loss function, the problem of insufficient detection accuracy of face detection in complex scenarios is solved, and higher detection accuracy and stability are achieved.

CN118470767BActive Publication Date: 2025-09-09HANGZHOU DIANZI UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410520447.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-28
Publication Date
2025-09-09
Estimated Expiration
2044-04-28

AI Technical Summary

Technical Problem

Existing face detection technology has insufficient detection accuracy in complex scenarios such as multi-scale, small faces, low light and dense scenes, and there are problems of missed detection and false detection.

Method used

An improved YOLOv8 target detection model is adopted. By introducing deformable convolution DCNv2 and large separable convolution attention mechanism LSKA in the feature extraction part, combined with exponential moving average sliding loss EMASlideLoss to optimize the intersection-over-union ratio, the model's detection capability in complex scenarios is enhanced.

Benefits of technology

The detection accuracy of face detectors in complex scenarios such as multi-scale, small faces, low light and dense scenes has been significantly improved, and the accuracy and stability of detection have been improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118470767B_ABST
    Figure CN118470767B_ABST
Patent Text Reader

Abstract

The present invention discloses a face detection method and device based on the YOLOv8 target detection model. First, a target detection model based on YOLOv8 is constructed and trained. Then, a face image to be detected is input into the trained target detection model to obtain a recognition result. The target detection model includes a backbone network, a neck network, and a prediction head. The backbone network includes a convolution module and a C2f module arranged in sequence, and a feature pyramid module at the end. The second convolution block in the bottleneck block of the C2f module is a deformable convolution DCNv2. The feature pyramid module introduces a large-scale separated convolution attention mechanism (LSKA) between the splicing module and the second convolution block that splices and fuses the pooling layer features. The present invention effectively improves the detection accuracy of face detectors in complex scenarios such as multi-scale, small faces, low light, and dense scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of face detection technology, and in particular to a face detection method and device based on the YOLOv8 target detection model. Background Art

[0002] Computer vision is a highly active research field. Face detection, a fundamental step in many computer vision tasks, plays a vital role in face recognition, facial expression recognition, head pose estimation, and human-computer interaction. 2014 marked a turning point in the transition of face detection and recognition technology from theory to application, and 2018 marked a crucial milestone in the full-scale application of face detection technology. Therefore, research on face detection technology has become extremely relevant. The full arrival of the "face recognition" era will bring enormous economic benefits to humanity.

[0003] Currently, a large number of research projects are underway both domestically and internationally on face detection technology. With the advent of the deep learning era marking a watershed moment, numerous research efforts have proposed specialized face detection methods from various perspectives, including model architecture, data augmentation, and label assignment. Notably, some of these face detectors explore the unique characteristics of the human face, while others simply adopt and modify general object detectors for face detection. Currently, almost all face detection methods are derived from existing general object detection methods. Despite significant achievements in face detection research, significant room for improvement remains due to challenges such as multi-scale, small faces, low light conditions, and dense scene conditions. Summary of the Invention

[0004] The purpose of this application is to provide a face detection method and device based on the YOLOv8 target detection model to solve the problems of missed detection, false detection and low face detection accuracy of dense small faces in actual scenes.

[0005] In order to achieve the above objectives, the technical solutions of this application are as follows:

[0006] A face detection method based on the YOLOv8 object detection model, comprising:

[0007] Build and train a target detection model based on YOLOv8, input the face image to be detected into the trained target detection model, and obtain the recognition result;

[0008] The target detection model includes a backbone network, a neck network and a prediction head;

[0009] The backbone network includes a convolutional module and a C2f module arranged in sequence, and a feature pyramid module at the end;

[0010] The second convolution block in the bottleneck block of the C2f module is the deformable convolution DCNv2;

[0011] The feature pyramid module introduces a large-scale separated convolution attention mechanism LSKA between the splicing module that splices and fuses the pooling layer features and the second convolution block.

[0012] Furthermore, the loss function of the YOLOv8-based target detection model includes classification loss and regression loss.

[0013] Furthermore, the classification loss adopts binary cross entropy loss.

[0014] Furthermore, the regression loss includes distribution focus loss and complete intersection-over-union loss.

[0015] Furthermore, calculating the classification loss includes:

[0016] Calculate binary cross entropy loss LOSS BCE ;

[0017] The exponential moving average method is used to update the average intersection-union ratio, and the result is assigned to the threshold μ;

[0018] According to the threshold μ, the true value x is divided into three intervals, and the weight values ​​corresponding to the three intervals are obtained. The formula is as follows:

[0019]

[0020] Among them, f(x) is the weight value corresponding to different intervals;

[0021] According to the weight values ​​corresponding to the three intervals, the adjustment weight w is calculated and the adjustment weight is compared with the binary cross entropy loss LOSS BCE Multiply together to get the final classification loss;

[0022] According to the weight values ​​corresponding to the three intervals, the adjustment weight w is calculated as follows:

[0023] w=a1×b1+a2×b2+a3×b3;

[0024] Among them, the value of a1 is 1 and the value of a2 is e 1-μ , the value of a3 is e 1-x , when the condition x≤μ-0.1 is met, b1 is 1, otherwise it is 0; when the condition μ>x>μ-0.1 is met, b2 is 1, otherwise it is 0; when the condition x≥μ is met, b3 is 1, otherwise it is 0.

[0025] The present application also proposes a face detection device based on the YOLOv8 target detection model, comprising a processor and a memory storing a plurality of computer instructions, characterized in that when the computer instructions are executed by the processor, the steps of the face detection method based on the YOLOv8 target detection model are implemented.

[0026] This application proposes a face detection method and device based on the YOLOv8 object detection model. This improved face detection model, referred to as DSE-YOLOv8, incorporates the Deformable Convolutional Network (DCNv2) into the C2f module of the feature extraction component, enabling the network to focus on more appropriate image regions through more efficient modeling and training. The Large Separated Convolutional Attention (LSKA) mechanism is introduced into the Feature Pyramid (SPPF) module to enhance multi-scale feature extraction capabilities. Furthermore, the exponential moving average sliding loss (EMASlideLoss) is used to optimize the mean value of the intersection-over-union (iou_mean), increasing model stability. This effectively improves the detection accuracy of face detectors in complex scenarios, such as those with multiple scales, small faces, low light conditions, and densely populated scenes. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] Figure 1 This is the model structure diagram of YOLOv8 general target detection.

[0028] Figure 2 This is the improved DSE-YOLOv8 model structure diagram for this application.

[0029] Figure 3 Schematic diagram of the C2f module transformation structure for applying for backbone network.

[0030] Figure 4 Schematic diagram of SPPF transformation of the feature pyramid module of the backbone network of this application.

[0031] Figure 5 This is a curve comparison chart of the original model and each improved module in terms of evaluation indicators such as accuracy, recall rate, and average accuracy during the training process.

[0032] Figure 6 Comparison of the loss curves of the original model and each improved module on the training set and validation set during the training process. DETAILED DESCRIPTION

[0033] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.

[0034] The overall idea of ​​this application is to improve the general object detection model YOLOv8 by introducing deformable convolution DCNv2 in the feature extraction part C2f module of the baseline model, introducing large separable convolution attention mechanism LSKA in the feature pyramid SPPF module, and using exponential moving average sliding loss EMASlideLoss to optimize the average intersection-over-union ratio iou_mean to modify the network structure. The model is trained and evaluated on the WIDER FACE face dataset. Finally, the average accuracy evaluation results at three different difficulty levels are improved, effectively improving the detection accuracy of face detectors in complex scenarios such as multi-scale, small faces, low light, and dense scenes.

[0035] The network structure of the YOLOv8 general target detection model is as follows Figure 1 As shown, it mainly consists of four parts, namely:

[0036] (1) Backbone network: The improved CSP-Darknet53 is used as the backbone network for feature extraction. It adopts a C2f structure with more residual connections. By parallelizing more gradient flow branches, it obtains richer gradient flow information while ensuring lightweight. The backbone network consists of a convolutional block (CBS) and a C2f block arranged in sequence, with a feature pyramid block (SPPF) at the end.

[0037] (2) Neck network: The feature fusion network composed of the feature pyramid network FPN and the path aggregation network PAN as the neck is called a dual-stream FPN, which is efficient and fast. The network structure of FPN is mainly divided into two parts: bottom-up and top-down. The bottom-up part is mainly responsible for feature extraction, while the top-down part is responsible for feature upsampling and fusion. Compared with FPN (information fusion from top to bottom), the path aggregation network PANet introduces a bottom-up path, making it easier for the bottom-level information to be transmitted to the top of the upper layer, compensating for and strengthening the positioning information.

[0038] (3) Prediction head: Anchor-free prediction heads of different scales predict targets of different sizes, including small-scale prediction heads, medium-scale prediction heads, and large-scale prediction heads. Prediction heads of different scales refer to the model making predictions at different feature map scales. The small-scale prediction head (8x downsampling, 80×80 feature map) has a smaller receptive field and is suitable for detecting smaller targets; the medium-scale prediction head (16x downsampling, 40×40 feature map) has a medium receptive field and is suitable for detecting medium-sized targets; the large-scale prediction head (32x downsampling, 20×20 feature map) has the largest receptive field and is suitable for detecting larger targets. Each prediction head outputs a classification branch and a regression branch. The classification branch is used to predict the category of the target, and the regression branch is used to predict the bounding box of the target.

[0039] (4) Loss function: The loss includes two parts: the positive and negative sample allocation strategy and the loss function calculation. For the positive and negative sample allocation strategy, the YOLOv8 algorithm directly refers to the task alignment allocator proposed in the single-stage target detection of task alignment. This allocation strategy selects positive samples based on the weighted score of classification and regression scores. The formula is:

[0040] t=s α ×u β ;

[0041] Where s is the predicted score for the labeled class, u is the Intersection over Union (IoU) between the predicted and ground-truth boxes, and α and β are weight hyperparameters. Multiplying these two together measures the degree of alignment. The higher the class prediction score and the higher the IoU, the closer the value of t is to 1. By training t, the network can be guided to dynamically focus on high-quality positive examples.

[0042] The calculation of the loss function includes two branches: classification loss and regression loss. The classification loss branch still uses binary cross entropy loss BCE Loss, and the formula is:

[0043]

[0044] Where N is the number of samples, y i is the true label of the i-th sample, which takes a value of 0 or 1, p i is the predicted value of the i-th sample, ranging from 0 to 1.

[0045] The regression branch includes the Distribution Focal Loss (DFL) and the Complete Intersection-over-Union Loss (CIoU Loss).

[0046] The formula for complete intersection-over-union loss CIoU Loss is:

[0047]

[0048]

[0049]

[0050] Among them, υ is used to measure the consistency of the relative proportions of the two rectangular boxes, α is the weight coefficient. IoU is the intersection over union ratio of the predicted box and the real box. ρ 2 (b,b gt ) is the square of the Euclidean distance between the center point of the predicted box and the true box. c 2 It is the square of the length of the diagonal of the minimum circumscribed rectangle of the two rectangular boxes. W, h and w gt 、h gtRepresent the width and height of the predicted box and the true box respectively.

[0051] DFL optimizes the probabilities of the two positions closest to the label y in the form of cross entropy, allowing the network to focus on the distribution of the neighborhood of the target position more quickly. It also obtains the weights of the integer coordinates to the left and right of the distance in a linear interpolation mode. The formula is:

[0052] LOSS DFL (S i ,S i+1 )=-((y i+1 -y)log(S i )+(yy i )log(S i+1 )).

[0053] Among them, y i ,y i+1 is the value of the two positions closest to the label y, one on the left and one on the right, S i , S i+1 They are y i ,y i+1 The probability of 2 positions corresponding to each other.

[0054] One embodiment of the present application provides a face detection method based on the YOLOv8 object detection model, including:

[0055] Build and train a target detection model based on YOLOv8, input the face image to be detected into the trained target detection model, and obtain the recognition result;

[0056] The target detection model includes a backbone network, a neck network and a prediction head;

[0057] The backbone network includes a convolutional module and a C2f module arranged in sequence, and a feature pyramid module at the end;

[0058] The second convolution block in the bottleneck block of the C2f module is the deformable convolution DCNv2;

[0059] The feature pyramid module introduces a large-scale separated convolution attention mechanism LSKA between the splicing module that splices and fuses the pooling layer features and the second convolution block.

[0060] This embodiment improves the general target detection model YOLOv8. The improved DSE-YOLOv8 model is as follows: Figure 2 As shown in the figure, the main improvements are as follows:

[0061] The first aspect: Introducing deformable convolution DCNv2 in the C2f module of the backbone network.

[0062] like Figure 3 As shown in Figure 1, the C2f module includes a Bottleneck bottleneck block, which has two convolutional blocks (CBS).

[0063] In this embodiment, the second convolution block CBS in the Bottleneck bottleneck block in the C2f module is replaced with the deformable convolution DCNv2 to obtain the Bottleneck_DCNV2 module. Through more effective modeling capabilities and training, the network focuses on more appropriate image areas.

[0064] In the improved C2f module, the Bottleneck block is replaced by the Bottleneck_DCNV2 module, as shown in Figure 3 C2f_DCNv2 in.

[0065] The Deformable Convolution layer originates from the core concept of DCNv1: deformable convolution is a learnable convolution operation. DCNv1 proposes learning an offset for each point on the convolution kernel, thereby indirectly changing the shape of the convolution kernel by modifying the sampled result. Deformable convolution first performs a convolution operation on the input feature map to obtain a set of predicted kernel offsets. This offset feature map maintains the same size as the input feature map and has 2N channels, meaning each offset is a two-valued (x, y) value, where N is the number of pixels in the convolution kernel.

[0066] However, the introduction of the offset module in DCNv1 introduced excessive irrelevant context, which is harmful to the model. To reduce irrelevant interference information in DCNv1 and improve the model's adaptability to different geometric changes, DCNv2 proposes a weighted sampling point offset operation. In addition to allowing the model to learn the offset of the sampling point, it also learns the weight of each sampling point.

[0067] The second aspect: the large-scale separated convolutional attention mechanism LSKA is introduced at the feature pyramid SPPF module at the end of the backbone network.

[0068] like Figure 4 As shown in the figure, the input features of the feature pyramid module SPPF first pass through the first convolution block CBS and then through three pooling layers. The output features of each pooling layer are concatenated and fused with the output features of the first convolution block CBS through the splicing module (Concat), and then output after passing through the second convolution block CBS.

[0069] This embodiment introduces the attention mechanism LSKA between the Concat module that splices and fuses the pooling layer features in the SPPF module and the second convolution kernel, which greatly improves the ability of the SPPF module to aggregate features at multiple scales. The improved SPPPF module structure is as follows: Figure 4As shown, it is also called SPPF_LSTA module.

[0070] The LSKA attention mechanism decomposes the two-dimensional convolution kernel of the deep convolution layer into stacked horizontal and vertical one-dimensional kernels. It can directly use the deep convolution layer with large kernels in the attention module, and capture the extensive contextual information of the image by utilizing large and separable convolution kernels and spatial dilation convolution. It generates an attention map and weights the original features through this attention map, thereby enhancing the network's attention to important features and improving the performance of the model.

[0071] By splitting the two-dimensional weight kernel of the depthwise convolution and depthwise dilated convolution in the LKA module into two cascaded one-dimensional separable weight kernels, the output of LSKA can be expressed as:

[0072]

[0073]

[0074] A C =W 1×1 *Z C

[0075]

[0076] in, is the input feature map F C The output obtained by convolving with two cascaded one-dimensional depthwise convolution kernels of kernel size 1×(2d-1) and (2d-1)×1. C yes With kernel size and The output obtained by convolution operation with two cascaded one-dimensional depth expansion convolution kernels is then convolved with a convolution kernel with a kernel size of 1×1 to obtain the attention map A. C , is the attention map A C And the input feature map F C The Hadamard product of .

[0077] The specific operation process of the LSKA module is as follows:

[0078] (1) Initialize the convolutional layers (conv0h and conv0v): The two 1D convolutional layers are responsible for extracting the horizontal and vertical features of the input feature map, respectively, and generating a preliminary attention map.

[0079] (2) Spatially dilated convolutional layers (conv_spatial_h and conv_spatial_v): Spatially dilated convolutions with different dilation rates are used to further extract features. By operating in the horizontal and vertical directions respectively, image features are processed more carefully, enhancing the model's understanding of spatial relationships in the image.

[0080] (3) Fusion and application of attention: The features obtained by the last convolutional layer (conv1) are fused to generate the final attention map. This attention map is multiplied element-wise with the original input feature map, i.e., the attention mechanism is applied. In this way, each element in the original feature map is weighted according to the value of the attention map, highlighting important features and suppressing unimportant features.

[0081] Another embodiment of the present application improves the original classification loss when training a target detection model based on YOLOv8, and uses the exponential moving average (EMA) to optimize the average intersection-over-union ratio iou_mean, thereby proposing an improved classification loss function EMASlideLoss.

[0082] EMASlideLoss is a variant of the sliding loss SlideLoss that introduces the concept of exponential moving average (EMA). In the original SlideLoss, the average of the IoU (intersection over union) values ​​of all bounding boxes is used as the threshold μ. Samples less than μ are taken as negative samples, and samples greater than μ are taken as positive samples. Then, the weighted function Slide is used to emphasize samples at the boundary, thereby focusing more attention on difficult samples to solve the sample imbalance problem and improve the model's performance in detecting difficult examples. However, due to unclear classification, samples near the boundary often suffer from large losses.

[0083] EMASlideLoss improves this problem by introducing EMA. EMA is a commonly used smoothing method for sequential data that better reflects the long-term trend of the data. In EMASlideLoss, EMA is used to optimize the average intersection-over-union ratio iou_mean, allowing the model to better learn and optimize samples at the boundary.

[0084] In this embodiment, the calculation process of EMASlideLoss includes:

[0085] (1) Calculate the original classification loss based on the true value and the predicted value. This classification loss uses the binary cross entropy loss BCE Loss mentioned above. The formula is:

[0086]

[0087] (2) Use the exponential moving average method to update the average intersection-union ratio iou_mean and assign the result to the threshold μ. The formula is as follows:

[0088]

[0089] iou_mean=d(t)×iou_mean+(1-d(t))×iou_mean(t-1);

[0090] μ = iou_mean;

[0091] Where t is the number of training iterations, decay is a decay constant very close to 1 (e.g., 0.999 or 0.9999), which controls the speed or magnitude of decay. τ is a time constant that controls the speed of decay. iou_mean is the average intersection-over-union ratio (IoU), which is weighted by the decay factor d(t) to obtain iou_mean after introducing an exponential moving average (EMA), giving greater weight to recent thresholds and reflecting them more closely.

[0092] (3) According to the threshold μ, the true value x is divided into three intervals, and the weight values ​​corresponding to the three intervals are obtained.

[0093] Based on the value of μ, the true value x is divided into three intervals, and the weight value of each interval is adjusted differently. This is the attempt proposed in SlideLoss to assign higher weights to difficult samples. The weighting function Slide emphasizes samples at the boundary of the threshold μ, increasing the relative loss of difficult samples, thereby focusing more attention on difficult samples. The Slide weighting function can be expressed as the following formula:

[0094]

[0095] Among them, x is the true value, μ is the exponential moving average iou_mean after this iteration, and f(x) is the weight value corresponding to different intervals, which will be dynamically adjusted according to the values ​​of x and μ.

[0096] (4) According to the weight values ​​corresponding to the three intervals, the adjustment weight w is calculated and the adjustment weight is compared with the binary cross entropy loss LOSS BCE Multiply them together to get the final classification loss.

[0097] Based on the values ​​of x and μ in the Slide weighting function, three different weight values ​​a1, a2, and a3 are calculated. The adjustment weight w is then calculated based on these three weights and the corresponding conditions b1, b2, and b3. Finally, the original loss value is multiplied by the adjustment weight to obtain the new loss function. The formula is as follows:

[0098] w=a1×b1+a2×b2+a3×b3

[0099] loss = w × LOSS BCE

[0100] Among them, the value of a1 is 1 and the value of a2 is e 1-μ , the value of a3 is e 1-x , the conditions b1, b2, and b3 corresponding to a1, a2, and a3 are all Boolean values. That is, when the condition x≤μ-0.1 holds, b1 is 1, otherwise it is 0; when the condition μ>x>μ-0.1 holds, b2 is 1, otherwise it is 0; when the condition x≥μ holds, b3 is 1, otherwise it is 0.

[0101] That is to say, during the training process, EMASlideLoss performs an exponential moving average operation on the fixed threshold μ (mean intersection-over-union ratio iou_mean) in SlideLoss to make it reflect the recent threshold more, reduce fluctuations and noise during training, and thus obtain a smooth loss value, thereby improving the stability and generalization ability of the model.

[0102] This application trains a face detection model on the open source dataset WIDER FACE dataset: first, the data annotation format of the WIDER FACE face dataset is converted into a format suitable for YOLO model training, then the YOLOv8 and improved DSE-YOLOv8 models are trained on the WIDERFACE training dataset respectively, and finally the performance of the best weight is tested on the validation set, including evaluation indicators such as precision P, recall rate R, average accuracy mAP50, mAP50-95 to measure model performance.

[0103] Precision: It indicates the proportion of samples predicted as positive samples that are actually positive samples. The calculation formula is:

[0104]

[0105] Among them, TP represents the number of true positive samples, and FP represents the number of negative samples that are mistakenly judged as positive samples.

[0106] Recall: It indicates the proportion of positive samples detected. The calculation formula is:

[0107]

[0108] Among them, TP represents the number of true positive samples, and FN represents the number of undetected positive samples.

[0109] Mean Average Precision (mAP50): Calculated at an IoU threshold of 0.50, a measure of the model’s accuracy considering only “easy” detections.

[0110] mAP50-95: A more stringent evaluation indicator. In the range of IoU thresholds from 0.50 to 0.95, with a step size of 0.05, the average mAP under all thresholds is calculated. This indicator can more accurately evaluate the performance of the model at different IoU thresholds.

[0111] The experimental environment is based on Python 3.8 and implemented using the PyTorch 2.0.1 framework. NVIDIA GeForce RTX4090 GPUs are used for training and testing. During training, the entire dataset is iterated 100 times, with mosaic data augmentation disabled during the last 10 training epochs. The specific training strategy includes: image height and width set to 640×640, batch size set to 16, number of workers set to 8, initial and final learning rates set to 0.01, and the optimizer selected as auto (the system automatically selects the most appropriate optimizer based on the characteristics of the model and training task). The weight decay coefficient is set to 0.0005, and the learning rate momentum is set to 0.937.

[0112] Figure 5 The figure shows the curve comparison of the original model and each improved module in terms of evaluation indicators such as accuracy, recall rate, and average accuracy during the training process.

[0113] Figure 6 The figure shows the comparison of the loss curves of the original model and each improved module in terms of bounding box regression loss, distribution focus loss, and category classification loss on the training set (train) and validation set (val) during training.

[0114] This application trains the YOLOv8 original model (using the minimum scale YOLOv8n as the benchmark model), the model after YOLOv8 improved the C2f_DCNv2 module (YOLOv8+C2f_DCNv2), the model after YOLOv8 improved the SPPF_LSKA module (YOLOv8+SPPF_LSKA), the model after YOLOv8 improved the classification loss EMASlideLoss (YOLOv8+EMASlideLoss), and the DSE-YOLOv8 model based on YOLOv8 that integrates the C2f_DCNv2 module, SPPF_LSKA module and the classification loss EMASlideLoss improvement method for 100 batches respectively, and obtains 5 groups of experimental results on evaluation indicators such as accuracy, recall rate, average accuracy, and loss indicators such as bounding box regression loss, distribution focus loss, and classification loss.

[0115] like Figure 5 As shown in the figure, the indicators of various evaluation models tend to converge, proving that the model training is successful. The experimental results show that compared with the original YOLOv8 model, the individual improved modules and the DSE-YOLOv8 module that integrates the three improved methods have a smaller improvement in average accuracy (mAP_0.5), mAP_0.5:0.95, and recall, but a more significant performance improvement in precision.

[0116] like Figure 6 As shown in the figure, all loss metrics converge, demonstrating successful model training. Box_loss represents the bounding box regression loss, which measures the difference between the model's predicted bounding box (i.e., the object's position and size) and the actual bounding box; cls_loss represents the class classification loss, which measures the difference between the model's predicted object class and the actual class; and dfl_loss represents the difference between the model's predicted distance field and the true distance field. The distance field is an encoding method for representing the relative positions of the bounding box's center and four corners. A smaller dfl_loss value indicates that the model more accurately describes the bounding box's shape. Experimental results show that compared to the original YOLOv8 model, the individual improved modules, as well as the DSE-YOLOv8 module that incorporates the three improved methods, show minimal improvement in bounding box regression loss (box_loss) on both the training set (train) and the validation set (val), while the distribution focus loss (dfl_loss) and class classification loss (cls_loss) decrease significantly, resulting in significant performance improvements.

[0117] In summary, the DSE-YOLOv8 model, which integrates the three improved methods of C2f_DCNv2, SPPF_LSKA and EMASlideLoss, has significantly reduced some loss values ​​and has a slight improvement in various evaluation indicators.

[0118] Evaluate model performance at three different difficulty levels of WIDER FACE: For each subset, divide it into three difficulty levels based on the EdgeBox detection rate: Easy, Medium, and Hard. EdgeBox is an object detection algorithm that uses bounding boxes to detect objects and calculates the probability of containing the object based on the framed outline to quantitatively analyze performance. After the training and validation phases are completed, first predict the images of the validation set based on the trained model weights, then execute the evaluation command, specifying the prediction result directory and the true annotation directory, and obtain the mean average precision (mAP) indicator of the model at the three difficulty levels. By evaluating the performance of the model at different difficulty levels on the WIDER FACE dataset, we can gain a more comprehensive understanding of the robustness and adaptability of the model.

[0119] Table 1

[0120]

[0121] Five sets of experimental results were obtained by training the original YOLOv8 model (using the minimum-scale YOLOv8n as the baseline model), the YOLOv8 model with the improved C2f_DCNv2 module (YOLOv8+C2f_DCNv2), the YOLOv8 model with the improved SPPF_LSKA module (YOLOv8+SPPF_LSKA), the YOLOv8 model with the improved EMASlideLoss classification loss (YOLOv8+EMASlideLoss), and the DSE-YOLOv8 model, which is based on the original YOLOv8 model and incorporates the C2f_DCNv2 module, the SPPF_LSKA module, and the improved EMASlideLoss classification loss. The best weighted results for each set were evaluated to obtain the mean average precision (mAP) metric on the three difficulty levels (Easy, Medium, and Hard) of the WIDER FACE validation set.

[0122] As shown in Table 1, Easy, Medium, and Hard represent the three difficulty levels of the validation set. Easy means that faces at this level are easier to detect and usually have obvious features such as clear lighting, low blur, and frontal posture; Medium means that faces at this level are relatively difficult to detect and may have some challenges, such as medium blur, less obvious lighting changes, and side posture; Hard means that faces at this level are the most challenging and may have high blur, strong lighting changes, occlusion, or extreme posture. The number of model parameters, Params (in M), indicates the size of the model. The number of floating-point operations per second, Flops (G), is used to measure the computational complexity of an algorithm or model.

[0123] Compared to the original YOLOv8 model, each improved module achieved improved mAP across all three difficulty levels, while modestly increasing the number of parameters (Params(M)) and floating-point operations per second (Flops(G)). The DSE-YOLOv8 model, which incorporates three improved methods, C2f_DCNv2, SPPF_LSKA, and EMASlideLoss, achieved mAP evaluation results of 93.86, 91.88, and 79.18, respectively, across the three difficulty levels. Compared to the baseline YOLOv8 model, face detection accuracy improved significantly, with a 0.355% increase in mAP at the most challenging Hard level.

[0124] Through experiments, it can be seen that the technical solution of the present application can effectively improve the accuracy of face detection. The examples verify the effectiveness of the technical solution of the present application and the reliability of the detection results.

[0125] In another embodiment, the present application also provides a face detection device based on the YOLOv8 target detection model, comprising a processor and a memory storing a plurality of computer instructions, characterized in that when the computer instructions are executed by the processor, the steps of the face detection method based on the YOLOv8 target detection model are implemented.

[0126] Regarding the specific limitations of the face detection device based on the YOLOv8 target detection model, please refer to the limitations of the face detection method based on the YOLOv8 target detection model above, which will not be repeated here. The above-mentioned face detection device based on the YOLOv8 target detection model can be implemented in whole or in part by software, hardware, and a combination thereof. It can be embedded in or independent of the processor in the computer device in hardware form, or it can be stored in the memory in the computer device in software form, so that the processor can call and execute the operations corresponding to the above modules.

[0127] The memory and processor are electrically connected, directly or indirectly, to enable data transmission or interaction. For example, these components may be electrically connected via one or more communication buses or signal lines. The memory stores a computer program executable on the processor, and the processor implements the above method by executing the computer program stored in the memory.

[0128] The memory may be, but is not limited to, a random access memory (RAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc. The memory is used to store a program, and the processor executes the program after receiving an execution instruction.

[0129] The processor may be an integrated circuit chip with data processing capabilities. The processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present invention. The general-purpose processor may be a microprocessor or any conventional processor.

[0130] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.

Claims

1. A face detection method based on the YOLOv8 target detection model, characterized in that: The face detection method based on the YOLOv8 target detection model includes: Build and train a target detection model based on YOLOv8, input the face image to be detected into the trained target detection model, and obtain the recognition result; The target detection model includes a backbone network, a neck network and a prediction head; The backbone network includes a convolutional module and a C2f module arranged in sequence, and a feature pyramid module at the end; The second convolution block in the bottleneck block of the C2f module is the deformable convolution DCNv2; The feature pyramid module introduces a large-scale separated convolution attention mechanism LSKA between the splicing module that splices and fuses the pooling layer features and the second convolution block; Among them, the output of the large-scale separation convolutional attention mechanism LSKA is expressed as: ; ; ; ; in, is the input feature map The output obtained by convolving with two cascaded one-dimensional depthwise convolution kernels with kernel sizes of 1×(2d-1) and (2d-1)×1, yes With the kernel size ( )and( The output of the convolution operation is obtained by convolving two cascaded one-dimensional depth-expanded convolution kernels, and then convolving with a convolution kernel of kernel size 1×1 to obtain the attention map , is the attention map And the input feature map The Hadamard product of The loss function of the YOLOv8-based target detection model includes classification loss and regression loss; The classification loss adopts binary cross entropy loss; Calculating the classification loss includes: Calculate binary cross entropy loss ; The exponential moving average method is used to update the average intersection-union ratio, and the result is assigned to the threshold μ; According to the threshold μ, the true value x is divided into three intervals, and the weight values ​​corresponding to the three intervals are obtained. The formula is as follows: ; in, is the weight value corresponding to different intervals; According to the weight values ​​corresponding to the three intervals, the adjustment weight w is calculated and the adjustment weight is compared with the binary cross entropy loss. Multiply together to get the final classification loss; According to the weight values ​​corresponding to the three intervals, the adjustment weight w is calculated as follows: ; in, The value of is 1, The value of , The value of ,when When the conditions are met, is 1, otherwise it is 0; when When the conditions are met, is 1, otherwise it is 0; when When the conditions are met, is 1 if the value is set, otherwise it is 0.

2. The face detection method based on the YOLOv8 target detection model according to claim 1, wherein The regression loss includes distribution focus loss and complete intersection-over-union loss.

3. A face detection device based on the YOLOv8 object detection model, comprising a processor and a memory storing a plurality of computer instructions, characterized in that: When the computer instructions are executed by a processor, the steps of the method according to any one of claims 1 to 2 are implemented.

Citation Information

Patent Citations

  • Small target floating garbage detection method based on improved YOLOv7 model

    CN117292313A

  • Polarization image road target detection method based on YOLOv8 improvement

    CN117351448A