Small face detection method, electronic equipment and storage medium
By introducing ES2D and SE modules in the yolov8 model, the global feature extraction capability is enhanced, and the PAFPN structural network is used for multi-scale feature fusion, which solves the problems of low accuracy and large positioning error in small face detection, and realizes efficient small people Face detection.
Patent Information
- Application Number
- CN202411574556.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2044-11-06
AI Technical Summary
The prior art has problems such as low detection accuracy, unbalanced sample and large positioning errors in small face detection, especially in detection scenarios with dense small faces.
The deep learning network model based on yolov8 is adopted, and the global feature extraction capability and computing efficiency of the model are enhanced by introducing ES2D module and SE module, and multi-scale feature fusion is realized through the PAFPN structural network.
The accuracy and speed of small face detection are improved, especially in detection scenarios with dense small faces, and they also perform well in detection of complex scenes.
Smart Images

Figure CN119445633A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a small-scale face detection method, electronic equipment and storage medium. Background Art
[0002] Face detection is an important research direction in the field of computer vision and a type of target detection. The core task of face detection is to accurately detect and locate faces from complex backgrounds. Studies have shown that there are modules in the human brain that specifically process face information, which highlights the importance of face detection in cognition and social interaction. In modern society, with the rapid development of face detection technology, its importance has become increasingly prominent. Face detection is not only the basis for face image analysis applications, but also a prerequisite for many computer vision tasks. For example, properly adjusted face detection algorithms can be widely used in many fields such as face recognition and verification, face tracking in surveillance situations, facial expression analysis, and facial attribute recognition. These applications play an important role in security monitoring, intelligent social media, and emotional computing.
[0003] Small face detection is a challenging task. At present, small face detection faces the following challenges: there are few available features. Small faces belong to the field of small target detection. Small targets usually carry less information, such as limited appearance information such as texture, shape, and color, and occupy fewer pixels in the image. After multiple downsampling, the resolution of small targets is further reduced, and the feature information is gradually weakened, which makes detection more difficult. The detection accuracy of general target detectors for small targets is low; the proportion of small face samples in existing datasets is low. Taking the Wider Face dataset as an example, the annotation of small faces depends on manual work, which may lead to insufficient annotation accuracy, thereby affecting the model's learning effect on small face features and causing a decrease in detection accuracy; the sample imbalance problem will also significantly affect the performance. Most current target detection methods are based on the anchor box mechanism. In the process of generating multiple anchor boxes for each target, only one positive sample is retained, and the others are regarded as negative samples. This makes the number of positive samples scarce and the number of negative samples huge, which aggravates the sample imbalance problem and reduces the accuracy of small face detection; in terms of positioning, due to the small target size of small faces, the area of their bounding boxes is also correspondingly small. Any slight deviation may cause significant errors in the regression of the box, thereby affecting the accurate positioning of the target.
[0004] At present, the target detection technology based on deep learning is mainly divided into two types: the first is a two-stage method based on candidate regions, represented by Fast R-CNN and Faster R-CNN. The second is a single-stage method, represented by SSD and YOLO series algorithms. Current target detection algorithms usually focus on detection in general scenarios. When small faces are densely distributed in special scenarios, it is difficult to achieve the best detection effect due to the small face pixel information. The target detection method based on CNN often only focuses on local information when extracting features. In order to make the model have stronger global perception ability, a Transformer-based structure can be introduced to expand the receptive field of the model and achieve performance improvement. However, this improvement will also bring about an increase in computational complexity. The complexity of the self-attention mechanism significantly increases the computational overhead of the model. In order to solve this problem, the introduction of the selective state space model as an innovative technology effectively reduces the computational burden of the model while having a strong global feature extraction capability. Considering that the yolo algorithm is fast, simple and intuitive, and has strong generalization ability, the present invention is innovatively designed based on yolov8. Summary of the invention
[0005] The purpose of the present invention is to provide a small-sized face detection method, electronic device and storage medium to solve the problems raised in the above-mentioned background technology.
[0006] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0007] A small face detection method, the method comprising:
[0008] Selecting a face image dataset, and preprocessing the images in the face image dataset;
[0009] Input the preprocessed image into a deep learning network model, wherein the deep learning network model includes a Backbone network, a Neck network, and a Head part;
[0010] Setting a loss function suitable for the deep learning network model, training and adjusting model parameters;
[0011] The small face image to be detected is input into the optimal network model, and a small face image detection result graph is output. The optimal network model is a deep learning network model after adjusting the model parameters to the optimal value.
[0012] Preferably, the Backbone network includes: stem Layer, stage Layer1, stage Layer2, StageLayer3 and Stage Layer4;
[0013] The stem layer uses the CBS module as the entrance of the network model. The CBS module consists of a convolutional layer, a BN layer and an activation function. The convolutional layer extracts local spatial features through convolution operations and downsamples the feature map for subsequent processing. The BN layer is used to normalize the output of the convolutional layer to stabilize the training process. The activation function is used to introduce nonlinear transformations, enhance the network's expressive power, and achieve efficient conversion and extraction of input features.
[0014] Stage Layer1 consists of CBS module, EVSS module and C2f module; the EVSS module is used to coordinately integrate global and local feature representations while maintaining computational efficiency; the C2f module is used to generate feature maps through a convolutional layer, and then divide these feature maps into two parts, one part is directly jump-connected to the output layer, and the other part is further extracted through multiple Bottleneck modules;
[0015] Stage Layer2 and Stage Layer3 are both composed of CBS modules and C2f modules;
[0016] Stage Layer4 consists of a CBS module, a C2f module, and an SPPF module; the SPPF module changes from a parallel structure to a serial structure, and the convolution kernel size is 5*5; two 5*5 convolution kernels connected in series will obtain a convolution kernel receptive field of 9*9, and three 5*5 convolution kernels connected in series will obtain a convolution kernel receptive field of 13*13;
[0017] Preferably, the EVSS module in stage Layer1 includes: two main branches;
[0018] Among the two main branches, the first main branch extracts the global context information in the image through the ES2D module; the second main branch is used to capture key local details through a specially designed convolutional network branch; wherein the outputs of the two main branches are passed through the SE module to adaptively adjust the weights of each feature, thereby enhancing important features and suppressing redundant information; the ES2D module provides an intelligent skip scanning mechanism, which is used to scan the feature blocks of a given feature map without cross scanning; wherein the feature map is expanded into 4 sequences after scanning, and then each sequence is processed in parallel using the S6 module, and finally merged to form an output map.
[0019] Preferably, the S6 module comprises:
[0020] The S6 module uses a learnable latent state h(t)∈R N×D The input D-dimensional sequence x(t)∈R L×D Convert to output sequence y(t)∈R L×DThe process is:
[0021]
[0022] where A∈R D×N ,B∈R D×N ,C∈R D×N ;
[0023] The continuous parameter is sampled at a given sampling time scale Δ∈R by the zero-order hold technique. D Discretize on
[0024]
[0025] To simplify the operation, the above repeated calculations can be effectively represented by convolution:
[0026]
[0027] Among them, * represents the convolution operation, is the convolution kernel of SSM;
[0028] At the same time, the S6 module introduces a selection mechanism to perform selective reasoning on the input. When the input changes, the model parameters will also be adjusted accordingly, so that the model can perform differentiated processing according to the characteristics of different inputs. The relationship between specific parameters and input changes is as follows:
[0029] B=S B (x),
[0030] C=S C (x),
[0031] Δ=τ Δ (Parameter+S Δ (x)),
[0032] Where S B (x),S C (x) is the linear function that projects the input x into N-dimensional space, τ Δ is the softplus activation function.
[0033] Preferably, the SE module includes: two main operations: a Squeeze operation and an Excitation operation;
[0034] The Squeeze operation aggregates the spatial information of the input feature map through global average pooling; the Excitation operation learns a weight coefficient for each channel through a two-layer fully connected network, and these weight coefficients are multiplied by the original feature map by channel to obtain a re-weighted output feature map;
[0035] The calculation process of the two main operations is as follows:
[0036] (1) Input M in By using a global average pooling operation to aggregate the spatial information of the feature map, a spatial context descriptor M is generated. avg :
[0037] M avg =AvgPool(M in );
[0038] (2) The descriptor is forwarded to a fully connected network consisting of two fully connected layers plus two activation functions to learn a weight coefficient S for each channel:
[0039] S=σ(FC2(δ(FC1(M in ))));
[0040] Among them, FC1 and FC2 both represent fully connected calculations, δ represents the Relu activation function, and σ represents the sigmoid activation function;
[0041] (3) Input M in Multiply it with the obtained weight coefficient to get the new feature M out :
[0042] M out =S×M in ;
[0043] Since the EVSS module consists of two main branches, the outputs of the two branches are independently input to the SE module, denoted as M and in1 ,M in2 , then M in1 ,M in2 The output obtained after SE module processing is recorded as M out1 ,M out2 ;
[0044] (4) M out1 ,M out2 Add them together to get a new feature map.
[0045] Preferably, the Neck network includes:
[0046] The Neck network adopts a PAFPN structure network, which consists of top-down and bottom-up branches, and can achieve effective multi-scale feature fusion; the PAFPN structure network introduces bottom-up path aggregation, transfers the underlying features to the upper layers through an additional upsampling path, thereby achieving efficient aggregation of multi-scale features.
[0047] Preferably, the Head part includes:
[0048] The head part adopts a decoupled architecture to separate the classification task and the regression task, so as to optimize them specifically for the different needs of the two tasks. Specifically, the head part is divided into two independent branches: one branch is dedicated to classifying the target category, and the other branch is used to predict the target location.
[0049] The Head part includes three detection heads: small-scale detection head, medium-scale detection head and large-scale detection head;
[0050] The small-scale detection head is used for high-resolution feature maps to capture small targets; the medium-scale detection head is used to process medium-resolution feature maps to detect medium-sized targets; the large-scale detection head is used for low-resolution feature maps to identify large targets.
[0051] Preferably, setting a loss function suitable for the deep learning network model, training and adjusting model parameters include:
[0052] The loss function can be divided into two branches: classification branch and regression branch;
[0053] The classification branch uses the BCE Loss function to measure the difference between the category probability predicted by the model and the true category label;
[0054] The regression branch includes the DFL function and the CIoU Loss function;
[0055] The DFL function is used to refine the distribution of bounding box predictions so that the predicted bounding box is more accurately aligned with the real box, thereby improving the accuracy of the regression task. The CIoU Loss function is used to enhance the positioning capability of the model by comprehensively considering the overlap between the predicted box and the real box, the center point distance, and the aspect ratio.
[0056] The process of training and adjusting model parameters includes: after inputting the preprocessed image into the deep learning network model, a preliminary prediction result is obtained, and the error between the prediction result and the true label is further calculated according to the loss function, and the error is fed back to the deep learning network model, and the weight parameters of the network model are updated using the back propagation algorithm.
[0057] An electronic device, comprising:
[0058] at least one processor;
[0059] and, a memory communicatively coupled to the at least one processor;
[0060] 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 so that the at least one processor can perform the above-mentioned detection method.
[0061] A computer-readable storage medium stores a computer program, and the computer program implements the above-mentioned detection method when executed by a processor.
[0062] Compared with the prior art, the beneficial effects achieved by the present invention are:
[0063] The present invention innovatively integrates the ES2D module into the model design in the Backbone network to obtain efficient global capture capabilities in a lightweight visual model. At the same time, considering that the convolution operation can achieve more efficient feature extraction when only local feature representation is required, a convolution branch is added next to the original ES2D branch, and the features of the two are fused through the SE module. The present invention has fast speed and shows great flexibility in face detection, especially for the detection scene of dense small faces, and also has good effects on detection in complex scenes. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0065] Figure 1 A schematic diagram of a yolov8 small face detection model based on mamba selective state space constructed in an embodiment of the present invention;
[0066] Figure 2 Schematic diagram of an EVSS (Efficient Visual State Space) module in an embodiment of the present invention;
[0067] Figure 3 Schematic diagram of an ES2D (efficient 2D scanning) module in an embodiment of the present invention;
[0068] Figure 4 Schematic diagram of the SE (channel attention) module in an embodiment of the present invention;
[0069] Figure 5 This is a schematic diagram of the effect in an embodiment of the present invention;
[0070] Figure 6 Adding ablation experiments of different modules to the embodiments of the present invention;
[0071] Figure 7 The comparative experimental results of different detection algorithms in the embodiments of the present invention are shown in FIG. DETAILED DESCRIPTION
[0072] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0073] See also Figure 1-Figure 7 , the present invention provides a technical solution:
[0074] A small face detection method, the method comprising:
[0075] Selecting a face image dataset, and preprocessing the images in the face image dataset;
[0076] The present invention uses the Wider Face dataset, which currently contains the most human faces, to train and verify the model effect. The image source of this dataset is the WIDER dataset, from which 32,203 images were selected for face annotation, and a total of 393,703 human face data were annotated. Each face has detailed information, including blur, expression, lighting, occlusion, posture, etc., and each subset contains 3 levels of test difficulty: Easy, Medium, Hard.
[0077] Input the preprocessed image into a deep learning network model, wherein the deep learning network model includes a Backbone network, a Neck network, and a Head part;
[0078] Preferably, the Backbone network includes: stem Layer, stage Layer1, stage Layer2, StageLayer3 and Stage Layer4;
[0079] The stem layer uses the CBS module as the entrance of the network model. The CBS module consists of a convolutional layer, a BN layer and an activation function. The convolutional layer extracts local spatial features through convolution operations and downsamples the feature map for subsequent processing. The BN layer is used to normalize the output of the convolutional layer to stabilize the training process. The activation function is used to introduce nonlinear transformations, enhance the network's expressive power, and achieve efficient conversion and extraction of input features.
[0080] Stage Layer1 consists of CBS module, EVSS module and C2f module; the EVSS module is used to coordinately integrate global and local feature representations while maintaining computational efficiency; the C2f module is used to generate feature maps through a convolutional layer, and then divide these feature maps into two parts, one part is directly jump-connected to the output layer, and the other part is further extracted through multiple Bottleneck modules; the results of the two parts are merged in the channel dimension, which helps the model capture more contextual information and thus identify the target more accurately. The merged feature map passes through the second convolutional layer to obtain the final output;
[0081] Preferably, the EVSS module in stage Layer1 includes: two main branches;
[0082] Among the two main branches, the first main branch extracts global context information in the image through the ES2D module; the second main branch is used to capture key local details through a specially designed convolutional network branch; wherein the outputs of the two main branches are passed through the SE module to adaptively adjust the weights of each feature, thereby enhancing important features and suppressing redundant information; the ES2D module provides an intelligent skip scanning mechanism, which is used to scan feature blocks of a given feature map without cross scanning; wherein the feature map is expanded into 4 sequences after scanning, and then each sequence is processed in parallel using the S6 module, and finally merged to form an output map;
[0083] Compared with the self-attention mechanism, the ES2D module reduces the computational complexity from quadratic to linear. Compared with the SS2D module, the ES2D module introduces a skip sampling mechanism, which reduces the number of tags that need to be scanned in the spatial dimension and saves computational costs.
[0084] Construct an EVSS module based on the combination of ES2D and SE channel attention mechanism. The EVSS module is placed after the CBS module and consists of two main branches: First, the input feature map passes through the ES2D (Efficient 2DScanning) module in the first branch to extract the global context information in the image. Secondly, it passes through a specially designed convolutional network in another branch. The convolutional network consists of a 3*3 depth-separable convolution and a 1*1 convolution, which is designed to capture key local details. To further improve the expressiveness of the model, the outputs of both branches are processed by a SE (channel attention mechanism) module to adaptively adjust the weights of each feature, thereby enhancing important features and suppressing redundant information;
[0085] In the field of computer vision, Transformer has attracted attention for its superiority in self-attention mechanism on large-scale data, but its quadratic computational complexity brings significant overhead when processing large-resolution visual tasks. In order to improve the efficiency of attention calculation, although existing studies have proposed a variety of improvement methods, there are still problems such as performance degradation. To this end, drawing on the Mamba algorithm based on the selection state space model (SSM), the ES2D module achieves efficient visual representation learning through a two-dimensional selective scanning mechanism, successfully reducing the computational complexity from quadratic to linear, and at the same time solving the challenges encountered by Mamba when processing two-dimensional visual data;
[0086] ES2D modules such as Figure 3 Compared with SS2D, which adopts a four-way scanning strategy and traverses the feature blocks of the entire feature map from the upper left corner and the lower right corner to the opposite position, ES2D uses an intelligent jump scanning mechanism. For a given feature map, it does not cross-scan all feature blocks, which reduces the amount of calculation for each scan and improves the efficiency of feature extraction. After scanning, the feature map is expanded into 4 sequences, and then each sequence is processed in parallel using the S6 block (selective state space module), and finally merged to form the output map.
[0087] Preferably, the S6 module comprises:
[0088] The S6 module uses a learnable latent state h(t)∈R N×D The input D-dimensional sequence x(t)∈R L×D Convert to output sequence y(t)∈R L×D The process is:
[0089]
[0090] where A∈R D×N ,B∈R D×N ,C∈R D×N ;
[0091] The continuous parameter is sampled at a given sampling time scale Δ∈R by the zero-order hold technique. D Discretize on
[0092]
[0093] To simplify the operation, the above repeated calculations can be effectively represented by convolution:
[0094]
[0095] Among them, * represents the convolution operation, is the convolution kernel of SSM;
[0096] At the same time, the S6 module introduces a selection mechanism to perform selective reasoning on the input. When the input changes, the model parameters will also be adjusted accordingly, so that the model can perform differentiated processing according to the characteristics of different inputs. The relationship between specific parameters and input changes is as follows:
[0097] B=S B (x),
[0098] C=S C (x),
[0099] Δ=τ Δ (Parameter+S Δ (x)),
[0100] Where S B (x),S C (x) is the linear function that projects the input x into N-dimensional space, τ Δ is the softplus activation function.
[0101] Preferably, the SE module includes: two main operations: a Squeeze operation and an Excitation operation;
[0102] The Squeeze operation aggregates the spatial information of the input feature map through global average pooling; the Excitation operation learns a weight coefficient for each channel through a two-layer fully connected network, and these weight coefficients are multiplied by the original feature map by channel to obtain a re-weighted output feature map;
[0103] The calculation process of the two main operations is as follows:
[0104] (1) Input M in By using a global average pooling operation to aggregate the spatial information of the feature map, a spatial context descriptor M is generated. avg :
[0105] M avg =AvgPool(M in );
[0106] (2) The descriptor is forwarded to a fully connected network consisting of two fully connected layers plus two activation functions to learn a weight coefficient S for each channel:
[0107] S=σ(FC2(δ(FC1(M in ))));
[0108] Among them, FC1 and FC2 both represent fully connected calculations, δ represents the Relu activation function, and σ represents the sigmoid activation function;
[0109] (3) Input M in Multiply it with the obtained weight coefficient to get the new feature M out :
[0110] M out =S×M in ;
[0111] Since the EVSS module consists of two main branches, the outputs of the two branches are independently input to the SE module, denoted as M and in1 ,M in2 , then M in1 ,M in2 The output obtained after SE module processing is recorded as M out1, M out2 ;
[0112] (4) M out1, M out2 Add them together to get a new feature map.
[0113] Stage Layer2 and Stage Layer3 are both composed of CBS modules and C2f modules;
[0114] Stage Layer4 consists of a CBS module, a C2f module and an SPPF module; the SPPF module changes from a parallel structure to a series structure, and its convolution kernel size is 5*5; two 5*5 convolution kernels connected in series will obtain a convolution kernel receptive field of 9*9, and three 5*5 convolution kernels connected in series will obtain a convolution kernel receptive field of 13*13; in this way, the SPPF module improves the detection speed without reducing the receptive field. At the same time, small convolution kernels are easier to train than large convolution kernels, making the model detection effect better.
[0115] Preferably, the Neck network includes:
[0116] The Neck network adopts a PAFPN structure network, which is composed of top-down and bottom-up branches, and can achieve effective multi-scale feature fusion; the PAFPN structure network introduces bottom-up path aggregation, and transmits the bottom-level features to the upper layer through an additional upsampling path, thereby achieving efficient aggregation of multi-scale features;
[0117] FPN is a multi-scale feature fusion design that achieves step-by-step feature fusion by performing channel transformation and upsampling on feature maps of different convolutional layers. However, traditional FPN uses a top-down feature fusion method, but the impact of underlying features on high-level semantic information is limited. The PAFPN structure, by introducing a bottom-up path aggregation mechanism, transfers underlying features to high-level layers, achieving more efficient multi-scale feature fusion.
[0118] The Neck network receives feature maps from Stage Layer4, Stage Layer3, and Stage Layer2 of the Backbone network, which are P3 (20*20*1024), P2 (40*40*512), and P1 (80*80*256), respectively, and performs multi-scale feature fusion. Specifically, P3 is first upsampled to increase its spatial size to 40*40*512. Subsequently, the upsampled P3 is fused with P2 through the Concat module to generate a new feature map with a size of 40*40*512. Next, the new feature map is processed by the C2f module, and upsampled again, and fused with P1 through the Concat module to obtain a feature map with a size of 80*80*256. Finally, the fused feature map is processed by the C2f module and recorded as Z1. Z1 is passed as input to the Head part;
[0119] The Neck network receives feature maps P3 (20*20*1024), P2 (40*40*512), and P1 (80*80*256) from Stage Layer4, Stage Layer3, and Stage Layer2 of the Backbone network, so that feature maps of multiple scales are fused. P3 is upsampled to double the image size to 40*40*512. The enlarged feature map is fused with P2 through the Concat module to obtain a new feature map with a feature map size of 40*40*512. The new feature map is fused with P1 through the C2f module and an upsampling operation through the Concat module. The fused feature map size is 80*80*256. Finally, it is passed through the C2f module and recorded as Z1. Z1 is processed through two branches: one branch is directly input to the Head network, and the other branch further performs bottom-up feature fusion. Specifically, Z1 reduces the size of the feature map by two times through the CBS module, and fuses it with the feature map output by the corresponding top-down branch through the Concat module, and then processes it through the C2f module to generate feature map Z2. Z2 repeats the same fusion steps, passing it as input to the Head network on the one hand, and continuing to fuse features from bottom to top on the other hand, finally generating feature map Z3.
[0120] The final output feature maps Z1 (80*80*256), Z2 (40*40*512), and Z3 (20*20*1024) of the Neck network are passed as input to the Head network for further detection.
[0121] Preferably, the Head part includes:
[0122] The head part adopts a decoupled architecture to separate the classification task and the regression task, so as to optimize them specifically for the different needs of the two tasks. Specifically, the head part is divided into two independent branches: one branch is dedicated to classifying the target category, and the other branch is used to predict the target location.
[0123] This part further extracts high-level features through multiple convolutional layers and activation functions, converting feature maps into specific information such as category, location, and confidence. The model contains three detection heads, which receive Z1 (80*80*256), Z2 (40*40*512), and Z3 (20*20*1024) as input to detect objects of different sizes. At the same time, each detection head is divided into two independent branches: one for target category classification and the other for location prediction, avoiding conflicts between tasks and improving detection accuracy;
[0124] The Head part includes three detection heads: small-scale detection head, medium-scale detection head and large-scale detection head;
[0125] The small-scale detection head is used for high-resolution feature maps to capture small targets; the medium-scale detection head is used to process medium-resolution feature maps to detect medium-sized targets; the large-scale detection head is used for low-resolution feature maps to identify large targets.
[0126] Setting a loss function suitable for the deep learning network model, training and adjusting model parameters;
[0127] Preferably, setting a loss function suitable for the deep learning network model, training and adjusting model parameters include:
[0128] The loss function can be divided into two branches: classification branch and regression branch;
[0129] The classification branch uses the BCE Loss function to measure the difference between the category probability predicted by the model and the true category label;
[0130] The regression branch includes the DFL function and the CIoU Loss function;
[0131] The DFL function is used to refine the distribution of bounding box predictions so that the predicted bounding box is more accurately aligned with the real box, thereby improving the accuracy of the regression task. The CIoU Loss function is used to enhance the positioning capability of the model by comprehensively considering the overlap between the predicted box and the real box, the center point distance, and the aspect ratio.
[0132] The process of training and adjusting model parameters includes: after inputting the preprocessed image into the deep learning network model, a preliminary prediction result is obtained, the prediction result is further calculated according to the loss function to determine the error between the model prediction result and the true label, and the error is fed back to the deep learning network model, and the weight parameters of the network model are updated using the back propagation algorithm;
[0133] The BCE Loss function is used to measure the difference between the class probability predicted by the model and the true class label. In this invention, it is used to measure the difference between the probability of the face predicted by the model and the true face label. Given a set of true labels y, the value is 0 or 1. The corresponding predicted value is p(y), and BCE Loss is recorded as L BCE , the specific calculation is as follows:
[0134]
[0135] Where N is the number of samples, y i is the actual binary label of the ith sample, which takes a value of 0 or 1. p(y) is the predicted probability of the ith sample, which is mapped to the [0,1] interval by the Sigmoid function output by the model, so its value range is between (0,1).
[0136] When y=1, it means that the sample is a face. The closer the model's predicted value p(y) is to 1, the higher the model's confidence that the sample is a face. BCE The closer the value of is to 0, the better the detection effect is. On the contrary, the closer the value of p(y) is to 0, the better the detection effect is. BCE The larger the value, the worse the prediction effect. When y = 0, it means that the sample is not a face. At this time, the closer the value of p(y) is to 0, the lower the confidence of the model that the sample is a face. BCE The closer the value of is to 0, the better the detection effect is. On the contrary, if the value of p(y) is closer to 1, L BCE The larger the value of , the larger the prediction error.
[0137] The DFL loss function is denoted as L DFL , DFL optimizes the probability of the two positions closest to label y in the form of cross entropy, so that the network can focus on the distribution of the target position and the adjacent area more quickly. The calculation is as follows:
[0138] L DFL =-((y i+1 -y)log(S i )+(yy i )log(S i+1 ));
[0139] Among them, y is the actual value of the label, y i ,y i+1are the predicted value of the label and the predicted value near the label, respectively. i , S i+1 y i ,y i+1 The corresponding probability.
[0140] The CIOU Loss function is used to measure the difference between the bounding box predicted by the model and the real bounding box. CIOU Loss is based on the traditional IoU Loss which only considers the overlapping area between the model predicted box and the real box. It introduces more geometric factors (center point distance and aspect ratio difference) to more accurately optimize the bounding box positioning, thereby improving the performance of the target detection model. CIOU Loss is denoted as L CIOU , the calculation process is as follows:
[0141]
[0142]
[0143]
[0144] Where ρ is the distance between the center point of the real box and the predicted box, c is the diagonal length of the minimum bounding matrix of the real box and the predicted box, α and υ are the aspect ratio, and w gt ,h gt Represents the width, height, and w of the real box respectively. p ,h p Represent the width and height of the prediction box respectively.
[0145] Inputting a small face image to be detected into an optimal network model, and outputting a small face image detection result graph, wherein the optimal network model is a deep learning network model after adjusting model parameters to the optimal value;
[0146] The network was trained under the pytorch deep learning framework, using the training set in the data set, the optimizer was optimized using sgd, the initial learning rate was set to 0.01, the optimizer internal parameters were 0.937, the weight decay was 0.0005, the learning rate was reduced by cos, and 300 epochs were trained to fully learn the data. Finally, the trained network model was used for verification;
[0147] This embodiment is verified by a validation set. Compared with the 90.9%, 88.9%, and 75.7% accuracy of the yolov8 basic model for large, medium, and small face detection, the network model in the present invention has detection accuracies of 93.4%, 92.1%, and 79.9% for large, medium, and small faces, respectively, which are improved by 2.6%, 3.2%, and 4.2%, respectively, and the detection effect of small faces is the most obvious.
[0148] An electronic device, comprising:
[0149] at least one processor;
[0150] and, a memory communicatively coupled to the at least one processor;
[0151] 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 so that the at least one processor can perform the above-mentioned detection method.
[0152] A computer-readable storage medium stores a computer program, and the computer program implements the above-mentioned detection method when executed by a processor.
[0153] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A small face detection method, characterized in that: The method comprises: Selecting a face image dataset, and preprocessing the images in the face image dataset; Input the preprocessed image into a deep learning network model, wherein the deep learning network model includes a Backbone network, a Neck network, and a Head part; Setting a loss function suitable for the deep learning network model, training and adjusting model parameters; The small face image to be detected is input into the optimal network model, and a small face image detection result graph is output. The optimal network model is a deep learning network model after adjusting the model parameters to the optimal value.
2. The small face detection method according to claim 1, characterized in that: The Backbone network includes: stemLayer, stage Layer 1, stage Layer 2, stage Layer 3 and stage Layer 4; The stem layer uses the CBS module as the entrance of the network model. The CBS module consists of a convolution layer, a BN layer and an activation function. The convolution layer extracts local spatial features through convolution operations and downsamples the feature map for subsequent processing. The BN layer is used to normalize the output of the convolution layer to stabilize the training process. The activation function is used to introduce nonlinear transformations, enhance the network's expressive power, and achieve efficient conversion and extraction of input features. The stage Layer1 consists of a CBS module, an EVSS module, and a C2f module; the EVSS module is used to collaboratively integrate global and local feature representations while maintaining computational efficiency; the C2f module is used to generate feature maps through a convolutional layer, and then divide these feature maps into two parts, one part is directly jump-connected to the output layer, and the other part is further extracted through multiple Bottleneck modules; The Stage Layer 2 and Stage Layer 3 are both composed of a CBS module and a C2f module; The Stage Layer 4 is composed of a CBS module, a C2f module and an SPPF module; the SPPF module is changed from a parallel structure to a series structure, and the convolution kernel size is 5*5; two 5*5 convolution kernels connected in series will obtain a convolution kernel receptive field of 9*9, and three 5*5 convolution kernels connected in series will obtain a convolution kernel receptive field of 13*13.
3. The small face detection method as claimed in claim 2, characterized in that: The EVSS module in the stage Layer1 includes: two main branches; Among the two main branches, the first main branch extracts global context information in the image through the ES2D module; the second main branch is used to capture key local details through a specially designed convolutional network branch; wherein the outputs of the two main branches are passed through the SE module to adaptively adjust the weights of each feature, thereby enhancing important features and suppressing redundant information; the ES2D module provides an intelligent skip scanning mechanism, which is used to scan feature blocks of a given feature map without cross scanning; wherein the feature map is expanded into 4 sequences after scanning, and then each sequence is processed in parallel using the S6 module, and finally merged to form an output map.
4. The small face detection method as claimed in claim 3, characterized in that: The S6 module includes: The S6 module uses a learnable latent state h(t)∈R N×D The input D-dimensional sequence x(t)∈R L×D Convert to output sequence y(t)∈R L×D The process is: where A∈R D×N ,B∈R D×N ,C∈R D×N ; The continuous parameter is sampled at a given sampling time scale Δ∈R by the zero-order hold technique. D Discretize on ; To simplify the operation, the above repeated calculations can be effectively represented by convolution: Among them, * represents the convolution operation, is the convolution kernel of SSM; At the same time, the S6 module introduces a selection mechanism to perform selective reasoning on the input. When the input changes, the model parameters will also be adjusted accordingly, so that the model can perform differentiated processing according to the characteristics of different inputs. The relationship between specific parameters and input changes is as follows: B=S B (x), C=S C (x), Δ=τ Δ (Parameter+S Δ (x)), Where S B (x),S C (x) is the linear function that projects the input x into N-dimensional space, τ Δ is the softplus activation function.
5. The small face detection method as claimed in claim 3, characterized in that: The SE module includes two main operations: Squeeze operation and Excitation operation; The Squeeze operation aggregates the spatial information of the input feature map through global average pooling; the Excitation operation learns a weight coefficient for each channel through a two-layer fully connected network, and these weight coefficients are multiplied by the original feature map by channel to obtain a re-weighted output feature map; The calculation process of the two main operations is as follows: (1) Input M in By using a global average pooling operation to aggregate the spatial information of the feature map, a spatial context descriptor M is generated. avg : M avg =AvgPool(M in ); (2) The descriptor is forwarded to a fully connected network consisting of two fully connected layers plus two activation functions to learn a weight coefficient S for each channel: S=σ(FC2(δ(FC1(M in )))); Among them, FC1 and FC2 both represent fully connected calculations, δ represents the Relu activation function, and σ represents the sigmoid activation function; (3) Input M in Multiply it with the obtained weight coefficient to get the new feature M out : M out =S×M in ; Since the EVSS module consists of two main branches, the outputs of the two branches are independently input to the SE module, denoted as M and in1 ,M in2 , then M in1 ,M in2 The output obtained after SE module processing is recorded as M out1, M out2 ; (4) M out1, M out2 Add them together to get a new feature map.
6. The small face detection method according to claim 1, characterized in that: The Neck network includes: The Neck network adopts a PAFPN structure network, which is composed of top-down and bottom-up branches, and can achieve effective multi-scale feature fusion; the PAFPN structure network introduces bottom-up path aggregation, transfers the bottom-level features to the upper layer through an additional upsampling path, thereby achieving efficient aggregation of multi-scale features.
7. The small face detection method according to claim 1, characterized in that: The Head part includes: The head part adopts a decoupled architecture to separate the classification task and the regression task, so as to optimize the different requirements of the two tasks. Specifically, the head part is divided into two independent branches: one branch is used to classify the target category, and the other branch is used to predict the position of the target. The Head part includes three detection heads: a small-scale detection head, a medium-scale detection head and a large-scale detection head; The small-scale detection head is used for high-resolution feature maps to capture small targets; the medium-scale detection head is used to process medium-resolution feature maps to detect medium-sized targets; and the large-scale detection head is used for low-resolution feature maps to identify large targets.
8. The small face detection method according to claim 1, characterized in that: The setting of a loss function suitable for the deep learning network model, training and adjusting model parameters, includes: The loss function can be divided into two branches: classification branch and regression branch; The classification branch uses the BCE Loss function to measure the difference between the category probability predicted by the model and the true category label; The regression branch includes a DFL function and a CIoU Loss function; The DFL function is used to refine the distribution of bounding box predictions so that the predicted bounding box is more accurately aligned with the real box, thereby improving the accuracy of the regression task; the CIoU Loss function is used to enhance the positioning capability of the model by comprehensively considering the overlap between the predicted box and the real box, the center point distance, and the aspect ratio; The process of training and adjusting model parameters includes: after inputting the preprocessed image into the deep learning network model, a preliminary prediction result is obtained, the prediction result is further calculated according to the loss function The error between the model prediction result and the true label, and the error is fed back to the deep learning network model, and the weight parameters of the network model are updated using the back propagation algorithm.
9. An electronic device, characterized in that: include: at least one processor; and, a memory communicatively coupled to the at least one processor; 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 so that the at least one processor can execute the detection method according to any one of claims 1 to 8.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the detection method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Face detection method and device
CN109753927A
Unmanned aerial vehicle aerial photography small target detection method based on improved YOLOv8s algorithm and electronic equipment
CN118230194A
High-resolution remote sensing image target detection method based on multi-scale network
CN118485927A
Infrared aerial photography target detection method of selective state space model
CN118537752A
Small target detection method for images acquired by unmanned aerial vehicle based on improved YOLOv8 algorithm
CN118628939A