Vehicle tracking method
By introducing a variable kernel convolution layer and a dynamic sampling layer into the single target tracking algorithm, the yolov5s network structure is improved, which solves the problem of adaptability and recognition accuracy improvement for vehicle target recognition of different shapes, and achieves efficient vehicle target recognition and Tracking meets the requirements of real-time and accuracy.
Patent Information
- Application Number
- CN202410902151.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-06
- Publication Date
- 2024-09-24
AI Technical Summary
Existing single-target tracking algorithms are difficult to adapt to vehicles of different shapes and sizes when identifying and tracking vehicle targets. While improving recognition accuracy, they increase algorithm complexity and cannot meet the real-time and accuracy requirements.
A variable kernel convolution layer is used to replace the original convolution layer, and a dynamic sampling layer is introduced in the neck part of the network, which improves the yolov5s network structure so that it can adjust the convolution kernel size according to different shapes of vehicle targets and improve recognition. accuracy and recover high-resolution feature maps without increasing complexity.
The test R on the verification set is 0.489, and the map50 is 0.413. The main indicators are higher than the original yolov5s and yolov8s networks, which meets the real-time and accuracy requirements of target recognition and has important application value.
Smart Images

Figure CN118691645A
Abstract
Description
Technical Field
[0001] The invention studies a single target tracking method based on a neural network architecture and belongs to the field of machine vision. Background Art
[0002] Single target visual tracking is one of the most worthy and popular fields in the field of computer and machine vision in recent years. Single target tracking technology based on machine vision methods has gradually penetrated into various application scenarios in daily life, such as unmanned driving, aerospace, intelligent security monitoring, robot-related technologies, etc.
[0003] In recent years, more and more tracking algorithms have been successfully applied. With the continuous evolution of deep learning network models, deep models built with neural network technology are constantly breaking through the performance indicators of related video data sets. The present invention adopts a two-step target tracking method. First, the vehicle target is identified by the target recognition neural network, and then the tracking is realized by the ordinary tracking algorithm. In the target recognition network, the present invention optimizes the structure of the yoloov5s neural network based on variable kernel convolution and dynamic sampling, and changes the convolution module to a variable kernel convolution module in the backbone network. In the neck of the network, the present invention proposes a dynamic sampling layer to replace the original upsampling layer. Through the above two improvements, the network can use different convolution kernels for different targets to improve the recognition accuracy. At the same time, the dynamic sampling layer is used. When the low-resolution feature map can be restored to high resolution, it is more accurate, and the complexity of the algorithm is not increased while improving the network recognition accuracy. After that, the present invention designs a target tracking method based on target recognition, first using the improved yolov5s network to identify the vehicle target in a frame, and selecting the target with the highest probability for tracking. Experiments have confirmed that after the above improvements, the network recognition model has a test R of 0.489 and a map50 of 0.413 on the validation set. The main indicators are higher than the original yolov5s network and yolov8s network, which meets the real-time and accuracy requirements of target recognition and has important application value. Summary of the invention
[0004] The present invention proposes a target tracking method based on yolov5s network, and its specific idea is:
[0005] (1) Constructing a target recognition neural network model. A new network structure was invented, which changed the convolution layer in the original network structure into a variable kernel convolution layer, which can change the size of the convolution kernel, improve the adaptability to vehicle targets of different shapes, and improve the recognition accuracy. Then, the upsampler layer in the network was changed to a dynamic sampling layer, which can improve the recognition accuracy without increasing the complexity of the network, and build the final target recognition neural network model.
[0006] (2) Model pre-training. We used the collected vehicle dataset, which contained 18,000 images in total. The training set, test set, and validation set were allocated in a 6:2:2 ratio. The training set contained approximately 10,800 images. The size of the model file generated by training was 10,467 kB, and the size of the original yolov5s model file was 11,134 kB. During training, the initial learning rate was set to 0.0001, the batch size was set to 8, and the training was repeated for 100 epochs.
[0007] (3) Perform target tracking. After the model pre-training is completed, the latest network model parameters will be updated, and then the latest weights will be used to perform the inference of the target recognition task. The target with the highest probability of being identified will be tracked.
[0008] A vehicle tracking method, characterized in that:
[0009] The proposed network structure consists of three parts: backbone network, neck network and detection head. The backbone network extracts features from the input image, the neck network performs feature fusion on the feature map, and the detection head performs detection.
[0010] First, the backbone network is introduced. The vehicle image is input and integrated into a three-channel image of size 640×640 through preprocessing. It first passes through a convolution layer with a convolution kernel of 6×6, a stride of 2, and a padding of 2. This is the 0th layer. The internal structure of the convolution layer consists of a two-dimensional convolution module, a batch normalization module, and an activation function module. The Sigmoid Gated Linear Unit is used as the activation function. This convolution layer converts the image into a 64-channel image of size 320×320. After that, it passes through a convolution layer with a convolution kernel of 3×3 and a stride of 2, which reduces the length and width of the feature image by half, to a size of 160×160.
[0011] After layer 0, the 1st, 3rd, and 5th layers are convolutional layers, and the 7th layer is an AKConv layer. After layers 1, 3, 5, and 7, there is a composite layer called C3_AKConv; that is, layers 2, 4, 6, and 8 are composite layers of C3_AKConv.
[0012] In the backbone network, the length and width of the image will be reduced by half after the 1st, 3rd, 5th, and 7th convolution layers. After each convolution layer, a composite layer called C3_AKConv is passed. Inside the C3_AKConv layer, the input passes through a convolution layer with a kernel of 1×1 and a stride of 1, where an output is obtained. The input passes through a convolution layer with a kernel of 1×1 and a stride of 1 and a BottleNeck layer, and an output is also obtained. The two outputs are feature fused, i.e., Concat, and then pass through another convolution layer to obtain the final output of the C3_AKConv layer. In the backbone network, the convolution layer inside the BottleNeck layer is the AKConv layer.
[0013] The feature map sizes of the 4th and 6th layers are 80×80 and 40×40 respectively; in the 7th layer, the image passes through an AKConv layer with a convolution kernel of 3×3 and a stride of 2; then passes through a C3_AKConv layer that is the same as the 2nd layer, that is, the 8th layer; then passes through a fast spatial pyramid pooling layer SPPF, that is, the 9th layer. The structure of the fast spatial pyramid pooling layer SPPF is: passing through a convolution layer with a kernel of 1×1 and a stride of 1, and then passing through three 5×5 maximum pooling layers. After the results of the three maximum pooling layers are feature fused, they pass through a convolution layer with a kernel of 1×1 and a stride of 1 to end the backbone network part;
[0014] The network is divided into two layers, the 10th layer and the 23rd layer. The output of the 9th layer is input to the 10th layer of the backbone network. The 10th layer is a convolution layer with a convolution kernel of 1×1 and a step size of 1. It extracts features, but the size of the feature map remains unchanged at 20×20. It is then passed to the 11th layer, and the output of the 10th layer is dynamically sampled with a sampling multiple of 2. The dynamic sampling layer doubles the length and width of the image, and the feature map size is 40×40. In the 12th layer, the output of the 6th layer with a size of 40×40 is fused with the output of the 11th layer. The 13th layer is a C3 layer. The 14th layer is a convolution layer with a convolution kernel of 1×1 and a step size of 1. The 15th layer is a dynamic sampling layer, which enlarges the size of the feature map to 80×80. The 16th layer enlarges the output of the 4th layer, i.e., the size The 17th layer is a C3 layer. From the 10th layer to the 17th layer, the length and width of the feature map are enlarged four times. Then the 18th layer is a convolution layer with a convolution kernel of 3×3 and a stride of 2, which reduces the length and width of the feature map by half to 40×40. The 19th layer is a feature fusion layer, which fuses the output of the 14th layer with the output of the 18th layer. The 20th layer is a C3 layer with the same parameters as the 13th layer. The 21st layer is a convolution layer with a convolution kernel of 3×3 and a stride of 2, which reduces the length and width of the feature map by half again to 20×20. The 22nd layer is a feature fusion layer, which fuses the output of the 10th layer with the output of the 21st layer. The 23rd layer is a C3 layer with the same parameters as the 20th layer.
[0015] After passing through a neck network, the feature maps of each size are fused, and the final feature maps of each size are obtained, that is, the outputs of the 17th, 20th and 23rd layers; these three outputs are sent to the head part to obtain the target recognition result.
[0016] Experiments have confirmed that after the above improvements, the network recognition model has a test R of 0.489 and a map50 of 0.413 on the validation set. The main indicators are higher than the original yolov5s network and yolov8s network, meeting the real-time and accuracy requirements of target recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 Yolov5s network structure
[0018] Figure 2 Convolutional layer structure
[0019] Figure 3 C3 layer structure
[0020] Figure 4 (a) (b) BottleNeck structures in the backbone network and C3 layer respectively
[0021] Figure 5 SPPF layer structure
[0022] Figure 6 Network structure of the present invention
[0023] Figure 7 This design proposes the BottleNeck structure in the C3_AKconv layer of the network
[0024] Figure 8 AKConv layer structure
[0025] Fig. 9 Dysample and Upsample structures
[0026] Fig.10 Sampling point generator structure in the Upsample layer
[0027] Fig.11 Sampling point generator structure in the Upsample layer DETAILED DESCRIPTION
[0028] The purpose of the present invention is to provide a vehicle tracking method based on a neural network, which can improve the tracking accuracy of a single target. In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. The present invention is mainly divided into two parts, namely vehicle identification and tracking. The vehicle identification part improves the network structure of yolov5s and improves the accuracy of identification. At the same time, a vehicle tracking method is invented, which tracks by judging the position of the vehicle, and can meet the requirements of real-time performance and accuracy at the same time.
[0029] 1. Vehicle identification procedure
[0030] The neural network proposed in this invention is based on the mainstream target detection network Yolov5s network. The specific structure is as follows: Figure 1 The entire network consists of three parts: the backbone network, the neck network, and the detection head. The backbone network is mainly used to extract features from the input image, the neck network is used to fuse feature maps, and the detection head is used to perform detection. The backbone network is introduced first. The vehicle image is input and preprocessed to integrate the vehicle image into a three-channel image of size 640×640. It first passes through a convolution layer with a convolution kernel of 6×6, a stride of 2, and a padding of 2 (such as Figure 1 The internal structure of the convolutional layer is as follows: Figure 2 , which consists of a two-dimensional convolution module, a batch normalization module (Batch Normalization) and an activation function module. The batch normalization module is used to normalize the input of the subsequent activation function so that the batch presents a standard normal distribution. After batch normalization, the Sigmoid Gated Linear Unit is used as the activation function to make the model converge faster. This convolution layer can convert the image into a 64-channel image with a size of 320×320. After that, it passes through a convolution layer with a convolution kernel of 3×3 and a stride of 2 (such as Figure 1 The first layer of the convolutional layer reduces the length and width of the feature image by half, and the size is 160×160. In the backbone network, the length and width of the image will be reduced by half after passing through the 1st, 3rd, 5th, and 7th convolutional layers. After that, it passes through a composite layer called the C3 layer ( Figure 1 The second layer of Figure 3 In the C3 layer, the input passes through a convolutional layer with a kernel of 1, 1 and a stride of 1 to obtain an output. The input passes through a convolutional layer with a kernel of 1×1 and a stride of 1 and a BottleNeck layer to obtain an output. These two outputs are feature fused ( Figure 3 The final output of the C3 layer is obtained through a convolutional layer. In the backbone network, the BottleNeck layer structure is as follows: Figure 4 (a). The main function of the C3 layer is to extract features from different dimensions and fuse them, without changing the image size. The image is then repeated three times through the above-mentioned layers 1 and 2, with the same parameters ( Figure 1 The feature map sizes of the 4th, 6th, and 8th layers are 80×80, 40×40, and 20×20, respectively. Then, a fast spatial pyramid pooling layer (Spatial Pyramid PoolingFast) is used. Figure 1 The 9th layer in ), the fast spatial pyramid pooling layer structure is as follows Figure 5 , first through a convolutional layer with a kernel of 1×1 and a stride of 1, then through three 5×5 maximum pooling layers, the results of the three maximum pooling layers are fused, and then through a convolutional layer with a kernel of 1×1 and a stride of 1. The main function of SPPF is to fuse features of different scales. This is the end of the backbone network part.
[0031] from Figure 1 The 10th to 23rd layers are the neck of the network. The output of the 9th layer is input to the 10th layer of the backbone network. The 10th layer is a convolution layer with a convolution kernel of 1×1 and a step size of 1. It further extracts features, but the size of the feature map remains unchanged at 20×20. It is then passed to the 11th layer, and the output of the 10th layer is upsampled by a sampling factor of 2. The upsampling layer doubles the length and width of the image, and the feature map size is 40×40. In the 12th layer, the output of the 6th layer (size 40×40) is fused with the output of the 11th layer. The 13th layer is also a C3 layer, and its internal structure is as follows: Figure 3 , but in the neck network, the BottleNeck structure inside the C3 layer is as follows Figure 4(b). The 14th layer is a convolutional layer with a convolution kernel of 1×1 and a stride of 1. The 15th layer is an upsampling layer similar to the 11th layer, which enlarges the feature map size to 80×80. The 16th layer fuses the output of the 4th layer (with a feature map size of 80×80) with the output of the 15th layer. The 17th layer is a C3 layer. From the 10th to the 17th layer, the length and width of the feature map are enlarged by four times, so that the information of the small feature map is also retained in the large feature map of the 17th layer, so that the semantic information of the image is retained. After that, the 18th layer is a convolution layer with a convolution kernel of 3×3 and a stride of 2, which reduces the length and width of the feature map by half to 40×40. The 19th layer is a feature fusion layer, which fuses the output of the 14th layer with the output of the 18th layer. The 20th layer is a C3 layer with the same parameters as the 13th layer. The 21st layer is a convolution layer with a convolution kernel of 3×3 and a stride of 2, which reduces the length and width of the feature map by half again to 20×20. The 22nd layer is a feature fusion layer, which fuses the output of the 10th layer with the output of the 21st layer. The 23rd layer is a C3 layer with the same parameters as the 20th layer. The 18th to 23rd layers are a process of gradually reducing and superimposing large-size feature maps, which can retain the detailed information of the image. After a neck network, the feature maps of each size are fused, and the final feature maps of each size are obtained, that is, Figure 1 The outputs of the 17th, 20th and 23rd layers of Figure 1 The head part of the target is used to obtain the result of target recognition.
[0032] The network structure proposed in this design also consists of three parts: backbone network, neck network and detection head. Figure 6 The backbone network is mainly used to extract features from the input image, the neck network is used to fuse the feature map, and the detection head is used to detect. The backbone network is introduced first. The vehicle image is input and preprocessed to integrate the vehicle image into a three-channel image of size 640×640. It first passes through a convolution layer with a convolution kernel of 6×6, a stride of 2, and a padding of 2 (such as Figure 6 The internal structure of the convolutional layer is as follows: Figure 2 , which consists of a two-dimensional convolution module, a batch normalization module (BatchNormalization) and an activation function module. The batch normalization module is used to normalize the input of the subsequent activation function so that the batch presents a standard normal distribution. After batch normalization, the Sigmoid Gated Linear Unit is used as the activation function to make the model converge faster. This convolution layer can convert the image into a 64-channel image with a size of 320×320. After that, it passes through a convolution layer with a convolution kernel of 3×3 and a stride of 2 (such as Figure 6The first layer of ), which reduces the length and width of the feature image by half, to a size of 160×160, and then passes through a composite layer called C3_AKConv ( Figure 6 The second layer of Figure 3 In the C3_AKConv layer, the input passes through a convolutional layer with a kernel of 1×1 and a stride of 1, where an output is obtained. The input passes through a convolutional layer with a kernel of 1×1 and a stride of 1 and a BottleNeck layer, where an output is obtained. The two outputs are feature fused ( Figure 3 The final output of the C3_AKConv layer is obtained after passing through a convolution layer. In the backbone network, the BottleNeck layer structure is as follows: Figure 7 , the convolutional layer inside the BottleNeck layer is changed to the AKConv layer. The main function of the C3_AKConv layer is to extract features from different dimensions and fuse them, without changing the image size. After that, the image is repeated twice through the first and second layers mentioned above, with the same parameters ( Figure 6 The feature map sizes of the 4th and 6th layers are 80×80 and 40×40 respectively. In the 7th layer, the image passes through an AKConv layer with a convolution kernel of 3×3 and a stride of 2. In the backbone network, the length and width of the image are reduced by half after passing through the 1st, 3rd, 5th, and 7th layers. Then, it passes through a C3_AKConv ( Figure 6 8th layer). Then it passes through a fast spatial pyramid pooling layer (Spatial Pyramid Pooling Fast) ( Figure 6 The 9th layer in ), the fast spatial pyramid pooling layer structure is as follows Figure 5 , first through a convolutional layer with a kernel of 1×1 and a stride of 1, then through three 5×5 maximum pooling layers, the results of the three maximum pooling layers are fused, and then through a convolutional layer with a kernel of 1×1 and a stride of 1. The main function of SPPF is to fuse features of different scales. This is the end of the backbone network part.
[0033] from Figure 6 The 10th to 23rd layers are the neck of the network. The output of the 9th layer is input to the 10th layer of the backbone network. The 10th layer is a convolution layer with a convolution kernel of 1×1 and a step size of 1. It further extracts features, but the size of the feature map remains unchanged at 20×20. It is then passed to the 11th layer, and the output of the 10th layer is dynamically sampled with a sampling multiple of 2. The dynamic sampling layer doubles the length and width of the image, and the feature map size is 40×40. In the 12th layer, the output of the 6th layer (size 40×40) is combined with the output of the 11th layer for feature fusion. The 13th layer is also a C3 layer, and its internal structure is as follows: Figure 3 , but in the neck network, the BottleNeck structure inside the C3 layer is as follows Figure 4 (b). The 14th layer is a convolutional layer with a convolution kernel of 1×1 and a stride of 1. The 15th layer is a dynamic sampling layer similar to the 11th layer, which enlarges the feature map size to 80×80. The 16th layer fuses the output of the 4th layer (with a feature map size of 80×80) with the output of the 15th layer. The 17th layer is a C3 layer. From the 10th layer to the 17th layer, the length and width of the feature map are enlarged by four times, so that the information of the small feature map is also retained in the large feature map of the 17th layer, so that the semantic information of the image is retained. After that, the 18th layer is a convolution layer with a convolution kernel of 3×3 and a stride of 2, which reduces the length and width of the feature map by half to 40×40. The 19th layer is a feature fusion layer, which fuses the output of the 14th layer with the output of the 18th layer. The 20th layer is a C3 layer with the same parameters as the 13th layer. The 21st layer is a convolution layer with a convolution kernel of 3×3 and a stride of 2, which further reduces the length and width of the feature map by half to 20×20. The 22nd layer is a feature fusion layer, which fuses the output of the 10th layer with the output of the 21st layer. The 23rd layer is a C3 layer with the same parameters as the 20th layer. The 18th to 23rd layers are a process of gradually reducing and superimposing large-size feature maps, which can retain the detailed information of the image. After a neck network, the feature maps of each size are fused, and the final feature maps of each size are obtained, that is, Figure 6 The outputs of the 17th, 20th and 23rd layers of Figure 6 The head part of the target is used to obtain the result of target recognition.
[0034] There are two main improvements in the network structure of this design. The first is to replace the original convolutional layer or some convolutional modules in the C3 layer with variable kernel convolution (AlterableKernel Convolution, AKConv) in the backbone network. The variable kernel convolution is mainly variable in the shape and size of the convolution kernel. Since the convolution module in the original neural network uses a square with a fixed size of m×m as the convolution kernel, in actual applications, the shape of the target is not always a square, so the square convolution kernel of a certain size may not be suitable for various target situations. Therefore, it is considered to replace the original convolution module with AKConv to improve the adaptability of this design to vehicle targets of different shapes and improve the recognition accuracy.
[0035] The AKConv layer structure diagram is as attached in the manual. Figure 8 , which has a structure similar to Figure 2 The convolutional layer structure of the proposed method improves the two-dimensional convolution module inside the convolutional layer, and the subsequent batch normalization and activation function remain unchanged.
[0036] First, the input image is convolved in two dimensions to obtain a learnable offset. The offset is the coordinates of the feature map minus the coordinates of the square convolution kernel. The shape of the sample is adjusted by the value of each position in the offset coordinates. The offset coordinates are added to the original coordinates to obtain the modified coordinates, so that the shape of the convolution kernel formed by the modified coordinates is more like the shape of the target, which solves the problem of the fixed shape of the convolution kernel. Then the modified coordinates are resampled to obtain the features at the corresponding positions, which solves the problem of the fixed sampling shape. In this way, the convolution operation can be performed according to the modified coordinates during the subsequent convolution. Then the features are reshaped and convolved again to achieve the effect of convolution with the most suitable convolution kernel. Therefore, the AKConv layer can perfectly complete the irregular convolution feature extraction process. The AKConv layer completes the feature extraction process through irregular convolution, and can flexibly adjust the sample shape according to the offset, bringing more options for the convolution sampling shape.
[0037] Specifically, in terms of network structure, the 2nd, 4th, 6th, and 8th layers (original C3 layers) in yolov5s are changed to C3-AKConv layers. Specifically, the convolutional layers in BottleNeck inside the C3 layer are changed to AKConv layers. The convolutional layer of the 7th layer in the original model is changed to AKConv layer.
[0038] The second improvement is to use a dynamic upsampler (DySample) layer at the neck of the network to replace the original upsampler layer to improve recognition accuracy. Specifically, in terms of network structure, the original Upsample sampling layers at layers 11 and 15 are replaced with Dysample dynamic upsample layers, with no change in parameters and the sampling multiple remaining at 2.
[0039] Upsample's flowchart is as follows Fig. 9 , the input feature X is passed through a sampling point generator to obtain a sampling set S, and the sampling set S and the input feature X are sampled by points to obtain the upsampled feature X′.
[0040] First, let’s introduce point sampling. If the input is a C×H 1 ×W 1 The feature X, and the size of the sampling set S is 2×H 2 ×W 2 , point sampling means resampling X to a size of C×H by the location of S 2 ×W 2 X′
[0041] This process is defined as formula (1)
[0042] X′=grid_sample(X,S) (1)
[0043] In Dysample and Upsample, the point sampling part is the same, the main difference is the sampling point generator structure. The sampling point generator structure of Upsample is as follows Fig.10 .
[0044] The Upsample sampling point generator is mainly based on a given C×H 1 ×W 1 Features Figure X and sampling multiple k, with input and output channels C and 2k respectively 2 A linear layer of size 2k 2 ×H 1 ×W 1 The offset O 1 , and then reshape the offset to size 2×kH through pixel transformation 1 ×kW 1 , then reshape the offset O 1 With size 2×kH 1 ×kW 1 The original sampling grid G is added to obtain the sampling set S 1 .
[0045] This process is defined as (2) and (3)
[0046] O 1 = linear(X) (2)
[0047] S 1 =G+O 1 (3)
[0048] Due to the existence of the normalization layer, the output feature value is usually in the range of [-1, 1], centered at 0, so the local k 2 The range of sampling positions may overlap. To alleviate this problem, the offset O 1 Multiplying by a factor of 0.25 satisfies the theoretical marginal condition between overlap and non-overlap. This factor is called the "static range factor" and constrains the range of the sampling position locally. However, it was found that multiplying by a factor of 0.25 does not completely solve the problem, because this explicit constraint of multiplying by a factor limits the expressive power of the model. In order to increase the offset O 1 To increase the flexibility, we further generate a point-wise “dynamic range factor” by linearly projecting the input features. By using the sigmoid function and a static factor of 0.5, the result can be obtained within the dynamic range of [0, 0.5]. As shown in formula (4):
[0049] O 2 =0.5×sigmod(linear(X))×linear(X) (4)
[0050] Dysample's sampling point generator structure, such as Fig.11 , given C×H 1 ×W 1 Features Figure X and sampling multiple k, with input and output channels C and 2k respectively 2 The linear layer of size 2k is generated by formula (4). 2 ×H 1 ×W 1 The offset O 2 , and then reshape the offset to size 2×kH through pixel transformation 1 ×kW 1 , then reshape the offset O 2 With size 2×kH 1 ×kW 1 The original sampling grid G is added to obtain the sampling set S 2 As shown in formula (5)
[0051] S 2 =G+O 2 (5)
[0052] The collected vehicle dataset is used in network training, and the training set, test set and validation set are allocated in a 6:2:2 ratio. The training set data contains approximately 10,800 images. The model file size generated by training is 10,467 kB, and the original yolov5s model file size is 11,134 kB. The initial learning rate during training is set to 0.0001, and 100 rounds of training are performed.
[0053] 2. Vehicle tracking program
[0054] The main tracking methods are as follows
[0055] The improved network is used to identify the vehicle in the first frame of the video stream. Assume that n vehicle targets are identified, which are denoted as x 0 to x n , the probability of each target being judged as a car is p 0 to p n , find the vehicle target with the highest probability, mark it as the tracking target, recorded as target, as shown in formula (6), frame the tracking target, and record the position of the vehicle tracking target.
[0056]
[0057] Identify all vehicle targets x in a new frame 0 to x n, compare each target with the tracking target position of the previous frame. If the distance between the target position and the tracking target position determined in the previous frame does not exceed the threshold, this design sets the threshold to 5 pixels, which can be adjusted according to the speed of the target to be tracked. The faster the target moves, the larger the threshold should be set, as shown in formula (7)
[0058] |target,x i | <threshold(i=0,1,…n) (7)
[0059] The target is considered to be the tracking target of the previous frame, and the tracking target is framed, and the position of the vehicle tracking target is recorded to achieve tracking. If the position of all targets is too far away from the tracking target of the previous frame, it is judged that the target has disappeared, and the vehicle target with the highest probability among all targets is determined as the new tracking target, as shown in formula (8)
[0060]
[0061] Track the target and record the position of the target.
Claims
1. A vehicle tracking method, Features: The proposed network structure consists of three parts: backbone network, neck network and detection head. The backbone network extracts features from the input image, the neck network performs feature fusion on the feature map, and the detection head performs detection. First, the backbone network is introduced. The vehicle image is input and integrated into a three-channel image of size 640×640 through preprocessing. It first passes through a convolution layer with a convolution kernel of 6×6, a stride of 2, and a padding of 2. This is the 0th layer. The internal structure of the convolution layer consists of a two-dimensional convolution module, a batch normalization module, and an activation function module. The Sigmoid Gated Linear Unit is used as the activation function. This convolution layer converts the image into a 64-channel image of size 320×320. After that, it passes through a convolution layer with a convolution kernel of 3×3 and a stride of 2, which reduces the length and width of the feature image by half, to a size of 160×160. After layer 0, the 1st, 3rd, and 5th layers are convolutional layers, and the 7th layer is an AKConv layer. After layers 1, 3, 5, and 7, there is a composite layer called C3_AKConv; that is, layers 2, 4, 6, and 8 are composite layers of C3_AKConv. In the backbone network, the length and width of the image will be reduced by half after the 1st, 3rd, 5th, and 7th convolution layers. After each convolution layer, a composite layer called C3_AKConv is passed. Inside the C3_AKConv layer, the input passes through a convolution layer with a kernel of 1×1 and a stride of 1, where an output is obtained. The input passes through a convolution layer with a kernel of 1×1 and a stride of 1 and a BottleNeck layer, and an output is also obtained. The two outputs are feature fused, i.e., Concat, and then pass through another convolution layer to obtain the final output of the C3_AKConv layer. In the backbone network, the convolution layer inside the BottleNeck layer is the AKConv layer. The feature map sizes of the 4th and 6th layers are 80×80 and 40×40 respectively; in the 7th layer, the image passes through an AKConv layer with a convolution kernel of 3×3 and a stride of 2; then passes through a C3_AKConv layer that is the same as the 2nd layer, that is, the 8th layer; then passes through a fast spatial pyramid pooling layer SPPF, that is, the 9th layer. The structure of the fast spatial pyramid pooling layer SPPF is: passing through a convolution layer with a kernel of 1×1 and a stride of 1, and then passing through three 5×5 maximum pooling layers. After the results of the three maximum pooling layers are feature fused, they pass through a convolution layer with a kernel of 1×1 and a stride of 1 to end the backbone network part; The network is divided into two layers, the 10th layer and the 23rd layer. The output of the 9th layer is input to the 10th layer of the backbone network. The 10th layer is a convolution layer with a convolution kernel of 1×1 and a step size of 1. It extracts features, but the size of the feature map remains unchanged at 20×20. It is then passed to the 11th layer, and the output of the 10th layer is dynamically sampled with a sampling multiple of 2. The dynamic sampling layer doubles the length and width of the image, and the feature map size is 40×40. In the 12th layer, the output of the 6th layer with a size of 40×40 is fused with the output of the 11th layer. The 13th layer is a C3 layer. The 14th layer is a convolution layer with a convolution kernel of 1×1 and a step size of 1. The 15th layer is a dynamic sampling layer, which enlarges the size of the feature map to 80×80. The 16th layer enlarges the output of the 4th layer, i.e., the size The 17th layer is a C3 layer. From the 10th layer to the 17th layer, the length and width of the feature map are enlarged four times. Then the 18th layer is a convolution layer with a convolution kernel of 3×3 and a stride of 2, which reduces the length and width of the feature map by half to 40×40. The 19th layer is a feature fusion layer, which fuses the output of the 14th layer with the output of the 18th layer. The 20th layer is a C3 layer with the same parameters as the 13th layer. The 21st layer is a convolution layer with a convolution kernel of 3×3 and a stride of 2, which reduces the length and width of the feature map by half again to 20×20. The 22nd layer is a feature fusion layer, which fuses the output of the 10th layer with the output of the 21st layer. The 23rd layer is a C3 layer with the same parameters as the 20th layer. After passing through a neck network, the feature maps of each size are fused, and the final feature maps of each size are obtained, that is, the outputs of the 17th, 20th and 23rd layers; these three outputs are sent to the head part to obtain the target recognition result.
2. The method according to claim 1, It is characterized in that AKCon v The layers are as follows: First, the input image is convolved in two dimensions to obtain a learnable offset. The offset is the coordinate of the feature map minus the coordinate of the square convolution kernel. The shape of the sample is adjusted by the value of each position in the offset coordinate. The offset coordinate is added to the original coordinate to obtain the modified coordinate. The modified coordinate is then resampled to obtain the features at the corresponding position. The features are then reconstructed and convolved again. A dynamic upsampler layer is used to replace the original upsampler layer at the neck of the network. In terms of network structure, the original Upsample sampling layers at layers 11 and 15 are replaced with Dysample dynamic upsampler layers, and the sampling multiple is still 2. Upsample process: Input feature X is passed through a sampling point generator to obtain a sampling set S, and the sampling set S and input feature X are sampled by points to obtain the upsampled feature X′; First, let’s introduce point sampling. If the input is a C×H 1 ×W 1 The feature X, and the size of the sampling set S is 2×H 2 ×W 2 , point sampling means resampling X to a size of C×H by the location of S 2 ×W 2 X′ This process is defined as formula (1) X′=grid_sample(X,S) (1) Upsample sampling point generator is given C×H 1 ×W 1 The feature map X and sampling multiple k are C and 2k respectively, with input and output channels 2 A linear layer of size 2k 2 ×H 1 ×W 1 The offset O 1 , and then reshape the offset to size 2×kH through pixel transformation 1 ×kW 1 , then reshape the offset O 1 With size 2×kH 1 ×kW 1 The original sampling grid G is added to obtain the sampling set S 1 ; This process is defined as (2) and (3) O 1 =linear(X) (2) S 1 =G+O 1 (3) Due to the existence of the normalization layer, the output feature value is in the range of [-1, 1], centered at 0, so the local k 2 The range of sampling positions may overlap. To alleviate this problem, the offset O 1 Multiply by the sigmoid function and the static factor 0.5 to obtain the result in the dynamic range of [0,0.5]; as shown in formula (4) O 2 =0.5×sigmod(linear(X))×linear(X) (4) Dysample's sampling point generator structure, given C×H 1 ×W 1 The feature map X and sampling multiple k are C and 2k respectively, with input and output channels 2 The linear layer of size 2k is generated by formula (4). 2 ×H 1 ×W 1 The offset O 2 , and then reshape the offset to size 2×kH through pixel transformation 1 ×kW 1 , then reshape the offset O2 to a size of 2×kH 1 ×kW 1 The original sampling grid G is added to obtain the sampling set S 2 ; As formula (5) S 2 =G+O 2 (5)。 3. The method according to claim 1, Features: The vehicle in the first frame of the video stream is identified by the network of claim 1. Assume that n vehicle targets are identified and are denoted as x 0 to x n , the probability of each target being judged as a car is p 0 to p n , find the vehicle target with the highest probability, mark it as the tracking target, denoted as target, as shown in formula (6), track the tracking target, and record the position of the vehicle tracking target; Identify all vehicle targets x in a new frame 0 to x n , compare each target with the tracking target position of the previous frame. If the distance between the target position and the tracking target position determined in the previous frame does not exceed the threshold, the threshold is set to 5 pixels, as shown in formula (7) |target,x i |<threshold,where i=0,1,...n (7) The target is considered to be the tracking target of the previous frame, and the position of the tracking target is recorded to achieve tracking; if the position of all targets is too far away from the tracking target of the previous frame, it is judged that the target has disappeared, and the vehicle target with the highest probability among all targets is determined as the new tracking target, as shown in formula (8) p target =max p i , where i = 0, 1, ... n (8) Track the target and record the position of the target.
Citation Information
Patent Citations
Unmanned aerial vehicle multi-target vehicle tracking method based on deep learning
CN114612776A
Vehicle target detection and identification method based on attention mechanism and dynamic convolution
CN118015595A
Domestic garbage sorting method and system based on deep learning
CN118279663A
Cited By
Method for detecting and identifying small targets and irregular targets in expressway scene
CN122416384A
Method for detecting and identifying small and irregular targets in highway scenes
CN122416384B
Multi-scale target feature enhancement method based on frequency domain-space domain cooperation
CN122454218A
