A general-purpose location counting method based on multi-scale perception

Through multi-scale sensing, a universal positioning and counting method, using the VGG-16 network and dual-branch prediction module, it solves the counting problem in dense crowds and complex backgrounds, achieving high-precision and anti-interference counting capabilities, and is suitable for a variety of applications. scenarios and provide auxiliary information for downstream tasks.

CN115082853BActive Publication Date: 2024-10-22长三角信息智能创新研究院
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210669997.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-14
Publication Date
2024-10-22
Estimated Expiration
2042-06-14

AI Technical Summary

Technical Problem

The existing technology is difficult to achieve high-precision counting in densely populated and complex backgrounds, and it is costly to design a separate counting network for each scene, and lacks versatility and anti-interference capabilities.

Method used

It adopts a multi-scale sensing universal positioning and counting method, uses the pre-trained VGG-16 network to extract features, combines dual-branch prediction and one-to-one matching modules, and senses multi-scale information through dilated convolution to achieve positioning and counting of targets. And enhance the processing power of the network through random scaling, cropping and flipping.

Benefits of technology

It achieves good recognition of scale-changing targets and anti-background interference capabilities, has excellent generalization ability and high counting accuracy, is suitable for a variety of scenarios, such as subway carriages, cell and steel bar counting, and provides auxiliary information for downstream tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115082853B_ABST
    Figure CN115082853B_ABST
Patent Text Reader

Abstract

The present invention discloses a general-purpose positioning and counting method of multi-scale perception, the method comprising: step 1, obtaining an image data set for fixed number counting, dividing the data set into a training set and a test set; step 2, constructing a multi-scale positioning and counting network model; step 3, training the multi-scale positioning and counting network model. The present invention can realize the functions of positioning and counting for complex crowd scenes with dense occlusion and perspective distortion, and has good versatility. In addition to crowd counting, it can also realize high-precision, anti-background interference positioning and counting functions in multiple application scenarios such as cell counting, steel bar counting, and retail commodity counting.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a general-purpose positioning and counting method of multi-scale perception. Background Art

[0002] With the increase in population and the frequent occurrence of accidents caused by population gathering, crowd counting as an important technology serving public safety has attracted more and more attention. Crowd counting is also of great significance to transportation facility planning, smart cities and other fields: for example, the TV on the subway platform can display the crowdedness of the subway car, which is convenient for passengers to travel. In addition to the need to count people, there are also needs in the life science field to count cells, the construction engineering field to count steel bars, and so on. These scenes are often close to actual production and life, with the variability of scenes and the complexity of backgrounds. It is costly to design a counting network for each scene separately, so there is a demand for a general-purpose, anti-interference, and high-precision counting network.

[0003] Early counting work was mainly based on target detection methods, which usually use sliding windows to detect human bodies or heads. With the emergence of target detectors such as R-CNN and YOLO in recent years, detection-based methods have good detection accuracy in sparse scenes, but when the crowd is dense and there are complex occlusions and backgrounds, the results of detection-based methods are often not ideal. Summary of the invention

[0004] The purpose of the present invention is to provide a general-purpose positioning and counting method with multi-scale perception. The method has good recognition ability for targets with greatly changed scales and excellent anti-background interference ability; it also has excellent generalization ability and counting accuracy; at the same time, it can also provide auxiliary information for downstream tasks such as pedestrian re-identification and path tracking.

[0005] In order to achieve the above object, the present invention provides a general-purpose positioning counting method for multi-scale perception, the method comprising:

[0006] Step 1: Obtain an image dataset for constant counting and divide the dataset into a training set and a test set;

[0007] Step 2: Construct a multi-scale positioning counting network model;

[0008] Step 3: Train the multi-scale positioning counting network model.

[0009] Preferably, in step 1, the original image data set of the target scene is obtained, and the targets in the scene to be located and counted are required to have similar image features, and each scene needs to be trained using the corresponding data set; including: using Matlab software to annotate the original image after obtaining it, and generating an annotation file; annotating the coordinates of the center points of all targets in the image in the image, and generating them in a .txt or .json format file; wherein, the data set is divided into a training set, a validation set, and a test set in a ratio of 7:1.5:1.5.

[0010] Preferably, the multi-scale positioning counting network structure in step 2 includes three modules: feature extraction, dual-branch prediction, and one-to-one matching.

