A crowd congestion degree safety early warning method, medium and system for school large-scale activities

CN122990625APending Publication Date: 2026-10-27QINGDAO UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611268763.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-20
Publication Date
2026-10-27

AI Technical Summary

Technical Problem

[0003]有鉴于此,本发明提供一种针对学校大型活动的人群拥挤程度安全预警方法、介质及系统,能够解决现有技术中存在在校园大型活动高并发人群轨迹场景下,图神经网络的全局注意力计算复杂度随节点数平方级增长、导致实时拥挤预警推理延迟无法满足安全响应时限的技术问题

Benefits of technology

[0027]本发明通过将线性注意力近似机制与斐波那契数列寻优动态轻量化拓扑图传导算法相结合,构建群体协同规避碰撞行为线性注意力近似图传导模型,将图节点全局关联的计算复杂度由降至,从根本上消除了注意力矩阵随节点数平方级增长的计算瓶颈。线性注意力通过局部滑动窗口限定感受野并经随机核函数映射将查询矩阵与键矩阵投影至低维空间,使单次注意力计算量与节点数保持线性正比关系,推理耗时不再随人群规模扩大而急剧累积。斐波那契寻优动态重构稀疏拓扑矩阵进一步压缩图结构的显存峰值占用,使系统在校园现有服务器资源下支持多路视频并行推理。综上所述,本发明解决了背景技术中提到的在校园大型活动高并发人群轨迹场景下图神经网络全局注意力计算复杂度随节点数平方级增长、导致实时拥挤预警推理延迟无法满足安全响应时限的技术问题。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122990625A_ABST
    Figure CN122990625A_ABST
Patent Text Reader

Abstract

The application provides a crowd congestion degree safety warning method, medium and system for school large-scale activities, and belongs to the technical field of safety warning. The application performs network pruning and knowledge distillation on a monitoring video compression feature flow to support multi-path real-time parallel processing, matrixes a crowd trajectory, adopts a lock-free parallel computing framework to eliminate thread synchronization waiting in high-concurrency warning queries, introduces state entropy increase dynamics constraints to embed an artificial intelligence model to improve mutation behavior prediction accuracy, uses a self-organizing feature mapping hidden layer depth continuous flow model to probabilistically extrapolate high-risk events and combine a full-parallel space-time transformation network to realize space-time feature synchronous parallel prediction, and starts a corresponding level warning response strategy. The application solves the technical problem that, in a high-concurrency crowd trajectory scene of a campus large-scale activity, global attention calculation complexity of a graph neural network increases with the square of the number of nodes, leading to real-time congestion warning reasoning delay that cannot meet the safety response time limit.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of safety early warning technology, and specifically relates to a method, medium and system for safety early warning of crowd density during large-scale school events. Background Technology

[0002] In the field of crowd safety monitoring for large-scale campus events, traditional crowd congestion early warning methods mainly rely on fixed cameras to collect video and use graph neural networks to model crowd trajectories. A fully connected attention mechanism is then used to calculate the global correlation between nodes to identify high-risk congestion situations. This type of method has been applied in scenarios such as stadiums and commercial plazas. However, in large-scale events on campuses with tens of thousands of participants, the number of trajectory nodes increases dramatically with the scale of the event. The computational complexity of the fully connected attention mechanism increases quadratically with the number of nodes, significantly increasing server inference latency. In current campus crowd safety early warning applications, the global attention matrix of the graph neural network needs to be stored and calculated synchronously as the node scale increases. The magnitude of the weighting causes the time taken for a single inference to exceed the safety response time limit, preventing the system from providing real-time early warnings at critical moments when crowd density surges. In other words, existing technologies suffer from a technical problem where the computational complexity of global attention in graph neural networks increases quadratically with the number of nodes in high-concurrency crowd trajectory scenarios during large-scale campus events, leading to real-time congestion warning inference delays that cannot meet safety response time limits. Summary of the Invention

[0003] In view of this, the present invention provides a method, medium and system for safety early warning of crowd congestion at large school events, which can solve the technical problem in the prior art that the computational complexity of global attention of graph neural networks increases quadratically with the number of nodes in the scenario of high-concurrency crowd trajectories at large school events, resulting in the real-time congestion warning inference delay failing to meet the safety response time limit.

[0004] The present invention is implemented as follows: The first aspect of the present invention provides a safety early warning method for crowd density during large-scale school events, comprising the following steps:

[0005] Multiple video acquisition devices are deployed at the site of large-scale campus events. An edge computing and central cloud collaborative architecture is adopted. Lightweight chips are used at the camera end to complete the foreground extraction and motion residual filtering of video frames, and the compressed feature stream containing the dynamics of key groups of people is uploaded to the central processor.

[0006] The compressed feature stream is pruned and quantized, converting full-precision floating-point operations into INT8 fixed-point operations. The capabilities of large models are transferred to lightweight networks through knowledge distillation to support real-time parallel processing of multiple video streams.

[0007] The crowd trajectory is matrixed, and a lock-free parallel computing framework based on the CUDA architecture is used to transform spatiotemporal collision detection into matrix multiplication operations, eliminating thread synchronization wait and deadlock in high-concurrency early warning queries.

[0008] By introducing state entropy increase dynamic constraints, the Shannon entropy evolution equation is embedded as a regularization penalty term into the kernel function weight scaling factor of the linear attention approximate graph transmission model of group collaborative collision avoidance behavior, which constrains the gradient flow of the intermediate layer and improves the prediction accuracy of mutation behavior.

[0009] By using a self-organizing feature map hidden layer deep continuous flow model to extrapolate the probability of sparse small sample high-risk events, and combining it with a mask self-attention mechanism to construct a fully parallel spatiotemporal transformation network, we can achieve synchronous parallel prediction of spatiotemporal dimension features.

[0010] The comprehensive score of the congestion warning confidence is calculated based on the dynamic adjustment function of the congestion warning confidence, and the corresponding level of warning response strategy is activated based on the interval to which the comprehensive score belongs.

[0011] Specifically, the edge computing and central cloud collaborative architecture is as follows: the foreground extraction module runs on the embedded chip at the camera end, and separates the foreground motion region using frame difference method and background subtraction method; the motion residual filtering module calculates the pixel residual between adjacent frames, and filters static region frames whose residual energy is lower than the residual filtering threshold; only the compressed feature stream containing the motion foreground is uploaded to the central processor via gigabit local area network.

[0012] Specifically, the INT8 fixed-point operation involves: performing symmetric linear quantization on the original full-precision floating-point weight matrix, using the maximum absolute value of each channel as the quantization scaling factor; and using the soft-label output of the original large model as the teacher signal, adjusting the smoothness of the soft-label distribution with a temperature coefficient.

[0013] Specifically, the lock-free parallel computing framework organizes the coordinates of all spatiotemporal trajectory points of the entire population into a two-dimensional matrix, and uses CUDA kernel functions to implement spatiotemporal collision detection in the form of matrix multiplication; it abandons the mutex lock mechanism and uses atomic operations and thread-private memory partitioning to allow each CUDA thread block to independently process its own trajectory submatrix.

[0014] Specifically, the linear attention approximate graph propagation model for group collaborative collision avoidance behavior is as follows: the model input is a spatial physical boundary constraint topology matrix, where graph nodes represent people and graph edges represent spatial proximity relationships, with edge weights obtained by real-time Euclidean distance normalization; the core attention layer limits the attention receptive field of each node through a local sliding window and maps the query matrix and key matrix to a low-dimensional feature space through random kernel function mapping, reducing the computational complexity of the attention matrix from... Downgraded to .

[0015] The linear attention approximation graph propagation model for group collaborative collision avoidance behavior further includes: the social force repulsion law is transformed into a loss penalty term; a repulsion potential term is constructed using an exponential function of the inverse of the distance between nodes; and the repulsion potential term is embedded in the weight scaling factor of the kernel function attention operator; a low gating threshold is used for the forward information propagation path of the locally asymmetric gated recurrent unit, while a high gating threshold is used for the feedback smoothing path; a long-span residual dense jump matrix is ​​introduced between layers, and the first... Layer output and the first The layer outputs are directly added together and then sent to the next layer.

[0016] In the linear attention approximate graph transmission model of the group collaborative collision avoidance behavior, the dynamic lightweight topological graph transmission algorithm that integrates Fibonacci sequence optimization takes the sparsity of the graph adjacency matrix and the Shannon entropy increase of information transmission as dual optimization objectives. It dynamically samples the topological adjacency features at the golden section point determined by the golden ratio and instantly reconstructs the lightweight topological matrix. The sparse graph adjacency matrix is ​​stored in a compressed sparse row format, and the memory usage is proportional to the graph sparsity.

