Machine vision crowd counting method based on MAPS-Net

Through MAPS-Net technology, combined with intensive multi-level hollow semantic coding and learnable threshold segmentation attention module, the accuracy and robustness of crowd counting in complex scenarios is solved, achieving higher counting performance and adaptability.

CN119048983APending Publication Date: 2024-11-29SOUTHWEST JIAOTONG UNIV
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411153137.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-21
Publication Date
2024-11-29

AI Technical Summary

Technical Problem

Existing crowd counting techniques do not perform well when dealing with complex scenarios, especially in the case of complex scene layouts, background noise, large-scale crowd-scale changes, lighting and perspective changes, making it difficult to achieve high accuracy and robustness.

Method used

Using the machine vision population counting method based on MAPS-Net, the data augmentation, intensive multi-level hollow semantic coding module and the learning threshold segmentation attention module are used to extract and aggregate the population density map and dynamically adjust the segmentation. Threshold and local attention loss to generate fine-grained features and improve counting performance.

Benefits of technology

It effectively solves the problem of head scale changes, background interference and segmentation details in crowd counting, improves the counting performance of the model, adapts to complex scenarios, and improves counting accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119048983A_ABST
    Figure CN119048983A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of crowd counting, in particular to a machine vision crowd counting method based on MAPS-Net. The machine vision crowd counting method based on the MAPS-Net comprises the following steps: inputting a crowd image, and performing data enhancement on the crowd image to obtain a crowd enhanced image; inputting the crowd enhanced image into a backbone feature extractor to obtain crowd-visual features; carrying out feature fusion on the crowd-visual features by adopting a dense multilevel cavity semantic coding module to obtain crowd-robust features; dynamically adjusting a segmentation threshold of the crowd-robustness feature by adopting a learnable threshold segmentation attention module to obtain a crowd-fine granularity feature; extracting and aggregating crowd-fine-grained features from a plurality of levels using a convolution group to generate a crowd density map; the crowd number of all areas and / or local areas in the crowd density map is obtained by adopting the loss function, the problems of head scale change, background noise interference and unclear segmentation edge are effectively solved, and the crowd counting performance is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of crowd counting, and in particular to a machine vision crowd counting method based on MAPS-Net. Background Art

[0002] Crowd counting is the process of counting people in a video or image using a computer. City managers and event organizers can use this technology to analyze crowd gatherings and monitor crowd levels in real time, which helps prevent stampedes. Therefore, crowd counting is of great significance in the fields of traffic management, urban planning, disease control, public security, etc.

[0003] Early detection-based crowd counting algorithms obtained the number of people by detecting the position of the head. However, such methods are more suitable for people with large heads and perform poorly when dealing with scenes with severe occlusion. In contrast, regression-based algorithms directly map from image features to the number of people. However, such algorithms require the selection and construction of features based on the knowledge of domain experts and have been surpassed by deep features extracted from convolutional neural networks. Unlike traditional detection-based and regression-based methods, density estimation-based crowd counting calculates the number of people by integrating the crowd density map. This method has become mainstream. The above methods have all been successful to some extent, but they still cannot cope with complex changes in crowd scenes, including complex scene layouts, background noise, large-scale changes in crowd scale, lighting, and changes in perspective.

[0004] Convolutional neural networks (CNNs) have played an important role in promoting the development of image segmentation, human-computer interaction and other fields with their excellent learning ability, and have also provided a foundation for the development of crowd counting. Crowd counting methods based on convolutional neural networks (CNNs) are good at modeling local feature structures, but they are not conducive to crowd counting due to their limited receptive field and poor ability to capture long-range dependencies, both of which are important in crowd counting. Researchers have proposed some methods to alleviate these problems, including the introduction of attention mechanisms, multi-scale feature fusion, and additional auxiliary task learning. These methods improve the performance of crowd counting by utilizing contextual information in images, multi-scale features, and auxiliary information of auxiliary tasks, but do not completely solve these problems. In addition, with the advent of a series of challenging datasets, such as NWPU-Crowd (the latest dataset for crowd density estimation), current crowd counting techniques face challenges in accuracy and robustness, and there is room for further improvement and optimization. Summary of the invention

[0005] In order to solve the problems existing in the prior art, the present application provides a machine vision crowd counting method based on MAPS-Net.

[0006] The present application provides a machine vision crowd counting method based on MAPS-Net, comprising inputting a crowd image, and performing data enhancement on the crowd image to obtain a crowd enhanced image;

[0007] Inputting the crowd-enhanced image into a backbone feature extractor to obtain crowd-visual features;

[0008] A dense multi-level hole semantic encoding module is used to fuse the crowd-visual features to obtain crowd-robust features;

[0009] A learnable threshold segmentation attention module is used to dynamically adjust the segmentation threshold of the crowd-robust feature to obtain crowd-fine-grained features;

[0010] A convolution group is used to extract and aggregate the crowd-fine-grained features from multiple levels to generate a crowd density map;

[0011] The loss function is used to obtain the number of people in all areas and / or local areas in the crowd density map.

[0012] Optionally, the backbone feature extractor is a Twins-PcPvT-large model pre-trained on the ImageNet dataset. The Twins-PcPvT-large model consists of four stages, specifically:

[0013] The input of each stage of the backbone feature extractor is the output of the previous stage, and the calculation formula is as follows:

[0014]

[0015] Where u = 1, 2, 3, 4, u represents the stage, F stage_u represents the output of the u-th stage of the Transformer encoder, represents the output of the u-1th stage, TraEncoder represents the Transformer encoder, Representation output Addition is performed on the channel, N represents the number of repetitions of the Transformer encoder, and PEG represents the position encoder;

