A traffic target detection method and system based on improved YOLOv8n

By improving the YOLOv8n model, combining StarDR_C2f, SPPF-LSKA, lightweight detection head and PSA structural block, the accuracy and efficiency of target detection in complex traffic scenarios are solved, and efficient traffic target detection in harsh environments is achieved.

CN118552929BActive Publication Date: 2024-11-26NANCHANG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411021431.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-29
Publication Date
2024-11-26
Estimated Expiration
2044-07-29

AI Technical Summary

Technical Problem

The existing traffic target detection algorithms have problems such as missed target detection, insufficient accuracy and insufficient robustness in complex traffic scenarios, especially in harsh environments, which are difficult to adapt to changeable conditions and meet real-time response needs.

Method used

By improving the YOLOv8n model, replacing the C2f structure block with StarDR_C2f and the SPPF structure block with SPPF-LSKA, lightweight detection head processing is performed, and lightweight downsampling SCDown and part self-attention PSA structure block are added, the model is optimized to improve detection accuracy and efficiency.

Benefits of technology

It improves the accuracy and efficiency of traffic target detection, can effectively detect small-scale targets and reduces calculation and inference delays, and enhances the performance and robustness of the model in complex scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118552929B_ABST
    Figure CN118552929B_ABST
Patent Text Reader

Abstract

The invention discloses a traffic target detection method and system based on improved YOLOv8n, and relates to the technical field of automatic driving and assisted driving. The method comprises: obtaining an initial driving video image, dividing it into a training image and a test image; improving the existing YOLOv8n model to obtain an improved YOLOv8n model, wherein the improvement comprises: replacing C2f in the YOLOv8n model with StarDR_C2f, replacing SPPF in the YOLOv8n model with SPPF‑LSKA with large-core strip convolution, performing lightweight processing on the classification head in the YOLOv8n model, adding lightweight downsampling SCDown in the YOLOv8n model, and adding partial self-attention PSA in the YOLOv8n model; iteratively optimizing and training the improved YOLOv8n model using the training image to obtain a traffic target detection model of the improved YOLOv8n; inputting the test image into the traffic target detection model of the improved YOLOv8n for detection, and outputting a traffic target detection result. The method can improve the accuracy and efficiency of traffic target detection in the technical field of automatic driving and assisted driving.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of autonomous driving and assisted driving technology, and in particular to a traffic target detection method and system based on improved YOLOv8n. Background Art

[0002] In the automotive industry, autonomous driving and assisted driving technologies are seen as the key to alleviating or even solving traditional traffic problems. Accurate detection of various road targets in a traffic environment is the basis and key step in completing autonomous driving tasks. Only by accurately identifying and understanding the surrounding environment can autonomous vehicles make correct decisions and ensure driving safety.

[0003] In the current research on deep learning target detection, the design of network frameworks can be divided into two categories. The first category is a two-stage detector based on candidate boxes, of which FasterR-CNN is a typical representative; the second category is a single target detector based on regression calculation, such as SSD and YOLO. Two-stage detectors usually have advantages in accuracy, but the processing speed is relatively slow; while single-stage detectors, although they perform well in speed, are often less accurate than two-stage models. Considering the strict real-time requirements of traffic target detection, more efficient single-stage detectors are preferred. However, in order to compensate for the lack of accuracy of single-stage detectors, these models need to be further optimized. The related art discloses the introduction of a selective kernel attention module SK, which adaptively selects and fuses feature information extracted from branches with different receptive fields, improves the network's attention to important features, and introduces a new SPD-Conv module to replace each stride convolution and pooling layer to improve the model accuracy in low-resolution and small target detection.

[0004] Although vision-based object detection algorithms are developing rapidly and have achieved remarkable results in road object detection in general traffic scenarios, there are still many challenges in more complex traffic scenarios. For example, in dense traffic, multiple targets may block each other, or there may be some smaller targets, which may lead to missed detection of targets and affect detection accuracy. Especially in harsh environments, such as at night or in low light conditions, the quality of photos taken is often low, and some areas may become blurred due to insufficient light, which further increases the difficulty of object detection. When target instances overlap with each other, the features extracted from the image may not be sufficient to support effective detection and classification, resulting in failure to successfully identify the target object. In addition, many existing algorithms are not robust enough in practical applications, and it is difficult to adapt to changing environments and meet the needs of real-time response. These problems need to be solved urgently.

[0005] Therefore, how to improve the accuracy and efficiency of target detection has become an important issue that needs to be urgently addressed in the current field of autonomous driving and assisted driving technology. Summary of the invention

[0006] Based on this, this application proposes a traffic target detection method and system based on improved YOLOv8n, aiming to improve the accuracy and efficiency of traffic target detection in the field of autonomous driving and assisted driving technology.

[0007] A first aspect of the present application provides a traffic target detection method based on improved YOLOv8n, comprising obtaining an initial driving video image, dividing it into a training image and a test image, and the method further comprising:

