People number identification statistical method based on HRNet and 3D attention mechanism
By introducing a multi-scale convolution kernel dual-branch structure and 3D attention mechanism in HRNet, the energy function is optimized, and the problem of low accuracy of population counting in dense scenarios is solved, accurate identification of people and location is achieved, and the level of public safety is improved.
Patent Information
- Application Number
- CN202411827756.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-04-22
AI Technical Summary
In dense scenarios, scale changes and occlusion will lead to low accuracy of population counting, which poses safety hazards.
The number identification statistics method based on HRNet and 3D attention mechanism is adopted. By introducing a multi-scale convolution kernel dual-branch structure and 3D attention mechanism in HRNet, the energy function is optimized to improve the generalization ability of the model and achieve accurate identification of the number and position.
By improving feature extraction capabilities and focusing on useful information, we can accurately identify the number and distribution locations of people in designated space areas, effectively carry out flow control and security deployment, and improve the level of public safety.
Smart Images

Figure CN119863750A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing, and in particular to a method for counting people based on HRNet and 3D attention mechanism. Background Art
[0002] With the rapid development of the economy and society, the pace of urbanization is advancing rapidly, and the urban population is growing sharply. Public places such as shopping malls, airports, railway stations, and hospital outpatient halls often have high crowds. When an emergency occurs, it is easy to cause stampedes due to crowding, which poses a huge safety hazard. Therefore, accurately predicting the number of people in the scene can effectively control the flow of people and deploy security, which is of great significance to social public safety. However, in dense scenes, the accuracy of crowd counting is not high due to scale changes and occlusion. Therefore, it is necessary to provide a method for crowd recognition statistics based on HRNet and 3D attention mechanism to solve the above problems. Summary of the invention
[0003] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0004] A method for counting people based on HRNet and 3D attention mechanism collects indoor image information through a camera installed indoors and transmits it to the server. The server detects the number of people and location information in the image through the following steps:
[0005] Step 1: Generate the truth map into independent non-overlapping regions in HRNet to facilitate the population location statistics of the network density map;
[0006] Step 2: Modify the Block module in HRNet into a multi-scale convolution kernel dual-branch structure to enhance the feature extraction capability;
[0007] Step 3: Introduce the 3D attention mechanism to make the network focus on the useful information of the feature map;
[0008] Step 4: Optimize the energy function and the generalization ability of the model to obtain the final loss of the people counting recognition model as shown in the formula:
[0009] L=αL1+βL2+γL CE (1)
[0010] Among them, α, β, and γ are L1 loss, mean square error L2 loss, and cross entropy L CE The weight of the loss is always 1.
[0011] In the step 4, the energy function is optimized to optimize the generalization ability of the model. During training, the mean square error L2 loss, L1 loss and cross entropy L CEThe loss is combined as the total loss function to optimize the generalization ability of the model. The 3D attention mechanism is different from the existing channel and spatial attention modules. A fast analytical solution is derived by calculating the optimal energy function of formula (2):
[0012]
[0013] in and are t and x respectively i The phenomenon transformation, t and x i They are the feature maps X∈R C×H×W The target neuron and other neurons of a certain channel in , i is the spatial dimension index value, M = H × W is the channel resolution, w t is the weight of the transformation, b t is the deviation of the transformation, y t , y0∈{-1, 1}.
[0014] The mean square error L2 loss is the sum of the squares of the differences between the predicted value and the target value, which can identify the pixel-level error between the predicted image and the true value image.
[0015]
[0016] In formula (3), p(x) is the predicted value of the feature map, g(x) is the true value of the annotation, and M = H × W is the product of the width and height of the image.
[0017] The mean square error L2 loss is easily affected by outliers. In order to alleviate this effect, the L1 loss is introduced, see formula (4), which can handle outliers and has better robustness than the mean square error loss method:
[0018]
[0019] The cross entropy L CE The loss is shown in formula (5). It is used for classification tasks. It reduces the difference between the distribution of the true value map and the predicted value map to achieve the prediction probability distribution fitting the true value probability distribution:
[0020]
[0021] Beneficial effects of the present invention: The present invention enhances the feature extraction capability by introducing a multi-scale convolution kernel dual-branch structure in the Block module in the HRNet network, and then adds a 3D attention mechanism, so that the extracted features focus on the useful information of the feature graph, thereby realizing the identification and statistics of the number of people in a specified spatial area and their distribution positions. By accurately predicting the number of people in the scene, crowd control and security deployment can be effectively carried out, which is of great significance to social public safety; in addition, the crowd counting results can also be applied to fields such as building energy management, actively responding to the call for energy conservation and emission reduction, and has a wide range of application value. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 It is a schematic diagram of the process of the present invention.
[0023] Figure 2 It is the backbone network of HRNet.
[0024] Figure 3 It is the Block of HRNet backbone network.
[0025] Figure 4 3D attention module diagram.
[0026] In the figure, CBA represents convolution, BatchNormation, and activation function; Act represents activation function; 3DAttention represents 3D attention module. DETAILED DESCRIPTION
[0027] In order to make the technical means, creative features, objectives and effects achieved by the present invention easy to understand, the present invention is further explained below in conjunction with specific implementation methods.
[0028] like Figures 1 to 4 As shown in the figure, a method for counting people based on HRNet and 3D attention mechanism is used to collect indoor image information through a camera installed indoors and transmit it to the server. The server detects the number of people and location information in the image through the following steps:
[0029] Step 1: Generate the truth map into independent non-overlapping regions in HRNet to facilitate the population location statistics of the network density map;
[0030] Step 2: Modify the Block module in HRNet to a multi-scale convolution kernel dual-branch structure (such as Figure 3 As shown), to enhance the feature extraction capability;
[0031] Step 3: Introduce 3D attention mechanism (such as Figure 3 , Figure 4 As shown), the network focuses on the useful information of the feature map;
[0032] Step 4: Optimize the energy function and the generalization ability of the model to obtain the final loss of the people counting recognition model as shown in the formula:
[0033] L=αL1+βL2+γL CE (1)
[0034] Among them, α, β, and γ are L1 loss, mean square error L2 loss, and cross entropy L CE The weight of the loss is always 1. The above method is used in the people recognition and counting system to improve the accuracy of the recognition technology.
[0035] In the step 4, the energy function is optimized to optimize the generalization ability of the model. During training, the mean square error L2 loss, L1 loss and cross entropy L CE The loss is combined as the total loss function to optimize the generalization ability of the model. The 3D attention mechanism is different from the existing channel and spatial attention modules. A fast analytical solution is derived by calculating the optimal energy function of formula (2):
[0036]
[0037] in and are t and x respectively i The phenomenon transformation, t and x i They are the feature maps X∈R C×H×W The target neuron and other neurons of a certain channel in , i is the spatial dimension index value, M = H × W is the channel resolution, w t is the weight of the transformation, b t is the deviation of the transformation, y t , y0∈{-1, 1}.
[0038] The mean square error L2 loss is the sum of the squares of the differences between the predicted value and the target value, which can identify the pixel-level error between the predicted image and the true value image.
[0039]
[0040] In formula (3), p(x) is the predicted value of the feature map, g(x) is the true value of the annotation, and M = H × W is the product of the width and height of the image.
[0041] The mean square error L2 loss is easily affected by outliers. In order to alleviate this effect, the L1 loss is introduced, see formula (4), which can handle outliers and has better robustness than the mean square error loss method:
[0042]
[0043] The cross entropy L CEThe loss is shown in formula (5). It is used for classification tasks. It reduces the difference between the distribution of the true value map and the predicted value map to achieve the prediction probability distribution fitting the true value probability distribution:
[0044]
[0045] It is known from common technical knowledge that the present invention can be implemented by other embodiments that do not deviate from its spirit or essential features. Therefore, the above disclosed embodiments are only illustrative in all respects and are not exclusive. All changes within the scope of the present invention or within the scope equivalent to the present invention are included in the present invention.
Claims
1. A method for counting people based on HRNet and 3D attention mechanism, characterized in that: The indoor camera collects indoor image information and transmits it to the server. The server detects the number of people and location information in the image through the following steps: Step 1: Generate the truth map into independent non-overlapping regions in HRNet to facilitate the population location statistics of the network density map; Step 2: Modify the Block module in HRNet into a multi-scale convolution kernel dual-branch structure to enhance the feature extraction capability; Step 3: Introduce the 3D attention mechanism to make the network focus on the useful information of the feature map; Step 4: Optimize the energy function and the generalization ability of the model to obtain the final loss of the people counting recognition model as shown in the formula: L=αL1+βL2+γL CE (1) Among them, α, β, and γ are L1 loss, mean square error L2 loss, and cross entropy L CE The weight of the loss is always 1.
2. A method for counting people based on HRNet and 3D attention mechanism according to claim 1, characterized in that: In the step 4, the energy function is optimized to optimize the generalization ability of the model. During training, the mean square error L2 loss, L1 loss and cross entropy L CE The loss is combined as the total loss function to optimize the generalization ability of the model. The 3D attention mechanism is different from the existing channel and spatial attention modules. A fast analytical solution is derived by calculating the optimal energy function of formula (2): in and are t and x respectively i The phenomenon transformation, t and x i They are the feature maps X∈R C ×H×W The target neuron and other neurons of a certain channel in , i is the spatial dimension index value, M = H × W is the channel resolution, w t is the weight of the transformation, b t is the deviation of the transformation, y t , y0∈{-1, 1}.
3. According to the method for counting people based on HRNet and 3D attention mechanism described in claim 1, it is characterized by: The mean square error L2 loss is the sum of the squares of the differences between the predicted value and the target value, which can identify the pixel-level error between the predicted image and the true value image. In formula (3), p(x) is the predicted value of the feature map, g(x) is the true value of the annotation, and M = H × W is the product of the width and height of the image.
4. According to the method for counting people based on HRNet and 3D attention mechanism described in claim 1, it is characterized by: The mean square error L2 loss is easily affected by outliers. In order to alleviate this effect, the L1 loss is introduced, see formula (4), which can handle outliers and has better robustness than the mean square error loss method:
5. According to the method for counting people based on HRNet and 3D attention mechanism as described in claim 1, it is characterized by: The cross entropy L CE The loss is shown in formula (5). It is used for classification tasks. It reduces the difference between the distribution of the true value map and the predicted value map to achieve the prediction probability distribution fitting the true value probability distribution:
Citation Information
Cited By
Commercial building scenarized control method based on image recognition
CN121505544A