[0016] The output results of the four stages are compressed to obtain the crowd-visual feature map Crowd-Visual Feature Map Crowd-Visual Feature Map and crowd-visual feature map Among them, H represents the height of the crowd enhanced image, W represents the width of the crowd enhanced image, and C represents the number of channels of the crowd enhanced image. Feature matrix dimensions representing the feature map.

[0017] Optionally, the adopting of a dense multi-level hole semantic coding module to fuse crowd-visual features to obtain crowd-robust features includes:

[0018] The dense multi-level hole semantic coding module consists of a multi-level hole feature extraction layer and a deconvolution recovery layer, and its output is denoted as O. Specifically, the crowd-visual feature map F2, the crowd-visual feature map F3, and the crowd-visual feature map F4 are respectively input into the dense multi-level hole semantic coding module to extract features O2, O3, and O4 with rich receptive fields;

[0019] The multi-level hole feature extraction layer is composed of parallel mode and stride connection. Specifically, a 1×1 convolution layer is used to compress the crowd-visual feature map F4 to obtain a compressed feature map. Among them C a is the number of image channels after feature map F4 is compressed;

[0020] In parallel mode, dilated convolutions with different dilation rates are used to extract the compressed feature map F. a The multi-scale receptive field features of the two-dimensional feature space mapping, the calculation formula of the hole convolution is as follows:

[0021]

[0022] Among them, y represents the output feature map matrix, i represents the number of rows of the input eigenvalue matrix, j represents the number of columns of the input eigenvalue matrix, and y i,j represents the output feature map matrix when the number of rows of the input eigenvalue matrix is ​​i and the number of columns of the input eigenvalue matrix is ​​j, Φ represents the input eigenvalue matrix, row represents the row number of the convolution kernel, col represents the column number of the convolution kernel, k row Indicates the number of rows of the convolution kernel, k col represents the number of columns of the convolution kernel, d represents the void ratio, and A represents the convolution kernel matrix;

[0023] Define the void ratio d = {d1, d2, d3, d4, d5}, where d m (m=1,2,…,5) represents the hole rate of the mth convolutional layer in the dense multi-level hole semantic coding module;

[0024] The stride connection is used to share the information of the previous convolutional layer. Specifically, the output formula of the parallel mode and the stride connection is as follows:

[0025]

[0026] Among them, p m represents the output of the mth convolutional layer in parallel mode, c mrepresents the output of the mth convolutional layer of the stride connection, d m represents the hole rate of the mth convolutional layer, represents the atrous convolution of the mth convolutional layer with a filter size of 3, function In is a custom function, which represents the cascade from convolution layer n to convolution layer m-1. represents the dilated convolution from convolution layer n to convolution layer m-1, represents the dilated convolution of convolutional layer m, d n represents the hole rate of the nth convolutional layer, Indicates cascade operation, c n Represents the output of the stride connection on the nth convolutional layer;

[0027] The deconvolution restoration layer fuses crowd-visual feature maps F1, crowd-visual feature maps F2, crowd-visual feature maps F3 and crowd-visual feature maps F4 of different sizes from bottom to top to obtain a feature map with coarse-fine granularity. Specifically, the deconvolution restoration module in the deconvolution restoration layer adjusts the feature map of this level to the same size as the feature map of the previous level from bottom to top during the image size restoration process. The formula is as follows:

[0028]

[0029] The final output q1 of the deconvolution recovery layer is concatenated with the output p1 of the first level of the parallel mode on the channel to output the final feature map. The calculation process is as follows:

[0030] O=p1+q1

[0031] Among them, q b represents the output of the b-th layer of the deconvolution recovery layer, represents the deconvolution of the b-th deconvolution recovery layer with a filter size of 3, d b represents the deconvolution rate of the b-th deconvolution recovery layer, c b represents the output of the first convolutional layer in parallel mode, and q1 represents the final output of the deconvolution recovery layer;

[0032] The outputs O2 and O3 of the dense multi-level hole semantic encoding module with rich receptive fields are further subjected to multi-layer feature aggregation. Specifically, the calculation formula of multi-layer feature aggregation is:

[0033]

[0034] Among them, O e represents the output of the e-th convolutional layer of multi-layer feature aggregation, conv(.) represents a 3×3 convolution operation, and up(·) represents an upsampling function with a sampling rate of 2.

[0035] Optionally, the step of dynamically adjusting the segmentation threshold of the crowd-robustness feature by using a learnable threshold segmentation attention module includes:

[0036] It uses a three-branch architecture to dynamically adjust the segmentation threshold, filter background noise, and highlight the characteristics of the crowd area. Specifically: the upper branch outputs the segmentation probability map F S ∈[0,1], the middle branch dynamically adjusts the segmentation threshold T∈[0,1] based on the crowd density, and the lower branch filters the interference of background noise;

[0037] In the upper branch, the feature map with crowd-robust features Pass it to three consecutive convolutional layers to obtain the segmentation probability map F S , using the person segmentation label S gt For the segmentation probability map F S Supervise so that the segmentation probability map F S Close to the person segmentation label S gt , character segmentation label S gt The formula definition is as follows:

[0038]

[0039] Among them, E represents the character segmentation label S gt The total number of pixels, represents the segmentation label of the E-th pixel, represents the value of the person segmentation label, represents the true value of the density map, ε represents the threshold and is set to 10 -3 ;

[0040] The three consecutive convolutional layers include two 3×3 convolution kernels and one 1×1 convolution kernel;