[0008] The existing YOLOv8n model is improved to obtain an improved YOLOv8n model, wherein the improvements include:

[0009] Replace the C2f structure block in the existing YOLOv8n model with the StarDR_C2f structure block to extract feature information of different scales.

[0010] The SPPF structure block in the existing YOLOv8n model is replaced by the SPPF-LSKA structure block with large kernel strip convolution.

[0011] The detection head in the existing YOLOv8n model is lightweighted to obtain a lightweight detection head.

[0012] A lightweight downsampling SCDown structure block is added to the existing YOLOv8n model to reduce the spatial dimension of feature information.

[0013] And add some self-attention PSA building blocks to the YOLOv8n model;

[0014] Using the training images to iteratively optimize the improved YOLOv8n model, to obtain an improved YOLOv8n traffic target detection model;

[0015] The image to be tested is input into the improved YOLOv8n traffic target detection model for detection, and the traffic target detection result is output.

[0016] Compared with the prior art, the present application provides a traffic target detection method based on improved YOLOv8n, which is implemented by an improved YOLOv8n model, wherein the improved YOLOv8n model includes: StarDR_C2f effectively combines large-core convolution and small-core convolution, wherein small-core convolution helps to capture small-scale features, and large-core convolution can enhance the model's ability to capture sparse features and improve the model's receptive field, and StarDR_C2f integrates the mechanisms of dilated convolution, reparameterization, and multiplication operations, which speeds up the inference speed and improves the ability of small models to capture image features, while also reducing the amount of parameters and calculations brought by large-core convolution The increase of the model; the introduction of strip-shaped large-kernel convolution through the SPPF-LSKA structural block can enable the model to better perceive global features, improve the receptive field, and reduce the increase in parameters and calculations caused by large-kernel convolution; through the classification head in the lightweight detection head, lower model parameters, calculations and reasoning delays are achieved without affecting the accuracy of the model; the lightweight downsampling SCDown structural block can maximize the retention of information while reducing the number of model parameters and calculations, thereby maintaining high performance while reducing delays; the PSA module strengthens the model's global representation learning ability at a lower computational cost, avoiding the excessive overhead caused by the secondary computational complexity of self-attention. Therefore, the improved YOLOv8n model proposed in this application can detect small-scale targets and reduce the calculation amount and reasoning delay of target detection. The traffic target detection model based on the improved YOLOv8n model can improve the accuracy and efficiency of traffic target detection in the field of autonomous driving and assisted driving technology.

[0017] As an optional implementation of the first aspect, replacing the C2f structure block in the YOLOv8n model with the StarDR_C2f structure block includes replacing the Bottleneck block in the C2f block with the StarDR block;

[0018] When inputting the feature map to the StarDR block, it first passes through a DRB layer, and then passes through a convolution layer with a convolution kernel of 1 to expand the number of channels to n times the original number of channels; then it passes through two branches, one branch is not processed, and the other branch passes through a ReLU activation function, and then the results of the two branches are multiplied, and then passes through a convolution layer with a convolution kernel of 1 to reduce the number of channels to n times the original number of channels, and finally passes through a DRB layer to obtain the output result of the StarDR block;

[0019] The DRB layer includes a large-core convolution layer with a convolution kernel of 9 and a dilation rate of 1, which is used to capture sparse features, and four small-core convolution layers with convolution kernel sizes of 5, 3, 3, and 3 and dilation rates of 1, 2, 3, and 4, which are used to capture small-scale features. A BN layer is provided after each convolution layer to form five branches, and the outputs of the five branches are spliced.

[0020] As an optional implementation manner of the first aspect, the image processing process of the SPPF-LSKA structure block with large kernel strip convolution includes:

[0021] After the SPPF block performs feature concatenation, an LSKA block with a convolution kernel of 11 is connected to obtain the SPPF-LSKA block. When the feature map is input to the SPPF-LSKA block, it first passes through a convolution layer with a convolution kernel of 1 to obtain the feature map. Figure 1 , and then go through three maximum pooling layers to get the features Figure 2 ,feature Figure 3 and Features Figure 4 , the feature Figure 1 ,feature Figure 2 ,feature Figure 3 ,feature Figure 4 After splicing, the LSKA structure block is input, and finally a convolution layer with a convolution kernel of 1 is passed to obtain the output result of the SPPF-LSKA structure block.

[0022] As an optional implementation of the first aspect, the lightweight detection head includes a classification head. The lightweight detection head is lightweighted by the lightweight classification head. When the feature map is input to the lightweight classification head, it first passes through two depth-separable convolution layers with a convolution kernel of 3, and then passes through a convolution layer with a convolution kernel of 1, and finally outputs the output result of the lightweight classification head.

[0023] As an optional implementation of the first aspect, the image processing process of the lightweight downsampling SCDown structure block includes:

[0024] The lightweight downsampling SCDown structure block is connected after the StarDR_C2f structure block. When the feature map is input to the lightweight downsampling SCDown structure block, the channel dimension is increased through point-by-point convolution, and then the space is reduced through depth-wise convolution. The operations of increasing the channel dimension and reducing the space are decoupled to achieve lightweight downsampling.

[0025] As an optional implementation of the first aspect, the image processing process of the partial self-attention PSA building block includes:

[0026] When the feature map is input to the partial self-attention PSA structure block, it passes through a convolution layer with a convolution kernel of 1, and then is divided into two parts. One part is fed to the block composed of the multi-head self-attention mechanism layer and the feedforward network layer, and is spliced ​​with the other part. Then, it passes through a convolution layer with a convolution kernel of 1 to obtain the output result of the partial self-attention PSA structure block.

[0027] As an optional implementation of the first aspect, the improvement also includes: setting four StarDR_C2f structure blocks in sequence in the backbone network of the YOLOv8n model, setting three branches after the second, third and fourth StarDR_C2f structure blocks, the first and second branches are connected to the LSKA structure block with large kernel strip convolution, and the third branch is connected to the SPPF-LSKA structure block.

[0028] A second aspect of an embodiment of the present application provides a traffic target detection system based on an improved YOLOv8n, including an image acquisition module for acquiring an initial driving video image, which is divided into a training image and a test image. The system also includes:

[0029] The model improvement module is used to improve the existing YOLOv8n model to obtain an improved YOLOv8n model. The model improvement module includes a first module replacement unit, a second module replacement unit, a first lightweight processing unit, a second lightweight processing module and an attention mechanism unit, wherein:

[0030] The first module replacement unit is used to replace the C2f structure block in the existing YOLOv8n model with the StarDR_C2f structure block to extract feature information of different size scales;

[0031] The second module replacement unit is used to replace the SPPF structure block in the existing YOLOv8n model with the SPPF-LSKA structure block with large kernel strip convolution;

[0032] A first lightweight processing unit, used for performing lightweight processing on the detection head in the existing YOLOv8n model to obtain a lightweight detection head;

[0033] The second lightweight processing unit is used to add a lightweight downsampling SCDown structure block to the existing YOLOv8n model to reduce the spatial dimension of feature information;

[0034] Attention mechanism unit, used to add some self-attention PSA building blocks to the YOLOv8n model;

[0035] A model training module, used to perform iterative optimization training on the improved YOLOv8n model using the training image to obtain an improved YOLOv8n traffic target detection model;

[0036] The target detection module is used to input the image to be tested into the improved YOLOv8n traffic target detection model for detection and output the traffic target detection result.

[0037] A third aspect of an embodiment of the present application provides a computer device, comprising a memory, a processor, and a processing program stored in the memory and executable on the processor, wherein the processing program, when executed by the processor, implements the above-mentioned traffic target detection method based on improved YOLOv8n.

[0038] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, on which a processing program is stored. When the processing program is executed by a processor, the above-mentioned traffic target detection method based on improved YOLOv8n is executed.

[0039] Additional aspects and advantages of the present application will be given in part in the following description, and in part will become apparent from the following description, or will be understood through the embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 A flow chart of a traffic target detection method based on improved YOLOv8n proposed in the first embodiment of the present application;

[0041] Figure 2 A structural diagram of a traffic target detection model of an improved YOLOv8n proposed in the first embodiment of the present application;

[0042] Figure 3 A structural diagram of the StarDR_C2f structural block proposed in the first embodiment of the present application;

[0043] Figure 4 A structural diagram of the StarDR block proposed in the first embodiment of the present application;

[0044] Figure 5 This is a structural diagram of the DRB layer proposed in the first embodiment of the present application;

[0045] Figure 6 This is a structural diagram of the SPPF-LSKA structural block proposed in the first embodiment of the present application;

[0046] Figure 7 This is a structural diagram of a lightweight detection head proposed in the first embodiment of the present application;

[0047] Figure 8 This is a structural diagram of the SCDown structural block proposed in the first embodiment of the present application;

[0048] Fig. 9The partial self-attention PSA structural block proposed in the first embodiment of the present application;

[0049] Fig.10 This is a structural diagram of a traffic target detection system based on improved YOLOv8n proposed in the second embodiment of the present application.

[0050] The following specific implementation methods will further illustrate the present application in conjunction with the above-mentioned drawings. DETAILED DESCRIPTION

[0051] In order to facilitate understanding of the present application, the present application will be described more fully below with reference to the relevant drawings. Several embodiments of the present application are provided in the drawings. However, the present application can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present application more thorough and comprehensive.

[0052] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.

[0053] In order to illustrate the technical solution described in this application, a specific embodiment is provided below for illustration.