[0011] Preferably, step 2 comprises:

[0012] Step 2.1, feature extraction, use the VGG-16 network pre-trained on ImageNet as the backbone network to extract input image features;

[0013] Step 2.2: Dual-branch prediction: Generate M anchor points according to the size of the original image, ensuring that M exceeds the true value N, such as generating an anchor point at each pixel position; predict the offset of the anchor point and the classification of the anchor point through the dual-branch head; the offset can make the anchor point generated at a fixed position offset to predict the position of the head, and the classifier is used to give a score to determine whether the predicted point is a positive example or a negative example;

[0014] The extracted image features are copied and input to the regression prediction head and the classification prediction head respectively. The classification prediction head uses three dilated convolution kernels with dilation rates of 1, 2, and 3 to extract features of different scales of the image. The extracted different features are then fused, and finally a classification score set is generated through a standard convolution with a convolution kernel size of 1. The regression branch head finally generates a set of offset prediction points The rest of the structure is the same as the classification prediction head structure;

[0015] Step 2.3: One-to-one matching: combine the offset position generated in step 2.2 with the classification score to generate M predicted points, and match them with the N real point set P = {p j =(x j ,y j )|j=1,2,...,N} are matched, and an M×N cost matrix D is generated for M predicted points and N real points. The generation method is as follows, where τ is a hyperparameter and the default τ=0.06:

[0016]

[0017] After generating the cost matrix D, the Hungarian algorithm is used to determine N one-to-one matching point pairs, and the remaining MN predicted points will be classified as negative examples. The generated space is re-divided, and is a permutation on the set {1, 2, ...M} such that for any i∈[1, N], With p i The first N predicted points after permutation are positive examples, and the last MN points are negative examples.

[0018] Preferably, step 3 comprises:

[0019] Step 3.1: First, randomly scale the input image to a range of 0.7 to 1.3 times the original image size, and then randomly crop the original image. Figure 1 / 4 size image blocks, and flip the image blocks horizontally with a probability of 0.5;

[0020] Step 3.2, using the Adam optimizer, the StepLR interval adjusts the learning rate, and the loss function L is defined as follows:

[0021]

[0022]

[0023] L=L c +λ2L l

[0024] Among them, L c represents the loss function of the classification branch head, L l Represents the loss function of the regression branch head, λ1 and λ2 are hyperparameters, with the default values ​​of λ1=1 and λ2=0.5;

[0025] Step 3.3

[0026] Use the training set to train the multi-scale positioning counting network model and record the effect on the validation set. Save the model that converges and has the best effect on the validation set, and then evaluate it in the test set. The evaluation method uses the mean absolute error MAE and the root mean square error RMSE. The formula is as follows:

[0027]

[0028]

[0029] Among them, K is the total number of images in the test set, pred(i) represents the predicted number of people in a single image, gt(i) represents the total number of labels in a single image, MAE reflects the accuracy of network estimation, and RMSE reflects the stability of the estimation results.

[0030] According to the above technical solution, the present invention uses the pre-trained VGG-16 as the backbone network to extract image features. The image features are input into the dual prediction branch structure, which first uses fixed convolution to process features, and then introduces dilated convolution structures with different dilated rates to perceive multi-scale information. The dual prediction branches predict the classification and offset vector of the anchor points respectively, and finally fuse the prediction information of the dual branches to achieve the positioning and counting of the target.

[0031] Other features and advantages of the present invention will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present invention but do not constitute a limitation of the present invention. In the accompanying drawings:

[0033] Figure 1 It is a structural schematic diagram of the positioning counting model provided by the present invention;

[0034] Figure 2 It is a schematic diagram of the application of the general-purpose positioning and counting method of multi-scale perception provided by the present invention in counting the crowd in a subway car;

[0035] Figure 3 It is a schematic diagram of the application of the general-purpose positioning counting method of multi-scale perception provided by the present invention in cell counting;

[0036] Figure 4 It is a schematic diagram of the application of the general-purpose positioning counting method of multi-scale perception provided by the present invention in steel bar counting;

[0037] Figure 5 It is a detailed structural diagram of the multi-scale positioning counting network in the present invention;

[0038] Figure 6 MAE comparison of different models under different scene data sets;

[0039] Figure 7 Comparison of RMSE of different models under different scenario data sets;

