Traffic flow detection method and device, electronic equipment and storage medium

Through drone route planning and deep learning target detection models, the problem of long delay in traditional traffic flow detection is solved, efficient, accurate and intelligent real-time traffic flow detection is achieved, and the detection accuracy and robustness in urban traffic scenarios are improved.

CN120673280APending Publication Date: 2025-09-19WUYI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510589065.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-08
Publication Date
2025-09-19

AI Technical Summary

Technical Problem

Traditional traffic flow detection methods rely on manual inspections and post-event feedback, resulting in long detection delays, consuming a large amount of manpower and material resources, and failing to achieve efficient, accurate, and intelligent real-time detection.

Method used

Using drone route planning and deep learning target detection models, the system shoots video streams through drones, performs data cleaning and model training, combines dynamic window method and Gaussian process regression to generate cruise paths, uses hybrid aggregation backbone network and neck network to perform multi-scale feature extraction and fusion, outputs traffic flow detection results, and pushes them to user terminals in real time through cloud servers.

Benefits of technology

It supports edge devices to process high-definition video streams in real time while ensuring detection accuracy, significantly improving the accuracy and robustness of traffic flow detection in complex urban traffic scenarios, and meeting the urban traffic system's needs for low latency and high throughput.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120673280A_ABST
    Figure CN120673280A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a traffic flow detection method and device, electronic equipment and a storage medium. The method comprises the following steps: acquiring traffic flow image information, and inputting the traffic flow image information into a trained target detection model to obtain a traffic flow detection result; transmitting the vehicle flow detection result to a cloud server, so that the cloud server sends the vehicle flow detection result to a user terminal and displays the vehicle flow detection result; the training method of the target detection model comprises the following steps: determining a target area of a to-be-detected traffic flow; performing unmanned aerial vehicle route planning on the target area to obtain a cruise path; controlling the unmanned aerial vehicle to shoot and sample the target area according to the cruise path to obtain a video stream; performing data cleaning on the video stream to obtain a data set; and performing model training on the target detection model based on the data set to obtain a trained target detection model. According to the embodiment of the invention, the traffic flow can be efficiently, accurately and intelligently detected in real time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the field of image recognition technology, and in particular to a vehicle flow detection method and device, an electronic device, and a storage medium. Background Art

[0002] Traditional traffic flow detection methods typically rely on users conducting manual inspections and providing feedback when they perceive traffic congestion or frequent accidents before the location of problematic road sections can be determined. This "after-the-fact" detection method significantly inconveniences urban traffic management. After receiving user feedback, detection personnel must locate the target vehicle and the complex traffic hub where it is located, manually annotating and measuring it. After obtaining actual vehicle location data, they use traditional image processing methods to measure the road surface from the feature map to the original image to locate the target boundary. By measuring the matching degree of multi-scale features, the detection model parameters are adjusted to improve the accuracy of small target detection and the efficiency of blind spot correction. The process from detecting traffic flow anomalies to blind spot correction requires significant manpower and resources, and significantly delays the user experience of intelligent transportation systems until the problem is resolved. Therefore, efficient, accurate, and intelligent real-time traffic flow detection has become a pressing technical challenge. Summary of the Invention

[0003] The embodiments of the present invention provide a vehicle flow detection method and device, electronic device and storage medium, which can efficiently, accurately and intelligently detect vehicle flow in real time. While ensuring detection accuracy, it supports edge devices to process high-definition video streams in real time, meets the urban traffic system's requirements for low latency and high throughput, and significantly improves the accuracy and robustness of vehicle flow detection in complex urban traffic scenarios.

[0004] In a first aspect, an embodiment of the present invention provides a vehicle flow detection method, comprising:

[0005] Obtaining traffic flow image information, inputting the traffic flow image information into a trained target detection model to obtain a traffic flow detection result;

[0006] Transmitting the vehicle flow detection result to a cloud server, so that the cloud server sends the vehicle flow detection result to a user terminal and displays it;

[0007] The target detection model training method includes:

[0008] Determine the target area for traffic flow inspection;

[0009] Performing UAV route planning on the target area to obtain a cruising path;

[0010] Controlling the UAV to shoot and sample the target area according to the cruising path to obtain a video stream;

[0011] Performing data cleaning on the video stream to obtain a data set;

[0012] The target detection model is trained based on the data set to obtain a trained target detection model.

[0013] In some embodiments, performing drone route planning on the target area to obtain a cruising path includes:

[0014] Control the drone to perform multiple circling flights around the target area, and simultaneously record flight attitude parameters, speed parameters, and obstacle avoidance operation parameters;

[0015] The onboard visual sensor on the drone collects dynamic traffic distribution data, obstacle space topology data and light intensity data in real time;

[0016] Extracting a traffic flow movement trend feature vector and an obstacle probability distribution map from the dynamic traffic flow distribution data, the obstacle space topology data, and the light intensity data;

[0017] Based on the dynamic window method and Gaussian process regression, the cruising path is generated according to the vehicle flow movement trend feature vector and the obstacle probability distribution map.

[0018] In some embodiments, the object detection model includes a backbone network, a neck network, and a detection head;

[0019] The backbone network is used to extract multi-scale features through multi-path depth-separable convolution layers;

[0020] The neck network is used to perform shallow attention feature enhancement and deep sparse cross-layer fusion;

[0021] The detection head is used to output bounding box coordinates, confidence and category prediction respectively;

[0022] End-to-end information transmission is achieved between the backbone network, the neck network and the detection head through tensor channel cascade.

[0023] In some embodiments, inputting the traffic flow image information into a trained target detection model to obtain a traffic flow detection result includes:

[0024] Inputting the traffic flow image information into the convolutional layer and maximum pooling of the backbone network for step-by-step downsampling to extract multi-scale basic features;