[0054] See also Figure 1 , is a flow chart of a traffic target detection method based on improved YOLOv8n proposed in the first embodiment of the present application, Figure 2 A traffic target detection model structure diagram of an improved YOLOv8n proposed in the first embodiment of the present application, the proposed method includes:

[0055] S01: Obtain an initial driving video image and divide it into a training image and a test image.

[0056] For example, images are selected from a public driving video dataset to ensure that a variety of scenes, weather conditions, and time periods are covered. Next, the format of the label file is converted to convert the original dataset format into a YOLO format annotation file to meet the needs of subsequent training and test verification. Based on a 7:1 ratio, the image dataset is divided into a training image set and a test image set to ensure that the data distribution between the two is reasonable.

[0057] In terms of weather, the dataset covers six conditions: sunny, cloudy, overcast, rainy, snowy, and foggy, which helps the model adapt to different weather conditions. In terms of scenes, the dataset covers six common scenes, including residential areas, highways, city streets, parking lots, gas stations, and tunnels, which enhances the generalization ability of the model in practical applications. In terms of time, the dataset covers three time periods: dawn / dusk, daytime, and nighttime, with daytime and nighttime as the main focus, further increasing the diversity of the dataset.

[0058] In order to obtain a more accurate and efficient training image set, the training image set was cleaned and repeated annotation boxes were removed. The image set to be tested does not require additional processing and can be used directly as a validation set.

[0059] In the process of optimizing the training image set, a variety of image enhancement techniques are used to expand the diversity and richness of the data. First, the mosaic enhancement method is used, which involves randomly selecting four images from the dataset and performing independent data augmentation operations on each image, and then splicing the four images into one, which effectively increases the complexity and diversity of the dataset. In addition, the image mixing technique is used, which achieves data enhancement by randomly selecting two sample images and mixing them in a certain proportion, and the classification results are also distributed according to the corresponding proportion. The copy and paste strategy is another effective data augmentation method. Two images are randomly selected for augmentation processing, and the target subset of one of the images is randomly selected and pasted to a random position of the other image to simulate object occlusion and overlap in actual scenes. In addition to the above methods, the random flipping technique is also implemented, which randomly flips the image horizontally or vertically to simulate image changes at different angles. The random scaling technique can randomly adjust the size of the image, either shrinking or enlarging it, to simulate objects of different scales. In terms of color processing, random color transformation was introduced. This method randomly adjusts the values ​​of the three channels h (color), s (saturation), and v (brightness) in the HSV color space to simulate images under different lighting conditions and color changes. Finally, random affine transformation technology was used, which involves a linear transformation and translation operation, including rotation, translation, scaling, and shearing. These operations can simulate multiple transformations of objects in three-dimensional space, further enhancing the complexity and generalization ability of the data set.

[0060] S02: Improve the existing YOLOv8n model to obtain an improved YOLOv8n model.

[0061] Specifically, the S02 includes S021, S022, S023, S024 and S025, wherein:

[0062] S021: Replace the C2f block in the existing YOLOv8n model with the StarDR_C2f block to extract feature information of different scales;

[0063] It should be noted that the StarDR_C2f module is an improved version of C2f in YOLOv8n, which uses the StarDR block to replace the Bottleneck block in C2f. That is, replacing the C2f structure block in the YOLOv8n model with the StarDR_C2f structure block includes using the StarDR block to replace the Bottleneck block in the C2f block. For details, please refer to Figure 3 , is the structure diagram of StarDR_C2f structure block;

[0064] For details, see Figure 4 , which is the structural diagram of the StarDR block. In the StarDR block: when the feature map is input to the StarDR block, it first passes through a DRB layer, and then passes through a convolution layer with a convolution kernel of 1 to expand the number of channels to n times the original number of channels; then it passes through two branches, one branch is not processed, and the other branch passes through a ReLU activation function, and then the results of the two branches are multiplied, and then passes through a convolution layer with a convolution kernel of 1 to reduce the number of channels to n times the original number of channels, and finally passes through a DRB layer to obtain the output result of the StarDR block;

[0065] Furthermore, in the DRB layer: During training, a large kernel convolution can be used in combination with a parallel small kernel convolution, because the latter helps capture small-scale features, and their outputs are added after two corresponding BN layers. After training, the BN layer is merged into the convolution layer using structural reparameterization, so that the small kernel convolution is equivalently merged into the large kernel convolution during inference. However, in addition to small-scale features, enhancing the ability of large kernel convolution to capture sparse features may produce higher quality features (i.e., a pixel on the feature map may be more closely related to some of its distant pixels than to its neighboring pixels). The need to capture this pattern fits the mechanism of dilated convolution. The DRB layer uses a dilated convolution layer in parallel with the large kernel convolution, and then adds their outputs. Its hyperparameters include the size of the large convolution kernel K, the size of the parallel convolution layer k, and the dilation rate r.