[0041] In the middle branch, a segmented binarization layer is constructed to generate a pixel-level learnable threshold. The segmented binarization layer is configured as follows: 3×3 convolution, 3×3 convolution, 1×1 convolution and Sigmoid function. The segmented binarization layer is a segmentation probability map. Find the appropriate segmentation threshold for each pixel, that is, learn a threshold matrix Make the output result O(i,j) and the character segmentation label S gt Getting closer, among them, H F Represents the segmentation probability map F S High, W F Represents the segmentation probability map F S The width of O(i,j) represents the final output of the dense multi-level hole semantic encoding module when the number of rows of the input eigenvalue matrix is ​​i and the number of columns of the input eigenvalue matrix is ​​j;

[0042] The specific forward propagation process of the piecewise binarization layer is: S (i,j)≥T(i,j), the output result is O(i,j)=1, otherwise O(i,j)=0; where T(i,j) represents the value of the threshold matrix T when the number of rows of the input eigenvalue matrix is ​​i and the number of columns of the input eigenvalue matrix is ​​j, and the gradient of the threshold matrix T is set to -1;

[0043] Specifically, the calculation process formula of the output result O(i,j) of the middle branch is as follows;

[0044]

[0045] Among them, B(.) represents the binarization function;

[0046] In the lower branch, the output O(i,j) is compared with the feature map before being input to the CUT layer. Multiply; then, the feature map is connected through a skip connection To connect, the formula is as follows:

[0047] F=Conv(CUT(F⊙O(i,j))+F)

[0048] Among them, Conv(.) represents a 1×1 convolution operation, ⊙ represents multiplication, + represents addition, CUT represents the convolution of the CUT layer, and F represents the feature map The CUT layer consists of the Transformer layer and conditional position encoding in the Twins PcPvT-large model. After the connection, you can obtain crowd-level fine-grained features.

[0049] Optionally, the convolution group for extracting and aggregating crowd-fine-grained features is configured as 3×3 convolution, 3×3 convolution, and 1×1 convolution.

[0050] Optionally, the step of using a loss function to obtain the number of people in all areas and / or local areas in the crowd density map includes:

[0051] The loss function is composed of different level combination losses L l Specifically, MASP-Net is supervised at three levels from the second stage to the fourth stage to obtain the combined loss L total :

[0052]

[0053] Different levels of combined loss L l The character segmentation loss L S , crowd density loss L R And the local perception attention loss LALoss, the character segmentation loss L SThe loss function is:

[0054]

[0055] Among them, z represents the character segmentation label S gt The pixels in p z represents the true value label of pixel z, l z represents the predicted probability that pixel z is the foreground, γ is the modulation factor, s represents the stage of supervision of MASP-Net, represents the modulation factor of the true value label of pixel z;

[0056] Crowd density loss L R The structural loss SL and the total change loss L TV Composition, crowd density loss L R The loss function is:

[0057] L R =SL(D P ⊙S gt ,D gt ⊙S gt )+λ·L TV (D P ,D gt ),s∈(2,3,4)

[0058] Among them, D P represents the predicted crowd density map, represents the true value of the crowd density map, ⊙ represents multiplication, and λ represents an adjustable hyperparameter;

[0059] Afterwards, the crowd density map truth D gt Get the number of people in all areas and each local area in the crowd density map, specifically:

[0060] First, the crowd density map truth value D gt Divided into 4×4 sub-regions, denoted as in represents the height of the crowd density map, z represents the sub-area number of the crowd density map, represents a sub-region, represents the width of the crowd density map, and w represents the number of rows of the crowd density map;

[0061] The calculation process of the true value of the number of people in the sub-area is:

[0062]

[0063] Among them, P w,z Represents the true value of the number of people in the z-th block of the w-th row of the crowd density map;

[0064] The true value P of the number of people in the sub-regionw,z Based on the proportion of the total number of people, the attention α allocated to people of different densities is calculated. w,z ;

[0065]

[0066] The local attention loss LALoss formula is defined as follows:

[0067]

[0068] in, represents the sub-region number, α w,z Represents the attention regulation factor of the sub-region.

[0069] In summary, this application at least includes the following beneficial technical effects:

[0070] 1. This application uses a dense multi-level void semantic coding module to simultaneously learn high-level features (including semantic information) and low-level features (including details and local information). Through feature fusion, it can cope with large-scale changes, effectively solve the problems of head scale changes, background interference and unclear segmentation details in crowd counting, and improve the counting performance of the model.

[0071] 2. The learnable threshold segmentation attention module proposed in this application can dynamically adjust the segmentation threshold to obtain fine-grained features of the crowd, thereby better distinguishing between crowd areas and background noise areas, making the model more adaptable to complex scenes.

[0072] 3. The local attention loss LALoss designed in this application gives different attention to image sub-regions based on the proportion of the local crowd in the total population, which can better supervise the local crowd. BRIEF DESCRIPTION OF THE DRAWINGS

[0073] Figure 1 A flowchart of a machine vision crowd counting method based on MAPS-Net in an embodiment of the present application;

[0074] Figure 2 This is the overall network framework diagram of the machine vision crowd counting method based on MAPS-Net in the embodiment of the present application;

[0075] Figure 3 This is a DMASE architecture diagram in an embodiment of the present application;

[0076] Figure 4 This is a diagram of the TSAM architecture in an embodiment of the present application. DETAILED DESCRIPTION