[0025] The multi-scale basic features are input into the neck network, where high-resolution features are restored through upsampling and concatenated with shallow detail features. Multi-scale fusion is achieved by combining cross-stage residual interaction of the bottleneck module and multi-level dilated pooling of the pooling layer. At the same time, an attention mechanism is embedded to dynamically enhance key area features of traffic flow and suppress background noise.

[0026] The optimized key area features are input into the lightweight convolution compression channel of the detection head, and the target position and category information are output to obtain the vehicle flow detection result.

[0027] In some embodiments, the backbone network includes a convolutional component, a hybrid aggregation backbone network component, and a pooling layer component;

[0028] The convolution component includes effective convolution and downsampling convolution. The effective convolution uses the parameter setting of not changing the original input in each convolution in the convolution kernel setting. The convolution kernel parameter used by the downsampling convolution is 3×3 and the step size is 2.

[0029] The input and output process of the hybrid aggregation backbone network component includes:

[0030] The input feature map first enters three processing branches in parallel. The left branch adjusts the channel dimension through 1×1 convolution; the middle branch is divided into two-way features through a segmentation operation, and inputs two convolution neck modules for multi-scale feature extraction respectively; the right branch expands the spatial receptive field through a depthwise separable convolution module, wherein the depthwise separable convolution module includes 1×1 point convolution, K×K depthwise convolution and 1×1 pointwise convolution; the three-way features of the left branch, the middle branch and the right branch are spliced ​​through the channels, and the cross-channel information is fused through 1×1 convolution to form the output feature map;

[0031] The input and output process of the pooling layer component includes:

[0032] The input feature map first passes through a three-stage cascaded convolution batch normalization Sigmoid linear unit module to complete basic feature enhancement, and then enters a cascaded void pooling structure consisting of three 3×3 maximum pooling layers with a stride of 1. The kernel size increases by 3, 5, and 7 gradients, gradually expanding the context perception range while maintaining the resolution of the feature map; the feature stream is then split into the first main path and the first bypass. The first main path uses depthwise separable convolution, including 1×1 point convolution and 3×3 depthwise convolution, to achieve lightweight feature transformation in conjunction with channel compression operation, and then performs multi-level pooling again to extract cross-scale information; the first bypass directly retains the original features to maintain information integrity; finally, the multi-scale features of the main path and the bypass features are fused through channel splicing, and then the number of channels is compressed to the original dimension through 1×1 convolution before output.

[0033] In some embodiments, the neck network includes a splicing component, a bottleneck module component, an upsampling component, and an attention component;

[0034] The splicing component is used to align and integrate feature maps from different depths or branches through channel-dimensional splicing, adopts 1×1 convolution preprocessing to reduce the computational load of redundant channels, and introduces a dynamic channel rearrangement strategy to enhance the information interaction capability across feature maps;

[0035] The input and output process of the bottleneck module component includes:

[0036] The input features are split into a main path and a bypass branch through a split operation. The main path stacks multiple lightweight bottleneck units to extract high-order spatial features. The bypass directly retains the original input features to maintain low-level details. After the two outputs are channel-wise concatenated, the number of channels is compressed to half of the input through a 1×1 convolution. The bottleneck module introduces a gradient splitting mechanism to disperse the back-propagated gradient to multiple bottleneck branches, while using dynamic channel weight allocation to improve the contribution of key features.

[0037] The upsampling component adopts a dual-branch collaborative strategy, which includes:

[0038] The second main path directly enlarges the feature map size through nearest neighbor interpolation, preserving the original feature distribution. The second bypass path introduces lightweight depthwise separable convolution to spatially enhance the input features and suppress grid artifacts during upsampling. After the outputs of the second main path and the second bypass are channel-wise concatenated, the channel weights are dynamically calibrated by 1×1 convolution and compressed to the target dimension. At the same time, a spatial attention subnet is embedded to optimize feature focusing capabilities. A spatial mask is generated through dual-path aggregation of global maximum pooling and average pooling.

[0039] The attention component calculates the energy value based on the global statistics and generates the attention weight through the Sigmoid function.

[0040] In some embodiments, transmitting the vehicle flow detection result to a cloud server so that the cloud server sends the vehicle flow detection result to a user terminal and displays it, includes:

[0041] The traffic flow detection result is uploaded to the cloud server through an encrypted channel. The cloud server evaluates the traffic situation based on a spatiotemporal data analysis engine. When it is detected that the congestion index exceeds the standard or the risk of an accident is detected, a multi-level alarm mechanism is immediately triggered to push visual warning information to the user terminal. At the same time, the event location and recommended detour route are displayed and marked on the electronic map of the user terminal.

[0042] In a second aspect, an embodiment of the present invention further provides a vehicle flow detection device, the device comprising:

[0043] A determination module, used to determine a target area of ​​traffic flow to be detected;

[0044] A planning module is used to plan the UAV route in the target area and obtain a cruising path;

[0045] A sampling module is used to control the UAV to shoot and sample the target area according to the cruising path to obtain a video stream;

[0046] A cleaning module, configured to clean the video stream to obtain a data set;

[0047] A training module is used to perform model training on the target detection model based on the data set to obtain a trained target detection model;

[0048] A detection module is used to obtain traffic flow image information and input the traffic flow image information into a trained target detection model to obtain a traffic flow detection result;

[0049] The transmission module is used to transmit the vehicle flow detection result to the cloud server, so that the cloud server sends the vehicle flow detection result to the user terminal and displays it.

[0050] In a third aspect, an embodiment of the present invention further provides an electronic device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the vehicle flow detection method as described in the first aspect when executing the computer program.