[0066] Specifically, see Figure 5 , is the structural diagram of the DRB layer, including a large-core convolution layer with a convolution kernel of 9 and a dilation rate of 1, which is used to capture sparse features, and four small-core convolution layers with convolution kernel sizes of 5, 3, 3, and 3 and dilation rates of 1, 2, 3, and 4, which are used to capture small-scale features. A BN layer is set after each convolution layer to form five branches, and the outputs of the five branches are spliced.

[0067] It is worth noting that the above is the structure of the DRB layer during model training. During model inference, the DRB layer will be reparameterized into a convolutional layer with a convolution kernel size of 9 and a dilation rate of 1 to speed up the inference speed.

[0068] S022: Replace the SPPF block in the existing YOLOv8n model with the SPPF-LSKA block with large kernel strip convolution;

[0069] It should be noted that the SPPF-LSKA building block is an improved version of SPPF. Figure 6 , which is the structural diagram of the SPPF-LSKA structural block.

[0070] Specifically, the image processing process of the SPPF-LSKA structure block with large kernel strip convolution includes:

[0071] After the SPPF block performs feature concatenation, an LSKA block with a convolution kernel of 11 is connected to obtain the SPPF-LSKA block. When the feature map is input to the SPPF-LSKA block, it first passes through a convolution layer with a convolution kernel of 1 to obtain the feature map. Figure 1 , and then go through three maximum pooling layers to get the features Figure 2 ,feature Figure 3 and Features Figure 4 , the feature Figure 1 ,feature Figure 2 ,feature Figure 3 ,feature Figure 4 After splicing, the LSKA structure block is input, and finally a convolution layer with a convolution kernel of 1 is passed to obtain the output result of the SPPF-LSKA structure block.

[0072] Furthermore, the LSKA block is composed of a depth-wise separable convolution with a convolution kernel size of 1*(2r-1), a depth-wise separable convolution with a convolution kernel size of (2r-1)*1, a depth-wise separable dilated convolution with a convolution kernel size of 1*(k / r), a depth-wise separable dilated convolution with a convolution kernel size of (k / r)*1, and a CBS block with a convolution kernel size of 1. The LSKA block includes two branches, one of which inputs the feature maps into the above-mentioned SPPF-LSKA block in sequence, and then multiplies the output with the other branch that does not perform any processing and outputs it.

[0073] S023: Lightweight the detection head in the existing YOLOv8n model to obtain a lightweight detection head;

[0074] It should be noted that in the YOLO algorithm family, the classification head and regression head usually use the same architecture. However, they show obvious differences in computational overhead. For example, in YOLOv8s, the FLOPs and parameters of the classification head are 2.5 times and 2.4 times that of the regression head, respectively. Some studies have pointed out that the regression head has a greater impact on the performance of the YOLO algorithm. Therefore, the overhead of the classification head can be reduced without worrying that the performance will be greatly affected.

[0075] The lightweight classification head consists of two depth-wise separable convolutions with a convolution kernel of 3 and a convolution layer with a convolution kernel of 1. Compared with the classification head in YOLOv8s (which consists of two CBS structural blocks with a convolution kernel of 3 and a convolution layer with a convolution kernel of 1), the lightweight classification head achieves lower model parameters and inference latency.

[0076] See also Figure 7 , is a structural diagram of a lightweight detection head. The lightweight detection head includes a classification head. The lightweight detection head is lightweighted by the lightweight classification head. When the feature map is input to the lightweight classification head, it first passes through two depth-separable convolution layers with a convolution kernel of 3, and then passes through a convolution layer with a convolution kernel of 1, and finally outputs the output result of the lightweight classification head.

[0077] S024: Add a lightweight downsampling SCDown structure block to the existing YOLOv8n model to reduce the spatial dimension of feature information;

[0078] For details, see Figure 8 , which is the structural diagram of the SCDown structural block. The lightweight downsampling SCDown structural block is connected after the StarDR_C2f structural block. When the feature map is input to the lightweight downsampling SCDown structural block, the channel dimension is increased through point-by-point convolution, and then the space is reduced through depth convolution. The operations of increasing the channel dimension and reducing the space are decoupled to achieve lightweight downsampling.

[0079] It should be noted that the YOLO algorithm usually uses standard convolution with a step size s of 2 and a convolution kernel of 3, while achieving spatial downsampling (from H*W to H / 2*W / 2) and channel transformation (from C to 2C), where H represents the height of the convolution kernel, W represents the width of the convolution kernel, and C represents the number of channels, that is, the number of input feature maps. This introduces considerable computational cost and parameter volume. The lightweight downsampling SCDown structural block decouples spatial downsampling and channel addition operations to achieve more efficient downsampling. Specifically, point-by-point convolution is first used to adjust the channel dimension, and then depth-wise convolution is used for spatial downsampling. At the same time, it retains information to the maximum extent during the downsampling process, thereby maintaining high performance while reducing latency.

