A small face detection method, electronic equipment and storage medium
Through the improved yolov8 network, combined with the ES2D module and SE module, the problems of insufficient feature information and sample imbalance in small face detection are solved, efficient and flexible dense small face detection is achieved, and the detection accuracy and speed are improved.
Patent Information
- Application Number
- CN202411574556.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2044-11-06
AI Technical Summary
Small face detection faces challenges such as insufficient feature information, sample imbalance, and difficulty in positioning. Existing algorithms have low detection accuracy in dense small face detection, especially in complex scenarios.
An improved yolov8 network based on the selective state space model is adopted, combined with the Backbone, Neck and Head parts. The global feature extraction is enhanced through the ES2D module and SE module. The Neck network realizes multi-scale feature fusion. The Head part decouples the classification and regression tasks, and uses a suitable loss function to optimize the model parameters.
The accuracy and speed of small face detection have been improved, especially in scenes with dense small faces. It also performs well in complex scenes, improving the flexibility and accuracy of detection.
Smart Images

Figure CN119445633B_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 a key research area in computer vision and a subcategory of object detection. The core task of face detection is to accurately detect and locate faces against complex backgrounds. Research indicates that the human brain has specialized modules for processing facial information, highlighting the importance of face detection in cognition and social interaction. In modern society, with the rapid development of face detection technology, its importance is becoming increasingly prominent. Face detection is not only the foundation of facial image analysis applications but also a prerequisite for a variety of computer vision tasks. For example, appropriately tuned face detection algorithms can be widely used in a variety of fields, including face recognition and verification, face tracking in surveillance environments, facial expression analysis, and facial attribute recognition. These applications play an important role in security monitoring, intelligent social media, and affective computing.
[0003] Small face detection is a challenging task. Small face detection currently faces the following challenges: There are few available features. Small faces belong to the field of small object detection, and small objects typically 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 objects is further reduced, and the feature information is gradually weakened, making detection more difficult. General object detectors have low detection accuracy for small objects. The proportion of small face samples in existing datasets is low. Taking the Wider Face dataset as an example, the annotation of small faces relies on manual work, which may lead to insufficient annotation accuracy, thus affecting the model's learning of small face features and causing a decrease in detection accuracy. Sample imbalance can also significantly affect performance. Most current object detection methods are based on the anchor box mechanism. When generating multiple anchor boxes for each object, only one positive example is retained, and the others are considered negative examples. This makes the number of positive examples scarce and the number of negative examples large, exacerbating the sample imbalance problem and reducing the accuracy of small face detection. In terms of positioning, due to the small size of small faces, the area of their bounding boxes is also small. Any slight deviation can cause significant errors in the box regression, thus affecting the accurate positioning of the object.
[0004] Currently, deep learning-based object detection technologies are primarily divided into two categories: the first is a two-stage approach based on candidate regions, exemplified by Fast R-CNN and Faster R-CNN. The second is a single-stage approach, exemplified by the SSD and YOLO family of algorithms. Current object detection algorithms typically focus on general scenarios. However, optimal detection is difficult when faced with densely populated small faces in specialized scenarios, as the pixel information available on these faces is limited. CNN-based object detection methods often focus only on local information when extracting features. To enhance the model's global perception, a Transformer-based architecture can be introduced to expand the model's receptive field and achieve improved performance. However, this improvement also comes with increased computational complexity, as the complexity of the self-attention mechanism significantly increases the model's computational overhead. To address this issue, the introduction of the Selective State Space Model (SSSM) is an innovative technique that effectively reduces the model's computational burden while maintaining strong global feature extraction capabilities. Given the YOLO algorithm's fast speed, simplicity, intuitiveness, and strong generalization capabilities, the present invention utilizes YOLOv8 as a basis for its innovative design. Summary of the Invention
[0005] The purpose of the present invention is to provide a small face detection method, electronic device and storage medium to solve the problems raised in the above 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 images in the face image dataset;
[0009] Input the preprocessed image into a deep learning network model, which 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 layer 1, stage layer 2, stage layer 3 and stage layer 4;
[0013] The stem layer uses the CBS module as the entrance to the network model. The CBS module consists of a convolutional layer, a batch normalization layer, and an activation function. The convolutional layer extracts local spatial features through convolution operations and downsamples the feature map to facilitate subsequent processing. The batch normalization 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 Layer 1 consists of the CBS module, the EVSS module, and the 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.
[0015] Stage Layer 2 and Stage Layer 3 are both composed of CBS modules and C2f modules;
[0016] Stage Layer 4 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 its convolution kernel size is 5*5. Two 5*5 convolution kernels connected in series will result in a 9*9 convolution kernel receptive field, and three 5*5 convolution kernels connected in series will result in a 13*13 convolution kernel receptive field.
[0017] Preferably, the EVSS module in stage Layer 1 includes: two main branches;
[0018] 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 both passed through the SE module to adaptively adjust the weight 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 includes:
[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 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, allowing the model to perform differentiated processing based on the characteristics of different inputs. The relationship between specific parameters and input changes is shown below:
[0029] B=S B (x),
[0030] C=S C (x),
[0031] Δ=τ Δ (Parameter+S Δ (x)),
[0032] Among them S B (x),S C (x) is a 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: Squeeze operation and 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 multiplies these weight coefficients with the original feature map channel by channel to obtain a reweighted output feature map;
[0035] The calculation process of the two main operations is as follows:
[0036] (1) Input M in By using the 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] Where 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 input to the SE module independently, 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 together to obtain 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 bottom-level features to the upper layer 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 decoupling architecture to separate the classification task and the regression task, thereby performing special optimization for different requirements of the two tasks; specifically, the head part is divided into two independent branches: one branch is specially used for classifying target categories, and the other branch is used for position prediction of the target;
[0049] The head part includes three detection heads: a small-scale detection head, a medium-scale detection head, and a 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 for 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.
[0051] Preferably, a loss function suitable for the deep learning network model is set, and model parameters are trained and adjusted, including:
[0052] The loss function can be divided into two branches: a classification branch and a regression branch.
[0053] The classification branch adopts a BCE Loss function to measure the difference between the predicted category probability of the model and the real category label.
[0054] The regression branch includes a DFL function and a CIoU Loss function.
[0055] The DFL function is used to refine the distribution of the predicted bounding box to make the predicted bounding box more accurately aligned with the real box, thereby improving the accuracy of the regression task; and the CIoU Loss function is used to enhance the positioning ability of the model by comprehensively considering the overlap, center distance, and aspect ratio of the predicted box and the real box.
[0056] The process of training and adjusting the model parameters includes: after the preprocessed picture is input into the deep learning network model, a preliminary prediction result is obtained, the error between the prediction result and the real label is calculated according to the loss function, and the error is fed back to the deep learning network model to update the weight parameters of the network model by using the back propagation algorithm.
[0057] An electronic device includes:
[0058] at least one processor;
[0059] and a memory connected in communication with the at least one processor;
[0060] The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the detection method described above.
[0061] A computer-readable storage medium stores a computer program, which implements the above-mentioned detection method when executed by a processor.
[0062] Compared with the prior art, the present invention has the following beneficial effects:
[0063] The present invention innovatively integrates the ES2D module into the model design of 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 scenarios of dense small faces, and also has good effects on detection in complex scenarios. 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 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 the EVSS (Efficient Visual State Space) module in an embodiment of the present invention;
[0067] Figure 3 Schematic diagram of the 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 Add ablation experiments of different modules to the embodiments of the present invention;
[0071] Figure 7 The following are comparative experimental results of different detection algorithms in the embodiments of the present invention; DETAILED DESCRIPTION
[0072] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. 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 making creative efforts are within the scope of protection of the present invention.
[0073] See also Figures 1-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 images in the face image dataset;
[0076] This paper uses the Wider Face dataset, the largest dataset currently containing the largest number of faces, to train and validate the model. This dataset, sourced from the WIDER dataset, includes 32,203 images for face annotation, yielding a total of 393,703 annotated faces. Each face is profiled with detailed information, including blur, expression, lighting, occlusion, and pose. Each subset includes three levels of difficulty: Easy, Medium, and Hard.
[0077] Input the preprocessed image into a deep learning network model, which includes a backbone network, a neck network, and a head part;
[0078] Preferably, the Backbone network includes: stem layer, stage layer 1, stage layer 2, stage layer 3 and stage layer 4;
[0079] The stem layer uses the CBS module as the entrance to the network model. The CBS module consists of a convolutional layer, a batch normalization layer, and an activation function. The convolutional layer extracts local spatial features through convolution operations and downsamples the feature map to facilitate subsequent processing. The batch normalization 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 Layer 1 consists of the CBS module, the EVSS module, and the 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, which are then divided into two parts. One part is directly 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. This process 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 Layer 1 includes: two main branches;
[0082] The first of the two main branches uses the ES2D module to extract global contextual information from the image; the second main branch uses a specially designed convolutional network branch to capture key local details. The outputs of both main branches pass 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 for non-cross-scanning feature blocks of a given feature map. After scanning, the feature map is expanded into four sequences, and each sequence is then processed in parallel using the S6 module, and finally merged to form the 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 the other 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 an 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, the Transformer has attracted attention for its superior self-attention mechanism on large-scale data, but its quadratic computational complexity introduces significant overhead when processing large-resolution visual tasks. To improve the efficiency of attention computation, existing studies have proposed various improvements, but these methods still suffer from performance degradation. To address this, the ES2D module, drawing on the Mamba algorithm based on the Selective State Space Model (SSM), implements efficient visual representation learning through a two-dimensional selective scanning mechanism, successfully reducing computational complexity from quadratic to linear, while also addressing the challenges Mamba encounters when processing two-dimensional visual data.
[0086] ES2D modules such as Figure 3 Compared to SS2D, which uses a four-way scanning strategy, traversing the feature blocks of the entire feature map from the top left and bottom right corners to the opposite position, ES2D uses an intelligent skip scanning mechanism. For a given feature map, it does not cross-scan all feature blocks, reducing the computational complexity of each scan and improving feature extraction efficiency. After scanning, the feature map is expanded into four sequences. Each sequence is then processed in parallel using the S6 block (Selective State Space Module) and finally merged to form the output map.
[0087] Preferably, the S6 module includes:
[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 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, allowing the model to perform differentiated processing based on the characteristics of different inputs. The relationship between specific parameters and input changes is shown below:
[0097] B=S B (x),
[0098] C=S C (x),
[0099] Δ=τ Δ (Parameter+S Δ (x)),
[0100] Among them S B (x),S C (x) is a 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: Squeeze operation and 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 multiplies these weight coefficients with the original feature map channel by channel to obtain a reweighted output feature map;
[0103] The calculation process of the two main operations is as follows:
[0104] (1) Input M in By using the 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] Where FC1 and FC2 both represent fully connected calculations, δ represents the Relu activation function, and σ represents the sigmoid activation function;
[0109] (3) multiply the input M in with the obtained weight coefficient to obtain a new feature M out :
[0110] M out = S x M in ;
[0111] Since the EVSS module is composed of two main branches, the outputs of the two branches are independently input into the SE module, and are denoted as M in1 and M in2 , respectively. After the SE module processing, the outputs obtained are denoted as M in1 and M in2 . out1, M out2 ;
[0112] (4) add M out1, and M out2 to obtain a new feature map.
[0113] Stage Layer2 and Stage Layer3 are both composed of a CBS module and a C2f module;
[0114] Stage Layer4 is composed of a CBS module, a C2f module and a SPPF module; the SPPF module is changed from a parallel structure to a serial structure, and the convolution kernel size is 5*5; two 5*5 convolution kernels in series will obtain a 9*9 convolution kernel receptive field, and three 5*5 convolution kernels in series will obtain a 13*13 convolution kernel receptive field; in this way, the SPPF module improves the detection speed without reducing the receptive field, and small convolution kernels are easier to train than large convolution kernels, so that the model detection effect is better.
[0115] Preferably, the Neck network comprises:
[0116] The Neck network adopts a PAFPN structure network composed of top-down and bottom-up branches, which can realize effective multi-scale feature fusion; the PAFPN structure network introduces a bottom-up path aggregation mechanism, which transmits the bottom layer features to the high layer through an additional up-sampling path, thereby realizing efficient aggregation of multi-scale features.
[0117] FPN is a multi-scale feature fusion design, which realizes step-by-step fusion of features by channel transformation and up-sampling of feature maps of different convolution layers. However, the traditional FPN adopts a top-down feature fusion method, but the influence of bottom layer features on high layer semantic information is limited. The PAFPN structure introduces a bottom-up path aggregation mechanism to transmit the bottom layer features to the high layer, thereby realizing 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 the size maintained at 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 of size 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 Layer 4, Stage Layer 3, and Stage Layer 2 of the Backbone network, fusing feature maps of multiple scales. P3 undergoes upsampling, doubling its size to 40*40*512. This upscaled feature map is fused with P2 via the Concat module to produce a new feature map of 40*40*512. This new feature map undergoes a C2f module and one upsampling operation, and is then fused with P1 via the Concat module. The resulting feature map is 80*80*256 in size. Finally, it passes through the C2f module and is denoted as Z1. Z1 is processed in two branches: one branch directly feeds into the Head network, while the other branch performs further bottom-up feature fusion. Specifically, Z1 uses the CBS module to reduce the size of the feature map by two times, and fuses it with the feature map output by the corresponding top-down branch through the Concat module. Then, it is processed by the C2f module to generate feature map Z2. Z2 repeats the same fusion steps, passing it as input to the Head network and continuing the bottom-up feature fusion to finally generate 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, thereby optimizing them for their different requirements. 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; and 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 ground-truth box, improving the accuracy of the regression task. The CIoU Loss function is used to enhance the model's positioning capability by comprehensively considering the overlap, center point distance, and aspect ratio between the predicted and ground-truth boxes.
[0132] The process of training and adjusting model parameters includes: inputting the preprocessed image into the deep learning network model to obtain a preliminary prediction result, further calculating the error between the model prediction result and the true label based on the loss function, and feeding the error back to the deep learning network model, and using the backpropagation algorithm to update the weight parameters of the network model;
[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 application, it measures the difference between the probability of the face predicted by the model and the true face label. Given a set of true labels y, which are either 0 or 1, the corresponding predicted value is p(y), and BCE Loss is denoted by 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 i-th sample, which takes a value of 0 or 1. p(y) is the predicted probability of the i-th 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 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 of L, 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 greater the prediction error.
[0137] The DFL loss function is recorded as L DFL , DFL optimizes the probability of the two positions closest to the label y in the form of cross entropy, so that the network can focus on the target position and the distribution of 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. S 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 prediction 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 frame 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 the model parameters to the optimal value;
[0146] The network was trained using the PyTorch deep learning framework, using the training set from the dataset. The optimizer used SGD optimization, with an initial learning rate of 0.01, an internal optimizer parameter of 0.937, a weight decay of 0.0005, and a learning rate reduction method of COS. Training was performed for 300 epochs to fully learn the data. The trained network model was then used for validation.
[0147] This example was validated using a validation set. Compared to the Yolov8 base model, which achieved accuracies of 90.9%, 88.9%, and 75.7% for large, medium, and small face detection, the network model in this invention achieved detection accuracies of 93.4%, 92.1%, and 79.9% for large, medium, and small faces, respectively, representing improvements of 2.6%, 3.2%, and 4.2%, respectively. The improvement in detection of small faces was most pronounced.
[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, which implements the above-mentioned detection method when executed by a processor.
[0153] Finally, it should be noted that the above descriptions are merely preferred embodiments of the present invention and are 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 will be able to modify the technical solutions described in the aforementioned embodiments or substitute equivalents for some of the technical features. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention shall be included within the scope of protection of the present invention.
Claims
1. A small face detection method, characterized by: The method comprises: Selecting a face image dataset and preprocessing images in the face image dataset; Input the preprocessed image into a deep learning network model, which 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; 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 the model parameters to the optimal value; The Backbone network includes: stem layer, stage layer 1, stage layer 2, stage layer 3 and stage layer 4; The stem layer uses the CBS module as the entrance to the network model. The CBS module consists of a convolutional layer, a batch normalization layer, and an activation function. The convolutional layer extracts local spatial features through convolution operations and downsamples the feature map to facilitate subsequent processing. The batch normalization 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. The stage Layer 1 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 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 result in a 9*9 convolution kernel receptive field, and three 5*5 convolution kernels connected in series will result in a 13*13 convolution kernel receptive field. The EVSS module in the stage Layer 1 includes: two main branches; Of the two main branches, the first one extracts global contextual information from the image through the ES2D module; the second one captures key local details through a specially designed convolutional network branch consisting of a 3*3 depthwise separable convolution and a 1*1 convolution. Among them, the outputs of the two main branches are both passed through the SE module to adaptively adjust the weight of each feature, thereby enhancing important features and suppressing redundant information; the ES2D module provides an intelligent jump scanning mechanism, which is used to scan the feature blocks of a given feature map without cross-scanning; the feature map is expanded into 4 sequences after scanning, and then the S6 module is used to process each sequence in parallel, and finally merged to form the output map.
2. The small face detection method according to claim 1, wherein: 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 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, allowing the model to perform differentiated processing based on the characteristics of different inputs. The relationship between specific parameters and input changes is shown below: B=S B (x), C=S C (x), Δ=τ Δ (Parameter+S Δ (x)), Among them S B (x),S C (x) is a linear function that projects the input x into N-dimensional space, τ Δ is the softplus activation function.
3. The small face detection method according to claim 1, wherein: 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 multiplies these weight coefficients with the original feature map channel by channel to obtain a reweighted output feature map; The calculation process of the two main operations is as follows: (1) Input M in By using the 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 )))); Where 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 input to the SE module independently, 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.
4. The small face detection method according to claim 1, wherein: The Neck network includes: 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 bottom-level features to the upper layer through an additional upsampling path, thereby achieving efficient aggregation of multi-scale features.
5. The small face detection method according to claim 1, wherein: The Head part includes: The head part adopts a decoupled architecture to separate the classification task and the regression task, thereby optimizing them specifically for the different requirements of these 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. The Head part includes three detection heads: small-scale detection head, medium-scale detection head and 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 for processing 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.
6. The small face detection method according to claim 1, wherein: 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 ground-truth box, thereby improving the accuracy of the regression task. The CIoU Loss function is used to enhance the model's positioning capability by comprehensively considering the overlap, center point distance, and aspect ratio between the predicted box and the ground-truth box. 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 calculated based on 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.
7. 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 perform the detection method according to any one of claims 1 to 6.
8. 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 6 is implemented.
Citation Information
Patent Citations
Unmanned aerial vehicle aerial photography small target detection method based on improved YOLOv8s algorithm and electronic equipment
CN118230194A
Small target detection method for images acquired by unmanned aerial vehicle based on improved YOLOv8 algorithm
CN118628939A