[0051] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the vehicle flow detection method as described in the first aspect.

[0052] According to the vehicle flow detection method and device, electronic device and storage medium provided by the embodiments of the present invention, the vehicle flow detection method includes: obtaining vehicle flow image information, inputting the vehicle flow image information into a trained target detection model to obtain a vehicle flow detection result; transmitting the vehicle flow detection result to a cloud server so that the cloud server sends the vehicle flow detection result to a user terminal and displays it; wherein the training method of the target detection model includes: determining a target area for vehicle flow to be detected; planning a drone route for the target area to obtain a cruising path; controlling the drone to shoot and sample the target area according to the cruising path to obtain a video stream; performing data cleaning on the video stream to obtain a data set; and training a target detection model based on the data set to obtain a trained target detection model. Based on this, the embodiments of the present invention can efficiently, accurately and intelligently perform real-time detection of vehicle flow, support edge devices to process high-definition video streams in real time while ensuring detection accuracy, meet the low latency and high throughput requirements of urban transportation systems, and significantly improve the accuracy and robustness of vehicle flow detection in complex urban traffic scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] Figure 1 is a flow chart of a vehicle flow detection method provided by one embodiment of the present invention;

[0054] Figure 2 This is a flow chart of a method for training an object detection model provided by one embodiment of the present invention;

[0055] Figure 3 This is an input and output block diagram of an object detection model provided by one embodiment of the present invention;

[0056] Figure 4 Schematic diagram of the overall network structure of the target detection model provided by one embodiment of the present invention;

[0057] Figure 5 It is a structural diagram of a hybrid aggregation backbone network component provided by one embodiment of the present invention;

[0058] Figure 6 is a schematic structural diagram of a pooling layer component provided by one embodiment of the present invention;

[0059] Figure 7 is a schematic structural diagram of a bottleneck module assembly provided by one embodiment of the present invention;

[0060] Figure 8 is a schematic diagram of the structure of an attention component provided by one embodiment of the present invention;

[0061] Figure 9 This is a schematic diagram of interaction with a user terminal provided by an embodiment of the present invention;

[0062] Figure 10 is a schematic diagram of a vehicle flow detection device provided by one embodiment of the present invention;

[0063] Figure 11 FIG. 1 is a schematic diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0064] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0065] It should be noted that although the device schematics illustrate functional module divisions and the flowcharts illustrate logical sequences, in certain circumstances, the steps shown or described may be performed in a sequence that differs from the module divisions in the device or the sequence in the flowcharts. The terms "first," "second," and so on, used in the specification, claims, and accompanying drawings are used to distinguish similar items and are not necessarily intended to describe a specific sequence or precedence.

[0066] In the embodiments of the present invention, words such as "further," "exemplarily," or "optionally" are used to indicate examples, illustrations, or explanations and should not be interpreted as being more preferred or advantageous over other embodiments or designs. The use of words such as "further," "exemplarily," or "optionally" is intended to present related concepts in a concrete manner.

[0067] In order to more conveniently describe the working principle of the embodiments of the present invention later, an introduction to relevant technical scenarios is first given below.

[0068] Traditional traffic flow detection methods typically rely on users conducting manual inspections and providing feedback when they perceive traffic congestion or frequent accidents before the location of problematic road sections can be determined. This "after-the-fact" detection method significantly inconveniences urban traffic management. After receiving user feedback, detection personnel must locate the target vehicle and the complex traffic hub where it is located, manually annotating and measuring it. After obtaining actual vehicle location data, they use traditional image processing methods to measure the road surface from the feature map to the original image to locate the target boundary. By measuring the matching degree of multi-scale features, the detection model parameters are adjusted to improve the accuracy of small target detection and the efficiency of blind spot correction. The process from detecting traffic flow anomalies to blind spot correction requires significant manpower and resources, and significantly delays the user experience of intelligent transportation systems until the problem is resolved. Therefore, efficient, accurate, and intelligent real-time traffic flow detection has become a pressing technical challenge.

[0069] Based on this, the present invention provides a vehicle flow detection method and device, electronic device and storage medium. The vehicle flow detection method includes: obtaining vehicle flow image information, inputting the vehicle flow image information into a trained target detection model to obtain a vehicle flow detection result; transmitting the vehicle flow detection result to a cloud server, so that the cloud server sends the vehicle flow detection result to a user terminal and displays it; the training method of the target detection model includes: determining the target area of ​​the vehicle flow to be detected; planning the drone route for the target area to obtain a cruising path; controlling the drone to shoot and sample the target area according to the cruising path to obtain a video stream; performing data cleaning on the video stream to obtain a data set; and training the target detection model based on the data set to obtain a trained target detection model. Based on this, the embodiment of the present invention can efficiently, accurately and intelligently detect vehicle flow in real time. While ensuring detection accuracy, it supports edge devices to process high-definition video streams in real time, meets the low latency and high throughput requirements of urban transportation systems, and significantly improves the accuracy and robustness of vehicle flow detection in complex urban traffic scenarios.

[0070] The embodiments of the present invention are further described below with reference to the accompanying drawings.

[0071] like Figure 1 As shown, Figure 1 1 is a flow chart of a vehicle flow detection method provided by an embodiment of the present invention. The vehicle flow detection method may include but is not limited to steps S101 to S102.

[0072] Step S101: Obtaining traffic flow image information, inputting the traffic flow image information into a trained target detection model, and obtaining a traffic flow detection result;

[0073] Step S102: Transmitting the vehicle flow detection result to the cloud server, so that the cloud server sends the vehicle flow detection result to the user terminal and displays it.

[0074] Among them, such as Figure 2 As shown in Figure 2, the training method of the target detection model includes:

[0075] Step S201: determining a target area for traffic flow to be detected;