[0080] S025: Add some self-attention PSA building blocks to the YOLOv8n model.

[0081] Understandably, attention has been widely used in various visual tasks due to its excellent global modeling ability. However, it exhibits high computational complexity and memory usage, and the partial self-attention (PSA) building block is an efficient and low-redundancy self-attention block.

[0082] For details, see Fig. 9 , is a partial self-attention PSA structural block. When the feature map is input to the partial self-attention PSA structural block, it passes through a convolution layer with a convolution kernel of 1 and is then divided into two parts. One part is fed to a block composed of a multi-head self-attention mechanism layer and a feedforward network layer, and is concatenated with the other part. Then, the output result of the partial self-attention PSA structural block is obtained through a convolution layer with a convolution kernel of 1.

[0083] In addition, the partial self-attention PSA block is only placed after the 4th stage with the lowest resolution (after the SPPF_LSKA block), avoiding the excessive overhead caused by the quadratic computational complexity of self-attention. In this way, the global representation learning capability can be integrated into the YOLO algorithm at a lower computational cost, which greatly enhances the model's capabilities and improves performance.

[0084] Based on the above-mentioned improvements, the improved method may also include: four StarDR_C2f structural blocks are sequentially set in the backbone network of the YOLOv8n model, and three branches are set after the second, third, and fourth StarDR_C2f structural blocks. The third branch is followed by the SPPF-LSKA structural block. Since the large kernel convolution brings a larger effective receptive field, the model can obtain better global features and improve the model performance; the first and second branches are followed by the LSKA structural block with large kernel strip convolution to further perceive the global feature map and improve the receptive field.

[0085] S03: Using the training image to iteratively optimize the improved YOLOv8n model to obtain an improved YOLOv8n traffic target detection model.

[0086] S04: Input the image to be tested into the improved YOLOv8n traffic target detection model for detection, and output the traffic target detection result.

[0087] In summary, the present application provides a traffic target detection method based on improved YOLOv8n, which is implemented by an improved YOLOv8n model, wherein the improved YOLOv8n model includes: StarDR_C2f effectively combines large-core convolution and small-core convolution, wherein small-core convolution helps to capture small-scale features, and large-core convolution can enhance the model's ability to capture sparse features and improve the model's receptive field, and StarDR_C2f integrates the mechanisms of dilated convolution, reparameterization, and multiplication operations, which speeds up the inference speed and improves the ability of small models to capture image features, while also reducing the amount of parameters and computational complexity brought by large-core convolution. The SPPF-LSKA structure block introduces strip-shaped large-kernel convolution, which enables the model to better perceive global features, improve the receptive field, and reduce the increase in parameters and calculations caused by large-kernel convolution; the classification head in the lightweight detection head achieves lower model parameters, calculations and reasoning delays without affecting the model accuracy; the lightweight downsampling SCDown structure block reduces the model parameters and calculations while retaining information to the maximum extent, thereby maintaining high performance while reducing delays; the PSA module strengthens the model's global representation learning ability at a lower computational cost, avoiding the excessive overhead caused by the secondary computational complexity of self-attention. Therefore, the improved YOLOv8n model proposed in this application can detect small-scale targets and reduce the calculation amount and reasoning delay of target detection. The traffic target detection model based on the improved YOLOv8n model can improve the accuracy and efficiency of traffic target detection in the field of autonomous driving and assisted driving technology.

[0088] See also Fig.10 , which is a schematic diagram of the structure of a traffic target detection system based on improved YOLOv8n proposed in the second embodiment of the present application, and the system includes:

[0089] An image acquisition module 10 is used to acquire an initial driving video image, which is divided into a training image and a test image;

[0090] The model improvement module 20 is used to improve the existing YOLOv8n model to obtain an improved YOLOv8n model. The model improvement module includes a first module replacement unit 201, a second module replacement unit 202, a first lightweight processing unit 203, a second lightweight processing unit 204 and an attention mechanism unit 205, wherein:

[0091] A first module replacement unit 201 is used to replace the C2f structure block in the existing YOLOv8n model with the StarDR_C2f structure block to extract feature information of different sizes;

[0092] A second module replacement unit 202 is used to replace the SPPF structure block in the existing YOLOv8n model with an SPPF-LSKA structure block with large kernel strip convolution;

[0093] A first lightweight processing unit 203 is used to perform lightweight processing on the detection head in the existing YOLOv8n model to obtain a lightweight detection head;

[0094] A second lightweight processing unit 204 is used to add a lightweight downsampling SCDown structure block to the existing YOLOv8n model to reduce the spatial dimension of feature information;

[0095] An attention mechanism unit 205, used to add some self-attention PSA building blocks to the YOLOv8n model;

[0096] A model training module 30 is used to perform iterative optimization training on the improved YOLOv8n model using the training image to obtain an improved YOLOv8n traffic target detection model;