[0077] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0078] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to be used as limitations to the present application. As used in the specification and the appended claims of the present application, the singular expressions "one", "a kind of", "said", "above", "the" and "this" are intended to also include plural expressions, unless there is a clear contrary indication in its context. It should also be understood that the term "and / or" used in the present application refers to and includes any or all possible combinations of one or more listed items. The term "exemplary" means "used as an example, embodiment or illustrative", and any embodiment described as "exemplary" here does not need to be interpreted as being superior to or better than other embodiments. The terms "first" and "second" are only used for descriptive purposes, and cannot be understood as implying or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first" and "second" can expressly or implicitly include one or more of these features, and in the description of the embodiments of the present application, unless otherwise specified, the meaning of "multiple" is two or more.

[0079] The embodiment of the present application provides a machine vision crowd counting method based on MAPS-Net.

[0080] refer to Figure 1 , a machine vision crowd counting method based on MAPS-Net, comprising the following steps:

[0081] S102: Input a crowd image, and perform data enhancement on the crowd image to obtain a crowd enhanced image.

[0082] In the embodiment of the present application, the data enhancement technology is: the input crowd image Perform random cropping and normalization operations. Represents the feature matrix dimension of the feature map, H I represents the height of the crowd image, W I represents the width of the crowd image, C I Indicates the number of channels of the crowd image. After randomly cropping and normalizing the crowd image, the crowd enhanced image can be obtained.

[0083] S104: Input the crowd-enhanced image into a backbone feature extractor to obtain crowd-visual features.

[0084] The backbone feature extractor (Backbone) is a Twins-PcPvT-large model pre-trained on the ImageNet dataset.

[0085] refer to Figure 2 The Twins-PcPvT-large model consists of four stages. Each stage has a similar structure, consisting of a Transformer encoder and a position encoder (PEG, Position Encoding Generator), and the input of each stage of the Transformer encoder is the output of the previous layer. The calculation formula is as follows:

[0086]

[0087] Where u = 1, 2, 3, 4, and u represents the stage. stage_u represents the output of the u-th stage of the Transformer encoder, represents the output of the u-1th stage, TraEncoder represents the Transformer encoder, Representation output The addition is performed on the channel, N represents the number of repetitions of the Transformer encoder, and PEG represents the position encoder.

[0088] After the crowd-enhanced image is input into the backbone feature extractor, the output results of the four stages are compressed using image compression technology to obtain the crowd-visual feature map. Crowd-Visual Feature Map Crowd-Visual Feature Map and crowd-visual feature map The image compression technology refers to compressing the image channels through 1×1 convolution, H represents the height of the crowd-enhanced image, W represents the width of the crowd-enhanced image, and C represents the number of channels of the crowd-enhanced image.

[0089] S106: A dense multi-level hole semantic encoding module is used to fuse crowd-visual features to obtain crowd-robust features.

[0090] refer to Figure 3 The dense multi-level hole semantic encoding module (DMASE) consists of a multi-level hole feature extraction layer and a deconvolution recovery layer, and the output of the dense multi-level hole semantic encoding module is recorded as O. Specifically, due to the differences in the size (scale) of the head of the characters in the crowd enhanced image, we input the crowd-visual feature map F2, the crowd-visual feature map F3 and the crowd-visual feature map F4 into the dense multi-level hole semantic encoding module to extract features O2, O3 and O4 with rich receptive fields to cope with characters of different scales.

[0091] The multi-level hole feature extraction layer is composed of parallel mode and stride connection. Specifically, taking feature map F4 as a preferred embodiment, in order to effectively reduce the computational complexity, we first use a 1×1 convolution layer to perform channel compression on feature map F4 to obtain a compressed feature map Among them C a is the number of image channels after feature map F4 is compressed, that is, the compressed feature map F a It should be understood that in addition to using feature map F4 for implementation, feature map F2 or feature map F3 can also be used as an implementation. Next, in parallel mode, dilated convolutions with different dilation rates are used to extract compressed feature maps F a Multi-scale receptive field features.

[0092] For two-dimensional feature space mapping, the calculation formula of the dilated convolution is as follows:

[0093]

[0094] Among them, y represents the output feature map matrix, i represents the number of rows of the input eigenvalue matrix, j represents the number of columns of the input eigenvalue matrix, and y i,j represents the output feature map matrix when the number of rows of the input eigenvalue matrix is ​​i and the number of columns of the input eigenvalue matrix is ​​j, Φ represents the input eigenvalue matrix, row represents the row number of the convolution kernel, col represents the column number of the convolution kernel, k row Indicates the number of rows of the convolution kernel, k col represents the number of columns of the convolution kernel, d represents the void rate, and A represents the convolution kernel matrix.

[0095] In order to cover more scales, we define the void ratio d = {d1, d2, d3, d4, d5}, where d m (m=1,2,…,5) represents the hole rate of the mth convolutional layer in the dense multi-level hole semantic coding module.

[0096] In order to obtain a combined feature map with rich semantic and spatial information, we use stride connections to share the information of the previous convolutional layer. Specifically, each stride connection stacks dilated convolutions with different dilation rates to form a dense convolution combination. This design gives the network the ability to encode multiple receptive fields.

[0097] The output formula of parallel mode and stride connection is as follows:

[0098]

[0099] Among them, p m represents the output of the mth convolutional layer in parallel mode, c m represents the output of the mth convolutional layer of the stride connection, dm represents the hole rate of the mth convolutional layer, represents the atrous convolution of the mth convolutional layer with a filter size of 3, function In is a custom function, represents the sequential cascade from convolutional layer n to convolutional layer m-1, represents the dilated convolution from convolution layer n to convolution layer m-1, represents the dilated convolution of convolutional layer m, d n represents the hole rate of the nth convolutional layer, Indicates cascade operation, c n Represents the output of the strided connection on the nth convolutional layer.