[0076] Step S202: Plan the drone route for the target area to obtain a cruising path;

[0077] Step S203: Control the UAV to shoot and sample the target area according to the cruising path to obtain a video stream;

[0078] Step S204: Clean the video stream to obtain a data set;

[0079] Step S205: Perform model training on the target detection model based on the data set to obtain a trained target detection model.

[0080] It is understandable that an autonomous path planning framework for UAVs can be constructed based on the dynamic trajectory optimization algorithm, and spiral cruising in three-dimensional interchanges at transportation hubs can be achieved through obstacle avoidance modeling and waypoint correction mechanisms.

[0081] The specific implementation is: manually control the drone to circle the traffic flow in advance and plan the inspection flight route. This system will perform the following operations:

[0082] Trajectory optimization algorithm technology is used to realize spiral cruising of three-dimensional interchanges in transportation hubs: the operator manually controls the drone to perform multiple circling flights along the target area, and simultaneously records the flight attitude, speed and obstacle avoidance operation parameters; through the onboard visual sensor and real-time collection of dynamic traffic distribution, obstacle space topology and light intensity data, the traffic movement trend feature vector and obstacle probability distribution map are extracted, and the initial inspection path reference trajectory is generated based on the dynamic window method and Gaussian process regression.

[0083] It is understandable that it is possible to shoot and sample traffic hubs, and perform data cleaning on the collected video streams to form a high-quality data set.

[0084] The specific implementation is: based on the trajectory optimization algorithm, the transportation hub is sampled and a high-quality data set is formed. The system will perform the following operations:

[0085] (1) Use “crawler” technology to collect data sets and clean up junk data:

[0086] Data sets can be collected in two ways. The first is to use "crawler" technology to crawl traffic flow images on the Internet, save them, and then clean up images with high similarity and junk data; the second is to use drones to fly around the overpass to take pictures and sample traffic flow, and delete images with high similarity between adjacent frames. After the data set is completed, the images are finally re-cropped (adjusted) to a fixed size.

[0087] (2) Labeling and classification of the entire dataset:

[0088] The vehicle targets in the dataset can be labeled using AI labeling software. Specifically, 25% of the images in the dataset are first labeled for model training, and then the remaining 75% of the data labels are predicted through model reasoning. Finally, incorrect labels are corrected through manual review.

[0089] It is understandable that the system model can be trained using the target detection algorithm based on the data set and the system model can be given recognition and judgment capabilities.

[0090] The specific implementation is as follows: The target detection model is based on the target detection algorithm of deep learning. The target detection model execution process is as follows Figure 3 As shown in the figure, the proposed method comprises five stages: 1) the input dataset is preprocessed by normalization; 2) a dynamic meshing module generates dense grid cells and predicts target heatmap keypoints; 3) a hybrid aggregation backbone network (MANet) extracts multi-scale features through multi-path deep separable convolution hierarchical layers; 4) a dual-path neck network performs shallow attention feature enhancement and deep sparse cross-layer fusion; and 5) a decoupled detection head outputs bounding box coordinates, confidence scores, and category predictions. Tensor channel cascades are used to achieve end-to-end information transfer between modules, ultimately outputting structured detection results.

[0091] It is understandable that for image grid and key point generation, image grid generation is a basic step in the target detection method. By dividing the input image into uniform regular grid cells, a spatial reference coordinate system is established. Each grid corresponds to a specific position on the feature map, providing a structured benchmark for subsequent target positioning. Grid division is based on a fixed step size (such as 8×8 pixels) to ensure that the feature map is aligned with the original image at the pixel level, thereby accurately mapping the target position and eliminating the size deviation caused by the pre-defined traditional anchor frame.

[0092] The grid-based Anchor-Free detection method abandons the redundant design of predefined anchor boxes and achieves efficient detection through direct alignment of feature maps with the grid. Each grid cell directly predicts the target center point coordinates and bounding box parameters (such as offset, width and height scaling factors). Combined with a dynamic positive sample allocation strategy, regression calculations are performed only on the grid where the target is located and its surrounding area. This method reduces computational complexity by integrating the prediction of center point confidence and bounding box parameters, while avoiding the detection limitations of anchor box size on targets with extreme aspect ratios, significantly improving positioning accuracy in densely occluded scenes.

[0093] The Anchor-Free mechanism is designed to simplify the detection process and enhance model adaptability. It directly regresses target parameters using a gridded spatial reference, eliminating the need for predefined anchor box sizes and effectively reducing the cost of model hyperparameter tuning. This method is particularly well-suited for multi-scale vehicle detection in urban traffic scenarios. By dynamically fusing multi-level features and adaptively allocating positive samples, it overcomes low light conditions, dense occlusions, and complex weather conditions, achieving high-precision, low-latency vehicle detection and providing reliable technical support for intelligent traffic management.

[0094] It is understandable that for the backbone network design, in the test phase, a 1280×1280 image is used as the input of the system, and the backbone network structure is as follows Figure 4As shown. The input image features are downsampled step by step through the convolution layer and maximum pooling of Backbone to extract multi-scale basic features; then they enter Neck, where they are restored to high-resolution features through upsampling and spliced ​​with shallow detail features. The cross-stage residual interaction of the bottleneck module and the multi-level hole pooling of the pooling layer are combined to achieve multi-scale fusion. At the same time, the attention mechanism is embedded to dynamically enhance the key area features of the vehicle and suppress background noise; finally, the optimized features are compressed through the lightweight convolution channel of the Head, and the target position and category information are output by the Detect module. This structure significantly improves the small target capture capability and occlusion robustness of traffic in urban traffic scenarios through the closed-loop design of "downsampling-cross-layer fusion-attention enhancement-multi-scale prediction", providing high-precision and low-latency core technical support for the traffic flow detection in the present invention.