[0097] The target detection module 40 is used to input the image to be tested into the improved YOLOv8n traffic target detection model for detection and output the traffic target detection result.

[0098] On the other hand, the present application also proposes a computer device, which includes a memory, a processor, and a processing program stored in the memory and executable on the processor, wherein the processing program implements the above-mentioned traffic target detection method based on improved YOLOv8n when executed by the processor.

[0099] On the other hand, the present application further proposes a computer-readable storage medium, on which a processing program is stored. When the processing program is executed by a processor, the above-mentioned traffic target detection method based on improved YOLOv8n is executed.

[0100] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0101] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A traffic target detection method based on improved YOLOv8n, comprising obtaining an initial driving video image, dividing it into a training image and a test image, characterized in that: The method further comprises: The existing YOLOv8n model is improved to obtain an improved YOLOv8n model, wherein the improvements include: Replace the C2f structure block in the existing YOLOv8n model with the StarDR_C2f structure block to extract feature information of different scales, replace the SPPF structure block in the existing YOLOv8n model with the SPPF-LSKA structure block with large kernel strip convolution, lightweight the detection head in the existing YOLOv8n model to obtain a lightweight detection head, add a lightweight downsampling SCDown structure block to the existing YOLOv8n model to reduce the spatial dimension of feature information, and add a partial self-attention PSA structure block to the YOLOv8n model; The StarDR_C2f structure block includes two convolutional layers consisting of convolution with kernel size 1 and stride 1, batch normalization and SiLU activation function, a segmentation layer, n StarDR blocks and a concatenation layer; the StarDR block includes two DRB layers, two convolutional layers with kernel size 1 and stride 1, a ReLU activation function layer and a multiplication layer; the DRB layer includes a large kernel convolutional layer with kernel size 9 and dilation rate 1, four small kernel convolutional layers with kernel sizes of 5, 3, 3, 3 and dilation rates of 1, 2, 3, 4, five batch normalization BN layers and an addition layer; The SPPF-LSKA block of large kernel strip convolution includes two convolutional layers consisting of convolution with kernel size 1 and stride 1, batch normalization and SiLU activation function, three maximum pooling layers, one concatenation layer and one LSKA block; SCDown includes a convolution layer consisting of a convolution with a kernel size of 1 and a stride of 1, batch normalization, and a SiLU activation function, and a convolution layer consisting of a depthwise convolution with a kernel size of 3 and a stride of 2, batch normalization, and a SiLU activation function; PSA includes two convolutional layers consisting of convolution with kernel size 1 and stride 1, batch normalization and SiLU activation function, a segmentation layer, a multi-head self-attention module layer, a feedforward network layer, two addition layers, and a splicing layer; Using the training images to iteratively optimize the improved YOLOv8n model, to obtain an improved YOLOv8n traffic target detection model; The image to be tested is input into the improved YOLOv8n traffic target detection model for detection, and the traffic target detection result is output.

2. A traffic target detection method based on improved YOLOv8n according to claim 1, characterized in that: Replacing the C2f structure block in the YOLOv8n model with the StarDR_C2f structure block includes replacing the Bottleneck block in the C2f block with the StarDR block; When inputting the feature map to the StarDR block, it first passes through a DRB layer, and then passes through a convolution layer with a convolution kernel of 1 to expand the number of channels to n times the original number of channels; then it passes through two branches, one branch is not processed, and the other branch passes through a ReLU activation function, and then the results of the two branches are multiplied, and then passes through a convolution layer with a convolution kernel of 1 to reduce the number of channels to n times the original number of channels, and finally passes through a DRB layer to obtain the output result of the StarDR block; The DRB layer includes a large-core convolution layer with a convolution kernel of 9 and a dilation rate of 1, which is used to capture sparse features, and four small-core convolution layers with convolution kernel sizes of 5, 3, 3, and 3 and dilation rates of 1, 2, 3, and 4, which are used to capture small-scale features. A BN layer is provided after each convolution layer to form five branches, and the outputs of the five branches are spliced.

3. A traffic target detection method based on improved YOLOv8n according to claim 1, characterized in that: The image processing process of the SPPF-LSKA structure block with large kernel strip convolution includes: After the SPPF structure block performs feature splicing, an LSKA structure block with a convolution kernel of 11 is connected to obtain the SPPF-LSKA structure block; when the feature map is input to the SPPF-LSKA structure block, it first passes through a convolution layer with a convolution kernel of 1 to obtain feature map one, and then passes through three maximum pooling layers in sequence to obtain feature map two, feature map three and feature map four. Feature map one, feature map two, feature map three and feature map four are spliced ​​and input into the LSKA structure block, and finally pass through a convolution layer with a convolution kernel of 1 to obtain the output result of the SPPF-LSKA structure block.