[0017] Specifically, the self-organizing feature mapping hidden layer deep continuous flow model is as follows: the front end of the model is a multi-level self-organizing feature mapping hidden layer, which performs adaptive topological mapping on the micro-behavioral feature vectors of the crowd through a competitive learning mechanism; the back end uses a series of reversible nonlinear transformations based on affine coupling layers to losslessly map the probability distribution output by the self-organizing feature mapping hidden layer to the standard Gaussian space.

[0018] In the self-organizing feature map hidden layer deep continuous flow model, the boundary dynamic convergence condition of group cooperative collision avoidance is directly used as the regularization constraint term of the continuous flow, and the logarithm of the Jacobian determinant of the affine coupling layer transformation is used as the upper bound of the constraint. If the Shannon entropy increase of the node activation energy distribution of the self-organizing feature map layer exceeds the outlier entropy increase threshold, the flow model generates the probability evolution trajectory of the population density in the future time period through inverse reversible mapping.

[0019] Specifically, the fully parallel spatiotemporal transformation network is as follows: the input is a multi-time-time crowd density feature sequence, a masked self-attention mechanism is used to shield information leakage in future time moments, and the position encoding uses sine and cosine encoding to distinguish different spatiotemporal positions; the self-attention calculations in the time dimension and the spatial dimension are executed synchronously and in parallel.

[0020] Specifically, the dynamic adjustment function for the congestion warning confidence level is: a comprehensive score value. Normalized value of population density Normalized value of velocity field discreteness Shannon entropy normalization value The weighted sum of the three terms yields, i.e. The weighting coefficient , , satisfy .

[0021] Specifically, the early warning response strategy is as follows: when When the level is below the first-level warning threshold, the system maintains normal monitoring status; when When the alert level is not lower than the Level 1 warning threshold but lower than the Level 2 warning threshold, a notification message will be sent to on-site safety management personnel; when... When the alert level is not lower than the Level II warning threshold but lower than the Level III warning threshold, a broadcast evacuation notice will be issued and security personnel will be dispatched to the scene; when When the alert level is not lower than the Level 3 warning threshold, an emergency broadcast will be triggered, relevant entrances and exits will be sealed off, and the campus emergency command center will be notified.

[0022] Specifically, the training dataset for the linear attention approximation graph propagation model of the group collaborative collision avoidance behavior is established by: collecting multiple videos of no less than 50 large-scale campus events, manually labeling personnel trajectories, density heatmaps, and frames of sudden collision avoidance events; for sparse high-risk stampede event samples, a self-organizing feature mapping hidden layer deep continuous flow model is used for data augmentation to generate synthetic samples consistent with the real distribution; and all samples are divided into training set, validation set, and test set in a ratio of 8:1:1.

[0023] Specifically, the training of the self-organizing feature map hidden layer deep continuous flow model is as follows: the self-organizing feature map hidden layer is pre-trained using unsupervised competitive learning, and the neighborhood radius decreases linearly with the training rounds; the deep continuous flow back end is fine-tuned in a supervised manner with the goal of maximizing the log-likelihood of the training samples; and the joint training stage uses the weighted sum of the negative log-likelihood loss and the boundary regularization constraint term as the total loss.

[0024] The residual filtering threshold ranges from 0.05 to 0.20 (normalized residual energy units), with an optimal value of 0.12; the temperature coefficient ranges from 2 to 8, with an optimal value of 4; the number of trajectory points processed per thread block ranges from 128 to 512, with an optimal value of 256; the local sliding window size is 5% to 20% of the total number of nodes, with an optimal value of 10%; the ratio of high to low gate thresholds ranges from 2:1 to 5:1, with an optimal value of 3:1; and the long-span residual dense jump matrix... The range of the entropy increase threshold is 2–5, with an optimal value of 3; the range of the entropy increase threshold is 0.15–0.50 (normalized Shannon entropy units), with an optimal value of 0.30. , , The range is 0.1 to 0.8; the first-level warning threshold is 0.40, the second-level warning threshold is 0.70, and the third-level warning threshold is 0.90.

[0025] A second aspect of the present invention provides a computer-readable storage medium storing program instructions that, when executed in a computer, perform the aforementioned method for providing a safety warning of crowd density during large-scale school events.

[0026] A third aspect of the present invention provides a safety early warning system for crowd congestion at large school events, comprising the aforementioned computer-readable storage medium, wherein the system is a computer, the computer-readable storage medium is disposed within the system, and the system is provided with a microprocessor for executing program instructions stored in the computer-readable storage medium.

[0027] This invention combines a linear attention approximation mechanism with a Fibonacci sequence optimization dynamic lightweight topology graph propagation algorithm to construct a linear attention approximation graph propagation model for group cooperative collision avoidance behavior. This reduces the computational complexity of global graph node association from... Down to This invention fundamentally eliminates the computational bottleneck caused by the attention matrix growing quadratically with the number of nodes. Linear attention limits the receptive field through a local sliding window and projects the query and key matrices into a low-dimensional space via a random kernel function, ensuring that the computational cost of a single attention operation remains linearly proportional to the number of nodes, and preventing the inference time from accumulating dramatically with the increase in crowd size. Fibonacci optimization dynamically reconstructs the sparse topology matrix, further compressing the peak memory usage of the graph structure, enabling the system to support parallel inference of multiple video streams under existing campus server resources. In summary, this invention solves the technical problem mentioned in the background art: in high-concurrency crowd trajectory scenarios during large-scale campus events, the computational complexity of global attention in graph neural networks increases quadratically with the number of nodes, leading to real-time congestion warning inference delays that cannot meet safety response time limits. Attached Figure Description

[0028] Figure 1 This is a flowchart of the method of the present invention.

[0029] Figure 2 The graph shows the accuracy loss curves of the student network under different temperature coefficients.

[0030] Figure 3 This is a graph comparing the total number of trajectory points with the collision detection time.

[0031] Figure 4 This is a graph showing the sparsity convergence curve during the Fibonacci iteration process.

[0032] Figure 5 The linear attention approximation graph transmission model structure and data flow graph for group collaborative collision avoidance behavior.

[0033] Figure 6 A comparison curve showing the variation of inference delay as a function of frame sequence length for a fully parallel spatiotemporal transformation network.

[0034] Figure 7 This is a dynamic curve showing the overall score value under each warning level.

[0035] Figure 8 This is a schematic diagram illustrating the deployment of a collaborative architecture between edge computing and central cloud. Detailed Implementation

[0036] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below.

[0037] like Figure 1 The diagram shown is a flowchart of a safety warning method for crowd congestion at large school events, provided by the first aspect of this invention. This method includes the following steps:

[0038] S01. Deploy multiple video acquisition devices at the site of large-scale campus events, adopt an edge computing and central cloud collaborative architecture, use lightweight chips at the camera end to complete the foreground extraction and motion residual filtering of video frames, and upload the compressed feature stream containing the dynamics of key groups of people to the central processor.

[0039] S02. Perform network pruning and fixed-point quantization on the compressed feature stream, convert full-precision floating-point operations into INT8 fixed-point operations, and transfer the capabilities of large models to lightweight networks through knowledge distillation to support real-time parallel processing of multiple video streams.

[0040] S03. The crowd trajectory is matrixed, and a lock-free parallel computing framework based on the CUDA architecture is used to transform spatiotemporal collision detection into matrix multiplication operations, eliminating thread synchronization waiting and deadlock in high-concurrency early warning queries.

[0041] S04. Introduce state entropy increase dynamic constraints, embed the Shannon entropy evolution equation as a regularization penalty term into the kernel function weight scaling factor of the linear attention approximate graph transmission model of group collaborative collision avoidance behavior, constrain the gradient flow of the intermediate layer, and improve the prediction accuracy of mutation behavior.

[0042] S05. Utilize the self-organizing feature mapping hidden layer deep continuous flow model to extrapolate the probability of sparse small sample high-risk events, and combine it with the mask self-attention mechanism to construct a fully parallel spatiotemporal transformation network to achieve synchronous parallel prediction of spatiotemporal dimension features.

[0043] S06. Calculate the comprehensive score of the congestion warning confidence based on the dynamic adjustment function of the congestion warning confidence, and activate the corresponding level of warning response strategy based on the interval to which the comprehensive score belongs;

[0044] The specific structure of the edge computing and central cloud collaborative architecture is as follows: the foreground extraction module runs on the embedded chip at the camera end, and separates the foreground motion region using frame difference method and background subtraction method; the motion residual filtering module calculates the pixel residual between adjacent frames, and filters static region frames with residual energy lower than a set threshold. The threshold is determined by collecting no less than 500 sets of experimental samples in typical campus scenes and statistically analyzing the distribution of inter-frame residual energy. The suggested range is 0.05 to 0.20 (normalized residual energy units); only the compressed feature stream containing the moving foreground is uploaded to the central processor via gigabit local area network, thereby reducing the network uplink bandwidth occupation to 15% to 35% of the original video stream bandwidth.

