Method and device for monitoring all-time human traffic and abnormal collecting and distributing behaviors
Through DCGAN data expansion and quadtree segmenter model, combined with ResNet-50 feature extraction and attention mechanism, the accuracy and real-time problems of crowd monitoring in low-light environments are solved, and high-precision human flow monitoring and abnormality monitoring are achieved throughout the period. Behavior detection reduces latency.
Patent Information
- Application Number
- CN202410628924.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-21
- Publication Date
- 2024-09-03
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing technology is difficult to accurately monitor crowd density in low-light environments, and traditional methods have single functions and cannot provide instance-level information. Furthermore, cloud computing-based data processing results in large delays and slow monitoring responses.
DCGAN is used to generate infrared night vision crowd data set, combined with ResNet-50 image feature extraction and quadtree splitter model, image processing is performed through encoder, quadtree splitter, decoder and prediction head, and the gradual introduction of attention mechanism A rectangular frame is used to monitor the flow of people and abnormal distribution behaviors during the whole period, and reduce the delay through edge computing.
The accuracy and robustness of the model are improved in standard lighting, low-light environments and infrared night vision scenarios. It can monitor crowd density and abnormal gathering and dispersing behavior in real time, provide instance-level information, and reduce latency.
Smart Images

Figure CN118587644A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision, and in particular to the field of crowd counting. Background Art
[0002] Crowd management is of great significance to public security and is closely related to maintaining the safety of people's lives and social stability. Crowd flow data is an important reference for crowd management. At the same time, according to the social force model and emotional contagion model, the sudden gathering or dispersion of crowds has a high probability of indicating the occurrence of abnormal events. Especially at night, due to insufficient light, the probability of accidents is higher, so it is very important to monitor crowd flow and abnormal gathering and dispersion behaviors at all times.
[0003] Traditional crowd counting models mostly use the method of converting images into density map counting, which has achieved good results. However, density maps cannot provide instance-level information of the crowd. Generally, they can only count the crowd, but there is no way to perform other operations such as positioning, and the functions are relatively simple. In addition, traditional models are mostly suitable for conditions with sufficient light, but when the light is insufficient, the feature extraction of the image becomes more difficult. The existing model trains the crowd data set with insufficient light, and the model accuracy will decrease to a certain extent. Moreover, most methods are still based on cloud computing for data processing and analysis, which has a large delay and a slow response to the monitoring output results. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a monitoring method and equipment for counting the number of people in dense crowds and abnormal crowd distribution status at all times of day and night with high accuracy and high efficiency in response to the defects in the prior art.
[0005] In a first aspect, the present invention provides a method for monitoring human flow and abnormal gathering and distribution behavior at all times, the method comprising:
[0006] Step S1.1: Collect data sets and manually label them. The data sets include both dark scene crowd data sets collected by infrared night vision cameras and open source data sets with sufficient brightness and insufficient brightness. The open source data sets have head truth point labels.
[0007] Step S1.2: Use DCGAN to generate more infrared night vision crowd datasets;
[0008] Step S1.3: Perform data enhancement operations such as histogram equalization, contrast enhancement, random cropping, rotation, and scaling on the original image;
[0009] Step S1.4: Use the ResNet-50 image feature extraction network to extract image features, use the Adam optimizer to optimize the model, and use ReLu as the activation function;
[0010] Step S1.5: Use the quadtree splitter model to train the processed data set. The model consists of an encoder, a quadtree splitter, a decoder, and a prediction head. The main steps include:
[0011] Step S1.5.1: The encoder encodes context information using image features extracted by ResNet-50;
[0012] Step S1.5.2: With the help of the encoded information, the quadtree splitter follows a sparse-to-dense process, that is, sparse query points first span the image and are adaptively segmented into dense query points in crowded scenes to perform dense crowd prediction; and the quadtree splitter introduces a progressive rectangular box method based on the attention mechanism, where the progressive rectangular windows are in a descending order, and the small rectangular windows are only used in densely populated areas;
[0013] Step S1.5.3: Obtain a decoded point representation through a decoder;
[0014] Step S1.5.4: Compare the true value point with the predicted point through a prediction head to determine whether it is a person.
[0015] In a second aspect, the present invention provides a data processing and transmission device, comprising:
[0016] One or more processors, memories, network interfaces, user interfaces, communication buses, and a computer program stored in the memories and executable on the processors, the program including instructions for executing the method for monitoring human flow and abnormal gathering and distribution behavior at all times as described above.
[0017] The technical solution provided by the present invention has the following advantages:
[0018] (1) Compared with the existing models that are generally applicable to scenes with sufficient light but have a lower model accuracy in dark scenes, the present invention uses DCGAN to expand the dark scene data set, providing more data sets for model training, avoiding the problem of too few collected data sets, and enhancing the robustness of the model. At the same time, the present invention can realize the monitoring of the flow of people and abnormal gathering and distribution behavior of crowd images in three scenes: standard lighting, low light environment, and infrared night vision, making the model suitable for crowd counting and abnormal gathering and distribution behavior monitoring at all times;
[0019] (2) Compared with the traditional method of using density maps to count people, the quadtree segmentation model can not only count people, but also obtain instance-level information of the crowd, thereby realizing the function of monitoring crowd dispersion;
[0020] (3) A progressive rectangular box method based on the attention mechanism is introduced in the quadtree segmenter. The dense crowd is distinguished from the sparse crowd by using two types of rectangular boxes, large and small, which avoids repeated training and improves the efficiency of the model.
[0021] (4) The present invention deploys the model on the edge device through the relevant edge computing technology, reduces the delay, and can obtain the monitoring results in real time. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] Figure 1 It is a flow chart for counting people flow and monitoring abnormal gathering and dispersion behaviors at all times;
[0023] Figure 2 A system block diagram of a data processing and transmission device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0024] The specific implementation of the present invention will be described in detail below with reference to the accompanying drawings and embodiments.
[0025] refer to Figure 1 As shown, for the first aspect of the present invention, a method for realizing full-time human flow and abnormal gathering and distribution behavior monitoring, the specific steps of constructing and training the model are as follows:
[0026] S1: Dataset collection. The dataset is a full-time crowd image. The present invention needs to collect three types of image data of dense crowds, namely, images under sufficient light, images under insufficient light, and images collected by infrared cameras in complete darkness. Therefore, a combination of on-site collection and open source datasets is adopted. At the same time, since the number of images under insufficient light and images collected by infrared cameras in darkness is much smaller than the number of images under sufficient light, DCGAN is used for data expansion.
[0027] S2: Data enhancement and preprocessing. This includes basic random cropping, rotation, scaling and other techniques, as well as histogram equalization and contrast enhancement of the original image to improve the visibility and extractability of the image.
[0028] S3: Feature extraction. Feature extraction is performed using ResNet-50. ResNet-50 contains 50 convolutional layers, including multiple residual blocks. It uses a max pooling layer to reduce the size of the feature map and a global average pooling layer after the convolutional layer. We use the Adam optimizer for optimization and ReLu as the activation function of the model.
[0029] S4: A quadtree splitter-based model is used for training. The model consists of an encoder, a quadtree splitter, a decoder, and a prediction head. The specific implementation steps are as follows:
[0030] S41: Encoding Transformer: Each spatial element in the feature F extracted by ResNet-50 is considered as a token. These tokens are then passed through a transformer encoder to calculate progressive rectangular window attention to encode context information. The encoder's window attention calculation formula is as follows:
[0031]
[0032]
[0033] In the formula, x l-1 and x l They are the output features of the encoder l-1 layer and l layer respectively, RectWin-SA is the rectangular window self-attention, FFN is the feedforward network, and FN is the layer normalization.
[0034] S42: Quadtree splitter: First, sparse query points are uniformly set on the image with K strides, which corresponds to quadtree level 0 (equivalent to sparse point 0). Then a quadtree splitter is applied to the encoded features, outputting a split map, and the query points in the original dense area are split into dense query points, forming quadtree level 1 (equivalent to dense point 1). The split map is:
[0035]
[0036] In the formula, each element in Ms represents the probability of a dense area (1 represents a dense area, 0 represents a sparse area), Represents a matrix of size h'×w'.
[0037] In the quadtree splitter, the quadtree splitter consists of an average pooling layer, a 1×1 convolution layer, and a sigmoid function. Its loss function is:
[0038]
[0039] In the formula, is an indicator function (when the input is True, the output is 1, when the input is False, the output is 0), M s For segmentation mapping.
[0040] S43: Decoding Transformer: Like encoding, decoding is also performed within a rectangular window. The transformer decoder receives the quadtree partitioner and the encoded image features as input and outputs the decoded prediction points. It infers the number and location of people by modeling the relationship between the prediction points under the guidance of the image context. The decoder's in-window attention calculation formula is as follows:
[0041]
[0042]
[0043]
[0044] In the formula, z l-1 and z l are the output features of the decoder l-1 layer and l layer respectively, RectWin-SA and RectWin-CA are the rectangular window self-attention and rectangular window cross-attention respectively, FFN is the feedforward network, and FN is the layer normalization.
[0045] S44: Prediction head: A prediction head is applied to the decoded prediction point, and outputs the judgment result ("yes" or "no") of whether it is a person by comparing the prediction point with the real point. The prediction head consists of an MLP layer with a ReLU activation function. Its loss function is as follows:
[0046]
[0047] In the formula, They are classification loss (cross entropy loss function is used here) and localization loss (smoothing loss is used here). loss function), c i 、c i * are the classification labels and predicted classification probabilities, respectively, i For the real point, P σ(i) is the point matched with the real point by the point query method, and λ1 is the hyperparameter of weight balance. They are classification loss (cross entropy loss function is used here) and localization loss (smoothing loss is used here). loss function), c i 、c i * are the classification labels and predicted classification probabilities, respectively, i For the real point, P σ(i) is the point matched with the real point by the point query method, and λ1 is the hyperparameter of weight balancing.
[0048] Combining the above formula, we have the loss function of the entire model:
[0049]
[0050] Where λ2 is a hyperparameter for weight balancing.
[0051] S5: The positions of people in the crowd obtained by the quadtree segmenter model are compared in adjacent frames to determine the discrete and aggregated states of the crowd.
[0052] refer to Figure 2 As shown, in the second aspect of the present invention, the present invention provides a data processing and transmission device, comprising:
[0053] One or more processors, memories, network interfaces, user interfaces, communication buses, and a computer program stored in the memories and executable on the processors, the program including instructions for executing the method for monitoring human flow and abnormal gathering and distribution behavior at all times as described above.
Claims
1. A method and device for monitoring full-time human flow and abnormal gathering and distribution behavior based on DCGAN and quadtree segmenter, characterized in that: The method uses DCGAN to expand the infrared night vision image dataset to enhance the robustness of the model, and obtains the crowd count value and the head position of the person through the quadtree segmenter model; The method comprises: Dataset collection: Use infrared + visible light cameras to collect crowd datasets in dark scenes, and combine them with open source datasets as input for model training; Generate more infrared night vision crowd datasets: Use DCGAN to obtain more crowd datasets in dark scenes; Data enhancement module: performs histogram equalization, contrast enhancement and other operations on the original image; Feature extraction network: ResNet-50 network is used to extract image features; Quadtree segmenter model: It consists of an encoder, a quadtree splitter, a decoder, and a prediction head. The encoder encodes context information using image features extracted by ResNet-50. The quadtree splitter uses the encoded information to follow a sparse-to-dense process, that is, sparse query points first span the image and are adaptively split into dense query points in crowded scenes to predict the crowd in dense scenes. Then, the decoder is used to obtain the decoded point representation, and a prediction head is used to compare the true value point with the predicted point to determine whether it is a person. Model deployment: The data collected by the infrared + visible light camera is input into the deployed model, and the video stream data, crowd counting statistics, and crowd dispersion and aggregation judgment results are sent to the LAN server through the network communication module and displayed on the client.
2. The data set as described in claim 1 includes a collected dark scene crowd data set and an open source data set with sufficient brightness and insufficient brightness, wherein the open source data set has a head truth point label.
3. The dark scene dataset as described in claim 1 is collected by an infrared + visible light camera.
4. The data enhancement as described in claim 1 includes basic random cropping, rotation, scaling and other operations.
5. The feature extraction network as described in claim 1 uses Adam optimizer to optimize the model and uses ReLu as the activation function.
6. The quadtree segmenter as described in claim 1 introduces a progressive rectangular frame method based on an attention mechanism, wherein the progressive rectangular windows are arranged in a descending order, and small rectangular windows are only used in areas with dense crowds. In this way, dense crowds can be distinguished from sparse crowds, while improving the training efficiency of the model.
7. The quadtree splitter in the quadtree segmenter as claimed in claim 1 consists of an average pooling layer, a 1×1 convolution layer and a sigmoid function.
8. The quadtree segmenter as claimed in claim 6 is a self-segmentation model that allows data-dependent segmentation in crowded areas, thereby being able to adaptively handle scenes with dense and sparse crowds.
9. The quadtree segmenter model as described in claim 6 can eventually output the count value of the crowd and the location of the crowd, so that the model has the function of monitoring the dispersion of the crowd.
10. The model deployment as described in claim 1 provides a data processing and transmission device, including one or more processors, memories, network interfaces, user interfaces, communication buses, and computer programs stored in the memories and executable on the processors, the programs including instructions for executing the full-time pedestrian flow and abnormal gathering and distribution behavior monitoring method as described in claims 1 to 8.
Citation Information
Patent Citations
Pedestrian flow monitoring method and device, storage medium and equipment
CN109697435A
Multi-label-based light-weight rapid crowd counting method
CN111144329A
Crowd counting method based on trans-scale pyramid Transform
CN116740439A
Multi-modal crowd counting model training method and system, storage medium and equipment
CN117876824A
Crowd density estimation method based on deep learning
CN117994720A