[0040] Figure 8 It is a visualization effect diagram of the model output provided by the present invention;

[0041] Fig. 9 This is a schematic diagram of the dilated convolution with dilation rates of 1, 2, and 4. DETAILED DESCRIPTION

[0042] The specific implementation of the present invention is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described here is only used to illustrate and explain the present invention, and is not used to limit the present invention.

[0043] In the present invention, unless otherwise stated, the directional words contained in the terms merely represent the direction of the terms in normal usage or are common names understood by those skilled in the art, and should not be regarded as limitations on the terms.

[0044] The present invention provides a general-purpose crowd positioning and counting method with multi-scale perception. It uses the pre-trained VGG-16 as the backbone network to extract image features. The image features are input into a dual prediction branch structure, which first uses a fixed convolution to process the features, and then introduces dilated convolution structures with different dilated rates to perceive multi-scale information. The dual prediction branches predict the classification of the anchor points and the offset vector respectively, and finally fuse the prediction information of the dual branches to achieve the positioning and counting of the target.

[0045] Figure 1 The figure shows the positioning counting model structure provided by the present invention. The general positioning counting method of multi-scale perception specifically includes:

[0046] Step 1: Obtain an image dataset for constant counting and divide the dataset into a training set and a test set;

[0047] Step 2: Construct a multi-scale positioning counting network model;

[0048] Step 3: Train the multi-scale positioning counting network model.

[0049] In step 1, the original image dataset of the target scene is obtained. The targets in the scene to be located and counted are required to have similar image features, such as crowds, cells, steel bars, etc. Each scene needs to be trained using the corresponding dataset; including: using Matlab software to annotate the original image after obtaining it, and generating an annotation file; annotating the coordinates of the center points of all targets in the image, and generating them in a .txt or .json format file; the applicable scenarios of the model and the annotation visualization examples are as follows: Figure 2 , Figure 3 , Figure 4 As shown in the figure, the dataset is divided into training set, validation set and test set in a ratio of 7:1.5:1.5.

[0050] See also Figure 5 ,The multi-scale positioning counting network structure in step 2 includes three modules of feature extraction, dual branch prediction, and one-to-one matching.

[0051] Specifically, the above step 2 includes:

[0052] Step 2.1, feature extraction, use the VGG-16 network pre-trained on ImageNet as the backbone network to extract input image features;

[0053] Step 2.2, dual-branch prediction, generates M anchor points according to the size of the original image, ensuring that M exceeds the true value N, such as generating an anchor point at each pixel position; the offset of the anchor point and the classification of the anchor point are predicted respectively through the dual-branch head; the offset can make the anchor point generated at a fixed position offset to predict the position of the head, and the classifier is used to give a score to determine whether the predicted point is a positive example or a negative example; in actual application scenarios, the objects to be located and counted often have perspective relationships that lead to large scale changes, and mutual occlusion between targets and targets, and targets and scenes. Therefore, a functional module that can perceive information at multiple scales and resist interference is required.

[0054] The extracted image features are copied and input into the regression prediction head and the classification prediction head respectively. The classification prediction head uses three dilated convolution kernels with dilation rates of 1, 2, and 3 to extract features of different scales of the image. Existing studies have shown that dilated convolution has a strong perception of the edge contours of objects. The extracted different features are then fused, and finally a classification score set is generated through a standard convolution with a convolution kernel size of 1. The regression branch head finally generates a set of offset prediction points The rest of the structure is the same as the classification prediction head structure;

[0055] Step 2.3: One-to-one matching: combine the offset position generated in step 2.2 with the classification score to generate M predicted points, and match them with the N real point set P = {p j =(x j ,y j )|j=1,2,...,N} are matched, and an M×N cost matrix D is generated for M predicted points and N real points. The generation method is as follows, where τ is a hyperparameter and the default τ=0.06:

[0056]

[0057] After generating the cost matrix D, the Hungarian algorithm is used to determine N one-to-one matching point pairs, and the remaining MN predicted points will be classified as negative examples. The generated space is re-divided, and is a permutation on the set {1, 2, ...M} such that for any i∈[1, N], With p i The first N predicted points after permutation are positive examples, and the last MN points are negative examples.

[0058] Step 3 includes:

[0059] Step 3.1: In order to enhance the network's image processing capabilities and improve the convergence speed, the input image is randomly cropped, randomly scaled, and randomly flipped for data enhancement. First, the input image is randomly scaled in the range of 0.7 to 1.3 times the original image size, and then the original image is randomly cropped. Figure 1 / 4 size image blocks, and flip the image blocks horizontally with a probability of 0.5;

[0060] Step 3.2, using the Adam optimizer, the StepLR interval adjusts the learning rate, and the loss function L is defined as follows:

[0061]

[0062]

[0063] L=L c +λ2L l

[0064] Among them, L c represents the loss function of the classification branch head, L l Represents the loss function of the regression branch head, λ1 and λ2 are hyperparameters, with the default values ​​of λ1=1 and λ2=0.5;

[0065] Step 3.3

[0066] Use the training set to train the multi-scale positioning counting network model and record the effect on the validation set. Save the model that converges and has the best effect on the validation set, and then evaluate it in the test set. The evaluation method uses the mean absolute error MAE and the root mean square error RMSE. The formula is as follows:

[0067]

[0068]

[0069] Among them, K is the total number of images in the test set, pred(i) represents the predicted number of people in a single image, gt(i) represents the total number of labels in a single image, MAE reflects the accuracy of network estimation, and RMSE reflects the stability of the estimation results.

[0070] In previous counting networks, it is often difficult to handle the complex relationship between mutual occlusion between people and occlusion between people and background. In addition, due to the fixed position of the camera, the photos taken will cause changes in the size of the human body due to the perspective relationship. For example, in scenes such as subway cars, due to the height limit and length influence, the perspective distortion effect is more serious. This multi-scale positioning counting network has a good recognition ability for targets with large scale changes and excellent anti-background interference ability due to its dual-branch head fusion multi-scale void convolution structure. In addition, this model has excellent generalization ability and has excellent counting accuracy in scenes such as subway car counting, cell counting, and steel bar counting. Finally, since this model completes the super task of counting tasks: positioning counting, the positioning information output by the model can also provide auxiliary information for downstream tasks such as pedestrian re-identification and path tracking.

[0071] The present invention is described in detail below by way of examples.

[0072] Example

[0073] The model and other crowd counting models were compared in the pytorch framework, and the experimental equipment was RTX3090. Figure 5As shown in the figure, the other five models are: the VGG model, which uses the VGG-16 network structure, including 13 convolutional layers and 3 fully connected layers, totaling 16 hidden layers. It is a classic deep learning basic network and is often used as a baseline for tasks; the MCNN model was published in CVPR2016 and uses a three-column convolutional neural network. The purpose is to use convolution kernels of various scales to adapt to the sizes of human heads of different scales to generate density maps, so it has good counting accuracy for multi-scale character images; the SCAR model was published in the journal Neurocomputing in 2019 and is mainly composed of two modules, namely the spatial attention module SAM and the channel attention module CAM. The former encodes the pixel-level contextual information of the image and enhances the prediction accuracy of the model density map. degree, the latter extracts feature information in different channels, which helps the model focus on the head area of ​​​​the person; the CSRNet model was published in CVPR2018. The model is divided into front-end and back-end networks. The front-end adopts the VGG-16 network with the fully connected layer removed, and the back-end network uses dilated convolution training to generate density maps, which has a strong ability to extract image details; the P2PNet model was published in ICCV2021. For the first time, a completely point-based framework was proposed, which uses dual branches to predict the position of the candidate head center point. Excellent counting accuracy was achieved in multiple public data sets without using a multi-scale feature fusion strategy; taking the steel bar counting scene as an example, the scene data set comes from the 2019 Digital China Innovation Competition Intelligent Inventory-Rebar Quantity AI Recognition Track. The model uses the Adam optimizer, the initial learning rate is 1e-4, and the StepLR interval is used to adjust the learning rate. The default learning rate decay per round is 0.998. The model loss function uses the dual-branch hybrid loss function L described in Part 4: Step 3.2. After the 170th round of training, the optimal model was obtained, with a predicted mean absolute error of 2.96 and a root mean square error of 4.01. The detailed evaluation results of the present invention are compared with other models in different data sets, such as Figure 6 , Figure 7 shown.

[0074] The MAE and RMSE of the proposed model on subway car, cell counting, steel bar counting and retail commodity counting datasets are better than those of other models, proving the superiority of the proposed model. The positioning effect can be demonstrated by visualizing the model output into the original image, such as Figure 8 As shown, the positioning function enables users to intuitively and clearly understand the output effect of the model.