[0095] For vehicle detection, the present invention will use appropriate components to form a backbone network, such as Figure 2 In the red box, each square represents a related component in the network, including the convolution component, the hybrid aggregation backbone network component MANet, and the pooling layer component.

[0096] Convolution components primarily include effective convolution and downsampling convolution. Effective convolution uses kernel parameters that do not change the original input during each convolution, while downsampling convolution uses a 3×3 kernel with a stride of 2. This setting is intended to improve the system model's ability to focus on image features after multiple learning and reorganization of image features.

[0097] like Figure 5 As shown, for the hybrid aggregation backbone network components, the input and output process of this framework can be described as follows: Input feature Figure X First, it enters three processing branches in parallel - the left branch adjusts the channel dimension through 1×1 convolution; the middle branch is divided into two-way features through a split operation, and inputs two convolution neck modules for multi-scale feature extraction; the right branch expands the spatial receptive field through a depth-separable convolution module (including 1×1 point convolution, K×K depth convolution and 1×1 point-by-point convolution). After the three-way features are spliced ​​through the channel, cross-channel information fusion is completed through 1×1 convolution to form an output feature map. It is worth noting that the channel attention mechanism is embedded in the feature aggregation process: after the global average pooling layer extracts the channel statistics, the dimension is compressed through a two-level fully connected layer and the channel attention weight Wc is generated. This weight is activated by the Sigmoid function and multiplied with the backbone feature to achieve dynamic recalibration of the feature channel. The entire processing flow effectively enhances the representation ability of multi-granularity semantic information while maintaining low computational complexity through cross-stage feature reuse and multi-branch interaction. The formula is as follows:

[0098] W c=σ(FC2(δ(FC1(GAP(X))))) (1)

[0099] Y=Concat[DSConv 3×3 (X),DSConv 5×5 (X)]·W p (2)

[0100] like Figure 6 As shown in the figure, the input and output process of the pooling layer component can be clearly described as follows: the input feature map first passes through three stages of convolutional batch normalization Sigmoid linear unit modules in series to achieve basic feature enhancement. It then enters a cascaded dilated pooling structure consisting of three 3x3 max pooling layers with a stride of 1. The kernel sizes increase gradually by 3, 5, and 7, gradually expanding the contextual perception range while maintaining the feature map resolution. The feature stream is then split into a main path and a side path. The main path uses depthwise separable convolution, including 1x1 point convolution and 3x3 depthwise convolution, combined with channel compression to achieve lightweight feature transformation, and then performs multi-level pooling again to extract cross-scale information. The side path directly retains the original features to maintain information integrity. Finally, the multi-scale features of the main path and the bypass features are fused through channel concatenation, and the number of channels is compressed to the original dimension through 1x1 convolution before output. This process improves efficiency through three key design features: 1) a cascaded pooling kernel size expansion strategy enhances multi-scale robustness; 2) a gradient splitting strategy across some stages of the dual-branch architecture reduces computational redundancy by 30%; and 3) a combination of depthwise separable convolution and channel compression reduces the number of parameters by 41.6% compared to traditional spatial pyramid pooling. Residual connections are used across the components to ensure gradient propagation stability, forming an efficient end-to-end feature pyramid fusion mechanism. The formula is as follows:

[0101] F pool =Concat[MaxPool 5×5 (X),MaxPool 9×9 (X),MaxPool 13×13 (X)] (3)

[0102] It can be understood that for the neck network design, the neck network structure such as Figure 4 As shown in the middle box. For vehicle detection, the present invention will design a suitable structure to form a neck network, such as Figure 4 In the figure, each block represents the relevant components in the network, including convolutional components, splicing components, bottleneck module components, upsampling components, and attention components.

[0103] The splicing component, as the core unit of feature fusion, focuses on efficient cross-level, multi-scale feature splicing and channel-dimensional optimization. Its design aligns and integrates feature maps from different depths or branches through channel-dimensional splicing. It employs 1×1 convolution preprocessing to reduce the computational load of redundant channels and introduces a dynamic channel reordering strategy to enhance information exchange across feature maps. To address gradient propagation issues, lightweight residual connections are embedded within the splicing to smooth gradient flow while supporting lossless transfer of features across stages.

[0104] For the bottleneck module component, the structure is as follows Figure 7 As shown. As the core feature fusion module of YOLOv8, the bottleneck module introduces a multi-branch residual interaction strategy of cross-stage features based on the C3 module, and optimizes detection accuracy by enhancing the fusion ability of shallow details and deep semantics. Its core process is: the input features are divided into the main path and the bypass branch through the Split operation, and the main path stacks multiple lightweight bottleneck units to extract high-order spatial features; the bypass directly retains the original input features to maintain low-level details. After the two outputs are spliced ​​through the channels, the number of channels is compressed to half of the input through 1×1 convolution, effectively balancing the amount of computation and the need for information retention. In addition, the bottleneck module introduces a gradient diversion mechanism to disperse the back-propagated gradient to multi-level bottleneck branches, alleviating the gradient attenuation problem of deep networks, and at the same time adopts dynamic channel weight allocation to improve the contribution of key features. Compared with the C3 module of YOLOv5, the bottleneck module significantly enhances the detection robustness of occluded targets and small-scale objects by adding a cross-layer feature reuse path. Xin: input feature map; Split: channel averaging operation: lightweight residual unit, the default stacking N is 4 layers; Layer-by-layer residual connection. The formula is as follows:

[0105]

