Pedestrian detection method, device, equipment and storage medium
By introducing the multi-level fine-grained YOLO model and PAFPN structure into the YOLO model, the problem of poor detection of small targets and occluded pedestrians in pedestrian detection is solved, achieving higher detection accuracy and richness of semantic information.
Patent Information
- Application Number
- CN202210585688.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-27
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2042-05-27
AI Technical Summary
The existing technology does not perform well in detecting small target pedestrians and occluded pedestrians in pedestrian detection.
Using a multi-level fine-grained YOLO model, a multi-level fine-grained PAFPN structure is set up between the backbone network and the decoupling head module, including the ResCoT module and the WG-NAM-CSPLayer module, to perform feature fusion and weight sparse penalty to enhance pedestrian detection. Semantic information and feature extraction capabilities.
It improves the detection accuracy of small target pedestrians and occluded pedestrians, and enhances the richness of semantic information and feature extraction capabilities of pedestrian detection.
Smart Images

Figure CN115131819B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a pedestrian detection method, device, equipment and storage medium. Background Art
[0002] Pedestrian detection is an important research direction in the field of computer vision and has a wide range of applications in autonomous driving, intelligent transportation, and robot vision. There are two main types of pedestrian detection algorithms: traditional pedestrian detection algorithms and pedestrian detection algorithms based on deep learning.
[0003] At present, compared with traditional pedestrian detection methods, pedestrian detection algorithms based on deep learning can better meet the real-time and accuracy requirements of current pedestrian detection, and therefore have become the mainstream method.
[0004] Pedestrian detection methods based on deep learning are mainly derived from general target detection algorithms. When general target detection algorithms are directly applied to pedestrian detection, although good results can be achieved, the detection effect of small target pedestrians and occluded pedestrians in pedestrian detection is poor.
[0005] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention
[0006] The present invention relates to the field of computer technology, and in particular to a pedestrian detection method, device, equipment and storage medium, which aims to solve the technical problem that the prior art has poor detection effect on small target pedestrians and obscured pedestrians in pedestrian detection.
[0007] To achieve the above object, the present invention provides a pedestrian detection method, the method comprising the following steps:
[0008] Obtain an image to be recognized;
[0009] Performing pedestrian detection on the image to be identified by using a preset multi-level fine-grained YOLO model, and outputting a pedestrian detection result, wherein the preset multi-level fine-grained YOLO model includes a multi-level fine-grained PAFPN structure;
[0010] Among them, the multi-level fine-grained PAFPN structure is used to perform feature fusion on the feature map output by the backbone network based on the image to be identified, obtain a fused feature map, and input the fused feature map into the decoupling head module for pedestrian detection.
[0011] Optionally, in the preset multi-level fine-grained YOLO model, the multi-level fine-grained PAFPN structure is arranged between the backbone network and the decoupling head module, and the multi-level fine-grained PAFPN structure includes: a ResCoT module;
[0012] The method of performing pedestrian detection on the image to be identified by using a preset multi-level fine-grained YOLO model and outputting a pedestrian detection result includes:
[0013] Extracting features of the image to be identified through the backbone network to obtain a feature map;
[0014] The feature map is fused with the pedestrian context information corresponding to the image to be identified through the ResCoT module, and the fusion result is subjected to feature extraction and then input into the decoupling head module;
[0015] The decoupling head module performs pedestrian detection on the fusion result and outputs the pedestrian detection result.
[0016] Optionally, the fusion result after the feature extraction includes a fusion output feature, and the ResCoT module includes: a CoT module, a feature component splitting and fusion module and an output feature component fusion module;
[0017] The CoT module is arranged between the feature component splitting and fusion module and the output feature component fusion module;
[0018] The feature map is fused with the pedestrian context information corresponding to the image to be identified through the ResCoT module, and the fusion result is subjected to feature extraction and then input into the decoupling head module, including:
[0019] Splitting the feature map into a plurality of feature components by the feature component splitting and fusion module, wherein the plurality of feature components include first to N feature components, where N is an integer greater than or equal to 2;
[0020] The plurality of feature components are traversed by the feature component splitting and fusion module, and the feature component traversed for the first time is output as a first output feature component to the output feature component fusion module;
[0021] The feature component splitting and fusion module fuses the currently traversed Nth feature component with the output feature components corresponding to the first N-1 feature components, and inputs the component fusion result into the CoT module;
[0022] The component fusion result is received through the CoT module, and a 3×3 convolution is performed on the component fusion result to obtain a key-value feature component that incorporates pedestrian context information;
[0023] The key-value feature component and the query value are tensor-joined by the CoT module to obtain static context modeling;
[0024] Performing 1×1 convolution on the component fusion result through the CoT module to obtain a convolution feature component;
[0025] The static context modeling is subjected to two 1×1 convolutions by the CoT module and then multiplied by the convolution feature component to obtain a dynamic context modeling;
[0026] The dynamic context modeling is fused with the static context modeling through the CoT module to obtain an output feature component corresponding to the component fusion result, and the output feature component corresponding to the component fusion result is output to the output feature component fusion module;
[0027] The output feature component corresponding to the component fusion result and the first output feature component are fused through the output feature component fusion module to obtain a fused output feature, and the fused output feature is input into the decoupling head module.
[0028] Optionally, the fusion result further includes a position output feature, and the ResCoT module further includes: a coordinate attention mechanism module;
[0029] The ResCoT module is used to fuse the feature map output by the backbone network based on the image to be identified with the pedestrian context information corresponding to the image to be identified, and after feature extraction is performed on the fusion result, it is input into the decoupling head module, and further includes:
[0030] The fused output features are received through the coordinate attention mechanism module, and horizontal average pooling and vertical average pooling are performed on the fused output features to obtain two 1D vectors;
[0031] Performing tensor splicing on the two 1D vectors through the coordinate attention mechanism module to obtain a 1D splicing vector, and performing channel compression on the 1D splicing vector to obtain a compressed 1D vector;
[0032] Encoding the spatial information of the compressed 1D vector in the vertical and horizontal directions by using batch normalization and nonlinear processing through the coordinate attention mechanism module to obtain an encoded 1D splicing vector;
[0033] Splitting the encoded 1D concatenated vector through the coordinate attention mechanism module to obtain two new 1D vectors, and adjusting the number of channels of the two new 1D vectors to keep the number of channels of the two new 1D vectors consistent;
[0034] The two new 1D vectors with the same number of channels are normalized and weighted through the coordinate attention mechanism module to obtain position output features, and the position output features are input into the decoupling head module.
[0035] Optionally, the multi-level fine-grained PAFPN structure further includes: a WG-NAM-CSPLayer module;
[0036] The method performs pedestrian detection on the image to be identified by using a preset multi-level fine-grained YOLO model and outputs a pedestrian detection result, and further includes:
[0037] Performing weight sparse penalty on the feature map or the fusion result through the WG-NAM-CSPLayer module to obtain a channel enhanced feature map;
[0038] The channel enhancement feature map is output to the decoupling head module through the WG-NAM-CSPLayer module.
[0039] Optionally, the WG-NAM-CSPLayer module includes: a WG-NAM attention module, a bottleneck layer module and at least two BaseConv modules;
[0040] The WG-NAM attention module is arranged after the 3×3 convolutional layer of the bottleneck layer module;
[0041] The step of receiving the feature map or the fusion result through the WG-NAM-CSPLayer module, performing weight sparse penalty on the feature map or the fusion result, and obtaining a channel enhanced feature map includes:
[0042] Outputting the feature map or the fusion node to the bottleneck layer module through one of the BaseConv modules for convolution operation;
[0043] The WG-NAM attention module receives feature maps generated by the 3×3 convolutional layer in the bottleneck layer, the same number of feature maps as the number of channels;
[0044] Performing weight sparse penalty on the feature map through the WG-NAM attention module to obtain a channel output feature map;
[0045] Inputting the channel output feature map into a first fusion module through the WG-NAM attention module, so that the first fusion module fuses the feature map with the channel output feature map to obtain a first fused output feature map;
[0046] The first fusion feature map is input into the second fusion module through the first fusion module, so that the second fusion module fuses the first fusion feature map with the feature map or the fusion result processed by the BaseConv module to obtain a channel enhanced feature map.
[0047] Optionally, performing weight sparse penalty on the feature map by the WG-NAM attention module to obtain a channel output feature map includes:
[0048] Extracting a scaling factor through a batch normalization operation based on the feature maps having the same number as the number of channels by the WG-NAM attention module;
[0049] The channel output feature map is determined by the WG-NAM attention module according to the scale factor and the feature map.
[0050] In addition, to achieve the above-mentioned purpose, the present invention also proposes a pedestrian detection device, which includes: a memory, a processor, and a pedestrian detection program stored in the memory and executable on the processor, and the pedestrian detection program is configured to implement the steps of the pedestrian detection method described above.
[0051] In addition, to achieve the above-mentioned purpose, the present invention further proposes a storage medium, on which a pedestrian detection program is stored, and when the pedestrian detection program is executed by a processor, the steps of the pedestrian detection method described above are implemented.
[0052] In addition, to achieve the above-mentioned purpose, the present invention also provides a pedestrian detection device, which includes: an image acquisition module and a pedestrian detection module;
[0053] The image acquisition module is used to acquire the image to be identified;
[0054] The pedestrian detection module is used to perform pedestrian detection on the image to be identified by using a preset multi-level fine-grained YOLO model and output a pedestrian detection result, wherein the preset multi-level fine-grained YOLO model includes a multi-level fine-grained PAFPN structure;
[0055] Among them, the multi-level fine-grained PAFPN structure is used to perform feature fusion on the feature map output by the backbone network based on the image to be identified, obtain a fused feature map, and input the fused feature map into the decoupling head module for pedestrian detection.
[0056] The present invention discloses a pedestrian detection method, which includes: obtaining an image to be identified; performing pedestrian detection on the image to be identified by using a preset multi-level fine-grained YOLO model, and outputting a pedestrian detection result, wherein the preset multi-level fine-grained YOLO model includes a multi-level fine-grained PAFPN structure; the multi-level fine-grained PAFPN structure is used to perform feature fusion on a feature map output by a backbone network based on the image to be identified, obtain a fused feature map, and input the fused feature map into a decoupling head module for pedestrian detection. Since the present invention adds a multi-level fine-grained PAFPN structure to the YOLO model, which is used to further perform feature fusion on the feature map output by the backbone network, the richness of semantic information when extracting pedestrian features from the image to be identified is ensured, and the technical problem that the detection effect of small-target pedestrians and occluded pedestrians in pedestrian detection is poor in the prior art is solved. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 It is a structural schematic diagram of a pedestrian detection device in a hardware operating environment involved in an embodiment of the present invention;
[0058] Figure 2 A schematic diagram of a flow chart of a first embodiment of a pedestrian detection method of the present invention;
[0059] Figure 3 It is a schematic diagram of the structure of the existing YOLO model PAFPN;
[0060] Figure 4 A schematic diagram of a multi-level fine-grained PAFPN structure of a multi-level fine-grained YOLO model preset in the first embodiment of the pedestrian detection method of the present invention;
[0061] Figure 5 A schematic diagram of the structure of a ResCot module of a multi-level fine-grained PAFPN structure in the first embodiment of the pedestrian detection method of the present invention;
[0062] Figure 6 Another structural diagram of the ResCot module of the multi-level fine-grained PAFPN structure in the second embodiment of the pedestrian detection method of the present invention;
[0063] Figure 7 It is a schematic diagram of the structure of the WG-NAM-CSPLayer module of the multi-level fine-grained PAFPN structure in the third embodiment of the pedestrian detection method of the present invention;
[0064] Figure 8 Schematic diagram of the structure of the WG-NAM attention module described in this embodiment;
[0065] Fig. 9 A weight comparison diagram after weight and gain in the third embodiment of the present invention;
[0066] Fig.10 FIG. 4 is a structural block diagram of a first embodiment of a pedestrian detection device according to the present invention.
[0067] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0068] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0069] Reference Figure 1 , Figure 1 A schematic diagram of the structure of a pedestrian detection device in a hardware operating environment according to an embodiment of the present invention.
[0070] like Figure 1 As shown, the pedestrian detection device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (Wireless-Fidelity, Wi-Fi) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM), or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk storage. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0071] Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the pedestrian detection device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0072] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating system, a network communication module, a user interface module, and a pedestrian detection program.
[0073] exist Figure 1In the pedestrian detection device shown, the network interface 1004 is mainly used for data communication with the network server; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the pedestrian detection device of the present invention can be set in the pedestrian detection device, and the pedestrian detection device calls the pedestrian detection program stored in the memory 1005 through the processor 1001, and executes the pedestrian detection method provided by the embodiment of the present invention.
[0074] The embodiment of the present invention provides a pedestrian detection method, referring to Figure 2 , Figure 2 FIG. 1 is a flow chart of a first embodiment of a pedestrian detection method according to the present invention.
[0075] In this embodiment, the pedestrian detection method includes the following steps:
[0076] Step S10: Acquire the image to be recognized.
[0077] It should be understood that the execution subject of this embodiment can be an electronic device with data processing, network communication and program running functions, such as a mobile phone, a tablet computer, a personal computer, etc., or other electronic devices that can achieve the same or similar functions, such as the above-mentioned pedestrian detection device, and this embodiment does not limit this. The following takes the pedestrian detection device as an example to specifically describe this embodiment and the following embodiments.
[0078] It should be noted that the image to be identified can be input in advance by the user or by an image acquisition device. The image acquisition device refers to a device with image acquisition and storage functions, such as a camera, a driving recorder, etc. The image acquisition device can be integrated into the above-mentioned pedestrian detection device, and is other electronic devices that can achieve the same or similar functions. This embodiment does not limit this.
[0079] It is understandable that in order to improve processing efficiency, in this embodiment, the pedestrian detection device may first pre-process the initial image captured by the image acquisition device to obtain an image to be identified. The pre-processing may be image denoising, image enhancement, etc. to improve image quality, thereby improving the final pedestrian detection accuracy.
[0080] Step S20: performing pedestrian detection on the image to be identified by using a preset multi-level fine-grained YOLO model, and outputting a pedestrian detection result, wherein the preset multi-level fine-grained YOLO model includes a multi-level fine-grained PAFPN structure;
[0081] Among them, the multi-level fine-grained PAFPN structure is used to receive the feature map output by the backbone network according to the image to be identified, perform feature fusion on the feature map, obtain a fused feature map, and perform pedestrian detection according to the fused feature map through the decoupling head module.
[0082] It should be noted that the preset multi-level fine-grained YOLO model can be improved based on any model from YOLOv3 to YOLOv5. As an implementation method, the preset multi-level fine-grained YOLO model in this embodiment is preferably improved based on the YOLOv3 model.
[0083] For ease of understanding, refer to Figure 3 To explain, Figure 3 shown. Figure 3 The schematic diagram of the PAFPN structure in the existing YOLOv3 model is shown in Figure 1. The backbone network (not shown) extracts features based on the image to be identified. Figure 1 To Features Figure 3 (Feature1~Feature3), the features Figure 1 To Features Figure 3 The semantic information of pedestrians contained gradually increases, and the features are received through the PAFPN structure. Figure 1 To Features Figure 3 , with the characteristics Figure 3 For example, after inputting the PAFPN structure, the Conv2D convolution layer performs convolution to obtain the first convolution feature map, and then upsamples the first convolution feature map (Upsampling2D) and combines it with the feature map. Figure 2 After tensor concatenation (Concat), the CSPLayer module is input to perform pedestrian feature extraction. The feature map obtained after pedestrian feature extraction is input into the Conv2D convolution layer to obtain a second convolution feature map, and then the second convolution feature map is upsampled and the upsampled second convolution feature map is combined with the feature map. Figure 1 Tensor splicing is performed, and the result is input into the CSPLayer module for pedestrian feature extraction to obtain a first fused feature map, and output; the first fused feature map is downsampled (DownSample) and then tensor spliced with the second convolution feature map, and then input into the CSPLayer module for pedestrian feature extraction, and the result is output as the second fused feature map; after downsampling the second fused feature map, tensor splicing is performed with the first convolution feature map, and the result is input into the CSPLayer module, and after pedestrian feature extraction, a third fused feature map is obtained as output, and the decoupling head (not shown in the figure) performs pedestrian detection according to the first to third fused feature maps.
[0084] For ease of understanding, refer to Figure 4 This is for illustration only, but is not intended to limit the present invention. Figure 4The schematic diagram of the multi-level fine-grained PAFPN structure in the preset multi-level fine-grained YOLO model of this embodiment. This embodiment adds a ResCoT module to the existing PAFPN structure, and correspondingly performs pedestrian detection on the image to be identified by the preset multi-level fine-grained YOLO model, and outputs the pedestrian detection result, including:
[0085] Step S21: extracting features of the image to be identified through the backbone network to obtain a feature map;
[0086] Step S22: fusing the feature map with the pedestrian context information corresponding to the image to be identified through the ResCoT module, extracting features from the fusion result, and inputting the result into the decoupling head module;
[0087] It can be understood that the pedestrian context information includes: some or all information that can affect the objects in the scene and the image, and captures the interaction information between different objects and the interaction information between objects and scenes as conditions to identify and process new targets, for example, the spatiotemporal relationship between pedestrians and background reference objects.
[0088] It should be understood that the fusion of the feature map output by the backbone network based on the image to be identified with the pedestrian context information corresponding to the image to be identified includes early fusion of the feature map output by the backbone network based on the image to be identified with the pedestrian context information corresponding to the image to be identified, and the early fusion includes: concat (tensor concatenation) and add (parallel strategy). The concat is to directly connect two features, and the add is to combine the two feature vectors into a composite vector.
[0089] It should be understood that the feature extraction of the fusion result is, in actual operation, to implement feature extraction of the fusion result through all modules except the ResCoT module in the existing PAFPN structure, so as to further highlight the pedestrian features in the image to be identified.
[0090] Step S23: Perform pedestrian detection on the fusion result after feature extraction through the decoupling head module, and output the pedestrian detection result.
[0091] It should be understood that the pedestrian detection result includes the presence of pedestrians in the image, including whether there are pedestrians in the image, predicting the possible travel direction of pedestrians in the image, etc.
[0092] refer to Figure 5 , Figure 5 is a structural diagram of the ResCoT module, wherein the ResCoT module includes: a CoT module, a feature component splitting and fusion module, and an output feature component fusion module;
[0093] The CoT module is arranged between the feature component splitting and fusion module and the output feature component fusion module;
[0094] The step S22: fusing the feature map with the pedestrian context information corresponding to the image to be identified through the ResCoT module, extracting features from the fusion result, and inputting the result into the decoupling head module, comprises:
[0095] Step S221: splitting the feature map into multiple feature components by the feature component splitting and fusion module, wherein the multiple feature components include the first to N feature components, where N is an integer greater than or equal to 2;
[0096] It should be understood that the multiple feature components may include four feature components, eight feature components, sixteen feature components, etc. in actual operation. This article takes four feature components as an example. For example, the feature component splitting and fusion module splits the feature map output by the backbone network based on the image to be identified into four feature components, the first feature component is directly output as the first output feature component, the second feature component is fused with the first component and output as the second output feature component, the third feature component is fused with the first feature component and the second feature component and output as the third output feature component, and the fourth feature component is fused with the first to third feature components and output as the fourth output feature component.
[0097] Step S222: traversing the plurality of feature components through the feature component splitting and fusion module, and outputting the feature component traversed for the first time as a first output feature component to the output feature component fusion module;
[0098] It should be understood that the feature component splitting and fusion module splits the feature map output by the backbone network based on the image to be identified into multiple feature components. This article takes four feature components as an example. The feature component splitting and fusion module splits the feature map output by the backbone network based on the image to be identified into four feature components, and the first feature component is directly output as the first output feature component.
[0099] Step S223: The feature component splitting and fusion module fuses the Nth feature component currently traversed with the output feature components corresponding to the first N-1 feature components, and inputs the component fusion result into the CoT module;
[0100] It should be understood that the feature component splitting and fusion module splits the feature map output by the backbone network based on the image to be identified into multiple feature components. This article takes four feature components as an example. The second feature component is fused with the first output feature component and output as the second fused feature component. The third feature component is fused with the first output feature component and the second output feature component and output as the third fused feature component. The fourth feature component is fused with the first to third output feature components and output as the fourth fused feature component. The second to fourth feature fusion components are output to the CoT module.
[0101] Step S224: receiving the component fusion result through the CoT module, performing 3×3 convolution on the component fusion result, and obtaining a key-value feature component fused with pedestrian context information;
[0102] It should be understood that, through the 3×3 convolution, the component fusion result obtains the key fused with the pedestrian context information, so that the component fusion result obtains the pedestrian context information and obtains the key-value feature component.
[0103] The key is key value data containing pedestrian context information obtained by the backbone network according to the image to be identified.
[0104] It should be understood that, taking four feature components as an example, the second to fourth fused feature components are respectively input into the CoT module, so that the CoT module performs 3×3 convolution on the second to fourth fused feature components respectively, so that the second to fourth fused feature components fuse the pedestrian context information to obtain the second to fourth key-value feature components.
[0105] Step S225: performing tensor concatenation of the key-value feature component and the query value through the CoT module to obtain static context modeling;
[0106] It should be understood that the query value is Figure 5 The query value is the query data obtained by the backbone network according to the image to be identified.
[0107] Taking four feature components as an example, the second to fourth key-value feature components are respectively concatenated with the query to obtain the second to fourth static context modeling.
[0108] Step S226: performing 1×1 convolution on the component fusion result through the CoT module to obtain a convolution feature component;
[0109] It should be understood that the component fusion result includes the second to fourth fused feature components, and the second to fourth fused feature components are respectively subjected to 1×1 convolution to obtain the second to fourth convolution feature components.
[0110] Step S227: performing two 1×1 convolutions on the static context modeling through the CoT module and then multiplying the result by the convolution feature component to obtain a dynamic context modeling;
[0111] It should be understood that, through the 1×1 convolution, the component fusion result is further used to extract the features, thereby obtaining the convolution feature components.
[0112] Taking four feature components as an example, the second to fourth static context modeling are respectively multiplied with the second to fourth convolution feature components after two 1×1 convolutions to obtain the second to fourth dynamic context modeling.
[0113] Step S228: fusing the dynamic context modeling with the static context modeling through the CoT module to obtain an output feature component corresponding to the component fusion result, and outputting the output feature component corresponding to the component fusion result to the output feature component fusion module;
[0114] It should be understood that, taking four feature components as an example, the dynamic context modeling is fused with the static context modeling, including: the second to fourth dynamic context modeling is fused with the second to fourth static context modeling, thereby obtaining the second to fourth output feature components.
[0115] It should be understood that, taking four feature components as an example, obtaining the output feature component corresponding to the component fusion result includes obtaining the second output feature component corresponding to the second fused feature component, obtaining the third output feature component corresponding to the third fused feature component, obtaining the fourth output feature component corresponding to the fourth fused feature component, and then outputting the second to fourth output feature components to the feature component fusion module.
[0116] Step S229: The output feature component corresponding to the component fusion result and the first output feature component are fused through the output feature component fusion module to obtain a fused output feature, and the fused output feature is input into the decoupling head module.
[0117] It should be understood that, taking four feature components as an example, the output feature components corresponding to the component fusion results and the first output feature components are fused through the output feature component fusion module, including: fusing the second to fourth output feature components with the first output feature component through the output feature component fusion module to obtain a fused output feature, and inputting the fused output feature into the decoupling head module so that the decoupling head module performs pedestrian detection according to the fused output feature map.
[0118] This embodiment adds the ResCoT module to the PAFPN structure, and the ResCoT module includes a CoT module, which increases the diversity of the feature map receptive field and divides the multi-scale features of pedestrians in a finer granularity. At the same time, some lateral connections are introduced in the ResCoT module, so that when the feature map performs 3×3 convolution, it not only accepts the features of the previous layer, but also takes into account the features of other layers, further improving the detection ability of the pedestrian detection method for pedestrian features, thereby realizing the detection of small target pedestrians and occluded pedestrians.
[0119] refer to Figure 6 , Figure 6 Schematic diagram of the ResCoT module structure of the second embodiment of the pedestrian detection method of the present invention.
[0120] Based on the above first embodiment, in this embodiment, step S22 further includes:
[0121] Step S2210: receiving the fused output features through the coordinate attention mechanism module, performing horizontal average pooling (X avg pool) and vertical average pooling (Y avg pool) on the fused output features, respectively, to obtain two 1D vectors;
[0122] It should be understood that the fused output features are received by the residual module (Residual) in the coordinate attention mechanism module, and the fused output features are respectively average pooled in the horizontal direction and average pooled in the vertical direction to obtain two 1D vectors;
[0123] It can be understood that the average pooling, that is, only averaging the feature points in the neighborhood, can reduce the increase in the variance of the estimated value caused by the limited size of the field and retain more background information of the image; the two 1D vectors are two vectors containing horizontal direction information and vertical direction information respectively. The two 1D vectors contain information in the horizontal and vertical directions, thereby realizing the addition of position information to the channel attention.
[0124] Step S2211: performing tensor splicing on the two 1D vectors through the coordinate attention mechanism module to obtain a 1D splicing vector, and performing channel compression on the 1D splicing vector to obtain a compressed 1D vector;
[0125] It can be understood that by tensor concatenation, the dimensions of the two 1D vectors are expanded, for example, the concatenation of two tensors 26×26×256 and 26×26×512 results in 26×26×768.
[0126] Step S2212: Encoding the spatial information of the compressed 1D vector in the vertical and horizontal directions by using batch normalization and nonlinear processing through the coordinate attention mechanism module to obtain an encoded 1D splicing vector;
[0127] It can be understood that the batch normalization (BN) operation is a method to make neural network training faster and more stable by calculating the mean and variance of each mini-batch and pulling each mini-batch back to a standard normal distribution with a mean of 0 and a variance of 1. The BN layer is usually used before / after a non-linear processing (Non-linear) operation.
[0128] Step S2213: Splitting the encoded 1D concatenated vector through the coordinate attention mechanism module to obtain two new 1D vectors, and adjusting the number of channels of the two new 1D vectors to keep the number of channels of the two new 1D vectors consistent;
[0129] It can be understood that the two new 1D vectors and the two 1D vectors contain spatial information in the vertical direction and the spatial direction.
[0130] Step S2214: The two new 1D vectors with the same number of channels are normalized and weighted through the coordinate attention mechanism module to obtain position output features, and the position output features are input into the decoupling head module.
[0131] It should be understood that, taking the Sigmoid function as an example, after batch normalization, the data as a whole is in the non-saturated region of the function and only contains linear transformations, which destroys the previously learned feature distribution. Through normalized weighting, the BN deliberately added for training can restore the original input and ensure the accuracy of the data.
[0132] In this embodiment, a coordinate attention mechanism module is added to the ResCoT module so that the position output feature contains spatial information in the vertical and horizontal directions, and the generated feature map is encoded into a pair of direction-aware and position-sensitive attention maps, which are complementarily applied to the input feature map to enhance the representation of the object of attention, thereby improving the detection effect of small targets.
[0133] refer to Figure 7 , Figure 7 It is a schematic diagram of the structure of PAFPN of the third embodiment of the pedestrian detection method of the present invention.
[0134] Based on the above first embodiment, in this embodiment, step S20 further includes:
[0135] Step S24: performing weight sparse penalty on the feature map or the fusion result through the WG-NAM-CSPLayer module to obtain a channel enhanced feature map;
[0136] It can be understood that the weighted sparse penalty is to receive the same number of feature maps as the number of channels, enhance the channels containing useful semantic information features in the feature maps, suppress the channels containing useless information, and highlight the significant features of pedestrians. The useful semantic information features include necessary information features related to pedestrian detection in the image to be identified, such as the facial contours of pedestrians, the movement trajectories of pedestrians' limbs, etc.
[0137] Step S25: Output the channel enhancement feature map to the decoupling head module through the WG-NAM-CSPLayer module.
[0138] It can be understood that the fusion output features and the position output features output by the ResCoT module and the channel enhanced feature map output by the WG-NAM-CSPLayer module can all realize the detection of small target pedestrians and occluded pedestrians. In actual operation, the ResCoT module outputs the position output features to the WG-NAM-CSPLayer module, so that the WG-NAM-CSPLayer module outputs the channel enhanced feature map to the decoupling head module according to the position output features, so that the decoupling head module performs pedestrian detection.
[0139] The step S24: performing weight sparse penalty on the feature map or the fusion result through the WG-NAM-CSPLayer module to obtain a channel enhanced feature map, further comprising:
[0140] Step S241: outputting the feature map or the fusion node to the bottleneck layer module through one of the BaseConv modules for convolution operation;
[0141] It should be understood that the BaseConv module includes a convolution layer Conv2D, a BN layer and an activation layer SiLu. The activation layer is used to add nonlinear factors to make up for the problem of insufficient expression of linear factors in the model; the bottleneck layer module includes a 1×1 convolution, a 3×3 convolution, and a WG-NAM attention module.
[0142] Step S242: receiving, through the WG-NAM attention module, feature maps generated by the 3×3 convolutional layer in the bottleneck layer, the same number of feature maps as the number of channels;
[0143] Reference here Figure 8 This is for illustration only, but is not intended to limit the present invention. Figure 8 Schematic diagram of the structure of the WG-NAM attention module described in this embodiment.
[0144] like Figure 8 As shown, the WG-NAM attention module receives feature input, extracts γi scaling factors through the BN layer, and generates corresponding weights W γ , and then use the weight W γ Calculate the weight G after gain γ , according to the weight G after gain γ The output characteristics are determined with the scaling factor.
[0145] It should be understood that after the feature map input into the WG-NAM-CSPLayer module undergoes 3×3 convolution, a feature map corresponding to the channel will be generated.
[0146] Step S243: performing weight sparse penalty on the feature map through the WG-NAM attention module to obtain a channel output feature map;
[0147] The step S243: performing weight sparse penalty on the feature map through the WG-NAM attention module to obtain a channel output feature map, including:
[0148] Step S2431: extracting a scaling factor through a batch normalization operation according to the feature maps having the same number as the number of channels through the WG-NAM attention module;
[0149] It can be understood that a BN layer is also included in the BaseConv module, and the BN layer in the BaseConv module is not further paid attention to during calculation. In actual operation, the scale factor extracted by the batch normalization operation of the WG-NAM attention module is further calculated.
[0150] Step S2432: Determine the channel output feature map according to the scale factor and the feature map through the WG-NAM attention module.
[0151] It should be understood that the determining of the channel output feature map according to the scale factor and the feature map includes: calculating the output feature according to the following formula:
[0152] M c =sigmoid(G γ (BN(F1)))
[0153]
[0154]
[0155] Among them, Wγ represents weight, G γ The weight after gain, Mc represents the output feature, F1 represents the input feature map, γ represents the scale factor of each channel, and BN() represents the Batch Normalization operation.
[0156] like Fig. 9 As shown, Fig. 9 This is a weight comparison diagram of the third embodiment of the present invention after weight and gain. It can be seen from the figure that after the weight Wγ is adaptively gained, the weights of important features are enhanced and other features are weakened.
[0157] Step S244: inputting the channel output feature map into the first fusion module through the WG-NAM attention module, so that the first fusion module fuses the feature map with the channel output feature map to obtain a first fused output feature map;
[0158] It should be understood that the first fusion module (not shown in the figure) is used to fuse the feature map with the channel output feature map, and the fusion can be the early fusion or the late fusion. The late fusion adopts an idea similar to the feature pyramid network (FPN) to predict the feature fusion.
[0159] Step S245: inputting the first fused feature map into the second fusion module through the first fusion module, so that the second fusion module fuses the first fused feature map with the feature map or the fusion result processed by the BaseConv module to obtain a channel enhanced feature map.
[0160] It should be understood that, so that the second fusion module fuses the first fusion feature map with the feature map or the fusion result processed by the BaseConv module, includes so that the second fusion module adds and fuses the first fusion feature map with the feature map or the fusion result processed by the BaseConv module.
[0161] The embodiment of the present invention adds the WG-NAM-CSPLayer module to the PAFPN structure, that is, adds the WG-NAM attention module to CSPLayer, so that the CSPLayer module becomes a WG-NAM-CSPLayer module, and introduces weight sparsity penalty to make the model pay more attention to contextual information when extracting pedestrian features, thereby highlighting the significant features of pedestrians and weakening the weights of secondary features, thereby improving the detection capability of occluded pedestrians.
[0162] In addition, an embodiment of the present invention further proposes a storage medium, on which a pedestrian detection program is stored. When the pedestrian detection program is executed by a processor, the steps of the pedestrian detection method described above are implemented.
[0163] In addition, an embodiment of the present invention further provides a pedestrian detection device, the pedestrian detection device comprising: an image acquisition module and a pedestrian detection module;
[0164] The image acquisition module 501 is used to acquire the image to be recognized;
[0165] The pedestrian detection module 502 is used to perform pedestrian detection on the image to be identified by using a preset multi-level fine-grained YOLO model and output a pedestrian detection result, wherein the preset multi-level fine-grained YOLO model includes a multi-level fine-grained PAFPN structure;
[0166] Among them, the multi-level fine-grained PAFPN structure is used to perform feature fusion on the feature map output by the backbone network based on the image to be identified, obtain a fused feature map, and input the fused feature map into the decoupling head module for pedestrian detection.
[0167] This embodiment performs pedestrian detection on the image to be identified by using a preset multi-level fine-grained YOLO model and outputs a pedestrian detection result. The preset multi-level fine-grained YOLO model includes a multi-level fine-grained PAFPN structure; the multi-level fine-grained PAFPN structure is used to perform feature fusion on the feature map output by the backbone network based on the image to be identified, obtain a fused feature map, and input the fused feature map into the decoupling head module for pedestrian detection. Since this embodiment adds a multi-level fine-grained PAFPN structure to the YOLO model for further feature fusion on the feature map output by the backbone network, the richness of semantic information when extracting pedestrian features from the image to be identified is ensured, and the technical problem that the prior art has poor detection effects on small-target pedestrians and occluded pedestrians in pedestrian detection.
[0168] Other embodiments or specific implementations of the pedestrian detection device of the present invention can refer to the above-mentioned method embodiments, which will not be described in detail here.
[0169] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0170] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0171] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory / random access memory, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0172] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A pedestrian detection method, characterized in that: The pedestrian detection method comprises: Obtain an image to be recognized; Performing pedestrian detection on the image to be identified by using a preset multi-level fine-grained YOLO model, and outputting a pedestrian detection result, wherein the preset multi-level fine-grained YOLO model includes a multi-level fine-grained PAFPN structure; The multi-level fine-grained PAFPN structure is used to perform feature fusion on the feature map output by the backbone network based on the image to be identified, obtain a fused feature map, and input the fused feature map into the decoupling head module for pedestrian detection; Among them, in the preset multi-level fine-grained YOLO model, the multi-level fine-grained PAFPN structure is arranged between the backbone network and the decoupling head module, and the multi-level fine-grained PAFPN structure includes: a ResCoT module; The method of performing pedestrian detection on the image to be identified by using a preset multi-level fine-grained YOLO model and outputting a pedestrian detection result includes: Extracting features of the image to be identified through the backbone network to obtain a feature map; The feature map is fused with the pedestrian context information corresponding to the image to be identified through the ResCoT module, and the fusion result is subjected to feature extraction and then input into the decoupling head module; Performing pedestrian detection on the fusion result after feature extraction through the decoupling head module, and outputting the pedestrian detection result; The fusion result after the feature extraction includes fusion output features, and the ResCoT module includes: a CoT module, a feature component splitting and fusion module, and an output feature component fusion module; The CoT module is arranged between the feature component splitting and fusion module and the output feature component fusion module; The method of fusing the feature map with the pedestrian context information corresponding to the image to be identified through the ResCoT module, extracting features from the fusion result, and inputting the result into the decoupling head module includes: Splitting the feature map into multiple feature components by the feature component splitting and fusion module, wherein the multiple feature components include first to N feature components, where N is an integer greater than or equal to 2; The plurality of feature components are traversed by the feature component splitting and fusion module, and the feature component traversed for the first time is output as a first output feature component to the output feature component fusion module; The feature component splitting and fusion module fuses the currently traversed Nth feature component with the output feature components corresponding to the first N-1 feature components, and inputs the component fusion result into the CoT module; The component fusion result is received through the CoT module, and a 3×3 convolution is performed on the component fusion result to obtain a key-value feature component that incorporates pedestrian context information; The key-value feature component and the preset query value are tensor-joined by the CoT module to obtain static context modeling; Performing 1×1 convolution on the component fusion result through the CoT module to obtain a convolution feature component; The static context modeling is subjected to two 1×1 convolutions by the CoT module and then multiplied by the convolution feature component to obtain a dynamic context modeling; The dynamic context modeling is fused with the static context modeling through the CoT module to obtain an output feature component corresponding to the component fusion result, and the output feature component corresponding to the component fusion result is output to the output feature component fusion module; The output feature component corresponding to the component fusion result and the first output feature component are fused through the output feature component fusion module to obtain a fused output feature, and the fused output feature is input into the decoupling head module.
2. The pedestrian detection method according to claim 1, characterized in that: The fusion result after the feature extraction also includes a position output feature, and the ResCoT module also includes: a coordinate attention mechanism module; The feature map is fused with the pedestrian context information corresponding to the image to be identified by the ResCoT module, and after feature extraction is performed on the fusion result, it is input into the decoupling head module, and further includes: The fused output features are received through the coordinate attention mechanism module, and horizontal average pooling and vertical average pooling are performed on the fused output features to obtain two 1D vectors; Performing tensor splicing on the two 1D vectors through the coordinate attention mechanism module to obtain a 1D splicing vector, and performing channel compression on the 1D splicing vector to obtain a compressed 1D vector; Encoding the spatial information of the compressed 1D vector in the vertical and horizontal directions by using batch normalization and nonlinear processing through the coordinate attention mechanism module to obtain an encoded 1D splicing vector; Splitting the encoded 1D concatenated vector through the coordinate attention mechanism module to obtain two new 1D vectors, and adjusting the number of channels of the two new 1D vectors to keep the number of channels of the two new 1D vectors consistent; The two new 1D vectors with the same number of channels are normalized and weighted through the coordinate attention mechanism module to obtain position output features, and the position output features are input into the decoupling head module.
3. The pedestrian detection method according to any one of claims 1 to 2, characterized in that: The multi-level fine-grained PAFPN structure also includes: a WG-NAM-CSPLayer module; The method performs pedestrian detection on the image to be identified by using a preset multi-level fine-grained YOLO model and outputs a pedestrian detection result, and further includes: Performing weight sparse penalty on the feature map or the fusion result through the WG-NAM-CSPLayer module to obtain a channel enhanced feature map; The channel enhancement feature map is output to the decoupling head module through the WG-NAM-CSPLayer module.
4. The pedestrian detection method according to claim 3, characterized in that: The WG-NAM-CSPLayer module includes: a WG-NAM attention module, a bottleneck layer module and at least two BaseConv modules; The WG-NAM attention module is arranged after the 3×3 convolutional layer of the bottleneck layer module; The step of receiving the feature map or the fusion result through the WG-NAM-CSPLayer module, performing weight sparse penalty on the feature map or the fusion result, and obtaining a channel enhanced feature map includes: Outputting the feature map or the fusion node to the bottleneck layer module through one of the BaseConv modules for convolution operation; The WG-NAM attention module receives feature maps generated by the 3×3 convolutional layer in the bottleneck layer, the same number of feature maps as the number of channels; Performing weight sparse penalty on the feature map through the WG-NAM attention module to obtain a channel output feature map; Inputting the channel output feature map into a first fusion module through the WG-NAM attention module, so that the first fusion module fuses the feature map with the channel output feature map to obtain a first fused output feature map; The first fusion feature map is input into the second fusion module through the first fusion module, so that the second fusion module fuses the first fusion feature map with the feature map or the fusion result processed by the BaseConv module to obtain a channel enhanced feature map.
5. The pedestrian detection method according to claim 4, characterized in that: The step of performing weight sparse penalty on the feature map by the WG-NAM attention module to obtain a channel output feature map includes: Extracting a scaling factor through a batch normalization operation based on the feature maps having the same number as the number of channels by the WG-NAM attention module; The channel output feature map is determined by the WG-NAM attention module according to the scale factor and the feature map.
6. A pedestrian detection device, characterized in that: The pedestrian detection device comprises: a memory, a processor, and a pedestrian detection program stored in the memory and executable on the processor. When the pedestrian detection program is executed by the processor, the pedestrian detection method according to any one of claims 1 to 5 is implemented.
7. A storage medium, characterized in that: The storage medium stores a pedestrian detection program, which, when executed by a processor, implements the pedestrian detection method according to any one of claims 1 to 5.
8. A pedestrian detection device, characterized in that: The pedestrian detection device comprises: an image acquisition module and a pedestrian detection module; The image acquisition module is used to acquire the image to be identified; The pedestrian detection module is used to perform pedestrian detection on the image to be identified by using a preset multi-level fine-grained YOLO model and output a pedestrian detection result, wherein the preset multi-level fine-grained YOLO model includes a multi-level fine-grained PAFPN structure; The multi-level fine-grained PAFPN structure is used to perform feature fusion on the feature map output by the backbone network based on the image to be identified, obtain a fused feature map, and input the fused feature map into the decoupling head module for pedestrian detection; Among them, in the preset multi-level fine-grained YOLO model, the multi-level fine-grained PAFPN structure is arranged between the backbone network and the decoupling head module, and the multi-level fine-grained PAFPN structure includes: a ResCoT module; The pedestrian detection module is further used to extract features from the image to be identified through the backbone network to obtain a feature map; fuse the feature map with the pedestrian context information corresponding to the image to be identified through the ResCoT module, and extract features from the fusion result, and then input it into the decoupling head module; perform pedestrian detection on the fusion result after feature extraction through the decoupling head module, and output the pedestrian detection result; The fusion result after the feature extraction includes fusion output features, and the ResCoT module includes: a CoT module, a feature component splitting and fusion module, and an output feature component fusion module; The CoT module is arranged between the feature component splitting and fusion module and the output feature component fusion module; The pedestrian detection module is further used to split the feature map into multiple feature components through the feature component splitting and fusion module, and the multiple feature components include the 1st to Nth feature components, where N is an integer greater than or equal to 2; traverse the multiple feature components through the feature component splitting and fusion module, and output the feature component traversed for the first time as the first output feature component to the output feature component fusion module; fuse the currently traversed Nth feature component with the output feature components corresponding to the first N-1 feature components through the feature component splitting and fusion module, and input the component fusion result to the CoT module; receive the component fusion result through the CoT module, perform 3×3 convolution on the component fusion result, and obtain the key-value feature component that integrates the pedestrian context information; The key-value feature component is tensor-joined with the preset query value to obtain static context modeling; the component fusion result is convolved 1×1 through the CoT module to obtain the convolution feature component; the static context modeling is convolved twice with 1×1 through the CoT module and then multiplied with the convolution feature component to obtain dynamic context modeling; the dynamic context modeling is fused with the static context modeling through the CoT module to obtain the output feature component corresponding to the component fusion result, and the output feature component corresponding to the component fusion result is output to the output feature component fusion module; the output feature component corresponding to the component fusion result and the first output feature component are fused through the output feature component fusion module to obtain the fused output feature, and the fused output feature is input to the decoupling head module.