[0100] In order to effectively utilize multi-level semantic information, the deconvolution recovery layer fuses crowd-visual feature maps F1, crowd-visual feature maps F2, crowd-visual feature maps F3 and crowd-visual feature maps F4 of different sizes from bottom to top to obtain feature maps with coarse-fine granularity. Specifically, the deconvolution recovery module in the deconvolution recovery layer adjusts the feature map of this level to the same size as the feature map of the previous level from bottom to top during the image size restoration process. The formula is as follows:

[0101]

[0102] The final output q1 of the deconvolution recovery layer is concatenated with the output p1 of the first level of the parallel mode on the channel to output the final feature map. The calculation process is as follows:

[0103] O=p1+q1

[0104] Among them, q b represents the output of the b-th layer of the deconvolution recovery layer, represents the deconvolution of the b-th deconvolution recovery layer with a filter size of 3, d b represents the deconvolution rate of the b-th deconvolution recovery layer, c b represents the output of the stride connection on the b-th deconvolution recovery layer, p1 represents the output of the parallel mode on the first convolution layer, and q1 represents the final output of the deconvolution recovery layer.

[0105] Inspired by the “U”-shaped structure, the outputs O2 and O2 with rich receptive fields of the dense multi-level hole semantic encoding module are further subjected to multi-layer feature aggregation. Specifically, the calculation formula of multi-layer feature aggregation is:

[0106]

[0107] Among them, O eIt represents the output of the e-th convolutional layer of multi-layer feature aggregation, conv(.) represents a 3×3 convolution operation, and up(·) represents an upsampling function with a sampling rate of 2. After completing the multi-layer feature aggregation, the feature fusion of the crowd-visual features is realized, and the corresponding crowd-robust features are obtained.

[0108] S108: Use a learnable threshold segmentation attention module to dynamically adjust the segmentation threshold of the crowd-robust feature to obtain the crowd-fine-grained feature.

[0109] As a preferred embodiment, the overall structure of the learnable threshold segmentation attention module (TSAM) is referenced Figure 4 As shown in the figure, it uses a three-branch architecture to dynamically adjust the segmentation threshold, filter background noise, and highlight the characteristics of the crowd area.

[0110] Specifically, the three-branch is mainly composed of an upper branch, a middle branch and a lower branch, where the upper branch is responsible for outputting the segmentation probability map F S ∈[0,1], the middle branch is responsible for dynamically adjusting the segmentation threshold T∈[0,1] based on the crowd density (i.e., dense crowd areas will generate smaller thresholds to make it easier to segment people), and the lower branch aims to filter out the interference of background noise.

[0111] In the upper branch, the feature map with crowd-robust features Pass it to three consecutive convolutional layers to obtain the segmentation probability map F S It should be noted that due to the significant difference in the probability distribution of heads of different scales, we use the person segmentation label S in the upper branch. gt For the segmentation probability map F S Supervise so that the segmentation probability map F S Close to the person segmentation label S gt .

[0112] Person segmentation label S gt The formula definition is as follows:

[0113]

[0114] Among them, E represents the character segmentation label S gt The total number of pixels, represents the segmentation label of the E-th pixel, represents the value of the person segmentation label, represents the ground-truth density map, ε represents the threshold, and in this invention we set the threshold ε to 10 -3 .

[0115] The three consecutive convolutional layers include two 3×3 convolution kernels and one 1×1 convolution kernel.

[0116] Most previous methods that introduce segmentation into crowd counting believe that when F S When (i,j)≥ε, there is someone at position (i,j), where F S (i,j) represents the segmentation probability map F S The value when the number of rows in the input eigenvalue matrix is ​​i and the number of columns in the input eigenvalue matrix is ​​j. Usually the threshold ε = 0.5. However, this fixed threshold setting limits the flexibility of the model in practical scenarios. According to our observation, the crowd density of different images varies, so a method of dynamically adjusting the threshold is needed to make the threshold ε change according to the crowd density. Therefore, we construct a segment binarization layer (SBL) in the middle branch to generate a pixel-level learnable threshold.

[0117] The configuration of the segmented binary layer is as follows: 3×3 convolution, 3×3 convolution, 1×1 convolution and Sigmoid function. The segmented binary layer is the segmentation probability map. Find the appropriate segmentation threshold for each pixel, that is, learn a threshold matrix Make the output result O(i,j) and the character segmentation label S gt Getting closer, among them, H F Represents the segmentation probability map F S High, W F Represents the segmentation probability map F S width, O(i,j) represents the final output of the dense multi-level hole semantic encoding module when the number of rows of the input eigenvalue matrix is ​​i and the number of columns of the input eigenvalue matrix is ​​j.

[0118] The specific forward propagation process of the piecewise binarization layer is: S (i, j) ≥ T(i, j), the output result is O(i, j) = 1, otherwise O(i, j) = 0. Wherein, T(i, j) represents the value of the threshold matrix T when the number of rows of the input eigenvalue matrix is ​​i and the number of columns of the input eigenvalue matrix is ​​j.

[0119] The threshold matrix T is a parameter that the network needs to learn, but it involves comparison operations, and the gradient of the threshold matrix T cannot be updated during the back propagation process. Therefore, the present invention sets the gradient of the threshold matrix T to -1 during the back propagation process of the segmented binarization layer.

[0120] Specifically, the calculation process formula of the output result O(i, j) of the middle branch is as follows, where B(.) represents a binarization function.

[0121]