[0106] For the upsampling component, this component is the core unit for feature map resolution recovery. It realizes the mapping of low-dimensional features to high-dimensional space through interpolation or learnable parameterization methods to adapt to the needs of multi-scale feature fusion. Its design adopts a dual-branch collaborative strategy: the main path directly enlarges the feature map size (default 2 times) through nearest neighbor interpolation to retain the original feature distribution; the bypass introduces lightweight depth-wise separable convolution to spatially enhance the input features and suppress grid artifacts during the upsampling process. After the outputs of the two are spliced ​​through the channels, the channel weights are dynamically calibrated by 1×1 convolution and compressed to the target dimension. At the same time, a spatial attention subnet is embedded to optimize the feature focusing ability - a spatial mask is generated through the dual-path aggregation of global maximum pooling and average pooling to enhance the response strength of key areas.

[0107] For the attention component, its logic diagram is as follows Figure 8As shown in Figure 2. Attention is a highly efficient attention module that requires no additional parameters. It dynamically evaluates the importance of each neuron in the feature map using energy function theory. Its core design calculates energy values ​​based on global statistics and generates attention weights using a sigmoid function, directly enhancing the response strength of high-energy regions. This module achieves global spatial perception with zero parameters and can be seamlessly embedded in convolutional backbone networks, making it suitable for real-time lightweight scenarios. The formula is as follows:

[0108]

[0109] It is understandable that based on the trained system model, a drone can be used to collect a small number of images at a specified location, and the system model can be fine-tuned using a small number of collected samples to make the model suitable for the specified location.

[0110] The specific implementation involves: Based on a trained traffic flow detection model, a drone captures low-resolution images (640×480) in the target area using a standard USB camera. Feature vectors of vehicle motion trajectories are extracted in real time. These feature data and the original images are stored, indexed by "grid coordinates_timestamp," on a Raspberry Pi Zero 2W onboard MicroSD card (FAT32 format, daily data volume ≤ 500MB). This feature data is then compressed using a 4G module (Zstandard algorithm, CR ≥ 60%), prioritizing the transmission of spatiotemporal grid data packets with a vehicle density change rate greater than 15% (single transmission ≤ 50KB). This simultaneously triggers model fine-tuning on the edge server, ultimately improving traffic flow detection accuracy in specific scenarios. This step is primarily intended to enhance the generalization capabilities of the system model and better integrate it with real-world scenarios. Therefore, a complete description of the storage and transmission process for the acquisition process is provided, allowing for effective adaptation to new environments. Therefore, unlike other methods, this invention incorporates fine-tuning techniques after model training. The key to fine-tuning lies in the creation of a small sample dataset.

[0111] The method of the present invention for producing a data set is to process the newly collected data set and the old data set in the same distribution. The specific method is as follows:

[0112] 1. Use drones to capture traffic flow maps of specific road sections. The objects captured must be similar to those in the training dataset.

[0113] 2. Apply autoencoding denoising technology to denoise the collected data set;

[0114] 3. Through manual intervention, label the denoised images, and the number of labels for each category must be the same;

[0115] 4. Adjust the labeled data so that its size adapts to the input size of the system model;

[0116] The above steps generally address the requirements for traffic flow detection on general roads. However, for certain high-accident road sections, the captured images are high-pixel images. Simply applying adjustments to these images will result in a loss of image features and a reduction in the system model's ability to detect small objects. Therefore, when capturing images with large pixels that cannot be adjusted, the system uses segmentation to convert them into input images suitable for the system model. The segmentation overlap is set to 20% to prevent objects from being segmented completely.

[0117] After obtaining the corresponding new dataset, it is fed into the system model for retraining and fine-tuning, allowing the system model to further optimize the system parameters based on the trained system. The training steps are the same as above. However, the fine-tuning training should be limited to no more than three times to prevent overfitting.

[0118] It is understandable that the model identification and determination results may be notified to the end user.

[0119] The specific implementation is as follows: After the drone starts the image acquisition task in the target area, the onboard camera captures the real-time video stream of the road scene at a preset frequency, and sends the original image data to the ground station where the edge computing node is deployed through the wireless transmission module; the built-in deep learning model of the ground station performs traffic flow feature extraction and abnormal event detection on the received image sequence, and generates structured data including vehicle location, movement trajectory and traffic status; the processed analysis results are uploaded to the cloud server cluster through an encrypted channel, and the cloud evaluates the traffic situation based on the spatiotemporal data analysis engine. When the congestion index exceeds the standard or the risk of an accident is detected, the multi-level alarm mechanism is immediately triggered, and visual warning information is pushed to the mobile terminal of the registered user. At the same time, the event location and recommended detour route are marked on the electronic map, realizing an end-to-end automated processing closed loop from data collection to decision feedback. The specific process is as follows Figure 9 shown.

[0120] It can be understood that the present invention proposes a vehicle flow detection method for urban traffic. First, the user determines the core traffic hub area that needs to be measured and formulates the route planning of the drone. Then, the drone flies around the core point of the three-dimensional interchange according to the path planning module and adjusts the path in real time. Then, the high-definition camera carried by the drone is used to collect traffic flow image information. The deep learning algorithm FM-YOLO and cross-layer feature aggregation technology in the model training module are used to automatically measure the vehicle target. The position, size, speed, type and distance between the vehicle and the traffic light are displayed in the ground terminal. A dynamic monitoring area is determined with the detection target as the center. The areas outside the combined monitoring area and adjacent traffic nodes are determined as potential risk areas. The real-time traffic situation is displayed in the terminal map, giving efficient work guidance to communication technicians. The solution provided by the present invention can be used in urban traffic inspections and accident-prone areas to achieve more efficient, more accurate and more intelligent detection of traffic density and abnormal events.

