Construction method of face detection model and trajectory analysis method
By using the position space attention mechanism in the backbone network of the face detection model and the non-local attention mechanism in the neck network, the occlusion and scale problems in face recognition are solved, the detection accuracy and efficiency are improved, and real-time Sexual requirements.
Patent Information
- Application Number
- CN202411776129.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2044-12-05
AI Technical Summary
The prior art is difficult to effectively solve the occlusion and scale problems in facial recognition, resulting in low recognition efficiency and inability to meet real-time requirements.
Feature extraction is performed using positional spatial attention mechanisms in the backbone network and the correlation between features is captured by processing different regions of the image in parallel. A non-local attention mechanism is used for multi-scale fusion in the neck network to improve the model's ability to capture global information.
The ability of the face detection model to extract feature quality is improved, and the ability to capture global information is enhanced, thus improving the accuracy and efficiency of target detection, solving occlusion and scale problems, and meeting the requirements of real-time.
Smart Images

Figure CN119251897B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of deep learning, and in particular to a method for constructing a face detection model and a trajectory analysis method. Background Art
[0002] Face recognition is one of the most mature and widely used technologies in the field of artificial intelligence. The purpose of face recognition is to determine the identity of faces in pictures and videos. From face recognition unlocking and face recognition payment on ordinary mobile phones to face recognition control in the security field, etc., face recognition technology has a wide range of applications. Traditional machine learning algorithms mainly consist of three parts: suggestion box generation, feature engineering and classification. Therefore, traditional machine learning algorithms are feature-based algorithms, so they require a lot of expert experience from algorithm engineers to perform feature engineering and parameter adjustment, and the algorithm effect is not very good, especially in the field of face recognition. In the past, image algorithms were more about engineers using traditional image processing methods to extract a large number of features based on real scenes and expert experience, and then statistically learn the extracted features. In this way, the performance of the overall algorithm is very dependent on real scenes and expert experience. For unconstrained scenes such as faces, which have a huge number of categories and serious imbalance of samples in each category, the effect is not very good. Therefore, in recent years, with the great success of deep learning in image processing, face recognition technology has also been based on deep learning, and has achieved very good results.
[0003] In the deep learning face recognition system, the problem is divided into a target detection problem and a classification problem. The target detection problem is essentially a classification problem and a regression problem in deep learning. Therefore, with the successful application of convolutional neural networks in image classification, the effect of face recognition systems has been rapidly and greatly improved, and a large number of visual algorithm companies have been born, and face recognition has been applied to all aspects of social life. In deep learning, a complete face recognition system also includes four steps. The first step is called face detection algorithm, which is essentially a target detection algorithm. The second step is called face alignment, which is currently based on geometric alignment of key points and face alignment based on deep learning. The third step is feature representation. In deep learning, the idea of classification network is used to extract some feature layers in the classification network as feature representation of the face, and then the standard face image is processed in the same way. Finally, the overall face recognition system is completed through comparison query.
[0004] In addition to being used in scenarios such as face unlocking and face payment, face recognition can also be used to analyze the trajectories of pedestrians by performing face recognition on videos obtained by different surveillance cameras. In some key areas, such as schools, the activity range of some people can be analyzed to implement intelligent management and control. However, when performing face recognition through surveillance cameras, there are some occlusion and scale problems that cannot be solved. In order to solve the occlusion and scale problems, the existing technology often introduces some new network frameworks for training. However, the introduction of a new network structure is bound to increase the recognition time of the face, resulting in the inability to meet the real-time problems in practical applications.
[0005] In summary, how to improve the efficiency of face recognition algorithms and take into account occlusion and scale issues so that they can perform trajectory analysis on people is an issue that the existing technology urgently needs to solve. Summary of the invention
[0006] The embodiments of the present application provide a method for constructing a face detection model and a trajectory analysis method, which extracts features by using positional spatial attention in a backbone network, captures the association between features from multiple dimensions by processing different areas of a pedestrian image to be detected in parallel, improves the quality of extracted features without increasing the amount of computation, and performs multi-scale fusion in a neck network through a non-local attention mechanism, thereby improving the model's ability to capture global information and improving the efficiency of target detection accuracy.
[0007] In a first aspect, an embodiment of the present application provides a method for constructing a face detection model, the method comprising:
[0008] Constructing a backbone network, wherein the backbone network is trained to extract features from a pedestrian image to be detected to obtain a first backbone feature map, a second backbone feature map, a third backbone feature map, and a fourth backbone feature map with successively reduced image scales, wherein the pedestrian image to be detected is a pedestrian image that does not contain annotation information;
[0009] A neck network is constructed, wherein the neck network is trained to perform multi-scale fusion of the first backbone feature map, the second backbone feature map, the third backbone feature map and the fourth backbone feature map to obtain a first neck output, a second neck output, a third neck output and a fourth neck output, wherein the first backbone feature map, the second backbone feature map, the third backbone feature map and the fourth backbone feature map are upsampled and stacked step by step in order of scale from small to large to obtain a first stacking result, a second stacking result, a third stacking result and a fourth stacking result, the fourth stacking result is passed through a first neck non-local attention mechanism module to obtain a first neck attention result, the first neck attention result is convolved and output to obtain a first neck output, and the first neck The local attention result is then feature stacked with the second stacking result and input into the second neck non-local attention mechanism module to obtain a second neck attention result, the second neck attention result is convolved and output to obtain a second neck output, the second neck attention result is then feature stacked with the third stacking result and input into the third neck non-local attention mechanism module to obtain a third neck attention result, the third neck attention result is convolved and output to obtain a third neck output, the third neck attention result is then feature stacked with the fourth stacking result and input into the fourth neck non-local attention mechanism module to obtain a fourth neck attention result, the fourth neck attention result is convolved and output to obtain a fourth neck output;
[0010] Constructing a head network, wherein the head network is trained to predict the first neck output, the second neck output, the third neck output, and the fourth neck output to obtain a face detection result;
[0011] The face detection model includes a backbone network, a neck network and a head network. During the training process, the face detection model is trained using at least one pedestrian image with a face position marked as a training sample.
[0012] In a second aspect, an embodiment of the present application provides a trajectory analysis method, including:
[0013] Obtain the surveillance video stream, input the surveillance video stream into the trained pedestrian detection model to obtain the pedestrian detection result, input the pedestrian detection result into the face detection model to obtain the face detection result, and then input the face detection result into the constructed face recognition model to perform face recognition to obtain the face recognition result. The movement trajectory of each person is reproduced according to the face recognition results obtained at different locations and different times.
[0014] In a third aspect, an embodiment of the present application provides a device for constructing a face detection model, including:
[0015] A backbone network construction device, used to construct a backbone network, wherein the backbone network is trained to extract features of a pedestrian image to be detected to obtain a first backbone feature map, a second backbone feature map, a third backbone feature map, and a fourth backbone feature map with successively reduced image scales, wherein the pedestrian image to be detected is a pedestrian image that does not contain annotation information;
[0016] A neck network construction device is used to construct a neck network, wherein the neck network is trained to perform multi-scale fusion of a first backbone feature map, a second backbone feature map, a third backbone feature map and a fourth backbone feature map to obtain a first neck output, a second neck output, a third neck output and a fourth neck output, wherein the first backbone feature map, the second backbone feature map, the third backbone feature map and the fourth backbone feature map are upsampled and stacked step by step in order of scale from small to large to obtain a first stacking result, a second stacking result, a third stacking result and a fourth stacking result, the fourth stacking result is passed through a first neck non-local attention mechanism module to obtain a first neck attention result, and the first neck attention result is convolved and output to obtain a first neck output , the first neck attention result is feature stacked with the second stacking result and input into the second neck non-local attention mechanism module to obtain a second neck attention result, the second neck attention result is convolved and output to obtain a second neck output, the second neck attention result is feature stacked with the third stacking result and input into the third neck non-local attention mechanism module to obtain a third neck attention result, the third neck attention result is convolved and output to obtain a third neck output, the third neck attention result is feature stacked with the fourth stacking result and input into the fourth neck non-local attention mechanism module to obtain a fourth neck attention result, the fourth neck attention result is convolved and output to obtain a fourth neck output;
[0017] A head network construction device is used to construct a head network, wherein the head network is trained to predict a first neck output, a second neck output, a third neck output, and a fourth neck output to obtain a face detection result; wherein the face detection model includes a backbone network, a neck network, and a head network, and the face detection model is trained using at least one pedestrian image with a face position marked as a training sample during the training process.
[0018] The main contributions and innovations of the present invention are as follows:
[0019] In the embodiment of the present application, a position space attention enhancement module with a multi-head attention mechanism and a feedforward neural network is set in the backbone network. The multi-head attention mechanism captures the subtle correlation between features from multiple dimensions by processing different areas of the pedestrian image to be detected in parallel, thereby achieving a comprehensive and accurate understanding of the spatial information of the pedestrian image to be detected, while the feedforward neural network further maps the input features to a higher-dimensional feature space, which not only captures the complex nonlinear relationship between features, but also gives the model the ability to learn more diverse and deep feature representations; when performing context extraction, this solution extracts features of different scales through the multi-core context anchored attention module in the backbone network, and effectively captures the background information in the pedestrian image to be detected, and introduces horizontal and vertical coordinate convolutions to capture long-distance context information, so that more accurate detection can be performed when facing obstructed pedestrian faces; this solution performs multi-scale fusion through a non-local attention mechanism in the neck network, improves the model's ability to capture global information, and thus improves the efficiency of target detection accuracy.
[0020] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0022] Figure 1 is a flow chart of a method for constructing a face detection model according to an embodiment of the present application;
[0023] Figure 2 is a structural schematic diagram of a face detection model according to an embodiment of the present application;
[0024] Figure 3 is a structural schematic diagram of a stem module according to an embodiment of the present application;
[0025] Figure 4 is a structural schematic diagram of a channel pixel enhancement module according to an embodiment of the present application;
[0026] Figure 5 is a structural schematic diagram of a residual bottleneck block according to an embodiment of the present application;
[0027] Figure 6 is a schematic diagram of the structure of a residual unit according to an embodiment of the present application;
[0028] Figure 7is a structural schematic diagram of a position space attention enhancement module according to an embodiment of the present application;
[0029] Figure 8 is a schematic diagram of the structure of a position space attention enhancement layer according to an embodiment of the present application;
[0030] Fig. 9 is a structural diagram of a multi-core context anchoring module according to an embodiment of the present application;
[0031] Fig.10 is a structural diagram of a non-local attention mechanism module according to an embodiment of the present application;
[0032] Fig.11 is a structural schematic diagram of a face recognition model according to an embodiment of the present application;
[0033] Fig.12 is a schematic diagram of performing trajectory reproduction according to an embodiment of the present application;
[0034] Fig.13 is a structural block diagram of a device for constructing a face detection model according to an embodiment of the present application;
[0035] Fig.14 It is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0036] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with one or more embodiments of this specification. Instead, they are merely examples of devices and methods consistent with some aspects of one or more embodiments of this specification as detailed in the appended claims.
[0037] It should be noted that: in other embodiments, the steps of the corresponding method are not necessarily performed in the order shown and described in this specification. In some other embodiments, the steps included in the method may be more or less than those described in this specification. In addition, a single step described in this specification may be decomposed into multiple steps for description in other embodiments; and multiple steps described in this specification may be combined into a single step for description in other embodiments.
[0038] Embodiment 1
[0039] The embodiment of the present application provides a method for constructing a face detection model, which uses positional spatial attention in the backbone network to extract features, and processes different areas of the pedestrian image to be detected in parallel to capture the association between features from multiple dimensions, thereby improving the quality of extracted features without increasing the amount of calculation, and performing multi-scale fusion in the neck network through a non-local attention mechanism, thereby improving the model's ability to capture global information, thereby improving the accuracy and efficiency of target detection. Specifically, reference Figure 1 , the method comprising:
[0040] Constructing a backbone network, wherein the backbone network is trained to extract features from a pedestrian image to be detected to obtain a first backbone feature map, a second backbone feature map, a third backbone feature map, and a fourth backbone feature map with successively reduced image scales, wherein the pedestrian image to be detected is a pedestrian image that does not contain annotation information;
[0041] A neck network is constructed, wherein the neck network is trained to perform multi-scale fusion of the first backbone feature map, the second backbone feature map, the third backbone feature map and the fourth backbone feature map to obtain a first neck output, a second neck output, a third neck output and a fourth neck output, wherein the first backbone feature map, the second backbone feature map, the third backbone feature map and the fourth backbone feature map are upsampled and stacked step by step in order of scale from small to large to obtain a first stacking result, a second stacking result, a third stacking result and a fourth stacking result, the fourth stacking result is passed through a first neck non-local attention mechanism module to obtain a first neck attention result, the first neck attention result is convolved and output to obtain a first neck output, and the first neck The local attention result is then feature stacked with the second stacking result and input into the second neck non-local attention mechanism module to obtain a second neck attention result, the second neck attention result is convolved and output to obtain a second neck output, the second neck attention result is then feature stacked with the third stacking result and input into the third neck non-local attention mechanism module to obtain a third neck attention result, the third neck attention result is convolved and output to obtain a third neck output, the third neck attention result is then feature stacked with the fourth stacking result and input into the fourth neck non-local attention mechanism module to obtain a fourth neck attention result, the fourth neck attention result is convolved and output to obtain a fourth neck output;
[0042] Constructing a head network, wherein the head network is trained to predict the first neck output, the second neck output, the third neck output, and the fourth neck output to obtain a face detection result;
[0043] The face detection model includes a backbone network, a neck network and a head network. During the training process, the face detection model is trained using at least one pedestrian image with a face position marked as a training sample.
[0044] In this solution, the structure diagram of the face detection model is as follows Figure 2 As shown by Figure 2 It can be seen that the backbone network of this solution is formed by connecting multiple different modules in series. The following describes each module in the backbone network one by one.
[0045] The backbone network includes a stem module, two channel pixel enhancement modules, four backbone convolution modules, three multi-core context anchoring modules and a position space attention enhancement module. The pedestrian image to be detected passes through the stem module, the first channel pixel enhancement module, the first backbone convolution module and the second channel pixel enhancement module in the backbone network in sequence to obtain a first backbone feature map. The first backbone feature map then passes through the second convolution module and the first multi-core context anchoring module in sequence to obtain a second backbone feature map. The second backbone feature map passes through the third convolution module and the second multi-core context anchoring module in sequence to obtain a third backbone feature map. The third backbone feature map passes through the fourth convolution module, the third multi-core context anchoring module and the position space attention enhancement module in sequence to obtain a fourth backbone feature map.
[0046] Specifically, the scales of the first backbone feature map, the second backbone feature map, the third backbone feature map and the fourth backbone feature map are reduced successively. For example, if the size of the input pedestrian image to be detected is H×W, the size of the first backbone feature map is H / 8×H / 8, the size of the second backbone feature map is H / 16×H / 16, the size of the third backbone feature map is H / 32×H / 32, and the size of the fourth backbone feature map is H / 64×H / 64.
[0047] Furthermore, the structure of the stem module is as follows Figure 3 As shown, the stem module is composed of four series-connected convolution modules, wherein the output of the first convolution module is subjected to maximum pooling to obtain a stem pooling result, and the pooling result is feature stacked with the output of the third convolution module and then input into the fourth convolution module for output. In the stem module, the first and third convolution modules use 3*3 convolution, and the second and fourth convolution modules use 1*1 convolution.
[0048] Specifically, the convolution module in the stem module consists of a convolution layer, a batch normalization layer, and an activation function. Batch normalization is a commonly used technique in deep learning to accelerate the training of neural networks. Batch Normalization makes the neural network more stable during training by standardizing each small batch of data, allowing a higher learning rate to be used and reducing the reliance on initialization weights. The basic idea of Batch Normalization is to standardize each small batch of data so that the mean of each feature is 0 and the variance is 1, and then adjust the distribution of the data through a learnable scaling factor and translation factor, making the neural network easier to train.
[0049] Specifically, this solution not only improves the generalization ability of the entire network through the stem module, but also reduces the complexity of calculation without reducing the performance, so it can save computing resources and improve the efficiency of face detection.
[0050] In some embodiments, the first channel pixel enhancement module has the same structure as the second channel pixel enhancement module, and the structure is as follows: Figure 4 As shown, it is composed of a first channel convolution module, a channel feature separation module, a plurality of residual bottleneck blocks connected in series, a channel feature stacking layer and a second channel convolution module, wherein the input of the channel pixel enhancement module is processed by the first channel convolution module and then averagely split in the channel dimension by the channel feature separation module to obtain a first channel separation result and a second channel separation result, and the second channel separation result is input into a plurality of residual bottleneck blocks connected in series, and the first channel separation result, the second channel separation result and the output of each residual bottleneck block are feature stacked in the channel feature stacking layer to obtain a channel feature stacking result, and finally the second channel convolution module outputs the channel feature stacking result.
[0051] Specifically, the channel pixel enhancement module can fuse feature maps of different scales to better process the details and contextual information in the image to improve the accuracy of target detection, especially to improve the recognition effect of faces in the image when there is partial occlusion. The channel pixel enhancement module will obtain richer gradient flow information while ensuring lightweight. Among them, the channel feature stacking layer forms a deeper feature map by splicing and stacking the first separation result, the second separation result and the output of each residual bottleneck block according to the dimension of the channel, thereby retaining more spatial information and semantic information and improving the performance of target detection.
[0052] In some specific embodiments, the number of residual bottleneck blocks in the channel pixel enhancement module is set according to actual conditions to make the model have better performance. The structure of the residual bottleneck block is as follows: Figure 5As shown in the figure, the residual bottleneck block is divided into two branches, one of which is composed of a convolution module and multiple residual units, and the other is composed of only one convolution module. The outputs of the two branches are feature stacked and output by a convolution module.
[0053] Furthermore, two convolutional modules connected in series are used in the residual unit for residual connection. The specific structure of the residual unit is as follows: Figure 6 shown.
[0054] Specifically, the main function of the residual bottleneck block is to perform a convolution operation on the input feature map to extract higher-level features, thereby improving the performance of the face detection model without increasing the amount of computation.
[0055] In some embodiments, the structure of the position space attention enhancement module is as follows: Figure 7 As shown, the position space attention enhancement module is composed of a first position convolution module, a position feature separation module, a plurality of serial position space attention enhancement layers, a position feature stacking layer and a second position convolution module, wherein the input of the position space attention enhancement module is processed by the first position convolution module and then separated in the channel dimension by the position feature separation module to obtain a first position separation result and a second position separation result, and the second position separation result is input into a plurality of serial position space attention enhancement layers for attention calculation, and the first position separation result and the attention calculation result of each position space attention enhancement module are feature stacked in the position feature stacking layer to obtain a position feature stacking result, and finally the second position convolution module outputs the position feature stacking result.
[0056] Specifically, this scheme uses multiple serially connected position space attention enhancement layers to form a multi-head attention mechanism to enhance the feature extraction capability, thereby increasing the ability of the face recognition model to capture important features.
[0057] Furthermore, the structure of the position space attention enhancement layer is as follows Figure 8 As shown, in the position space attention enhancement module of this scheme, the attention calculation results of each position space attention enhancement layer are mapped to a higher dimensional space through a feedforward neural network, and a residual structure is added to the feedforward neural network.
[0058] Specifically, the feature extraction capability of the face recognition model is further enhanced by enhancing the feedforward neural network in the position-space attention module, and the residual structure can be selectively added to optimize the gradient propagation and network training effects, thereby capturing the complex nonlinear relationship of the input features and allowing the face recognition model to learn richer feature representations.
[0059] In some embodiments, the first multi-core context anchoring module, the second multi-core context anchoring module, and the third multi-core context anchoring module have the same structure, and their structures are as follows: Fig. 9 As shown, the input of the multi-core context anchoring module is feature separated to obtain a first anchor separation result and a second anchor separation result, and the first anchor separation result is respectively input into the parallel depth convolution branch and the horizontal and vertical coordinate convolution branch, and in the parallel depth convolution branch, the first anchor separation result is firstly subjected to a 3*3 depth-separable convolution to obtain a first depth-separable convolution result, and the first depth-separable convolution result is input into a plurality of depth-separable convolution layers of different sizes connected in parallel, and then the output result of each depth-separable convolution layer is concatenated with the first depth-separable convolution result and then convolved point by point to obtain a parallel depth convolution result, and in the horizontal and vertical coordinate convolution branch, the first anchor separation result is firstly subjected to average pooling and point-by-point convolution to obtain To the first processing result, the first processing result is successively passed through the horizontal coordinate convolution layer and the vertical coordinate convolution layer to obtain the second processing result, the second processing result is output through point-by-point convolution and activation function to obtain the horizontal and vertical coordinate convolution results, the parallel depth convolution result and the horizontal and vertical coordinate convolution results are first feature multiplied to obtain the multiplication result, the multiplication result and the parallel depth convolution result are feature added and then point-by-point convolution is performed to obtain the first branch result, wherein the horizontal coordinate convolution layer is a depth-separable convolution of 1*set size, the vertical coordinate convolution layer is a depth-separable convolution of set size*1, the second anchoring result is passed through the feedforward neural network to obtain the second branch result, and the first branch result and the second branch result are feature stacked and convolved for output.
[0060] In some specific embodiments, the horizontal coordinate convolution layer of the first multi-core context anchoring module of this scheme is a depth-separable convolution of size 1*11, and the vertical coordinate convolution layer is a depth-separable convolution of size 11*1, the horizontal coordinate convolution layer of the second multi-core context anchoring module is a depth-separable convolution of size 1*13, and the vertical coordinate convolution layer is a depth-separable convolution of size 13*1, and the horizontal coordinate convolution layer of the third multi-core context anchoring module is a depth-separable convolution of size 1*15, and the vertical coordinate convolution layer is a depth-separable convolution of size 15*1.
[0061] Specifically, the multi-core context anchoring module in this scheme extracts target features of different scales by using parallel depthwise separable convolutions of different sizes and effectively captures local background information. At the same time, this scheme constructs horizontal coordinate convolution layers and vertical coordinate convolution layers in the multi-core context anchoring module to capture long-distance context information, enhances the relationship between remote pixels, and improves training efficiency.
[0062] In some specific embodiments, Figure 2The structure of the neck network can be seen. In this scheme, the fourth backbone feature map is directly processed by the convolution module to obtain the first stacking result. The first stacking result is up-sampled and feature-stacked with the third backbone feature map, and then passed through the non-local attention mechanism module and the convolution module to obtain the second stacking result; the second stacking result is up-sampled and feature-stacked with the second backbone feature map, and then passed through the non-local attention mechanism module and the convolution module to obtain the third stacking result; the third stacking result is up-sampled and feature-stacked with the first backbone feature map to obtain the fourth stacking result.
[0063] Specifically, the above-mentioned non-local attention mechanism module has the same structure as the first neck non-local attention mechanism module, the second neck non-local attention mechanism module, the third neck non-local attention mechanism module and the fourth neck non-local attention mechanism module, and the structures of these modules will be explained below.
[0064] Specifically, the neck network in this scheme improves the target detection performance of the head network by fusing a shallow feature map with higher resolution but less semantic information with a deep feature map with lower resolution but richer semantic information.
[0065] In some specific embodiments, before “feature stacking of the first neck attention result and the second stacking result”, the first neck attention result is processed using a convolution module. Similarly, the second neck attention result is processed using a convolution module and then feature stacked with the third stacking result. The third neck attention result is processed using a convolution module and then feature stacked with the fourth stacking result.
[0066] In this solution, the structures of the first neck non-local attention mechanism module, the second neck non-local attention mechanism module, the third neck non-local attention mechanism module and the fourth neck non-local attention mechanism module are the same, and their structures are as follows: Fig.10 As shown, a branch, b branch and c branch are constructed. Branch a performs point-by-point convolution and feature reshaping on the input of the neck non-local attention mechanism module to obtain the a branch result. Branch b performs point-by-point convolution and feature reshaping on the input of the neck non-local attention mechanism module to obtain the b branch result. Branch c performs point-by-point convolution and feature reshaping on the input of the neck non-local attention mechanism module to obtain the c branch result. The a branch result is matrix multiplied with the b branch result to obtain a first multiplication result. The first multiplication result is matrix multiplied with the c branch result to obtain a second multiplication result. The second multiplication result is first feature reshaped, then point-by-point convolution is performed, and then matrix addition is performed with the input of the neck non-local attention mechanism module for output.
[0067] Specifically, the non-local attention mechanism module can effectively capture the relationship between all positions in the input feature map, and is particularly suitable for processing tasks that require global context information. Compared with traditional convolutional neural networks, non-local blocks are no longer limited to the features of local neighborhoods. For example, the input size of the non-local attention mechanism module is N*H*W*C, where N represents the batch, H and W are the spatial dimensions of the feature map, and C is the number of channels. Branch a applies point-by-point convolution to the input features, reducing the number of channels to C / 2, and the output size is N*H*W*C / 2; the input features are reduced in dimension, while the spatial dimension remains unchanged, thereby reducing the amount of computation; this step is similar to the query vector (query) in the traditional attention mechanism; branch b also performs point-by-point convolution on the input features, and the output size is the same as branch a, which is N*H*W*C / 2; significance: the reduced-dimensional features are used to calculate the similarity in the spatial dimension; this step is similar to generating a key vector (key) for similarity calculation with the query vector; branch c undergoes point-by-point convolution, and the output size is N*H*W*C / 2. Generate a reduced-dimensional input feature representation for feature aggregation after weighting in the attention mechanism; this step is equivalent to a value vector (value), which carries the information of the input feature, and will be multiplied by the weight matrix to generate the output. The a branch result is matrix-multiplied with the b branch result, and the similarity relationship between all positions is calculated and then normalized by softmax to obtain the first multiplication result of size NHW*NHW. The first multiplication result represents the similarity between each position in the input feature map. The first multiplication result is an attention weight matrix, and then the first multiplication result is feature-multiplied with the c branch result to obtain the second multiplication result. The second multiplication result is a weighted global feature representation. Finally, the number of channels of the second multiplication result is restored to the original number of channels through feature reshaping and point-by-point convolution, and then it is residually connected with the original input feature for output. The residual structure can retain the original feature information and superimpose the globally weighted features, so as to retain local details and combine global information.
[0068] In this solution, the head network includes 4 detection heads for predicting the first neck output, the second neck output, the third neck output and the fourth neck output, respectively. Each detection head detects the face based on the facial key points, and constructs the key point loss to combine the detection loss as the loss function of the face detection model. The formula is as follows:
[0069]
[0070]
[0071] Where wing is the key point loss, ω is a positive number used to limit the range of the nonlinear part to the interval [-ω, ω], ϵ is the curvature used to constrain the nonlinear region, and is a constant, and the nonlinear part of the keypoint loss simply uses ln(x) in and scale it by W along the X and Y axes; additionally apply a translation along the Y axis so that wing(0)=0, and impose continuity on the loss function, is the general target detection loss, is the weight of the key point loss.
[0072] In some embodiments, the final face detection result is obtained by a maximum value suppression method.
[0073] In some specific embodiments, the hyperparameter settings for training the face detection model: Dynamically adjust the hyperparameters, learning rate scheduling: Warm-up: Use a lower learning rate at the beginning of training, and then gradually increase it to a predetermined value, which can help the model converge faster. Plateau-based: Adjust the learning rate according to the change in validation loss, and reduce the learning rate when the validation loss stagnates. Cycle-based: Use a periodic learning rate adjustment strategy, such as Cyclic Learning Rate (CLR) or One Cycle Policy. Momentum adjustment: Adjust the momentum value at different stages of training, such as using a lower momentum at the beginning of training and gradually increasing the momentum value as training progresses.
[0074] Relationship between hyperparameters, learning rate and batch size: There is a correlation between learning rate and batch size, and usually the learning rate needs to be adjusted accordingly when the batch size increases. You can use the Linear Scaling Rule, that is, every time the batch size doubles, the learning rate also increases by the same multiple. Regularization and learning rate: A higher learning rate may cause the model to be more prone to overfitting, and appropriate regularization (such as weight decay) can help alleviate this problem.
[0075] Monitoring and adjustment during training, monitoring indicators: Regularly monitor the loss function value, accuracy, recall rate and other indicators during training, and draw charts to intuitively understand the training status of the model. Use TensorBoard or similar tools to visualize various indicators during training. Adjustment time: Adjust hyperparameters in a timely manner according to monitoring results. If you find that the training curve is flat and not decreasing, you may need to reduce the learning rate; if the training loss is small but the validation loss is large, you may need to increase regularization.
[0076] Advanced optimization strategies, second-order optimization methods: Use second-order optimization methods (such as AdamW, Nadam, Adadelta, etc.), which can provide better convergence speed and stability in some cases. Pre-training and transfer learning: Using pre-trained models for transfer learning can significantly reduce the workload of hyperparameter adjustment and speed up the training process. In transfer learning, you can first freeze some layers of the pre-trained model, train only the newly added layers, and then unfreeze and fine-tune the pre-trained layers.
[0077] Use tool assistance, hyperparameter search tools: Use Bayesian Optimization, Evolutionary Algorithms and other methods to automatically search for the best hyperparameter combination. Use libraries such as Hyperopt and Optuna to simplify the hyperparameter search process. Distributed training: In the case of large-scale data sets and complex models, using distributed training can significantly shorten the training time. When distributing training, you need to pay attention to adjusting the learning rate and batch size to adapt to the collaborative work of multiple GPUs or servers.
[0078] During the training process, it is necessary to perform data enhancement on the training samples to obtain better training results. The data enhancement methods are as follows: Geometric transformation: Translation: Move the image horizontally. Perspective Transformation: Simulate the effect of observing the same object from different angles. Blur and sharpen: Apply Gaussian blur or average blur filter. Use sharpening filter to enhance the edge of the image. Noise addition: Add random noise to the image, such as Gaussian noise or salt and pepper noise. Simulate the change of image quality under different conditions. Occlusion: Randomly occlude some areas in the image to simulate the situation where some information is missing. Super-resolution / downsampling: Downsample the image and then restore it to the original resolution to simulate the image effects at different resolutions. Hybrid technology: CutMix: Randomly select an area from one image and replace it with the corresponding area in another image. MixUp: Linearly interpolate two input samples and their labels. Mosaic: Splice multiple images into a larger image and then cut out new images from it. GANs generation: Generate new samples using generative adversarial networks (GANs) to expand the data set. Variants such as CycleGAN can be used for unsupervised domain adaptation.
[0079] In some specific embodiments, the face detection model is iterated in the following manner during the training process:
[0080] 1. Evaluate the current model performance
[0081] Performance metrics: Define the main metrics for evaluating model performance, such as accuracy, recall, F1 score, AUC, etc. Baseline comparison: Compare the performance of the current model with the baseline model to determine the strengths and weaknesses of the current model. Error analysis: Analyze the samples where the model predicts errors and find out the causes of the errors, especially those recurring error patterns.
[0082] 2. Lock in optimization goals
[0083] Determine optimization goals: Determine the main direction of optimization based on application requirements, such as improving accuracy, reducing false positives, increasing recall, etc. Prioritization: List possible improvement directions and sort them by priority, solving the most important problems first.
[0084] 3. Collect and preprocess data
[0085] Data enhancement: Increase the diversity of the data set and improve the generalization ability of the model through data enhancement technology. Data cleaning: Remove outliers and duplicate data to ensure data quality. Feature engineering: Optimize input features through feature selection, feature construction, etc.
[0086] 4. Adjust the model structure
[0087] Network architecture adjustment: According to the model performance evaluation results, adjust the network architecture, such as adding or reducing convolutional layers, introducing residual connections, etc. Hyperparameter adjustment: Optimize hyperparameters such as learning rate, batch size, optimizer parameters, etc. Regularization method: Adjust regularization parameters, such as L1 / L2 regularization coefficient, Dropout ratio, etc.
[0088] 5. Retrain the model
[0089] Initial conditions: Adjust the model initialization parameters according to the results of the previous round of optimization. Training strategy: Use learning rate scheduling, early stopping and other strategies to optimize the training process. Validation set monitoring: Use the validation set to monitor overfitting during training to ensure the generalization ability of the model.
[0090] 6. Evaluate the new model
[0091] Performance testing: Evaluate the performance of the new model on the test set and compare it with the old model. Result analysis: Analyze the improvements of the new model over the old model to determine whether the expected optimization goal has been achieved.
[0092] 7. Deployment and Monitoring
[0093] Model deployment: Deploy the optimized model to the production environment. Continuous monitoring: Continuously monitor the performance of the model in actual applications and collect feedback data. A / B testing: If possible, conduct A / B testing to evaluate the actual effect of the new model.
[0094] 8. Iteration loop
[0095] Iteration: Continue to the next round of optimization iterations based on the performance of the model in actual applications. Documentation: Record the improvement measures, results, and lessons learned of each iteration for easy review and summary.
[0096] In some specific embodiments, the image of the pedestrian to be detected is acquired by detecting and acquiring it in a surveillance video stream such as a surveillance camera through a constructed pedestrian detection model. The structure and training method of the pedestrian detection model are exactly the same as those of the face detection model except for the head network. Only the training samples used are different. The training samples of the pedestrian detection model are multiple video streams acquired by the camera, so this solution will no longer elaborate on the structure and training method of the pedestrian detection model.
[0097] Furthermore, the detection head in the head network of the pedestrian detection model consists of 4 3*3 convolutions and 2 1*1 convolutions. The WIOU loss function is added to the regression branch of the head network of the pedestrian detection model. The regression head needs to calculate the position offset between the predicted box and the real box, and then send the offset to the regression head for loss calculation, and then output a four-dimensional vector, which represents the upper left corner coordinates x, y and lower right corner coordinates x, y of the target box respectively; the classification head performs pooling and convolution operations on the region of interest for each extracted candidate box to obtain a classifier output tensor. The value at each position represents the probability that the candidate box belongs to each category, and finally the final detection result is screened out by maximum value suppression.
[0098] In some embodiments, the training samples of the pedestrian detection network collect data from multiple sources, including public data sets (such as COCO, Cityscapes, KITTI, etc.), self-owned data sets (such as campus surveillance videos), data captured by Internet crawlers, etc. And ensure that the annotation standards of all data sources are consistent, such as the size and position of the pedestrian box. It is also necessary to pay attention to the class distribution in the data set, ensure that the ratio of positive and negative samples is reasonable, and avoid the training model being biased towards a certain class. When annotating, use professional annotation tools (such as LabelMe, VGG Image Annotator (VIA), etc.) to manually annotate to ensure the annotation accuracy, or annotate by combining automatic detection algorithms with manual verification to improve efficiency. The training sample data set is randomly divided into a training set, a validation set, and a test set according to a certain ratio (such as 80% training, 10% validation, and 10% testing). Data cleaning and removal of duplicates: Clear duplicate images or annotations in the data set, and filter out data with obvious incorrect annotations, such as cases where the pedestrian box obviously deviates from the actual position.
[0099] Embodiment 2
[0100] A trajectory analysis method, comprising:
[0101] Obtain a surveillance video stream, input the surveillance video stream into a trained pedestrian detection model to obtain a pedestrian detection result, input the pedestrian detection result into the face detection model constructed in Example 1 to obtain a face detection result, and then input the face detection result into a constructed face recognition model to perform face recognition to obtain a face recognition result, and reproduce the movement trajectory of each person based on the face recognition results obtained at different locations and at different times.
[0102] In some specific embodiments, the pedestrian detection model can be trained using any deep learning architecture. In this solution, the structure and training method of the pedestrian detection model are exactly the same as those of the face detection model except for the head network. Only the training samples used are different. The training samples of the pedestrian detection model are multiple video streams obtained by the camera, so this solution will no longer elaborate on the structure and training method of the pedestrian detection model.
[0103] In some embodiments, the structure of the face recognition model is as follows: Fig.11 As shown, face recognition is performed through multiple serially connected convolution structures and residual structures.
[0104] Furthermore, the face recognition model uses Softmax loss plus Center loss as a loss function during training.
[0105] In some specific embodiments, Fig.12 This is a schematic diagram of trajectory reproduction for this solution. A person is identified by face recognition, for example, Zhang San, and Zhang San is saved as a video with a length of 15 seconds. If you want to obtain Zhang San's movement trajectory, the system automatically reproduces the trajectory based on time and location.
[0106] Therefore, based on all the contents of this plan, the entire process of this plan is as follows:
[0107] Initialization phase: First, the interface receives a request from the front end, including necessary parameters such as the camera address, the selected algorithm type, and the callback address.
[0108] Video stream capture: After receiving the parameters, the interface starts a new process to continuously capture image frames in the video stream from the specified camera address. These image frames will be temporarily stored in the memory database Redis and trigger the notification mechanism of the listener at the same time.
[0109] Image frame processing and algorithm instantiation: After receiving the notification, the listener reads the image frame from Redis and creates the corresponding algorithm instance. Subsequently, the algorithm instance starts to analyze and process the acquired image frame.
[0110] Image analysis and result storage: The algorithm instance processes the image frame according to the preset business logic, including but not limited to tasks such as person recognition and trajectory tracking. After the analysis is completed, the results will be stored back to the Redis database and the listening program will be notified again.
[0111] Result feedback: Finally, after receiving the notification of result update, the listening program reads the analysis results from Redis and returns the results to the front-end business interface through a pre-defined callback mechanism, completing a complete processing flow.
[0112] Error handling and logging: In the entire process, an exception handling mechanism needs to be added to deal with network fluctuations, camera failures, etc. At the same time, detailed log information should be recorded for each key step to facilitate subsequent troubleshooting and performance optimization.
[0113] Resource management and optimization: Considering that video stream processing requires a lot of computing resources, a reasonable resource allocation strategy should be considered during the design, such as using load balancing technology to distribute the processing load, or dynamically adjusting the priority of algorithm execution according to actual conditions.
[0114] Security considerations: Ensure the security of image frames during data transmission, and use encrypted communication protocols to protect data from illegal interception. At the same time, corresponding access control policies are also required for temporary data stored in Redis.
[0115] Embodiment 3
[0116] Based on the same idea, refer to Fig.13 , the present application also proposes a device for constructing a face detection model, including:
[0117] A backbone network construction device, used to construct a backbone network, wherein the backbone network is trained to extract features of a pedestrian image to be detected to obtain a first backbone feature map, a second backbone feature map, a third backbone feature map, and a fourth backbone feature map with successively reduced image scales, wherein the pedestrian image to be detected is a pedestrian image that does not contain annotation information;
[0118] A neck network construction device is used to construct a neck network, wherein the neck network is trained to perform multi-scale fusion of a first backbone feature map, a second backbone feature map, a third backbone feature map and a fourth backbone feature map to obtain a first neck output, a second neck output, a third neck output and a fourth neck output, wherein the first backbone feature map, the second backbone feature map, the third backbone feature map and the fourth backbone feature map are upsampled and stacked step by step in order of scale from small to large to obtain a first stacking result, a second stacking result, a third stacking result and a fourth stacking result, the fourth stacking result is passed through a first neck non-local attention mechanism module to obtain a first neck attention result, and the first neck attention result is convolved and output to obtain a first neck output , the first neck attention result is feature stacked with the second stacking result and input into the second neck non-local attention mechanism module to obtain a second neck attention result, the second neck attention result is convolved and output to obtain a second neck output, the second neck attention result is feature stacked with the third stacking result and input into the third neck non-local attention mechanism module to obtain a third neck attention result, the third neck attention result is convolved and output to obtain a third neck output, the third neck attention result is feature stacked with the fourth stacking result and input into the fourth neck non-local attention mechanism module to obtain a fourth neck attention result, the fourth neck attention result is convolved and output to obtain a fourth neck output;
[0119] A head network construction device is used to construct a head network, wherein the head network is trained to predict a first neck output, a second neck output, a third neck output, and a fourth neck output to obtain a face detection result; wherein the face detection model includes a backbone network, a neck network, and a head network, and the face detection model is trained using at least one pedestrian image with a face position marked as a training sample during the training process.
[0120] Embodiment 4
[0121] This embodiment also provides an electronic device, referring to Fig.14 , comprises a memory 404 and a processor 402, wherein the memory 404 stores a computer program, and the processor 402 is configured to run the computer program to execute the steps in any of the above method embodiments.
[0122] Specifically, the processor 402 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0123] Among them, the memory 404 may include a large capacity memory 404 for data or instructions. For example, but not limitation, the memory 404 may include a hard disk drive (HDD), a floppy disk drive, a solid state drive (SSD), a flash memory, an optical disk, a magneto-optical disk, a tape, or a universal serial bus (USB) drive, or a combination of two or more of these. In appropriate cases, the memory 404 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 404 may be inside or outside the data processing device. In a specific embodiment, the memory 404 is a non-volatile memory. In a specific embodiment, the memory 404 includes a read-only memory (ROM) and a random access memory (RAM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (Programmable Read-Only Memory, PROM for short), an erasable PROM (Erasable Programmable Read-Only Memory, EPROM for short), an electrically erasable PROM (Electrically Erasable Programmable Read-Only Memory, EEPROM for short), an electrically alterable ROM (Electrically Alterable Read-Only Memory, EAROM for short) or a flash memory (FLASH) or a combination of two or more of these. In appropriate circumstances, the RAM may be a static random access memory (SRAM) or a dynamic random access memory (DRAM), wherein the DRAM may be a fast page mode dynamic random access memory 404 (FPMDRAM), an extended data output dynamic random access memory (EDODRAM), a synchronous dynamic random access memory (SDRAM), etc.
[0124] The memory 404 may be used to store or cache various data files required for processing and / or communication, as well as possible computer program instructions executed by the processor 402 .
[0125] The processor 402 reads and executes computer program instructions stored in the memory 404 to implement any one of the face detection model construction methods and trajectory analysis methods in the above embodiments.
[0126] Optionally, the electronic device may further include a transmission device 406 and an input / output device 408 , wherein the transmission device 406 is connected to the processor 402 , and the input / output device 408 is connected to the processor 402 .
[0127] The transmission device 406 can be used to receive or send data via a network. Specific examples of the above-mentioned network may include a wired or wireless network provided by a communication provider of the electronic device. In one example, the transmission device includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 406 can be a radio frequency (Radio Frequency, referred to as RF) module, which is used to communicate with the Internet wirelessly.
[0128] The input and output device 408 is used to input or output information. In this embodiment, the input information may be training samples, images of pedestrians to be detected, etc., and the output information may be face detection results, etc.
[0129] Optionally, in this embodiment, the processor 402 may be configured to perform the following steps through a computer program:
[0130] Constructing a backbone network, wherein the backbone network is trained to extract features from a pedestrian image to be detected to obtain a first backbone feature map, a second backbone feature map, a third backbone feature map, and a fourth backbone feature map with successively reduced image scales, wherein the pedestrian image to be detected is a pedestrian image that does not contain annotation information;
[0131] A neck network is constructed, wherein the neck network is trained to perform multi-scale fusion of the first backbone feature map, the second backbone feature map, the third backbone feature map and the fourth backbone feature map to obtain a first neck output, a second neck output, a third neck output and a fourth neck output, wherein the first backbone feature map, the second backbone feature map, the third backbone feature map and the fourth backbone feature map are upsampled and stacked step by step in order of scale from small to large to obtain a first stacking result, a second stacking result, a third stacking result and a fourth stacking result, the fourth stacking result is passed through a first neck non-local attention mechanism module to obtain a first neck attention result, the first neck attention result is convolved and output to obtain a first neck output, and the first neck The local attention result is then feature stacked with the second stacking result and input into the second neck non-local attention mechanism module to obtain a second neck attention result, the second neck attention result is convolved and output to obtain a second neck output, the second neck attention result is then feature stacked with the third stacking result and input into the third neck non-local attention mechanism module to obtain a third neck attention result, the third neck attention result is convolved and output to obtain a third neck output, the third neck attention result is then feature stacked with the fourth stacking result and input into the fourth neck non-local attention mechanism module to obtain a fourth neck attention result, the fourth neck attention result is convolved and output to obtain a fourth neck output;
[0132] Constructing a head network, wherein the head network is trained to predict the first neck output, the second neck output, the third neck output, and the fourth neck output to obtain a face detection result;
[0133] The face detection model includes a backbone network, a neck network and a head network. During the training process, the face detection model is trained using at least one pedestrian image with a face position marked as a training sample.
[0134] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.
[0135] In general, various embodiments may be implemented in hardware or dedicated circuits, software, logic, or any combination thereof. Some aspects of the invention may be implemented in hardware, while other aspects may be implemented in firmware or software executed by a controller, microprocessor, or other computing device, but the invention is not limited thereto. Although various aspects of the invention may be shown and described as block diagrams, flow charts, or using some other graphical representation, it should be understood that, as non-limiting examples, the boxes, devices, systems, techniques, or methods described herein may be implemented in hardware, software, firmware, dedicated circuits or logic, general-purpose hardware or controllers or other computing devices, or some combination thereof.
[0136] Embodiments of the present invention may be implemented by computer software that is executable by a data processor of a mobile device, such as in a processor entity, or by hardware, or by a combination of software and hardware. Computer software or programs (also referred to as program products) including software routines, applets and / or macros may be stored in any device-readable data storage medium, and they include program instructions for performing specific tasks. A computer program product may include one or more computer executable components configured to perform an embodiment when the program is run. One or more computer executable components may be at least one software code or a portion thereof. In addition, at this point, it should be noted that, for example, Fig.14 Any block of the logic flow in the program may represent program steps, or interconnected logic circuits, blocks and functions, or a combination of program steps and logic circuits, blocks and functions. The software may be stored on physical media such as memory chips or storage blocks implemented within a processor, magnetic media such as hard disks or floppy disks, and optical media such as, for example, DVDs and their data variants, CDs, etc. Physical media are non-transitory media.
[0137] Those skilled in the art should understand that the technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0138] The above embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A method for constructing a face detection model, characterized in that: The following steps are involved: Constructing a backbone network, wherein the backbone network is trained to extract features from a pedestrian image to be detected to obtain a first backbone feature map, a second backbone feature map, a third backbone feature map, and a fourth backbone feature map with successively reduced image scales, wherein the pedestrian image to be detected is a pedestrian image that does not contain annotation information; A neck network is constructed, wherein the neck network is trained to perform multi-scale fusion of the first backbone feature map, the second backbone feature map, the third backbone feature map and the fourth backbone feature map to obtain a first neck output, a second neck output, a third neck output and a fourth neck output, wherein the first backbone feature map, the second backbone feature map, the third backbone feature map and the fourth backbone feature map are upsampled and stacked step by step in order of scale from small to large to obtain a first stacking result, a second stacking result, a third stacking result and a fourth stacking result, the fourth stacking result is passed through a first neck non-local attention mechanism module to obtain a first neck attention result, the first neck attention result is convolved and output to obtain a first neck output, and the first neck The local attention result is then feature stacked with the second stacking result and input into the second neck non-local attention mechanism module to obtain a second neck attention result, the second neck attention result is convolved and output to obtain a second neck output, the second neck attention result is then feature stacked with the third stacking result and input into the third neck non-local attention mechanism module to obtain a third neck attention result, the third neck attention result is convolved and output to obtain a third neck output, the third neck attention result is then feature stacked with the fourth stacking result and input into the fourth neck non-local attention mechanism module to obtain a fourth neck attention result, the fourth neck attention result is convolved and output to obtain a fourth neck output; Constructing a head network, wherein the head network is trained to predict the first neck output, the second neck output, the third neck output, and the fourth neck output to obtain a face detection result; The face detection model includes a backbone network, a neck network and a head network. During the training process, the face detection model is trained using at least one pedestrian image with a face position marked as a training sample.
2. The method for constructing a face detection model according to claim 1, characterized in that: The pedestrian image to be detected passes through the stem module, the first channel pixel enhancement module, the first backbone convolution module and the second channel pixel enhancement module in the backbone network in sequence to obtain a first backbone feature map, the first backbone feature map then passes through the second convolution module and the first multi-core context anchoring module in sequence to obtain a second backbone feature map, the second backbone feature map passes through the third convolution module and the second multi-core context anchoring module in sequence to obtain a third backbone feature map, the third backbone feature map passes through the fourth convolution module, the third multi-core context anchoring module and the position space attention enhancement module in sequence to obtain a fourth backbone feature map.
3. The method for constructing a face detection model according to claim 2, characterized in that: The stem module is composed of four convolution modules connected in series, wherein the output of the first convolution module is subjected to maximum pooling to obtain a stem pooling result, and the pooling result is feature stacked with the output of the third convolution module and then input into the fourth convolution module for output. In the stem module, the first and third convolution modules use 3*3 convolution, and the second and fourth convolution modules use 1*1 convolution.
4. The method for constructing a face detection model according to claim 2, characterized in that: The first channel pixel enhancement module has the same structure as the second channel pixel enhancement module, and is composed of a first channel convolution module, a channel feature separation module, a plurality of residual bottleneck blocks connected in series, a channel feature stacking layer and a second channel convolution module, wherein the input of the channel pixel enhancement module is processed by the first channel convolution module and then averagely split in the channel dimension by the channel feature separation module to obtain a first channel separation result and a second channel separation result, and the second channel separation result is input into a plurality of residual bottleneck blocks connected in series, and the first channel separation result, the second channel separation result and the output of each residual bottleneck block are feature stacked in the channel feature stacking layer to obtain a channel feature stacking result, and finally the second channel convolution module outputs the channel feature stacking result.
5. The method for constructing a face detection model according to claim 2, characterized in that: The position space attention enhancement module is composed of a first position convolution module, a position feature separation module, a plurality of serial position space attention enhancement layers, a position feature stacking layer and a second position convolution module, wherein the input of the position space attention enhancement module is processed by the first position convolution module and then separated in the channel dimension by the position feature separation module to obtain a first position separation result and a second position separation result, and the second position separation result is input into a plurality of serial position space attention enhancement layers for attention calculation, and the first position separation result and the attention calculation result of each position space attention enhancement layer are feature stacked in the position feature stacking layer to obtain a position feature stacking result, and finally the second position convolution module outputs the position feature stacking result.
6. The method for constructing a face detection model according to claim 5, characterized in that: The attention calculation results of the spatial attention enhancement layer at each position are mapped to a higher-dimensional space through a feedforward neural network.
7. The method for constructing a face detection model according to claim 2, characterized in that: The first multi-core context anchoring module, the second multi-core context anchoring module and the third multi-core context anchoring module have the same structure. The input of the multi-core context anchoring module is feature separated to obtain a first anchor separation result and a second anchor separation result. The first anchor separation result is respectively input into the parallel depth convolution branch and the horizontal and vertical coordinate convolution branch. In the parallel depth convolution branch, the first anchor separation result is firstly subjected to a 3*3 depth-separable convolution to obtain a first depth-separable convolution result. The first depth-separable convolution result is input into a plurality of depth-separable convolution layers of different sizes connected in parallel. The output result of each depth-separable convolution layer is then concatenated with the first depth-separable convolution result and then convolved point by point to obtain a parallel depth convolution result. In the horizontal and vertical coordinate convolution branch, the first anchor separation result is firstly subjected to a 3*3 depth-separable convolution to obtain a first depth-separable convolution result. The anchored separation result is average pooled and point-by-point convolution to obtain a first processing result. The first processing result is sequentially passed through the horizontal coordinate convolution layer and the vertical coordinate convolution layer to obtain a second processing result. The second processing result is output through point-by-point convolution and an activation function to obtain horizontal and vertical coordinate convolution results. The parallel depth convolution result and the horizontal and vertical coordinate convolution results are first feature multiplied to obtain a multiplication result. The multiplication result is feature added to the parallel depth convolution result and then point-by-point convolution is performed to obtain a first branch result, wherein the horizontal coordinate convolution layer is a depth-separable convolution of 1*set size, and the vertical coordinate convolution layer is a depth-separable convolution of set size*1. The second anchored separation result is passed through a feedforward neural network to obtain a second branch result, and the first branch result and the second branch result are feature stacked and convolved for output.
8. The method for constructing a face detection model according to claim 1, characterized in that: The fourth backbone feature map is directly processed by the convolution module to obtain the first stacking result. The first stacking result is upsampled and feature stacked with the third backbone feature map, and then passed through the non-local attention mechanism module and the convolution module to obtain the second stacking result. The second stacking result is upsampled and feature stacked with the second backbone feature map, and then passed through the non-local attention mechanism module and the convolution module to obtain the third stacking result. The third stacking result is upsampled and feature stacked with the first backbone feature map to obtain the fourth stacking result.
9. A trajectory analysis method, characterized in that: include: Obtain a surveillance video stream, input the surveillance video stream into a trained pedestrian detection model to obtain a pedestrian detection result, input the pedestrian detection result into the face detection model constructed in claim 1 to obtain a face detection result, then input the face detection result into a constructed face recognition model to perform face recognition to obtain a face recognition result, and reproduce the movement trajectory of each person based on the face recognition results obtained at different locations and different times.
10. A device for constructing a face detection model, characterized in that: include: A backbone network construction device, used to construct a backbone network, wherein the backbone network is trained to extract features of a pedestrian image to be detected to obtain a first backbone feature map, a second backbone feature map, a third backbone feature map, and a fourth backbone feature map with successively reduced image scales, wherein the pedestrian image to be detected is a pedestrian image that does not contain annotation information; A neck network construction device is used to construct a neck network, wherein the neck network is trained to perform multi-scale fusion of a first backbone feature map, a second backbone feature map, a third backbone feature map and a fourth backbone feature map to obtain a first neck output, a second neck output, a third neck output and a fourth neck output, wherein the first backbone feature map, the second backbone feature map, the third backbone feature map and the fourth backbone feature map are upsampled and stacked step by step in order of scale from small to large to obtain a first stacking result, a second stacking result, a third stacking result and a fourth stacking result, the fourth stacking result is passed through a first neck non-local attention mechanism module to obtain a first neck attention result, and the first neck attention result is convolved and output to obtain a first neck output , the first neck attention result is feature stacked with the second stacking result and input into the second neck non-local attention mechanism module to obtain a second neck attention result, the second neck attention result is convolved and output to obtain a second neck output, the second neck attention result is feature stacked with the third stacking result and input into the third neck non-local attention mechanism module to obtain a third neck attention result, the third neck attention result is convolved and output to obtain a third neck output, the third neck attention result is feature stacked with the fourth stacking result and input into the fourth neck non-local attention mechanism module to obtain a fourth neck attention result, the fourth neck attention result is convolved and output to obtain a fourth neck output; A head network construction device is used to construct a head network, wherein the head network is trained to predict a first neck output, a second neck output, a third neck output, and a fourth neck output to obtain a face detection result; wherein the face detection model includes a backbone network, a neck network, and a head network, and the face detection model is trained using at least one pedestrian image with a face position marked as a training sample during the training process.
Citation Information
Patent Citations
Self-attention mechanism-based shielded face expression deep convolution recognition method
CN116758621A
Human-face detection model training method, device, medium, and human-face detection method
WO2021208687A1