[0122] In the lower branch, the output O(i,j) is compared with the feature map before being input to the CUT layer. Then, the feature map is multiplied by skip connection. To connect, the formula is as follows:

[0123] F=Conv(CUT(F⊙O)+F)

[0124] Among them, Conv(.) represents a 1×1 convolution operation, ⊙ represents multiplication, + represents addition, and CUT represents the convolution of the CUT layer. The CUT layer consists of the Transformer layer and conditional position encoding (CPE) in the Twins PcPvT-large model, which is mainly used to extract character information. After the connection, you can obtain crowd-level fine-grained features.

[0125] S110: Convolutional groups are used to extract and aggregate crowd-fine-grained features from multiple levels to generate crowd density maps.

[0126] The configuration of the convolution group (CG) is as follows: 3×3 convolution, 3×3 convolution, 1×1 convolution. After the crowd-fine-grained features are extracted and aggregated by the convolution group, the crowd density map can be generated.

[0127] S112: Using a loss function to obtain the number of people in all areas and / or local areas in the crowd density map.

[0128] The loss function is composed of different level combination losses L l Specifically, in order to further accelerate the convergence of the network, the present invention supervises MASP-Net at three levels from the second stage to the fourth stage (Stage2-4) to obtain the combined loss L total :

[0129]

[0130] Different levels of combined loss L l The character segmentation loss L S , crowd density loss L R And the local perception attention loss LALoss, the character segmentation loss L S The loss function is:

[0131]

[0132] Among them, z represents the character segmentation label S gt The pixels in p z represents the true value label of pixel z, l zrepresents the predicted probability that pixel z is the foreground, γ is the modulation factor, s represents the stage of supervision of MASP-Net, represents the modulation factor of the true value label of pixel z;

[0133] Crowd density loss L R The structural loss SL and the total change loss L TV Composition, crowd density loss L R The loss function is:

[0134] LR=SL(DP☉Sgt,Dgt☉Sgt)+in·LTV(DP,Dgt),s∈(2,3,4)

[0135] Among them, D P Represents the predicted crowd density map, D gt Represents the true value of the crowd density map, ⊙ represents multiplication, and λ represents an adjustable hyperparameter.

[0136] Afterwards, the crowd density map truth D gt Get the number of people in all areas and each local area in the crowd density map, specifically:

[0137] We first transform the crowd density map truth value D gt Divided into 4×4 sub-regions, denoted as in represents the height of the crowd density map, z represents the sub-area number of the crowd density map, represents a sub-region, represents the width of the crowd density map, and w represents the number of rows of the crowd density map;

[0138] The calculation process of the true value of the number of people in the sub-area is:

[0139]

[0140] Among them, P w,z Represents the true value of the number of people in the z-th block of the w-th row of the crowd density map;

[0141] The true value P of the number of people in the sub-region w,z Based on the proportion of the total number of people, the attention α allocated to people of different densities is calculated. w,z ;

[0142]

[0143] The local perceptual attention loss LALoss aims to make the population of the sub-region consistent with the local population truth on the image. The formula is defined as follows:

[0144]

[0145] in, represents the sub-region number, α w,z Represents the attention adjustment factor of the sub-region. With the help of local perceptual attention loss LALoss, the present invention can not only supervise the segmentation probability map and threshold map to reduce the influence of background noise, but also emphasize the counting model's attention to the dense areas prone to errors, thereby improving the crowd counting performance.

[0146] The effectiveness of the present invention is verified based on four different crowd datasets: ShanghaiTechA, JHU-Crowd++, UCF-QNRF and NWPU-CROWD. ShanghaiTechA includes a total of 482 images, of which the training set contains 300 images and the test set contains 182 images. The JHU-Crowd++ dataset covers a wide range of image scenes, including different scene styles (such as street scenes, train stations, parades, etc.), various weather conditions (such as rain, snowfall, etc.) and lighting changes. The dataset contains a total of 4372 images, of which 2272 are used for training, 500 are used for verification, and 1600 are used for testing. The images in the UCF-QNRF dataset are collected from dense crowd scenes around the world, including various elements such as buildings, vegetation, sky and roads. The dataset contains a total of 1535 high-resolution images, of which 1201 images are used for training, and the remaining 334 images are used for testing. NWPU-crowd is one of the largest crowd datasets at present, containing a total of 5109 images. Among them, the training set contains 3109 images, the validation set contains 500 images, and the test set contains 1500 images. The average resolution of these images is 2191×3209 pixels.

[0147] Mean absolute error (MAE) and mean square error (MSE) are used as evaluation indicators of the present invention, and their definitions are as follows:

[0148]

[0149]

[0150] Where M represents the total number of images, P b represents the predicted number of people in the bth image, G b Indicates the actual number of people in the bth image.

[0151] Table 1 shows the comparison results between the proposed method and other methods. It can be clearly observed from the table that, compared with other methods, the proposed method (MASP-Net) can better handle crowd scenes with large scale changes and noisy backgrounds. This shows that the proposed method is superior to other methods in performance.

[0152] Table 1 Comparison results of the present invention with other algorithms on different data sets

[0153]

[0154] As described above, the above embodiments are only used to introduce the technical solution of the present application in detail, but the description of the above embodiments is only used to help understand the method and core idea of ​​the present application and should not be understood as limiting the present application. Any changes or substitutions that can be easily thought of by technicians in this technical field within the technical scope disclosed in the present application should be included in the protection scope of the present application.

Claims