[0075] The preferred embodiments of the present invention are described in detail above in conjunction with the accompanying drawings. However, the present invention is not limited to the specific details in the above embodiments. Within the technical concept of the present invention, a variety of simple modifications can be made to the technical solution of the present invention, and these simple modifications all belong to the protection scope of the present invention.

[0076] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present invention will not further describe various possible combinations.

[0077] In addition, various embodiments of the present invention may be arbitrarily combined, and as long as they do not violate the concept of the present invention, they should also be regarded as the contents disclosed by the present invention.

Claims

1. A general-purpose positioning and counting method based on multi-scale perception, characterized in that: The method comprises: Step 1: Obtain an image dataset for constant counting and divide the dataset into a training set and a test set; Step 2: Construct a multi-scale positioning counting network model; Step 3: Train a multi-scale positioning counting network model; The multi-scale positioning counting network structure in step 2 includes three modules: feature extraction, dual-branch prediction, and one-to-one matching. Step 2 includes: Step 2.1, feature extraction, use the VGG-16 network pre-trained on ImageNet as the backbone network to extract input image features; Step 2.2: Dual-branch prediction: Generate M anchor points according to the size of the original image, ensuring that M exceeds the true value N, such as generating an anchor point at each pixel position; predict the offset of the anchor point and the classification of the anchor point through the dual-branch head; the offset can make the anchor point generated at a fixed position offset to predict the position of the head, and the classifier is used to give a score to determine whether the predicted point is a positive example or a negative example; The extracted image features are copied and input to the regression prediction head and the classification prediction head respectively. The classification prediction head uses three dilated convolution kernels with dilation rates of 1, 2, and 3 to extract features of different scales of the image. The extracted different features are then fused, and finally a classification score set is generated through a standard convolution with a convolution kernel size of 1. The regression branch head finally generates a set of offset prediction points The rest of the structure is the same as the classification prediction head structure; Step 2.3: One-to-one matching: combine the offset position generated in step 2.2 with the classification score to generate M predicted points, and match them with the N real point set P = {p i =(x j ,y j )|j=1,2,...,N} are matched, and an M×N cost matrix D is generated for M predicted points and N real points. The generation method is as follows, where τ is a hyperparameter and the default τ=0.06: After generating the cost matrix D, the Hungarian algorithm is used to determine N one-to-one matching point pairs, and the remaining MN predicted points will be classified as negative examples. The generated space is re-divided, and is a permutation on the set {1, 2, ...M} such that for any i∈[1, N], With p i Match, that is, after permutation, the first N predicted points are positive examples, and the last MN points are negative examples; Step 3 includes: Step 3.1: First, randomly scale the input image to a range of 0.7 to 1.3 times the original image size, then randomly crop an image block that is 1 / 4 the size of the original image, and flip the image block horizontally with a probability of 0.5; Step 3.2, using the Adam optimizer, the StepLR interval adjusts the learning rate, and the loss function L is defined as follows: L=L c +λ2L l Among them, L C represents the loss function of the classification branch head, L l Represents the loss function of the regression branch head, λ1 and λ2 are hyperparameters, with the default values ​​of λ1=1 and λ2=0.5; Step 3.3 Use the training set to train the multi-scale positioning counting network model and record the effect on the validation set. Save the model that converges and has the best effect on the validation set, and then evaluate it in the test set. The evaluation method uses the mean absolute error MAE and the root mean square error RMSE. The formula is as follows: Among them, K is the total number of images in the test set, pred(i) represents the predicted number of people in a single image, gt(i) represents the total number of labels in a single image, MAE reflects the accuracy of network estimation, and RMSE reflects the stability of the estimation results.

2. The general-purpose positioning and counting method of multi-scale perception according to claim 1 is characterized in that: In step 1, the original image dataset of the target scene is obtained. The targets in the scene to be located and counted are required to have similar image features. Each scene needs to be trained using the corresponding dataset; including: using Matlab software to annotate the original image after obtaining it and generate an annotation file; annotating the coordinates of the center points of all targets in the image and generating them in a .txt or .json format file; wherein, the dataset is divided into a training set, a validation set, and a test set in a ratio of 7:1.5:1.5.