4. A traffic target detection method based on improved YOLOv8n according to claim 1, characterized in that: The lightweight detection head includes a classification head. The lightweight detection head is lightweighted by the lightweight classification head. When the feature map is input to the lightweight classification head, it first passes through two depth-separable convolution layers with a convolution kernel of 3, then passes through a convolution layer with a convolution kernel of 1, and finally outputs the output result of the lightweight classification head.

5. A traffic target detection method based on improved YOLOv8n according to claim 1, characterized in that: The image processing process of the lightweight downsampling SCDown structure block includes: The lightweight downsampling SCDown structure block is connected after the StarDR_C2f structure block. When the feature map is input to the lightweight downsampling SCDown structure block, the channel dimension is increased through point-by-point convolution, and then the space is reduced through depth-wise convolution. The operations of increasing the channel dimension and reducing the space are decoupled to achieve lightweight downsampling.

6. A traffic target detection method based on improved YOLOv8n according to claim 1, characterized in that: The image processing process of the partial self-attention PSA building block includes: When the feature map is input to the partial self-attention PSA structure block, it passes through a convolution layer with a convolution kernel of 1, and then is divided into two parts. One part is fed to the block composed of the multi-head self-attention mechanism layer and the feedforward network layer, and is spliced ​​with the other part. Then, it passes through a convolution layer with a convolution kernel of 1 to obtain the output result of the partial self-attention PSA structure block.

7. A traffic target detection method based on improved YOLOv8n according to claim 1, characterized in that: The improvement also includes: setting four StarDR_C2f structure blocks in sequence in the backbone network of the YOLOv8n model, setting three branches after the second, third and fourth StarDR_C2f structure blocks, the first and second branches are connected to the LSKA structure block with large kernel strip convolution, and the third branch is connected to the SPPF-LSKA structure block.

8. A traffic target detection system based on improved YOLOv8n, comprising an image acquisition module for acquiring an initial driving video image, which is divided into a training image and a test image, characterized in that: The system further comprises: The model improvement module is used to improve the existing YOLOv8n model to obtain an improved YOLOv8n model. The model improvement module includes a first module replacement unit, a second module replacement unit, a first lightweight processing unit, a second lightweight processing module and an attention mechanism unit, wherein: The first module replacement unit is used to replace the C2f structure block in the existing YOLOv8n model with the StarDR_C2f structure block to extract feature information of different scales; wherein the StarDR_C2f structure block includes two convolution layers consisting of convolution with a kernel size of 1 and a step size of 1, batch normalization and SiLU activation function, a segmentation layer, n StarDR blocks and a splicing layer; wherein the StarDR block includes two DRB layers, two convolution layers with a kernel size of 1 and a step size of 1, a ReLU activation function layer and a multiplication layer; wherein the DRB layer includes a large kernel convolution layer with a convolution kernel of 9 and a dilation rate of 1, four small kernel convolution layers with convolution kernel sizes of 5, 3, 3, 3 and dilation rates of 1, 2, 3, 4, five batch normalization BN layers and an addition layer; The second module replacement unit is used to replace the SPPF structure block in the existing YOLOv8n model with an SPPF-LSKA structure block with large-core strip convolution; wherein the SPPF-LSKA structure block with large-core strip convolution includes two convolution layers consisting of convolution with a kernel size of 1 and a step size of 1, batch normalization, and SiLU activation function, three maximum pooling layers, a splicing layer, and an LSKA block; A first lightweight processing unit, used for performing lightweight processing on the detection head in the existing YOLOv8n model to obtain a lightweight detection head; The second lightweight processing unit is used to add a lightweight downsampling SCDown structure block to the existing YOLOv8n model to reduce the spatial dimension of feature information; wherein SCDown includes a convolution layer consisting of a convolution with a kernel size of 1 and a stride of 1, batch normalization, and a SiLU activation function, and a convolution layer consisting of a deep convolution with a kernel size of 3 and a stride of 2, batch normalization, and a SiLU activation function; Attention mechanism unit, used to add some self-attention PSA building blocks to the YOLOv8n model; PSA includes two convolutional layers consisting of convolution with kernel size 1 and stride 1, batch normalization and SiLU activation function, a segmentation layer, a multi-head self-attention module layer, a feedforward network layer, two addition layers, and a splicing layer; A model training module, used to perform iterative optimization training on the improved YOLOv8n model using the training image to obtain an improved YOLOv8n traffic target detection model; The target detection module is used to input the image to be tested into the improved YOLOv8n traffic target detection model for detection and output the traffic target detection result.

9. A computer device, characterized in that: The computer device includes a memory, a processor, and a processing program stored in the memory and executable on the processor. When the processing program is executed by the processor, a traffic target detection method based on improved YOLOv8n as described in any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a processing program, and when the processing program is executed by the processor, the traffic target detection method based on improved YOLOv8n as described in any one of claims 1 to 7 is implemented.