[0121] Based on this, the present invention is based on the original FM-YOLO multi-scale feature fusion architecture, and through the collaborative design of cross-stage residual interaction, multi-level void pooling and parameter-free attention, it significantly improves the accuracy and robustness of vehicle flow detection in complex urban traffic scenarios. This model efficiently integrates vehicle edge details and global semantic information through cross-layer feature splicing and dynamic weight calibration of the backbone network and the neck network, and realizes multi-scale precise positioning of large vehicles in the foreground, small vehicles in the distance and partially obscured vehicles; at the same time, the attention module adaptively enhances the key area feature response based on the energy function, and combines the MAnet hybrid anti-noise unit to effectively suppress rain, fog, shadows and dynamic background interference, ensuring stable detection performance under complex lighting and weather conditions. In addition, the present invention supports edge devices to process high-definition video streams in real time while ensuring detection accuracy through lightweight modules and model structure optimization, meeting the low latency and high throughput requirements of urban traffic systems. Its modular design can flexibly adapt to multi-source inputs such as on-board cameras and fixed monitoring equipment, and accelerate efficient deployment of electronic equipment through TensorRT, providing a highly reliable and low-cost technical solution for smart traffic management, with significant industrial application value and social and economic benefits.

[0122] In addition, if Figure 10 As shown, one embodiment of the present invention further discloses a vehicle flow detection device, which includes:

[0123] A determination module 110 is used to determine a target area for traffic flow to be detected;

[0124] Planning module 120, for planning the UAV route in the target area to obtain a cruising path;

[0125] The sampling module 130 is used to control the UAV to shoot and sample the target area according to the cruising path to obtain a video stream;

[0126] A cleaning module 140 is used to clean the video stream to obtain a data set;

[0127] A training module 150 is used to train the target detection model based on the data set to obtain a trained target detection model;

[0128] The detection module 160 is used to obtain traffic flow image information and input the traffic flow image information into the trained target detection model to obtain traffic flow detection results;

[0129] The transmission module 170 is used to transmit the vehicle flow detection result to the cloud server, so that the cloud server sends the vehicle flow detection result to the user terminal and displays it.

[0130] The vehicle flow detection device of the embodiment of the present invention is used to execute the vehicle flow detection method in the above embodiment. Its specific processing process is the same as the vehicle flow detection method in the above embodiment, and will not be repeated here.

[0131] In addition, if Figure 11 As shown, an embodiment of the present invention further discloses an electronic device, comprising: at least one processor 210; at least one memory 220 for storing at least one program; when the at least one program is executed by the at least one processor 210, a vehicle flow detection method as in any of the previous embodiments is implemented.

[0132] In addition, an embodiment of the present invention further discloses a computer-readable storage medium, in which computer-executable instructions are stored. The computer-executable instructions are used to execute the vehicle flow detection method in any of the above embodiments.

[0133] The system architecture and application scenarios described in the embodiments of the present invention are intended to more clearly illustrate the technical solutions of the embodiments of the present invention and do not constitute a limitation on the technical solutions provided by the embodiments of the present invention. Those skilled in the art will appreciate that with the evolution of the system architecture and the emergence of new application scenarios, the technical solutions provided by the embodiments of the present invention are equally applicable to similar technical problems.

[0134] Those skilled in the art will appreciate that all or some of the steps in the methods, systems, and functional modules / units in the devices disclosed above may be implemented as software, firmware, hardware, or appropriate combinations thereof.

[0135] In a hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, as is well known to those skilled in the art, communication media typically embodies computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.

[0136] As used in this specification, the terms "component," "module," "system," and the like are used to refer to computer-related entities, hardware, firmware, a combination of hardware and software, software, or software in execution. For example, a component can be, but is not limited to, a process running on a processor, a processor, an object, an executable file, an execution thread, a program, or a computer. By way of illustration, both applications running on a computing device and a computing device can be components. One or more components can reside in a process or execution thread, and a component can be located on one computer or distributed between two or more computers. In addition, these components can be executed from various computer-readable media having various data structures stored thereon. Components can communicate, for example, through local or remote processes based on signals having one or more data packets (e.g., data from two components interacting with another component on a local system, a distributed system, or a network, such as the Internet interacting with other systems via signals).

Claims

1. A method for detecting vehicle flow, comprising: Obtaining traffic flow image information, inputting the traffic flow image information into a trained target detection model to obtain a traffic flow detection result; Transmitting the vehicle flow detection result to a cloud server, so that the cloud server sends the vehicle flow detection result to a user terminal and displays it; The target detection model training method includes: Determine the target area for traffic flow inspection; Performing UAV route planning on the target area to obtain a cruising path; Controlling the UAV to shoot and sample the target area according to the cruising path to obtain a video stream; Performing data cleaning on the video stream to obtain a data set; The target detection model is trained based on the data set to obtain a trained target detection model.

2. The method according to claim 1, characterized in that The drone route planning for the target area to obtain a cruising path includes: Control the drone to perform multiple circling flights around the target area, and simultaneously record flight attitude parameters, speed parameters, and obstacle avoidance operation parameters; The onboard visual sensor on the drone collects dynamic traffic distribution data, obstacle space topology data and light intensity data in real time; Extracting a traffic flow movement trend feature vector and an obstacle probability distribution map from the dynamic traffic flow distribution data, the obstacle space topology data, and the light intensity data; Based on the dynamic window method and Gaussian process regression, the cruising path is generated according to the vehicle flow movement trend feature vector and the obstacle probability distribution map.

3. The method according to claim 1, characterized in that The target detection model includes a backbone network, a neck network and a detection head; The backbone network is used to extract multi-scale features through multi-path depth-separable convolution layers; The neck network is used to perform shallow attention feature enhancement and deep sparse cross-layer fusion; The detection head is used to output bounding box coordinates, confidence and category prediction respectively; End-to-end information transmission is achieved between the backbone network, the neck network and the detection head through tensor channel cascade.