1. A machine vision crowd counting method based on MAPS-Net, It is characterized in that include: Input a crowd image, and perform data enhancement on the crowd image to obtain a crowd enhanced image; Input the crowd-enhanced image into the backbone feature extractor to obtain crowd-visual features; A dense multi-level hole semantic encoding module is used to fuse crowd-visual features to obtain crowd-robust features; A learnable threshold segmentation attention module is used to dynamically adjust the segmentation threshold of the crowd-robust feature to obtain crowd-fine-grained features; Convolutional groups are used to extract and aggregate crowd-fine-grained features from multiple levels to generate crowd density maps; The loss function is used to obtain the number of people in all areas and / or local areas in the crowd density map.

2. A machine vision crowd counting method based on MAPS-Net as claimed in claim 1, It is characterized in that The backbone feature extractor is the Twins-PcPvT-large model pre-trained on the ImageNet dataset. The Twins-PcPvT-large model consists of four stages, specifically: The input of each stage of the backbone feature extractor is the output of the previous stage, and the calculation formula is as follows: Where u = 1, 2, 3, 4, u represents the stage, F stage_u represents the output of the u-th stage of the Transformer encoder, represents the output of the u-1th stage, TraEncoder represents the Transformer encoder, Representation output Addition is performed on the channel, N represents the number of repetitions of the Transformer encoder, and PEG represents the position encoder; The output results of the four stages are compressed to obtain the crowd-visual feature map Crowd-Visual Feature Map Crowd-Visual Feature Map and crowd-visual feature map Among them, H represents the height of the crowd enhanced image, W represents the width of the crowd enhanced image, and C represents the number of channels of the crowd enhanced image. Feature matrix dimensions representing the feature map.

3. A machine vision crowd counting method based on MAPS-Net as claimed in claim 2, It is characterized in that The method of using a dense multi-level hole semantic coding module to fuse crowd-visual features to obtain crowd-robust features includes: The dense multi-level hole semantic encoding module consists of a multi-level hole feature extraction layer and a deconvolution recovery layer, and its output is denoted as O. Specifically, the crowd-visual feature map F 2 , Crowd-Visual Feature Map F 3 and crowd-visual feature map F 4 Input into the dense multi-level hole semantic encoding module to extract features with rich receptive fields O 2 , O 3 and O 4 ; The multi-level hole feature extraction layer is composed of parallel mode and stride connection. Specifically, a 1×1 convolutional layer is used to extract the crowd-visual feature map F 4 Perform channel compression to obtain a compressed feature map Among them C a is the crowd-visual feature map F 4 The number of channels of the compressed image; In parallel mode, dilated convolutions with different dilation rates are used to extract the compressed feature map F. a The multi-scale receptive field features of the two-dimensional feature space mapping, the calculation formula of the hole convolution is as follows: Among them, y represents the output feature map matrix, i represents the number of rows of the input eigenvalue matrix, j represents the number of columns of the input eigenvalue matrix, and y i,j represents the output feature map matrix when the number of rows of the input eigenvalue matrix is ​​i and the number of columns of the input eigenvalue matrix is ​​j, Φ represents the input eigenvalue matrix, row represents the row number of the convolution kernel, col represents the column number of the convolution kernel, k row Indicates the number of rows of the convolution kernel, k col represents the number of columns of the convolution kernel, d represents the void ratio, and A represents the convolution kernel matrix; Define void ratio d = {d 1 ,d 2 ,d 3 ,d 4 ,d 5 }, where d m (m=1,2,…,5) represents the hole rate of the mth convolutional layer in the dense multi-level hole semantic coding module; The stride connection is used to share the information of the previous convolutional layer. Specifically, the output formula of the parallel mode and the stride connection is as follows: Among them, p m represents the output of the mth convolutional layer in parallel mode, c m represents the output of the mth convolutional layer of the stride connection, d m represents the hole rate of the mth convolutional layer, represents a dilated convolution with a filter size of 3 and the mth convolutional layer, It means that the convolutional layers n to m-1 are cascaded in sequence. represents the dilated convolution from convolution layer n to convolution layer m-1, represents the dilated convolution of convolutional layer m, d n represents the hole rate of the nth convolutional layer, Indicates cascade operation, c n Represents the output of the stride connection on the nth convolutional layer; The deconvolution recovery layer fuses crowd-visual feature maps F of different sizes from bottom to top. 1 , Crowd-Visual Feature Map F 2 , Crowd-Visual Feature Map F 3 and crowd-visual feature map F 4 To obtain a feature map with coarse-fine granularity, specifically: the deconvolution recovery module in the deconvolution recovery layer adjusts the feature map of this level from bottom to top to the same size as the feature map of the previous level during the image size restoration process. The formula is as follows: The final output q of the deconvolution recovery layer 1 The output p of the first level of parallel mode 1 Splicing is performed on the channel to output the final feature map. The calculation process is as follows: O=p 1 +q 1 Among them, q b represents the output of the b-th layer of the deconvolution recovery layer, represents the deconvolution of the b-th deconvolution recovery layer with a filter size of 3, d b represents the deconvolution rate of the b-th deconvolution recovery layer, c b represents the output of the stride connection on the b-th deconvolution recovery layer, p 1 represents the output of the first convolutional layer in parallel mode, q 1 Represents the final output of the deconvolution recovery layer; The output of the dense multi-level hole semantic encoding module with rich receptive field O 2 , O 3 Multi-layer feature aggregation is further performed. Specifically, the calculation formula for multi-layer feature aggregation is: Among them, O e represents the output of the e-th convolutional layer of multi-layer feature aggregation, conv(.) represents a 3×3 convolution operation, and up(·) represents an upsampling function with a sampling rate of 2.

