Vehicle target detection method based on YOLOv7
By improving YOLOv7's network structure and feature extraction module, the problem of traditional object detection algorithm insufficient detection capabilities for small objects in complex traffic scenarios is solved, and higher detection accuracy and speed are achieved.
Patent Information
- Application Number
- CN202411378761.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-01-07
AI Technical Summary
Traditional object detection algorithms are difficult to accurately detect small objects in complex traffic scenarios, especially in the case of low resolution, blurred background and small amount of feature information, resulting in slow detection speed and poor accuracy.
Improve the backbone network structure of YOLOv7, use PConv to replace the convolutional layer, reduce the size of the receptive field module, add the ECA attention mechanism, replace the detection scale and loss function, and improve the model's detection ability of small targets.
It improves the accuracy and speed of vehicle target detection, enhances the detection effect of small targets, and improves the overall performance and computing efficiency of the model.
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical field:
[0001] The present invention belongs to the technical field of autonomous driving, and in particular relates to a vehicle target detection method based on improved YOLOv7. Background technology:
[0002] With the rapid development of economy and society, autonomous driving technology has attracted extensive attention and in-depth research from the government and the business community. It has the ability to enable vehicles to autonomously complete operations such as driving, steering and parking without human intervention. Relying on cutting-edge sensor technology, artificial intelligence algorithms and big data analysis, it can accurately perceive the environment, identify traffic signs, locate vehicles, detect pedestrians and obstacles, and realize intelligent navigation and decision-making. With the continuous development of autonomous driving technology, vehicle recognition plays a vital role in intelligent transportation systems. Accurately identifying surrounding vehicles is of great significance for realizing intelligent driving, improving traffic safety and optimizing traffic flow. However, due to the influence of factors such as complex traffic scenes, changes in lighting and changes in perspective, traditional target detection algorithms often find it difficult to achieve ideal results.
[0003] Traditional target detection often has problems such as slow detection speed and poor detection accuracy. With the development of deep learning, researchers have proposed more improved algorithms, among which the YOLO series of algorithms have attracted much attention due to their simple structure and fast calculation speed. However, if the distance is too far or the background is complex, the size of the vehicle may be too small, which will make the detection algorithm have higher requirements for small target processing capabilities. Traditional detection algorithms may not be able to effectively detect these due to insufficient resolution or unclear features. In order to solve the above problems, this paper proposes a vehicle target recognition method based on YOLOv7, especially for scenes with small targets, low resolution, blurred background and a small amount of feature information. This method effectively responds to the challenges of vehicle target recognition in autonomous driving scenarios and improves the detection performance and accuracy of the algorithm. Summary of the invention:
[0004] In view of the problems existing in the prior art, the present invention provides a road vehicle target detection method based on YOLOv7, which mainly includes the following steps:
[0005] Step 1: Select and download the data set required for target detection, expand and divide the data set according to the needs, and enhance the image to obtain a data set suitable for the research object;
[0006] Step 2: Improve the backbone network structure of YOLOv7 and use PConv to replace the convolution of the Backbone part of YOLOv7 to reduce the redundant calculation amount of the algorithm;
[0007] Step 3: Improve the feature extraction module, reduce the size of the receptive field module, increase the model speed and enhance the ability to extract image feature information;
[0008] Step 4: Add the ECA attention mechanism to enhance the model’s feature extraction capabilities.
[0009] Step 5: Improve the feature output stage, replace the detection scale, increase the shallow feature extraction capability, and improve the detection effect of small targets.
[0010] Step 6: Design a loss function to speed up model convergence.
[0011] Beneficial effects of this invention:
[0012] The invention proposes a vehicle target detection method based on YOLOv7, which improves the detection accuracy, recognition speed and detection effect of small targets by replacing part of the convolution in the backbone structure, improving the feature extraction module, changing the detection scale and replacing the loss function. Description of the drawings:
[0013] Figure 1 Improved YOLOv7 network structure diagram;
[0014] Figure 2 ELAN-PC network structure diagram;
[0015] Figure 3 SPPFCSPC module structure diagram; Specific implementation method:
[0016] The following embodiments of the present invention are further described in detail in conjunction with the accompanying drawings and examples. The following examples are only used to more clearly illustrate the technical solutions of the present invention, and cannot be used to limit the protection scope of the present invention.
[0017] The present invention proposes a vehicle target detection method based on YOLOv7, which includes the following steps:
[0018] Step 1: Select and download the data set required for target detection, expand and divide the data set according to the needs, and enhance the image to obtain a data set suitable for the research object;
[0019] Step 2: Improve the backbone network structure of YOLOv7 and use PConv to replace the convolution of the Backbone part of YOLOv7 to reduce the redundant calculation amount of the algorithm;
[0020] Step 3: Improve the feature extraction module, reduce the size of the receptive field module, increase the model speed and enhance the ability to extract image feature information;
[0021] Step 4: Add the ECA attention mechanism to enhance the model’s feature extraction capabilities;
[0022] Step 5: Improve the feature output stage, replace the detection scale, increase the shallow feature extraction capability, and improve the detection effect of small targets;
[0023] Step 6: Design a loss function to speed up model convergence.
[0024] Furthermore, the step 1 is specifically as follows:
[0025] Select the required images from multiple data sets, summarize and organize them into a new data set, label the new data set by category, obtain a complex data set suitable for research, preprocess the data set, including data enhancement, image scaling, normalization and other operations, and obtain the required training set, test set, and validation set;
[0026] Furthermore, the step 2 is specifically as follows:
[0027] Replacing some convolutional layers in Backbone with PConv (a special convolutional layer) improves the model's recognition performance when detecting missing or irregular objects. The core principle of PConv is to use partial convolution to process occluded images, perform effective reasoning in occluded areas, and retain key information. Therefore, PConv performs particularly well in scenarios with missing or irregular objects. Replacing some convolutions in the first two ELANs in Backbone with PConv gives us a new module ELAN-PC. Figure 2 As shown;
[0028] Furthermore, the step 3 is specifically as follows:
[0029] Improve the feature extraction module and build the SPPCSPC module. The SPPCSPC module in the previous YOLOv7 introduced the CSP structure, which increased the model calculation parameters and slowed down the calculation speed. In most cases, the network will introduce a fully connected layer between or after the SPP and CSP modules to more effectively capture global features. This approach helps the network better integrate information of different scales, thereby improving the richness of feature expression. However, due to the large number of parameters and computational overhead of the fully connected layer, the three pooling kernels of the three maximum pooling layers with sizes of 5, 9, and 13 are replaced with three pooling kernels of all 5, which not only makes the pooling size consistent, but also improves the calculation speed;
[0030] Furthermore, the step 4 is specifically as follows:
[0031] The feature map output by the backbone module is first sent to the ECA module. The ECA module is an efficient channel attention mechanism that aims to improve network performance while reducing computational complexity. The ECA module introduces cross-channel interactions to achieve a simpler and more efficient design. The core idea of the ECA module is to achieve attention allocation between channels in a lighter way without introducing additional fully connected layers.
[0032] The module first performs global average pooling on the input feature map, compressing the features of each channel into a globally described scalar to obtain a feature vector of size C, where C is the number of channels in the feature map. A 1D convolution operation is used to capture cross-channel dependencies. The kernel size K of this 1D convolution is adaptively determined based on the number of channels C, rather than a fixed hyperparameter. Usually K is calculated according to the following formula: K = [log2(C) + 1]
[0033] Finally, through sigmoid activation and channel reweighting, by introducing the ECA module, the convolutional neural network can focus on key features more effectively, significantly improving the feature extraction ability and overall performance of the model.
[0034] Furthermore, the step 5 is specifically as follows:
[0035] Improve the network structure of the feature output layer. The scales of the three feature layers finally output by YOLOv7 are 20*20, 40*40, and 80*80 respectively. 20*20 is replaced by 160*160 to improve the detection effect of small targets.
[0036] Furthermore, the step 6 is specifically as follows:
[0037] Replace the loss function to speed up the model convergence. The loss function is used to optimize the accuracy of the target detection task, which includes three parts: positioning loss, classification loss, and confidence loss. The CIOU loss function used in the original positioning loss is changed to the EIOU loss function;
[0038] Compared with the original function, the EIOU loss function pays more attention to the angle of the target frame and has advantages in adapting to different shapes and sizes of targets, thereby improving accuracy, reducing errors, and improving training stability:
[0039] Its definition formula is:
[0040]
[0041] The above embodiments are only used to explain the present invention and are intended to help readers understand the principles of the present invention rather than to limit the present invention. Readers may make various modifications or improvements to the present invention based on relevant knowledge in this field. Without violating the spirit and principles of the present invention, all modifications should be included in the scope of the claims of the present invention.
Claims
1. A vehicle target detection method based on YOLOv7 in a complex autonomous driving environment, the method comprising the following steps: Step 1: Select and download the data set required for target detection, and expand and divide the data set according to the needs to obtain a data set suitable for the research object; Step 2: Improve the backbone network structure of YOLOv7 and use PConv to replace the convolution of the Backbone part of YOLOv7 to reduce the redundant calculation amount of the algorithm; Step 3: Improve the feature extraction module, reduce the size of the receptive field module, increase the model speed and enhance the ability to extract image feature information; Step 4: Add the ECA attention mechanism to enhance the model’s feature extraction capabilities; Step 5: Improve the feature output stage, replace the detection scale, increase the shallow feature extraction capability, and improve the detection effect of small targets; Step 6: Design a loss function to speed up model convergence.
2. A vehicle target detection method of YOLOv7 according to claim 1, characterized in that, The specific step 1 is: (1) Select the required images from multiple data sets and organize them into a new data set; (2) Label the new dataset by category to obtain a complex dataset suitable for research; (3) Preprocess the data set, including data enhancement, image scaling, normalization, etc., to obtain the required training set, test set, and validation set.
3. A vehicle target detection method of YOLOv7 according to claim 1, characterized in that, The specific step 2 is: (1) Replace some convolutional layers in Backbone with PConv (a special convolutional layer) to improve the model's recognition performance when detecting missing or irregular objects. The core principle of PConv is to process images with occlusions through partial convolution, which can effectively reason in the occluded areas while retaining key information. This makes PConv perform particularly well in scenarios where images are missing or have irregular objects; (2) Only some input channels are convolved, while other channels remain unchanged. This operation can avoid computational redundancy between different channels while fully utilizing the computing power of the device.
4. A vehicle target detection method of YOLOv7 according to claim 1, characterized in that, The specific step 3 is: (1) Since CSP is introduced into the SPPCSPC module structure in the YOLOv7 network, the number of model parameters and the amount of calculation increase, resulting in a slower model speed. Therefore, the SPPFCSPC module is constructed to replace the SPPCSPC module in the original network; (2) The SPPFCSPC module first adjusts the number of channels and extracts features from the input features through three CBS modules, and then sequentially passes through three maximum pooling layers of different scales to obtain features of different receptive fields. By combining these receptive fields of different scales, richer image feature information can be obtained, so that each convolution output covers a wider range of feature information, thereby improving the model's perception and feature expression capabilities.
5. A vehicle target detection method of YOLOv7 according to claim 1, characterized in that, The specific step 4 is: (1) The feature map output by the backbone module is first sent to the ECA module. The ECA module is an efficient channel attention mechanism that aims to improve network performance while reducing computational complexity. The ECA module introduces cross-channel interactions and achieves a more concise and efficient design. The core idea of the ECA module is to achieve attention allocation between channels in a lighter way without introducing additional fully connected layers; (2) The module first performs global average pooling on the input feature map to compress the features of each channel into a scalar describing the whole world, and obtains a feature vector of size C, where C is the number of channels in the feature map. A 1D convolution operation is used to capture cross-channel dependencies. The kernel size K of this 1D convolution is adaptively determined based on the number of channels C, rather than a fixed hyperparameter. Usually K is calculated according to the following formula: K = [log2(C) + 1] (3) Finally, the convolution output is normalized by the sigmoid activation function to obtain the attention weight of each channel, and the calculated weight is applied to each channel of the input feature map to achieve channel recalibration. By introducing the ECA module, the convolutional neural network can focus on key features more effectively, significantly improving the feature extraction capability and overall performance of the model.
6. A vehicle target detection method of YOLOv7 according to claim 1, characterized in that, The specific step 5 is: YOLOv7 finally outputs three feature layers of different scales, of which 20*20 is responsible for large target detection and 80*80 is responsible for small target detection. The 20*20 feature layer is removed and a 160*160 small target detection layer is added to extract richer shallow features.
7. A vehicle target detection method of YOLOv7 according to claim 1, characterized in that, The specific step 6 is: (1) The EIOU loss function is used instead of the original CIOU loss function. By minimizing the difference in height and width between the predicted box and the true box, it not only speeds up the convergence of the model but also improves the positioning accuracy. (2) The EIOU loss function consists of three parts: IOU loss, distance loss, and position loss. This not only retains the advantages of the CIOU loss function, but also further reduces the difference in width and height between the target box and the anchor box, thereby optimizing the regression effect and improving the convergence speed and positioning accuracy. The formula is as follows:
Citation Information
Cited By
Sea surface enteromorpha detection method and system based on deep learning
CN120564034A