[0045] The specific implementation steps of the INT8 fixed-point arithmetic are as follows: symmetric linear quantization is performed on the original full-precision floating-point weight matrix, using the maximum absolute value of each channel as the quantization scaling factor; the specific steps of knowledge distillation are as follows: the soft-label output of the original large model is used as the teacher signal, and the smoothness of the soft-label distribution is adjusted by a temperature coefficient. The suggested range of the temperature coefficient is 2 to 8. The optimal value is determined by comparing the precision loss curves of the student network on the campus population dataset under different temperature coefficients; the inference latency of the student network is recommended to be controlled within 15 to 50 ms per video stream, and the specific value is determined after multiple rounds of benchmark testing on the target server.

[0046] The specific implementation of the lock-free parallel computing framework is as follows: the coordinates of all spatiotemporal trajectory points of the entire population are organized into a two-dimensional matrix, and spatiotemporal collision detection in the form of matrix multiplication is implemented using CUDA kernel functions; lock-free means abandoning the mutex lock mechanism and using atomic operations and thread-private video memory partitions, so that each CUDA thread block can independently process its own trajectory submatrix; the video memory allocation between thread blocks is dynamically allocated according to the current total number of concurrent trajectory points, and the mapping relationship between the total number of trajectory points and the size of video memory blocks is determined after stress testing on simulation data of tens of thousands of people. It is recommended that the number of trajectory points processed by a single thread block be 128 to 512.