4. A machine vision crowd counting method based on MAPS-Net as claimed in claim 3, It is characterized in that The method of dynamically adjusting the segmentation threshold of the crowd-robustness feature using a learnable threshold segmentation attention module includes: It uses a three-branch architecture to dynamically adjust the segmentation threshold, filter background noise, and highlight the characteristics of the crowd area. Specifically: the upper branch outputs the segmentation probability map F S ∈[0,1], the middle branch dynamically adjusts the segmentation threshold T∈[0,1] based on the crowd density, and the lower branch filters the interference of background noise; In the upper branch, the feature map with crowd-robust features Pass it to three consecutive convolutional layers to obtain the segmentation probability map F S , using the person segmentation label S gt For the segmentation probability map F S Supervise so that the segmentation probability map F S Close to the person segmentation label S gt , character segmentation label S gt The formula definition is as follows: Among them, E represents the character segmentation label S gt The total number of pixels, represents the segmentation label of the E-th pixel, represents the value of the person segmentation label, represents the true value of the density map, ε represents the threshold and is set to 10 -3 ; The three consecutive convolutional layers include two 3×3 convolution kernels and one 1×1 convolution kernel; In the middle branch, a segmented binarization layer is constructed to generate a pixel-level learnable threshold. The segmented binarization layer is configured as follows: 3×3 convolution, 3×3 convolution, 1×1 convolution and Sigmoid function. The segmented binarization layer is a segmentation probability map. Find the appropriate segmentation threshold for each pixel, that is, learn a threshold matrix Make the output result O(i,j) and the character segmentation label S gt Getting closer, among them, H F Represents the segmentation probability map F S High, W F Represents the segmentation probability map F S The width of O(i,j) represents the final output of the dense multi-level hole semantic encoding module when the number of rows of the input eigenvalue matrix is ​​i and the number of columns of the input eigenvalue matrix is ​​j; The specific forward propagation process of the piecewise binarization layer is: S (i,j)≥T(i,j), the output result is O(i,j)=1, otherwise O(i,j)=0; where T(i,j) represents the value of the threshold matrix T when the number of rows of the input eigenvalue matrix is ​​i and the number of columns of the input eigenvalue matrix is ​​j, and the gradient of the threshold matrix T is set to -1; Specifically, the calculation process formula of the output result O(i,j) of the middle branch is as follows; Among them, B(.) represents the binarization function; In the lower branch, the output O(i,j) is compared with the feature map before being input to the CUT layer. Multiply; then, the feature map is connected through a skip connection To connect, the formula is as follows: F=Conv(CUT(F⊙O(i,j))+F) Among them, Conv(.) represents a 1×1 convolution operation, ⊙ represents multiplication, + represents addition, and CUT(.) represents the convolution of the CUT layer. The CUT layer consists of the Transformer layer and conditional position encoding in the Twins PcPvT-large model. After the connection, you can obtain crowd-level fine-grained features.

5. A machine vision crowd counting method based on MAPS-Net as claimed in claim 1, It is characterized in that The convolution group configuration for extracting and aggregating crowd-fine-grained features is 3×3 convolution, 3×3 convolution, and 1×1 convolution.

6. A machine vision crowd counting method based on MAPS-Net as claimed in claim 4, It is characterized in that The method of using the loss function to obtain the number of people in all areas and / or local areas in the crowd density map includes: The loss function is composed of different level combination losses L l Specifically, MASP-Net is supervised at three levels from the second stage to the fourth stage to obtain the combined loss L total : Different levels of combined loss L l The character segmentation loss L S , crowd density loss L R And the local perception attention loss LALoss, the character segmentation loss L S The loss function is: Among them, z represents the character segmentation label S gt The pixels in p z represents the true value label of pixel z, l z represents the predicted probability that pixel z is the foreground, γ is the modulation factor, s represents the stage of supervision of MASP-Net, represents the modulation factor of the true value label of pixel z; Crowd density loss L R The structural loss SL and the total change loss L TV Composition, crowd density loss L R The loss function is: L R =SL(D P ⊙S gt ,D gt ⊙S gt )+λ·L TV (D P ,D gt ),s∈(2,3,4) Among them, D P Represents the predicted crowd density map, D gt represents the true value of the crowd density map, ⊙ represents multiplication, and λ represents an adjustable hyperparameter; Afterwards, the crowd density map truth D gt Get the number of people in all areas and each local area in the crowd density map, specifically: First, the crowd density map truth value D gt Divided into 4×4 sub-regions, denoted as in represents the height of the crowd density map, z represents the sub-area number of the crowd density map, represents a sub-region, represents the width of the crowd density map, and w represents the number of rows of the crowd density map; The calculation process of the true value of the number of people in the sub-area is: Among them, P w,z Represents the true value of the number of people in the z-th sub-region of the w-th row of the crowd density map; The true value P of the number of people in the sub-region w,z Based on the proportion of the total number of people, the attention α allocated to people of different densities is calculated. w,z ; The local attention loss LALoss formula is defined as follows: in, represents the sub-region number, α w,z Represents the attention regulation factor of the sub-region.

Citation Information

Patent Citations

  • Crowd counting network modeling method based on hierarchical difference feature aggregation

    CN115861930A

  • Crowd density estimation method based on spatial context learning network

    CN116403152A

  • Crowd counting method based on trans-scale pyramid Transform

    CN116740439A

  • Double-attention-guided crowd counting method and device and computer storage medium

    CN117409375A

  • Joint count and flow analysis for video crowd scenes

    US20240144490A1