4. The method according to claim 3, characterized in that Inputting the traffic flow image information into a trained target detection model to obtain a traffic flow detection result includes: Inputting the traffic flow image information into the convolutional layer and maximum pooling of the backbone network for step-by-step downsampling to extract multi-scale basic features; The multi-scale basic features are input into the neck network, where high-resolution features are restored through upsampling and concatenated with shallow detail features. Multi-scale fusion is achieved by combining cross-stage residual interaction of the bottleneck module and multi-level dilated pooling of the pooling layer. At the same time, an attention mechanism is embedded to dynamically enhance key area features of traffic flow and suppress background noise. The optimized key area features are input into the lightweight convolution compression channel of the detection head, and the target position and category information are output to obtain the vehicle flow detection result.

5. The method according to claim 3, characterized in that The backbone network includes a convolution component, a hybrid aggregation backbone network component and a pooling layer component; The convolution component includes effective convolution and downsampling convolution. The effective convolution uses the parameter setting of not changing the original input in each convolution in the convolution kernel setting. The convolution kernel parameter used by the downsampling convolution is 3×3 and the step size is 2. The input and output process of the hybrid aggregation backbone network component includes: The input feature map first enters three processing branches in parallel. The left branch adjusts the channel dimension through 1×1 convolution; the middle branch is divided into two-way features through a segmentation operation, and inputs two convolution neck modules for multi-scale feature extraction respectively; the right branch expands the spatial receptive field through a depthwise separable convolution module, wherein the depthwise separable convolution module includes 1×1 point convolution, K×K depthwise convolution and 1×1 pointwise convolution; the three-way features of the left branch, the middle branch and the right branch are spliced ​​through the channels, and the cross-channel information is fused through 1×1 convolution to form the output feature map; The input and output process of the pooling layer component includes: The input feature map first passes through a three-stage cascaded convolution batch normalization Sigmoid linear unit module to complete basic feature enhancement, and then enters a cascaded void pooling structure consisting of three 3×3 maximum pooling layers with a stride of 1. The kernel size increases by 3, 5, and 7 gradients, gradually expanding the context perception range while maintaining the resolution of the feature map; the feature stream is then split into the first main path and the first bypass. The first main path uses depthwise separable convolution, including 1×1 point convolution and 3×3 depthwise convolution, to achieve lightweight feature transformation in conjunction with channel compression operation, and then performs multi-level pooling again to extract cross-scale information; the first bypass directly retains the original features to maintain information integrity; finally, the multi-scale features of the main path and the bypass features are fused through channel splicing, and then the number of channels is compressed to the original dimension through 1×1 convolution before output.

6. The method according to claim 3, characterized in that The neck network includes a splicing component, a bottleneck module component, an upsampling component and an attention component; The splicing component is used to align and integrate feature maps from different depths or branches through channel-dimensional splicing, adopts 1×1 convolution preprocessing to reduce the computational load of redundant channels, and introduces a dynamic channel rearrangement strategy to enhance the information interaction capability across feature maps; The input and output process of the bottleneck module component includes: The input features are split into a main path and a bypass branch through a split operation. The main path stacks multiple lightweight bottleneck units to extract high-order spatial features. The bypass directly retains the original input features to maintain low-level details. After the two outputs are channel-wise concatenated, the number of channels is compressed to half of the input through a 1×1 convolution. The bottleneck module introduces a gradient splitting mechanism to disperse the back-propagated gradient to multiple bottleneck branches, while using dynamic channel weight allocation to improve the contribution of key features. The upsampling component adopts a dual-branch collaborative strategy, which includes: The second main path directly enlarges the feature map size through nearest neighbor interpolation, preserving the original feature distribution. The second bypass path introduces lightweight depthwise separable convolution to spatially enhance the input features and suppress grid artifacts during upsampling. After the outputs of the second main path and the second bypass are channel-wise concatenated, the channel weights are dynamically calibrated by 1×1 convolution and compressed to the target dimension. At the same time, a spatial attention subnet is embedded to optimize feature focusing capabilities. A spatial mask is generated through dual-path aggregation of global maximum pooling and average pooling. The attention component calculates the energy value based on the global statistics and generates the attention weight through the Sigmoid function.

7. The method according to claim 1, characterized in that The step of transmitting the vehicle flow detection result to a cloud server so that the cloud server sends the vehicle flow detection result to a user terminal and displays the result, includes: The traffic flow detection result is uploaded to the cloud server through an encrypted channel. The cloud server evaluates the traffic situation based on a spatiotemporal data analysis engine. When it is detected that the congestion index exceeds the standard or the risk of an accident is detected, a multi-level alarm mechanism is immediately triggered to push visual warning information to the user terminal. At the same time, the event location and recommended detour route are displayed and marked on the electronic map of the user terminal.

8. A vehicle flow detection device, characterized in that: The device comprises: A determination module, used to determine a target area of ​​traffic flow to be detected; A planning module is used to plan the UAV route in the target area and obtain a cruising path; A sampling module is used to control the UAV to shoot and sample the target area according to the cruising path to obtain a video stream; A cleaning module, configured to clean the video stream to obtain a data set; A training module is used to perform model training on the target detection model based on the data set to obtain a trained target detection model; A detection module is used to obtain traffic flow image information and input the traffic flow image information into a trained target detection model to obtain a traffic flow detection result; The transmission module is used to transmit the vehicle flow detection result to the cloud server, so that the cloud server sends the vehicle flow detection result to the user terminal and displays it.

9. An electronic device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the vehicle flow detection method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are used to execute the vehicle flow detection method according to any one of claims 1 to 7.