[0047] The group collaborative collision avoidance behavior linear attention approximation graph transmission model is based on deep learning. Its specific structure is as follows: the model input is a spatial physical boundary constraint topology matrix, where graph nodes represent people and graph edges represent spatial proximity relationships, with edge weights obtained by real-time Euclidean distance normalization. The core attention layer abandons the quadratic computational complexity of traditional fully connected attention and instead uses a linear attention approximation mechanism. Specifically, it limits the receptive field of each node through a local sliding window, with the window size recommended to be 5%–20% of the total number of nodes. Furthermore, it maps the query matrix and key matrix to a low-dimensional feature space through a random kernel function mapping, reducing the computational complexity of the attention matrix from... Downgraded to The social force repulsion law is transformed into a loss penalty term equation, specifically by constructing a repulsion potential term using an exponential function of the inverse of the distance between nodes, and embedding this repulsion potential term into the weight scaling factor of the kernel function attention operator, thereby forcibly constraining the upper bound of the attention weights between nearby nodes during forward propagation; the locally asymmetric gated recurrent unit is designed as follows: the forward information transmission path uses a low gate threshold to achieve fast activation, and the feedback smoothing path uses a high gate threshold to achieve slow decay. The recommended range for the ratio of the high and low gate thresholds is 2:1 to 5:1, determined by joint analysis of convergence speed and smoothing error on a crowd trajectory dataset; a long-span residual dense jump matrix is ​​introduced between layers, which will... Layer output and the first Layer output ( The suggested range is 2-5. The features are directly added and fed into the next layer to achieve low-latency alignment of multi-scale pyramid spatial features. When the warning confidence output by the low-level classifier is higher than the dynamic level early exit threshold, simple region features directly output warning values. The threshold is determined by grid search on the validation set with F1 score as the target, and the suggested range is 0.90-0.97. In the model, the dynamic lightweight topological graph propagation algorithm integrating Fibonacci sequence optimization uses the sparsity of the graph adjacency matrix and the Shannon entropy increase in information propagation as dual optimization objectives. The ratio of adjacent terms in the Fibonacci sequence (i.e., the golden ratio) is used to optimize the graph adjacency matrix. The algorithm dynamically samples topological adjacency features at the golden section points determined by the algorithm, and the sampling step size directly controls the skip-adjacency sampling density of the graph propagation layer. When a sudden collision avoidance event occurs in the crowd, the algorithm quickly locks the optimal graph adjacency threshold through Fibonacci iteration, instantly reconstructs the lightweight topological matrix, and directly uses the reconstructed topological matrix as the input of the current layer mapping operator, eliminating the latency accumulation of traditional dense graph calculations. The convergence criterion of Fibonacci iteration is that the change in graph sparsity between two adjacent iterations is less than a set precision, and the suggested precision range is... ~ The convergence rounds were determined after testing simulation data of different population sizes. At the memory allocation level, the sparse graph adjacency matrix is ​​stored in a compressed sparse row format, and the memory usage is proportional to the graph sparsity. The graph sparsity is determined in real time by the Fibonacci optimization result, thereby realizing dynamic on-demand allocation of memory. At the inter-neuron resource allocation level, the mapping dimension of the random kernel function of linear attention is adaptively adjusted according to the graph node density at the current time. The suggested range of the mapping dimension is 32 to 256, which was determined through experiments that weighed the accuracy and computational cost.

[0048] The steps for establishing the training dataset for the linear attention approximate graph transmission model of the group collaborative collision avoidance behavior specifically include: collecting multi-channel videos of no less than 50 large-scale campus events, manually labeling personnel trajectories, density heatmaps, and frames of sudden collision avoidance events; constructing a spatial physical boundary constraint topology matrix, encoding walls, doorways, and obstacles in the site plan as fixed boundary nodes of the graph; for sparse high-risk stampede event samples, using a self-organizing feature mapping hidden layer deep continuous flow model for data augmentation to generate synthetic samples consistent with the real distribution, increasing the proportion of high-risk event samples to 10%–30% of the total training set, with the specific proportion determined by comparing the model recall rate under different proportions; and dividing all samples into training set, validation set, and test set in an 8:1:1 ratio.

[0049] The specific steps for training the linear attention approximate graph propagation model for group collaborative collision avoidance behavior include: updating parameters using the Adam optimizer, with an initial learning rate suggested to be within a certain range. ~ The total loss function consists of a weighted sum of three parts: the early warning classification cross-entropy loss, the social force exclusion penalty term, and the graph sparsity regularization term. The weights of each part are determined by grid search on the validation set, and the suggested range is 0.1 to 1.0. The exit rate of the dynamic hierarchical early exit mechanism is used as the training monitoring indicator. When the exit rate is lower than 30%, the exit threshold of the low-level classifier is appropriately reduced. The suggested range for the number of training rounds is 50 to 200 rounds, and the early stopping condition is that the F1 score on the validation set does not improve for 10 consecutive rounds.

[0050] The self-organized feature map hidden layer deep continuous flow model is based on deep learning, and its specific structure is as follows: the model front end consists of multi-level self-organized feature map hidden layers, and the recommended grid size for each self-organized map layer is [insert grid size here]. ~ This paper describes a method for adaptive topological mapping of micro-behavioral feature vectors of a population through a competitive learning mechanism. This projects the sample distribution in the high-dimensional nonlinear dynamic feature space onto a low-dimensional regular grid, achieving spatial orthogonal decoupling of heterogeneous sensing data. The backend seamlessly integrates a deep continuous flow model. Through a series of reversible nonlinear transformations based on affine coupling layers, the probability distribution output of the self-organized feature mapping hidden layer is losslessly mapped to a standard Gaussian space. The suggested number of affine coupling layers is 6–16, determined through ablation experiments on the negative log-likelihood loss on a small validation set. The boundary dynamic convergence condition of the group's cooperative collision avoidance is directly used as a regularization constraint term for the continuous flow. Specifically, the logarithm of the Jacobian determinant of the affine coupling layer transformation is used as the upper bound of the constraint to ensure the local volumetric variation of the flow transformation. The conversion rate does not exceed the range allowed by the boundary conditions; during the streaming process, if the Shannon entropy increase of the node activation energy distribution of the self-organizing feature map layer exceeds the set out-of-value entropy increase threshold, the streaming model will generate the probability evolution trajectory of the population density within the next 2 to 10 minutes through reverse reversible mapping. The out-of-value entropy increase threshold is determined by statistically comparing the normal and abnormal activation energy distributions in historical activity data, and the suggested range is 0.15 to 0.50 (normalized Shannon entropy units); at the memory allocation level, the intermediate activation values ​​of each layer of the continuous stream are optimized through implicit lossless reversible storage: during forward propagation, only the final layer output and the affine parameters of each layer are retained, and during backward propagation, the intermediate activation values ​​of each layer are reconstructed through inverse transformation, thereby compressing the memory usage from a linear multiple of the number of layers to a constant level.

[0051] The steps for establishing the training dataset for the self-organizing feature mapping hidden layer deep continuous flow model specifically include: selecting segments containing extreme crowding and stampede events from historical event videos and public crowd density datasets, with a total number of stampede event samples recommended to be no less than 200, and supplementing any insufficient samples through continuous flow reverse generation; extracting three types of features—crowd density heatmap, velocity field, and directional entropy—from each sample, and labeling them with a hazard level label for future moments; and dividing all samples into a training set and a validation set in a 9:1 ratio.

[0052] The specific steps for training the deep continuous flow model with the hidden layer of the self-organizing feature map include: pre-training the hidden layer of the self-organizing feature map using unsupervised competitive learning, with a suggested learning rate range of 0.01–0.5, and the neighborhood radius decreasing linearly with each training epoch; and supervising fine-tuning of the deep continuous flow backend with the goal of maximizing the log-likelihood of the training samples, using Adam as the recommended optimizer, with a suggested learning rate range of [missing information]. ~ During the joint training phase, the total loss is the weighted sum of the negative log-likelihood loss and the boundary regularization constraint term. The weight of the constraint term is determined by line search on the negative log-likelihood of the validation set, with a suggested range of 0.01 to 0.5. The suggested training epochs are 30 to 100 epochs, with the early stopping condition being that the negative log-likelihood of the validation set does not decrease for 5 consecutive epochs.

[0053] The specific structure of the fully parallel spatiotemporal transformation network is as follows: the input is a multi-time-time crowd density feature sequence, a masked self-attention mechanism is used to shield information leakage in future time moments, and the position encoding uses sine and cosine encoding to distinguish different spatiotemporal positions; the self-attention calculations in the time dimension and the spatial dimension are executed synchronously and in parallel, thereby eliminating the gradient vanishing and serial waiting problems of traditional recurrent neural networks.

[0054] The specific form of the congestion warning confidence dynamic adjustment function is: comprehensive score value. Normalized value of population density Normalized value of velocity field discreteness Shannon entropy normalization value The weighted sum of the three terms yields, i.e. The weighting coefficient satisfy The recommended range for all three is 0.1–0.8, determined through Bayesian optimization based on historical activity data with early warning recall rate as the target. When s < 0.40, the system maintains normal monitoring, and the early warning response strategy is to only record data without manual intervention. When this occurs, a Level 1 early warning response strategy is activated, and a notification message is sent to on-site safety management personnel; when At that time, the Level II early warning response strategy is activated, triggering a broadcast evacuation notice and dispatching security personnel to the scene; when When the time comes, a three-level early warning response strategy will be activated, immediately triggering emergency broadcasts, sealing off relevant entrances and exits, and notifying the campus emergency command center. The threshold values ​​of 0.40, 0.70, and 0.90 for each interval were determined by jointly analyzing the early warning recall rate and false alarm rate based on historical data from no less than 30 events. It is recommended to conduct experimental verification and correction based on specific campus scenarios before formal deployment.

[0055] The specific implementation of the state entropy increase dynamic constraint is as follows: an entropy increase evolution equation is constructed using the rate of change of Shannon entropy with respect to time of the probability distribution of spatial location of the crowd, and the divergence term of the entropy increase evolution equation is used as a regularization penalty term and superimposed in a weighted manner into the total loss function of the linear attention approximation graph transmission model of the group's collaborative collision avoidance behavior, thereby constraining the response amplitude of the intermediate layer gradient flow during the period of entropy increase anomaly and improving the model's sensitivity to sudden behavior.

[0056] The principle of the dynamic lightweight topology graph propagation algorithm for Fibonacci sequence optimization is as follows: the ratio of adjacent terms in the Fibonacci sequence converges to the golden ratio. In unimodal optimization problems, using Fibonacci split points as sampling locations can narrow the search interval to the target accuracy in the fewest iterations, exhibiting higher convergence efficiency compared to equal-interval sampling. In dynamic topology reconstruction scenarios involving crowds, with graph sparsity and Shannon entropy increase in information transmission as dual objectives, Fibonacci iteration dynamically samples within the search interval of the graph adjacency threshold. Each iteration synchronously updates two candidate thresholds and retains the better one. After iteration, the optimal threshold is directly used to sparsify the current layer's graph adjacency matrix. The entire reconstruction process does not require storing historical dense graph structures, thus eliminating latency accumulation. In sudden collision avoidance scenarios in campus crowds, this algorithm enables the convergence of topology reconstruction iterations to a minimum. (in The length of the search interval. (For higher accuracy), significantly reducing the latency and peak memory usage of real-time graph computation.

[0057] The technical advantages of the self-organizing feature mapping hidden layer deep continuous flow model are as follows: the self-organizing feature mapping hidden layer adaptively maps high-dimensional nonlinear crowd behavior features to a low-dimensional regular topological grid through competitive learning, making the input distribution of the back-end deep continuous flow model more regular. Thus, even with a very small number of stampede event samples, it can still accurately estimate the tail probability distribution of high-risk density in a way that maximizes likelihood. The reversible transformation structure of the deep continuous flow ensures bidirectional lossless extrapolation from the standard Gaussian space to the crowd density probability space. This allows the system to extrapolate the evolution trajectory of high-risk states in real time when it detects an abnormal increase in the Shannon entropy of node activation energy, providing safety managers with a deterministic and confident early warning, rather than a passive alarm triggered solely by a threshold.

[0058] The technical effect of the linear attention approximation graph propagation model for collaborative collision avoidance is that the linear attention approximation mechanism reduces the computational complexity of global associations between graph nodes from... Down to This allows the model to maintain real-time inference even in concurrent trajectory scenarios involving tens of thousands of people; after embedding the social force exclusion penalty term into the kernel function weight scaling factor, the network automatically suppresses excessive clustering predictions of nearby nodes during forward propagation, reducing collision misses caused by insufficient data; Fibonacci optimization dynamically reconstructs sparse topology, which adaptively reduces peak memory usage as the population becomes sparse, ensuring stable multi-path parallel operation of the system under existing campus server resources; the forward fast propagation and slow feedback smoothing characteristics formed by the asymmetric gated recurrent unit enable the model to respond quickly when the population suddenly changes state while suppressing false alarms caused by short-term noise.

[0059] The specific implementation of step S01 is as follows: At the site of a large-scale campus event, multiple high-definition cameras are deployed along the main entrances and exits, passage convergence points, and the core area of ​​the square, forming a collaborative architecture of edge computing and central cloud. The embedded chip at the camera end runs a foreground extraction module, using the frame difference method to calculate the pixel grayscale difference between adjacent frames, while simultaneously maintaining an adaptive background model using background subtraction to separate the moving foreground region from the static background. The motion residual filtering module calculates the inter-frame pixel residual energy for the separated foreground region. When the residual energy of a certain region is lower than the residual filtering threshold (recommended range 0.05–0.20 normalized residual energy units, reference value 0.12), the region is determined to be a static frame and discarded, retaining only the frame features containing the moving foreground. After the above two-stage filtering, the edge only uploads the compressed feature stream containing key crowd dynamics to the central processor via the gigabit LAN, reducing the network uplink bandwidth usage to 15%–35% of the original video stream bandwidth, thereby significantly reducing network transmission pressure while retaining effective crowd dynamic information.

[0060] The specific implementation of step S02 is as follows: After receiving the compressed feature stream, the central processor first performs network pruning on the crowd detection and trajectory prediction model, removing redundant channels and weights whose contribution to the early warning accuracy is lower than the set pruning threshold, thus compressing the model parameter scale. Then, the remaining weight matrix is ​​subjected to INT8 fixed-point quantization, using a symmetric linear quantization method. The maximum absolute value of each channel weight is used as the quantization scaling factor, mapping full-precision floating-point numbers to 8-bit integer representation. Inference calculations are transformed from floating-point operations to fixed-point integer operations, significantly reducing the computational power consumption of a single inference. In the knowledge distillation stage, the soft labels output by the original large model are used as teacher signals. A temperature coefficient (suggested range 2-8, reference value 4) is introduced to adjust the smoothness of the soft label probability distribution. The larger the temperature coefficient, the smoother the soft label distribution, and the stronger the generalization ability of the student network under small sample conditions. The KL divergence between the soft labels of the original large model and the output of the student network is used as the distillation loss, and after weighted summation with the original classification cross-entropy loss, the student network is jointly trained. After pruning, quantization, and distillation, the inference latency of the lightweight student network is controlled within 15–50 ms per video stream, supporting real-time parallel processing of multiple video compression feature streams by the central processor.

[0061] The specific implementation of step S03 is as follows: Organize the spatiotemporal trajectory coordinates (including timestamps and two-dimensional spatial coordinates) of all tracked personnel at the current moment into a two-dimensional matrix, with each row corresponding to a trajectory point and each column corresponding to a coordinate dimension. A lock-free parallel computing framework is designed based on the CUDA architecture, transforming spatiotemporal collision detection into matrix multiplication: the spatiotemporal distance between all trajectory point pairs is calculated using the matrix multiplication of two trajectory matrices, and those below the collision threshold are marked as potential collision events. The lock-free design abandons the traditional mutex lock mechanism, instead using CUDA atomic operations and thread-private memory partitions. Each CUDA thread block independently processes its own responsible trajectory submatrix, eliminating the need for synchronization waits between thread blocks, thus eliminating deadlocks and thread synchronization waits in high-concurrency early warning queries. Memory allocation for thread blocks is dynamically assigned based on the total number of concurrent trajectory points, with a recommended range of 128–512 trajectory points processed per thread block (reference value 256).

[0062] The specific implementation of step S04 is as follows: A linear attention approximate graph propagation model for group collaborative collision avoidance behavior is constructed. The input is a spatial physical boundary constraint topology matrix, graph nodes represent the tracked personnel at the current moment, and graph edge weights are obtained by normalizing the real-time Euclidean distance between nodes. The core attention layer limits the receptive field of each node with a local sliding window (window size is 5%–20% of the total number of nodes, reference value 10%). The query matrix and key matrix are projected to a low-dimensional feature space (the suggested mapping dimension is 32–256) through random kernel function mapping, reducing the computational complexity of attention from... Down to The social force repulsion penalty term constructs a repulsion potential energy using an exponential function of the inverse of the distance between nodes, embedding a kernel function weight scaling factor to suppress excessive clustering predictions of nearby nodes during forward propagation. The state entropy increase dynamic constraint constructs an entropy increase evolution equation using the rate of change of Shannon entropy with respect to the probability distribution of spatial location of the population over time, and its divergence term is superimposed as a regularization penalty term on the total loss function to constrain the response amplitude of the intermediate layer gradient flow during periods of abnormal entropy increase. The Fibonacci sequence optimization dynamic lightweight topology graph propagation algorithm takes graph sparsity and information propagation Shannon entropy increase as dual objectives. Within the graph adjacency threshold search interval, it dynamically samples according to the golden ratio. After iterative convergence, the optimal threshold is directly used to sparsify the current layer adjacency matrix. The sparse matrix is ​​stored in a compressed sparse row format, and the memory usage adaptively decreases with graph sparsity. The asymmetric gated cyclic unit uses a low gate threshold for fast activation in the forward path and a high gate threshold for slow decay in the feedback smoothing path. The ratio of high to low gate thresholds ranges from 2:1 to 5:1 (reference value 3:1). The inter-layer long-span residual dense jump matrix will... Layer and First layer( (Range 2-5, reference value 3) The outputs are directly added and sent to the next layer.

[0063] The specific implementation of step S05 is as follows: The front end of the self-organizing feature map hidden layer deep continuous flow model uses multi-level self-organizing feature map hidden layers to competitively learn adaptive topological mapping of the crowd's micro-behavioral feature vectors (including density heatmaps, velocity fields, and orientation entropy), projecting high-dimensional nonlinear features onto a low-dimensional regular grid. The suggested grid size range is... ~ The backend uses 6–16 affine coupling layers (10 layers for reference) to perform a reversible nonlinear transformation, losslessly mapping the probability distribution output from the frontend to a standard Gaussian space. When the Shannon entropy increase of the activation energy distribution of the self-organizing feature mapping layer nodes exceeds the outlier entropy increase threshold (suggested range 0.15–0.50 normalized Shannon entropy units, reference value 0.30), the model generates the probability evolution trajectory of crowd density over the next 2–10 minutes through a reverse reversible mapping, achieving advanced extrapolation of high-risk states. The fully parallel spatiotemporal transformation network takes multi-momentary crowd density feature sequences as input, uses a masked self-attention mechanism to shield information leakage from future moments, and employs sine and cosine position encoding to distinguish different spatiotemporal locations. The self-attention calculations in the temporal and spatial dimensions are executed synchronously and in parallel, eliminating the gradient vanishing and serial waiting problems of traditional recurrent neural networks.

[0064] The specific implementation of step S06 is as follows: the crowding warning confidence dynamic adjustment function normalizes the crowd density value. Normalized value of velocity field discreteness Shannon entropy normalization value The weighted sum of the three factors yields the overall score. Weighting coefficient , , satisfy The suggested range for all three values ​​is 0.1 to 0.8, determined through Bayesian optimization based on historical activity data with early warning recall as the target. The corresponding level of early warning response strategy is activated based on the interval to which the comprehensive score falls: when... When the value is below 0.40, the system maintains normal monitoring and only records data; when... When the value is in the range of 0.40 to 0.70, a Level 1 warning is activated, and a notification message is sent to on-site safety management personnel; when... When the value is in the range of 0.70 to 0.90, a Level II warning is activated, triggering a broadcast evacuation announcement and dispatching security personnel; when... When the value is not lower than 0.90, a Level 3 early warning will be activated, triggering emergency broadcasts, sealing off entrances and exits, and notifying the emergency command center.

[0065] It should be noted that the key technologies of this invention include: firstly, the linear attention approximation mechanism reduces the computational complexity of attention from a local sliding window to a random kernel function through mapping between a local sliding window and a random kernel function. Down to First, the system enables real-time inference even in scenarios with tens of thousands of nodes, overcoming the computational bottleneck of fully connected attention. Second, the Fibonacci sequence optimization dynamic lightweight topology graph propagation algorithm utilizes the fast convergence characteristic of the golden ratio to complete topology reconstruction with the fewest iterations within the graph adjacency threshold search interval. The sparse matrix allocates memory on demand in a compressed sparse row format, adaptively reducing the peak memory usage as the population becomes sparser. Third, the self-organizing feature mapping hidden layer deep continuous flow model maps high-dimensional nonlinear crowd behavior features to a low-dimensional regular topology grid, and then maps them to a standard Gaussian space through an invertible affine transformation, achieving accurate estimation and advanced extrapolation of high-risk tail probabilities under a very small number of stampede event samples. These three key technologies work together to ensure that the computational load of the system maintains linear growth as the node scale increases, while still reliably outputting early warning signals with deterministic confidence under sparse high-risk sample conditions, thus jointly guaranteeing real-time safety response capabilities from both computational efficiency and early warning accuracy perspectives.

[0066] It should be noted that in scenarios involving parallel processing of multiple video streams and continuously changing crowd sizes, the gradient signals of intermediate layers in graph neural networks are prone to amplitude loss when the crowd state undergoes abrupt changes. This leads to a sharp drop in the model's prediction confidence for sudden congestion events, resulting in missed detections. The reason for this technical problem is that when the crowd rapidly transitions from a sparse state to a high-density clustered state, the distance distribution between nodes changes drastically, and the information transmission path of the graph structure is reconstructed synchronously. At this time, the gradient flow of intermediate layers is subjected to strong perturbations from multiple sources, causing the gradient amplitude to be irregularly amplified during backpropagation. This results in a deviation between the model's output warning confidence and the actual dangerous situation. Common solutions to this problem include global gradient pruning or introducing batch normalization layers to stabilize the training process. However, while global gradient pruning cuts off abnormal gradients, it also suppresses effective gradient information that truly reflects abrupt changes. Batch normalization layers have limited effectiveness in small-batch inference or streaming inference scenarios due to unstable sample statistics. Neither approach can specifically constrain the gradient response during periods of entropy increase anomalies directly related to abrupt changes. This invention effectively solves this technical problem by introducing a dynamic constraint on state entropy increase. It constructs an entropy increase evolution equation based on the rate of change of Shannon entropy over time in the probability distribution of population spatial locations. The divergence term is then used as a regularization penalty term and weighted and added to the total loss function. When the entropy increase rate exceeds the normal range, the regularization penalty term automatically increases, applying additional suppression to the gradient flow in the intermediate layers, causing the gradient amplitude to converge to a reasonable range matching the current entropy increase level. This mechanism directly couples the uncertain evolution of the population state with the response amplitude of the model gradient from an information theory perspective. This ensures that the model can quickly detect state jumps during population mutations without outputting false high-confidence warnings due to gradient runaway, thus achieving a balance between the accuracy of mutation behavior prediction and the robustness of warnings.

[0067] A second aspect of the present invention provides a computer-readable storage medium storing program instructions that, when executed in a computer, perform the aforementioned method for providing a safety warning of crowd density during large-scale school events.

[0068] A third aspect of the present invention provides a safety early warning system for crowd congestion at large school events, comprising the aforementioned computer-readable storage medium. The system can be any one of a computer, a server, or a microcontroller. The computer-readable storage medium is disposed within the system, and the system is provided with a microprocessor that executes program instructions stored in the computer-readable storage medium.

[0069] Specifically, the principle of this invention is:

[0070] The fundamental reason why this invention can solve the above-mentioned technical problems is that it simultaneously implements linearization transformation from two levels: the computational structure of graph attention and the storage structure of graph topology, so that the time complexity and space complexity of the entire reasoning process are freed from the quadratic constraints of the number of nodes.

[0071] At the computational structure level, traditional fully connected attention mechanisms require each node to calculate similarity with every other node pairwise. When the number of nodes is... At that time, the total number of elements in the attention matrix is Reasoning time and Proportional. This invention uses a local sliding window to limit the receptive field of each node to its spatial neighbor subset, and projects the query matrix and key matrix to a low-dimensional feature space through random kernel function mapping, making the calculation of attention weights equivalent to the accumulation of low-dimensional vector inner products, thus reducing the computational complexity from Down to This linearization process is mathematically rigorous: the random kernel function mapping guarantees an unbiased approximation of the original kernel function in the desired sense, thus achieving a substantial reduction in computational cost while keeping the loss of accuracy controllable.

[0072] At the graph topology storage structure level, this invention introduces a Fibonacci sequence optimization dynamic lightweight topology graph propagation algorithm. With graph sparsity and Shannon entropy increase in information propagation as dual objectives, it dynamically samples within the search interval of the graph adjacency threshold, and the iteration rounds converge to... This is far fewer iterations than a search using equally spaced grids. After each iteration, the optimal threshold is directly used to sparsify the adjacency matrix of the current layer. The sparse matrix is ​​stored in a compressed sparse row format, and the memory usage is proportional to the graph sparsity, thus achieving dynamic on-demand allocation of memory. When a sudden collision avoidance occurs in the crowd, the Fibonacci iteration quickly locks a new optimal threshold, instantly reconstructing the lightweight topology matrix and eliminating the latency accumulation of traditional dense graph computation.

[0073] Furthermore, the social force rejection penalty term is embedded in the kernel function's weight scaling factor, automatically suppressing excessive clustering predictions of nearby nodes during forward propagation and reducing collision misses caused by data sparsity. The asymmetric gated recurrent unit's characteristics of fast forward propagation and slow, smooth feedback enable the model to respond quickly to sudden changes in crowd states while suppressing false alarms caused by short-term noise. These mechanisms collectively ensure the system's real-time inference capabilities in scenarios with tens of thousands of concurrent users, enabling congestion warning outputs to be completed within a safe response timeframe, thus logically and self-consistently solving the core technical problem from a technical principle perspective.

[0074] The following provides a specific embodiment 1 of the present invention, and the specific implementation of each step in this embodiment 1 is described in detail below.

[0075] The specific implementation method of step S01 is as follows.

[0076] Multiple video capture devices were deployed at the site of a large-scale campus event, employing a collaborative architecture of edge computing and a central cloud. An embedded chip at the camera end runs a foreground extraction module, using frame difference and background subtraction to separate the moving foreground region. Subsequently, a motion residual filtering module calculates the pixel residual between adjacent frames, setting the frame rate as... The pixel matrix is Residual energy between adjacent frames The formula is expressed as follows:

[0077] ;

[0078] In the formula, , These are the frame height and width, in pixels. For the first Frame position Normalized pixel values ​​at that location For the first Frame position Normalized pixel values ​​at that location, This is the normalized residual energy, with dimensions equal to the square of the normalized pixel value, and the dimensions are consistent. When Below the set threshold At that time, the frame was identified as a stationary region frame and filtered out. After collecting no fewer than 500 sets of experimental samples in typical campus settings, The distribution was determined through statistical analysis, with values ​​ranging from 0.05 to 0.20. Uploading only the compressed feature stream containing the moving foreground to the central processor via a gigabit LAN can reduce network uplink bandwidth usage to 15%–35% of the original video stream bandwidth.

[0079] The specific implementation method of step S02 is as follows.

[0080] The compressed feature stream is pruned and quantized using a network, and the full-precision floating-point weight matrix is ​​then processed. Convert to INT8 fixed-point weight matrix The quantification formula is expressed as follows:

[0081] ;

[0082] In the formula, This is the original full-precision floating-point weight matrix. This is the quantized INT8 integer weight matrix. For each channel, the quantization scaling factor is determined by taking the maximum absolute value of the channel's weights. This indicates the rounding operation. This function represents a truncation function that cuts the result to the range of INT8. and All are dimensionless quantities with consistent dimensions. Knowledge distillation utilizes temperature coefficients. Adjusting the distribution of soft tags, the teacher's network output of the first Class soft tag probability The formula is expressed as follows:

[0083] ;

[0084] In the formula, For Teachers' Network The logical output value of the class. For Teachers' Network The logical output value of the class. This is the temperature coefficient, with a value ranging from 2 to 8. The value is a dimensionless probability value. The optimal value is determined by comparing the accuracy loss curves of the student network on the campus population dataset under different temperature coefficients. It is recommended that the inference latency of the student network be controlled within 15-50ms per video stream.

[0085] The specific implementation method of step S03 is as follows.

[0086] Organize the spatiotemporal trajectory coordinates of all population groups into a two-dimensional matrix. ,in This represents the total number of concurrent trajectory points. Each row contains the personnel ID, timestamp, and... coordinate, The coordinates have four fields. Based on the CUDA architecture, a lock-free parallel computing framework transforms spatiotemporal collision detection into matrix multiplication operations, specifically the inner product matrix of spatial location. The formula is expressed as follows:

[0087] ;

[0088] In the formula, From The spatial coordinate submatrix extracted from it. Corresponding to the With the The inner product of the spatial locations of each trajectory point is used to quickly filter collision candidate pairs. The unit for each element is m. The unit of each element is The units are consistent. The lock-free mechanism abandons mutex locks and uses atomic operations and thread-private memory partitions. Each CUDA thread block independently processes its own trajectory submatrix, and the memory allocation between thread blocks is based on... For dynamic assignment, the recommended range for the number of trajectory points processed by a single-threaded block is 128 to 512. The specific value will be determined after stress testing using simulated data from a large-scale event involving tens of thousands of participants.

[0089] The specific implementation method of step S04 is as follows.

[0090] Introducing the dynamic constraint of increasing state entropy, let the probability density function of the spatial location of the crowd be... ,in For spatial coordinate variables, For the moment, Shannon entropy The formula is expressed as follows:

[0091] $H(t)=-\int p(x,t)\ln p(x,t)\,dx$;

[0092] In the formula, for Shannon entropy of the spatial distribution of the population at any given time, expressed in nat. satisfy , and All are logarithms of dimensionless quantities, with consistent dimensions. The divergence term in the entropy-increasing evolution equation. As a regularization penalty term, its formula is expressed as follows:

[0093] ;

[0094] In the formula, This indicates taking the divergence operator on the spatial variable. Shannon entropy is the rate of change of time, in units of 1 / 2 t. , The unit is $\text{nat / (s\cdot m)}$, which has consistent dimensions. The weighted summation is added to the total loss function of the linear attention approximation graph propagation model for group collaborative collision avoidance behavior, constraining the response amplitude of the intermediate layer gradient flow during periods of abnormal entropy increase, thereby improving the prediction accuracy of mutation behavior.

[0095] The specific implementation method of step S05 is as follows.

[0096] The front end of the self-organized feature map hidden layer deep continuous flow model consists of multi-level self-organized feature map hidden layers, with a recommended mesh size for each layer. ~ Through competitive learning, high-dimensional crowd behavior feature vectors are mapped to low-dimensional regular grids. The backend deep continuous flow model is... It consists of an affine coupling layer. The suggested range is 6–16. The input distribution is mapped to a standard Gaussian space through an invertible nonlinear transformation, and training is performed with negative log-likelihood as the target. When the Shannon entropy increase of the activation energy of the self-organizing feature map layer nodes exceeds the outlier entropy increase threshold... At that time, the flow model uses a reverse reversible mapping to extrapolate the probability evolution trajectory of crowd density over the next 2–10 minutes. The range of 0.15–0.50 (normalized Shannon entropy units) was determined by statistically comparing the distribution of normal and abnormal activation energy in historical activity data. The fully parallel spatiotemporal transformation network uses a masked self-attention mechanism to shield information from future moments, with self-attention calculations in both time and space dimensions executed synchronously and in parallel, eliminating the gradient vanishing and serial waiting problems of traditional recurrent neural networks.

[0097] The specific implementation method of step S06 is as follows.

[0098] The comprehensive score is calculated based on the congestion warning confidence dynamic adjustment function. Its formula is expressed as follows:

[0099] ;

[0100] In the formula, This is the normalized value of population density. This is the normalized value of the velocity field discreteness. For Shannon's entropy increase normalization value, , , They are respectively , , The corresponding weighting coefficients satisfy The values ​​of all three range from 0.1 to 0.8. , , All are dimensionless normalized values. It is also a dimensionless comprehensive score, with consistent dimensions. Each weight is determined through Bayesian optimization based on historical activity data, targeting the warning recall rate. When the system is in normal monitoring mode, it only records data; when... When this occurs, a Level 1 warning is activated, and a notification message is sent to on-site safety management personnel; when At that time, a level-two warning is activated, triggering a broadcast evacuation and dispatching security personnel; when Upon activation of the Level 3 alert, an emergency broadcast will be immediately triggered, entrances and exits will be sealed off, and the emergency command center will be notified. The thresholds of 0.40, 0.70, and 0.90 were determined through a joint analysis of the alert recall rate and false alarm rate using historical data from at least 30 events.

[0101] The specific implementation of the linear attention approximation graph transmission model for group collaborative collision avoidance behavior is as follows.

[0102] The model input is the spatial physical boundary constraint topology matrix. , By the With the The real-time Euclidean distance of each node is normalized, and each element is a dimensionless value. The linear attention approximation mechanism maps the query matrix through a random kernel function. AND key matrix Mapping them to low-dimensional feature spaces respectively reduces the computational complexity of attention from... Downgraded to ,in As a feature dimension. Social force repulsion potential term. The weight scaling factor for the embedded kernel function attention operator is expressed by the following formula:

[0103] ;

[0104] In the formula, For nodes With nodes The Euclidean distance between them, in meters. Let be the repulsion strength coefficient, in meters, such that... It is a dimensionless quantity. The dimensionless repulsive potential energy weight value. The attention weights are embedded as an upper bound for the penalty, automatically suppressing excessive clustering predictions between nearby nodes. In the asymmetric gated recurrent unit, the forward gating threshold... With feedback gating threshold The recommended range for the ratio is: ~ The convergence speed and smoothing error were determined through joint analysis on a crowd trajectory dataset. The long-span residual dense jump matrix will... Layer output With the Layer output The products are directly added together and then fed into the next layer. The formula is as follows:

[0105] ;

[0106] In the formula, The feature matrix after fusion is fed into the next layer. and They have the same dimensions and consistent units. The suggested range is 2–5, determined through ablation experiments. A dynamic, lightweight topological graph propagation algorithm for Fibonacci sequence optimization is used, focusing on graph sparsity. Shannon entropy increase in information transmission For dual objectives, search within the graph adjacency threshold range. The graph uses Fibonacci split points for dynamic sampling, and two candidate thresholds are updated synchronously in each iteration. The convergence criterion is the change in graph sparsity between two adjacent iterations. Less than precision , The recommended scope is ~ The upper bound of the number of iterations required for convergence is ,in The length of the search interval. Using the golden ratio, the optimal threshold obtained after the algorithm's iterations is directly used to sparsify the adjacency matrix of the current layer graph. The sparse graph adjacency matrix is ​​stored in a compressed sparse row format, with low memory usage. Proportional, linear attention random kernel function mapping dimension Adaptively adjust based on the node density of the current time-to-time graph. The recommended range is 32 to 256, determined through experiments that balance accuracy and computational cost.

[0107] To better understand and implement this invention, the following is a specific application scenario of this invention, Example 2:

[0108] This embodiment uses the opening ceremony of a university sports meet as the application scenario. The event is expected to have 8,500 attendees. The main activity area includes four main entrances and exits and a central plaza gathering area. A total of 16 high-definition cameras are deployed along each passage and around the plaza. The embedded chip at the camera end has real-time video processing capabilities. The central processor is equipped with four graphics processors that support CUDA parallel computing. The total video memory of the server is 128GB.

[0109] During step S01, the foreground extraction module and motion residual filtering module of the 16-channel camera end-side chips run synchronously. The frame difference method takes the absolute value of the pixel gray-level difference matrix of adjacent frames and then takes the union with the foreground mask of the background subtraction method to obtain the foreground motion region. The residual filtering threshold is set to 0.12 (normalized residual energy unit), which is determined based on the statistical distribution of inter-frame residual energy of 500 experimental samples in the historical video of the school's sports meet. After filtering, the compressed feature stream containing only the moving foreground is uploaded to the central processor via gigabit LAN. The measured uplink bandwidth usage is 22% of the original video stream bandwidth, effectively reducing the network transmission pressure. The bandwidth usage of the compressed feature stream of each channel is shown in Table 1.

[0110] Table 1. Bandwidth occupancy of each channel's compressed characteristic stream.

[0111]

[0112] During step S02, after performing network pruning on the lightweight student network, the number of model parameters was compressed from 187M in the original large model to 23M; INT8 quantization reduced the computational power consumption of each video stream per inference from the original floating-point mode to about 1 / 4; the knowledge distillation temperature coefficient was set to 4, and the measured inference latency of the student network on the campus population dataset was 28ms per stream, with a total latency of 32ms for 16 parallel inference streams, meeting the safety response time limit requirements. The trend of the student network accuracy loss curve under different temperature coefficients is as follows: Figure 2 As shown, as the temperature coefficient increases from 2 to 4, the accuracy loss curve of the student network under small sample conditions tends to flatten, indicating that the improved smoothness of the soft label distribution enables the student network to obtain a more stable generalization ability; after the temperature coefficient exceeds 6, the slope of the accuracy loss curve narrows, indicating that the dilution of information by excessively high temperature coefficients has tended to saturate, and the reference value of 4 is at the balance point between accuracy gain and information dilution.

[0113] During the implementation of step S03, the system has tracked a total of 6823 valid trajectory points at the current moment. All trajectory point coordinates are organized into a 6823×3 two-dimensional matrix (including timestamps and two-dimensional spatial coordinates). Spatiotemporal collision detection is implemented using matrix multiplication in the form of CUDA kernel functions. The number of trajectory points processed per thread block is set to 256, with a total of 27 thread blocks allocated. Each thread block independently processes its own submatrix, eliminating the need for inter-thread synchronization. The overall collision detection time is 9ms. Figure 3 As shown, as the total number of trajectory points increases from 1000 to 8000, the collision detection time of the lock-free parallel framework increases linearly, while the traditional mutex lock scheme experiences a sharp increase in time due to deadlock waiting when the total number of trajectory points exceeds 3000. The difference between the two curves continues to widen as the total number of trajectory points increases, verifying the latency advantage of the lock-free design in high-concurrency scenarios.

[0114] In step S04, a linear attention approximate graph propagation model for collaborative collision avoidance is constructed, using the 6823 trajectory points at the current moment as graph nodes, and a spatial physical boundary constraint topology matrix is ​​built. The sliding window size of the core attention layer is set to 10% of the total number of nodes (i.e., 682 nodes), and the dimension of the random kernel function mapping is set to 128. The Fibonacci sequence optimization dynamic lightweight topology graph propagation algorithm is applied within the graph adjacency threshold range. Inner iteration, precision set to The measured convergence rounds were 17. The sparsity of the adjacency matrix of the reconstructed sparse graph was 0.94. The memory usage was reduced from 214GB for the dense graph to 12.7GB, meeting the server's total 128GB memory constraint. The convergence curve of graph sparsity with iteration rounds during the Fibonacci iteration process is shown below. Figure 4 As shown. Figure 4 As shown, the sparsity of the graph converges rapidly with each iteration, and the change is below the accuracy threshold after the 13th iteration. The sparsity difference curve between two adjacent iterations shows a monotonically decreasing trend, indicating that the Fibonacci split point sampling strategy effectively shortens the search interval and avoids redundant iterations of equal-interval sampling in large intervals.

[0115] In this embodiment, the specific structure of the linear attention approximate graph transmission model for group collaborative collision avoidance behavior is as follows: Figure 5 As shown. The model input is a spatial physical boundary constraint topology matrix. The data flow is as follows: the input layer feeds the trajectory point coordinates and edge weights into the linear attention layer. The linear attention layer calculates the low-dimensional inner product weights between nodes through a local sliding window and a random kernel function mapping. After embedding the social force repulsion potential energy into the weight scaling factor, the node features are output. The node features are then processed sequentially through a long-span residual dense jump matrix ( =3) With the asymmetric gated recurrent unit, the forward path with a low gate threshold quickly activates the node state, and the feedback path with a high gate threshold (high-low ratio 3:1) outputs a slow and smooth output; finally, the low-level classifier outputs the warning confidence. If the confidence exceeds the dynamic level early exit threshold (reference value 0.93), the warning value is directly output without continuing to propagate to the deeper layers.

[0116] As an alternative, the core attention layer in the linear attention approximate graph propagation model of the above-mentioned group collaborative collision avoidance behavior can be replaced with a graph attention convolutional network structure: attention weights are calculated for each node's neighborhood subset using a multi-head attention mechanism, where the neighborhood is composed of... Nearest neighbor graph ( =32) Defined, each attention independently calculates the weighted aggregation of node features in the neighborhood, and the multi-head outputs are concatenated and linearly transformed to obtain the node update features. The data flow is consistent with the main scheme, that is, input topology matrix → multi-head neighborhood attention aggregation → residual jump → asymmetric gated recurrent unit → classification output. The feature extraction dimension and loss function are consistent with the main scheme.

[0117] During the implementation of step S05, the size of the self-organizing feature map hidden layer mesh is set to... (256 neurons) Unsupervised competitive learning pre-training was performed on three types of features collected during the historical phases of this event: crowd density heatmap, velocity field, and directional entropy. The learning rate linearly decreased from 0.3 to 0.01, and the neighborhood radius linearly decreased from 8 to 1. Ten affine coupling layers were deployed in the backend. After joint training, the weight ratio of negative log-likelihood loss to boundary regularization constraint in the total loss was set to 1.0:0.1. At 2 hours and 47 minutes into the event, the activation energy Shannon entropy increase of a node cluster in the self-organizing feature mapping layer reached 0.34 (exceeding the outlier entropy increase threshold of 0.30). The flow model initiated reverse reversible mapping and extrapolated the probability evolution trajectory of crowd density in the central square gathering area within the next 5 minutes. The output showed that the area would enter the level 2 warning zone in 4 minutes and 23 seconds. The fully parallel spatiotemporal transformation network synchronously and in parallel processed the density feature sequence of 20 consecutive frames before and after this moment, with a total inference latency of 41ms. Figure 6 As shown, the inference delay of the fully parallel spatiotemporal transformation network during synchronous parallel computation in the time and space dimensions varies with the frame sequence length. This indicates that its delay increases sublinearly with the sequence length, while the delay of the traditional recurrent neural network accumulates linearly with the sequence length due to serial waiting delay. The difference between the two widens as the sequence length increases.

[0118] During the implementation of step S06, the weighting coefficients determined by Bayesian optimization on the historical 31 event data are as follows: =0.40、 =0.35、 =0.25. As shown in Table 2, the comprehensive score values ​​and corresponding warning levels for typical moments during the activity are as follows.

[0119] Table 2. Comprehensive Score and Warning Level for Typical Moments

[0120]

[0121] At 2 hours and 52 minutes, the overall score was... The confidence score reached 0.744, triggering a Level 2 alert. The system automatically broadcast evacuation instructions and dispatched security personnel to the central plaza gathering area. Upon arrival, security personnel guided and diverted the crowd. The overall score subsequently dropped to 0.55 within 3 minutes, not entering the Level 3 alert range. The dynamic trends of the overall confidence score for each alert level are shown below. Figure 7 As shown. With the normalized value of population density The overall score curve rose from 0.74 to 0.91, with the slope initially steepening and then gradually decreasing. The gradual decrease in slope occurred after security personnel intervened to divert the flow, indicating that the normalized value of the velocity field dispersion... The decrease (restoration of orderly crowd flow) has a negative pulling effect on the comprehensive score. The dynamic coupling relationship of the three weighted components enables the comprehensive score to sensitively reflect the real evolution of the crowd status, rather than a lagging alarm triggered by a single density threshold.

[0122] It should be noted that the variables involved in this invention are explained in detail in Tables 3 and 4.

[0123] Table 3. Variable Explanation Table (Part 1)

[0124]

[0125] Table 4. Variable Explanation Table (Part Two)

[0126]

[0127] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.

Claims

1. A safety early warning method for crowd congestion levels during large-scale school events, characterized in that, Includes the following steps: Multiple video acquisition devices are deployed at the site of large-scale campus events. An edge computing and central cloud collaborative architecture is adopted. Lightweight chips are used at the camera end to complete the foreground extraction and motion residual filtering of video frames, and the compressed feature stream containing the dynamics of key groups of people is uploaded to the central processor. The compressed feature stream is pruned and quantized, converting full-precision floating-point operations into INT8 fixed-point operations. The capabilities of large models are transferred to lightweight networks through knowledge distillation to support real-time parallel processing of multiple video streams. The crowd trajectory is matrixed, and a lock-free parallel computing framework based on the CUDA architecture is used to transform spatiotemporal collision detection into matrix multiplication operations, eliminating thread synchronization wait and deadlock in high-concurrency early warning queries. By introducing state entropy increase dynamic constraints, the Shannon entropy evolution equation is embedded as a regularization penalty term into the kernel function weight scaling factor of the linear attention approximate graph transmission model of group collaborative collision avoidance behavior, which constrains the gradient flow of the intermediate layer and improves the prediction accuracy of mutation behavior. By using a self-organizing feature map hidden layer deep continuous flow model to extrapolate the probability of sparse small sample high-risk events, and combining it with a mask self-attention mechanism to construct a fully parallel spatiotemporal transformation network, we can achieve synchronous parallel prediction of spatiotemporal dimension features. The comprehensive score of the congestion warning confidence is calculated based on the dynamic adjustment function of the congestion warning confidence, and the corresponding level of warning response strategy is activated based on the interval to which the comprehensive score belongs.

2. The safety early warning method for crowd congestion levels at large school events according to claim 1, characterized in that, The edge computing and central cloud collaborative architecture is as follows: the foreground extraction module runs on the embedded chip at the camera end, and separates the foreground motion region using frame difference method and background subtraction method; the motion residual filtering module calculates the pixel residual between adjacent frames and filters static region frames whose residual energy is lower than the residual filtering threshold. Only compressed features containing motion foregrounds are streamed through a gigabit LAN to the central processor.

3. The safety early warning method for crowd congestion levels at large school events according to claim 2, characterized in that, The INT8 fixed-point operation specifically involves: performing symmetric linear quantization on the original full-precision floating-point weight matrix, using the maximum absolute value of each channel as the quantization scaling factor; and using the soft-label output of the original large model as the teacher signal, adjusting the smoothness of the soft-label distribution with a temperature coefficient.

4. The safety early warning method for crowd congestion levels at large school events according to claim 3, characterized in that, The lock-free parallel computing framework specifically involves: organizing the coordinates of all spatiotemporal trajectory points of the entire population into a two-dimensional matrix, implementing spatiotemporal collision detection in the form of matrix multiplication using CUDA kernel functions; abandoning the mutex lock mechanism and instead using atomic operations and thread-private memory partitioning, allowing each CUDA thread block to independently process its own trajectory submatrix.

5. The safety early warning method for crowd congestion levels at large school events according to claim 4, characterized in that, The linear attention approximation graph propagation model for collaborative collision avoidance behavior is as follows: the model input is a spatial physical boundary constraint topology matrix, where graph nodes represent people and graph edges represent spatial proximity relationships, and the edge weights are obtained by real-time Euclidean distance normalization; the core attention layer limits the attention receptive field of each node through a local sliding window, and maps the query matrix and key matrix to a low-dimensional feature space through random kernel function mapping.

6. The safety early warning method for crowd congestion levels at large school events according to claim 5, characterized in that, The linear attention approximation graph propagation model for group collaborative collision avoidance behavior further includes: the social force repulsion law is transformed into a loss penalty term, a repulsion potential term is constructed using an exponential function of the inverse of the distance between nodes, and the repulsion potential term is embedded in the weight scaling factor of the kernel function attention operator; the forward information propagation path of the locally asymmetric gated recurrent unit uses a low gate threshold, while the feedback smoothing path uses a high gate threshold; a long-span residual dense jump matrix is ​​introduced between layers, and the first... Layer output and the first The layer outputs are directly added together and then sent to the next layer.

7. The safety early warning method for crowd congestion levels at large school events according to claim 6, characterized in that, In the linear attention approximate graph transmission model of the group collaborative collision avoidance behavior, the dynamic lightweight topological graph transmission algorithm that integrates Fibonacci sequence optimization takes the sparsity of the graph adjacency matrix and the Shannon entropy increase of information transmission as dual optimization objectives. It dynamically samples the topological adjacency features at the golden section point determined by the golden ratio and instantly reconstructs the lightweight topological matrix. The adjacency matrix of a sparse graph is stored in a compressed sparse row format, and the memory usage is proportional to the sparsity of the graph.

8. The safety early warning method for crowd congestion levels at large school events according to claim 7, characterized in that, The self-organizing feature mapping hidden layer deep continuous flow model is as follows: the front end of the model is a multi-level self-organizing feature mapping hidden layer, which performs adaptive topological mapping on the micro-behavioral feature vectors of the crowd through a competitive learning mechanism; the back end uses a series of reversible nonlinear transformations based on affine coupling layers to losslessly map the probability distribution output by the self-organizing feature mapping hidden layer to the standard Gaussian space.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores program instructions, which, when executed in a computer, are used to perform a safety early warning method for crowd congestion levels at large school events as described in any one of claims 1-8.

10. A safety early warning system for crowd congestion levels at large school events, characterized in that, The system comprises the computer-readable storage medium of claim 9, wherein the system is a computer, the computer-readable storage medium is disposed within the system, and the system is provided with a microprocessor that executes program instructions stored in the computer-readable storage medium.