A Target Detection Method for Complex Road Scenes Improved Based on YOLOv7

By adding a small object detection layer, a K-means++ reclustering prior box, a WIoU loss function and CoordConv in YOLOv7, and combining the P-ELAN structure to lighten the backbone network, the problems of high error detection rate, background interference and slow speed of small object detection in complex road scenarios are solved, and the accuracy and speed of detection are improved, which is suitable for the perception of autonomous driving environments.

CN116844126BActive Publication Date: 2025-07-25TAIYUAN UNIVERSITY OF SCIENCE AND TECHNOLOGY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310888360.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-19
Publication Date
2025-07-25
Estimated Expiration
2043-07-19

AI Technical Summary

Technical Problem

The existing complex road scene object detection methods have problems such as high false detection and missed detection rates, serious background interference and slow detection speed in small target detection, which is difficult to meet the real-time and accuracy requirements of the autonomous driving system.

Method used

On the basis of YOLOv7, a small object detection layer was added, a K-means++ reclustering prior box was used, a WIoU loss function was used, a CoordConv was introduced, and a P-ELAN structure was proposed to lighten the backbone network, which improved the feature learning ability and positioning accuracy of small objects.

Benefits of technology

It effectively solves the detection problem of small targets in complex road scenarios, improves the accuracy and speed of detection, and achieves a balance between accuracy and speed, and is suitable for the perception of autonomous driving environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116844126B_ABST
    Figure CN116844126B_ABST
Patent Text Reader

Abstract

A method for object detection in complex road scenes improved based on YOLOv7 belongs to the technical fields of computer vision and environmental perception for autonomous driving, and solves the technical problems of insufficient accuracy and speed of current object detection methods in complex road scenes. The solution is as follows: adding a small object detection layer to increase the learning ability of small object features; using the K-means++ algorithm to re-cluster the prior boxes to optimize the size of the object prior boxes; introducing the WIoU loss function to replace the original CIoU loss function; adding coordinated coordinate convolution to the neck and head of the YOLOv7 model; and proposing the P-ELAN structure to lightweight the backbone network. Through the above technical solutions, the present invention effectively solves the problems such as dense occlusion, missed detection and misdetection of small-scale objects encountered in object detection in complex road scenes, improves the detection accuracy, and achieves the balance between accuracy and speed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of computer vision and environmental perception for autonomous driving, and particularly relates to a method for detecting targets in complex road scenes improved based on YOLOv7. Background Art

[0002] In the past few years, with the gradual development of computer technology and deep learning technology, road target detection technology has played an increasingly important role in fields such as autonomous driving and intelligent transportation systems. The main purpose of road target detection is to detect and identify various traffic signs, pedestrians, vehicles, and other obstacles in road images, so as to provide necessary information for autonomous driving and intelligent transportation systems. Therefore, accurately detecting and identifying these targets is crucial for ensuring the safety of vehicles and pedestrians and improving road traffic efficiency.

[0003] Currently, although object detection algorithms based on deep learning have achieved good results in object detection in complex road scenes, there are still some problems in detecting small targets in the scene:

[0004] 1. In terms of small target detection, the current algorithms still have a certain false detection rate and missed detection rate. This is because the sizes and shapes of small targets are diverse, and coupled with the interference of environmental factors, it is easy to cause false detection or missed detection;

[0005] 2. Background interference in complex road scenes is also a difficult problem. Since the background in road scenes is complex and changeable, it is easy for objects in the background to be misdetected as small targets;

[0006] 3. The detection speed of small targets in complex road scenes is also an issue that needs attention.

[0007] In summary, due to the high requirements for the real-time performance and accuracy of detection data in autonomous driving, the detection speed of the algorithm needs to be fast enough and the accuracy needs to be high enough so that the autonomous driving system can make decisions in a timely manner. Summary of the Invention

[0008] The main purpose of the present invention is to overcome the deficiencies in the prior art and solve the technical problems of insufficient accuracy and speed of the current method for detecting targets in complex road scenes. The present invention provides a method for detecting targets in complex road scenes improved based on YOLOv7.

[0009] The design concept of the present invention mainly includes the following aspects:

[0010] 1. Add a small target detection layer on the basis of YOLOv7 to enhance the feature learning ability for small targets;

[0011] 2. Use K-means++ to recluster the prior boxes, making the prior boxes more fitting to the targets and increasing the localization accuracy of the network for the targets.

[0012] 3. Adopt the WIoU loss function to increase the network's attention to the ordinary-quality anchor boxes and improve the network's localization ability for the targets.

[0013] 4. Introduce CoordConv in the neck and detection head to enable the network to better perceive the position information in the feature map.

[0014] 5. Propose the P-ELAN structure to lightweight the backbone network and reduce the algorithm's parameter quantity and computational complexity.

[0015] To achieve the above invention purpose, the technical solution adopted by the present invention is: A complex road scene target detection method improved based on YOLOv7, including the following steps:

[0016] Step 1: Obtain the complex road scene target images and construct a dataset, and divide the road target dataset into a training set, a validation set, and a test set. Among them, the annotation files in the training set, validation set, and test set are all in.txt format, and the content of the annotation files includes in sequence: the id number corresponding to the category, the coordinates (x, y) of the center point of the normalized target box, and the width w and height h of the normalized target box.

[0017] Step 2: Read the complex road scene target images obtained in Step 1, perform enhancement processing on the images, and align the enhanced images into pictures of the same size; after data enhancement, align the image size to 640*640 and input it into the feature extraction network.

[0018] Step 3: Use the K-Means++ clustering algorithm to analyze the sizes of the annotation boxes of the training samples and generate four groups of prior boxes with different sizes.

[0019] Step 4: Construct an improved YOLOv7 target detection network model. The improved YOLOv7 target detection network model includes a feature extraction network, a feature fusion network, and a multi-scale detection head, where:

[0020] The feature extraction network is a stack of CBS, P-ELAN, and MP modules, with a total of 32 times downsampling.

[0021] The feature fusion network is used to fuse multi-scale features. The feature fusion network consists of SPPCSPC module, ELANW module, CBS module, MP module, and CoordConv module to form a top-down FPN and a bottom-up PAN.

[0022] The multi-scale detection head: performs detections on the feature maps downsampled by 4 times, 8 times, 16 times, and 32 times respectively, obtaining four-scale detection heads. That is, the 20*20 detection layer is used to detect large targets, the 40*40 detection layer is used to detect larger targets, the 80*80 detection layer is used to detect smaller targets, and the 160*160 detection layer is used to detect small targets, thereby improving the network's positioning ability for small-sized targets in complex road scenes;

[0023] Step Five: Use the coordinate loss L loc , the object confidence loss L loc and the classification loss L cls to construct an overall loss function. The calculation formula of the overall loss function is:

[0024] Loss = λ1L cls + λ2L obj + λ3L loc ;

[0025] In the formula, λ1, λ2, and λ3 are all weight coefficients;

[0026] In the constructed loss function, the coordinate loss is the WIoU loss, and the object confidence loss and the classification loss adopt the binary cross-entropy loss with log (BCE With Logits Loss);

[0027] Step Six: First, send the dataset into the improved YOLOv7 object detection network model constructed in Step Four for training, and output the bounding box position, size, and object category of each object in the image; then, perform backpropagation through the loss function constructed in Step Five to update the weights, and iterate a predetermined number of rounds to obtain the model training weights for complex road object detection;

[0028] Step Seven: Send the image to be detected into the trained detection model to obtain the test results, and the detected results are framed by rectangular bounding boxes to complete the object detection in complex road scenes.

[0029] Furthermore, in Step Two, the image enhancement processing includes the following three aspects:

[0030] 1), Data enhancement uses HSV enhancement: adjusts the hue, saturation, and brightness of the image;

[0031] 2), Geometric transformation enhancement: includes random rotation, random translation, random scaling, and random flipping;

[0032] 3), Picture-level pixel enhancement: mosaic data enhancement or mixup data enhancement.

[0033] 3. A method for object detection in complex road scenes improved based on YOLOv7, characterized in that: step three includes the following steps: First, the total number of prior boxes is set to 12; then, the K-means++ clustering algorithm is used to perform clustering analysis on the object bounding boxes labeled in the dataset: The K-means++ algorithm first randomly selects a point as the first clustering center, and then selects other points as new clustering centers in the form of probability, so that the points farther away from the selected clustering centers have a higher probability of being selected. Repeat this process until all clustering centers are selected. This method enables the network to better detect small targets in complex road scenes and obtain prior boxes suitable for object detection in complex road scenes.

[0034] Further, in step four:

[0035] The P-ELAN module is composed of a common convolutional layer and a partial convolutional layer PConv. The partial convolutional layer makes the feature extraction network more lightweight, and the MP structure is used to increase the receptive field; among them, the partial convolutional layer performs conventional convolutional operations on some channels in the input feature map, and the remaining channels remain unchanged and perform Identity operations. The specific steps are as follows:

[0036] For a convolutional kernel of size k, the size of the input feature map is h×w, and the number of channels is c. If the size and number of channels of the input and output feature maps are the same, the computational complexity of the conventional convolution is: h×w×k 2 ×c 2 ; The computational complexity of PConv is: The ratio of the computational complexity of conventional convolution to PConv is: If Then the computational complexity of PConv is 1 / 16 of that of conventional convolution;

[0037] The memory access volume of conventional convolution is: h×w×2c + k 2 ×c 2 ≈h×w×2c; The memory access volume of PConv is: The ratio of the memory access volume of conventional convolution to PConv is: If Then the memory access volume of PConv is 1 / 4 of that of conventional convolution.

[0038] Further, in step four: The implementation method of the CoordConv module is completed by connecting two additional i and j channels to the input channels. If the coordinates layer connected to CoordConv and the weights of the convolution are not zero, the CoordConv module allows learning functions with a certain degree of translational dependence; if the coordinates layer connected to CoordConv and the weights of the convolution are zero, it simulates a conventional convolutional layer.

[0039] Furthermore, the WIoU loss includes three versions, namely WIoUv1, WIoUv2, and WIoUv3. The present invention uses the WIoUv3 version, which is optimized based on WIoUv1 and WIoUv2. The relevant formula for WIoUv1 is as follows:

[0040] L IoU = 1 - IoUL IoU ;

[0041] L WIoUv1 = R WIoU L IoU ;

[0042]

[0043] In the formula, R WIoU ∈[0, e) will significantly amplify L of ordinary anchor boxes IoU , L IoU ∈[0, 1] will significantly reduce R of high-quality anchor boxes WIoU , and significantly reduce their attention to the distance from the center point when the anchor box and the target box overlap well. W g , H g are the width and height of the minimum bounding rectangle respectively. * means separating W g , H g from the computational graph, and its role is to prevent R WIoU from generating gradients that hinder convergence;

[0044] WIoUv2 constructs a monotonic focusing coefficient based on WIoUv1 and its relevant formula is as follows:

[0045]

[0046] During the model training process, the gradient gain decreases as L IoU decreases. Therefore, the mean value of L IoU is introduced as a normalization factor:

[0047]

[0048] In the formula, is the average running value with momentum m, and dynamically updating the normalization factor makes the gradient gain remain at a relatively high level overall;

[0049] WIoUv3 introduces a dynamic non-monotonic focusing coefficient based on WIoUv2. Its relevant formula is as follows:

[0050]

[0051]

[0052] Wherein, β is the outlier, α and δ are hyperparameters for controlling the gradient gain r, α = 1.9, and δ = 3.

[0053] The beneficial effects of the present invention are as follows: By improving the target detection method for complex road scenes in YOLOv7, adding a small target detection layer and re-clustering the prior boxes using the K-means++ algorithm, the network becomes more sensitive to the features of small targets. Using the WIoU loss function makes the network pay more attention to the ordinary-quality anchor boxes. Introducing CoordConv enables the network to better extract spatial features, thus better sensing the position information. The P-ELAN structure is proposed to lightweight the network. Through the above technical solutions, the present invention effectively solves the problems of multi-scale, small samples, and high density encountered in target detection in complex road scenes, improves the detection accuracy, and achieves a balance between accuracy and speed. Brief Description of the Drawings

[0054] Figure 1 is the target detection flowchart of the method proposed by the present invention;

[0055] Figure 2 is the schematic diagram of the network model of the method proposed by the present invention;

[0056] Figure 3 is the schematic diagram of the working principle of CoordConv;

[0057] Figure 4 is the schematic diagram of the working principle of PConv;

[0058] Figure 5 is the schematic diagram of the structure of the P-ELAN module. Detailed Embodiments

[0059] The present invention will be further described in detail below with reference to the drawings and embodiments.

[0060] As Figure 1 shown, a target detection method for complex road scenes improved based on YOLOv7 includes the following steps:

[0061] Step 1: Obtain target images of complex road scenes and construct a data set. In this specific implementation, the autonomous driving data set SOAD10M released by Huawei Noah's Ark Laboratory and Sun Yat-sen University, which is open and widely recognized in the field of autonomous driving, is used. This data set collects scenes in different weather conditions, different time periods, and different locations in different cities in my country. The road target data set is divided into 2,500 training sets, validation sets, and 2,500 test sets, which contain 6 main categories of human-vehicle scenes: Pedestrian, Cyclist, Car, Truck, Tram, and Tricycle. The annotation files in the training set, validation set, and test set are all in .txt format, and the contents of the annotation files include: the id number corresponding to the category, the coordinates (x, y) of the center point of the normalized target frame, and the width w and height h of the normalized target frame;

[0062] Step 2: Read the complex road scene target image obtained in step 1 and enhance the image. Image enhancement includes the following three aspects: 1) Data enhancement uses HSV enhancement: adjust the hue, saturation and brightness of the image; 2) Geometric transformation enhancement: including random rotation, random translation, random scaling and random flipping; 3) Image-level pixel enhancement: mosaic data enhancement or mixup data enhancement. Align the enhanced images to images of the same size; after data enhancement, align the image size to 640*640 and input it into the feature extraction network;

[0063] Step 3: Use the K-Means++ clustering algorithm to analyze the size of the annotation boxes of the training samples and generate four groups of prior boxes of different sizes; specifically, the following steps are included:

[0064] First, the total number of prior boxes is set to 12; then, the K-means++ clustering algorithm is used to perform cluster analysis on the object bounding boxes annotated in the data set: the K-means++ algorithm first randomly selects a point as the first cluster center, and then selects other points as new cluster centers in the form of probability, so that the farther the new cluster center is from the selected cluster center, the higher the probability of being selected. This process is repeated until all cluster centers are selected. This method enables the network to better detect small targets in complex road scenes and obtain prior boxes suitable for targets in complex road scenes. The comparison of prior boxes before and after clustering is shown in Table 1.

[0065] Table 1 Results of prior box size before and after clustering

[0066]

[0067] Step 4: If Figure 2As shown, an improved YOLOv7 object detection network model is constructed. The improved YOLOv7 object detection network model includes a feature extraction network, a feature fusion network, and a multi-scale detection head, where:

[0068] The feature extraction network is a stack of CBS, P-ELAN, and MP modules, with a total of 32 times downsampling; among them, as Figure 4 and Figure 5 shown, the P-ELAN module consists of a common convolutional layer and a partial convolutional layer (PConv). The partial convolutional layer performs a conventional convolutional operation on some channels in the input feature map, and the remaining channels remain unchanged and perform an Identity operation. The specific steps are as follows:

[0069] For a convolutional kernel of size k, the size of the input feature map is h×w, and the number of channels is c. If the sizes and numbers of channels of the input and output feature maps are the same, the computational amount of the conventional convolution is: h×w×k 2 ×c 2 ; The computational amount of PConv is: The ratio of the computational amount of conventional convolution to PConv is: If then the computational amount of PConv is 1 / 16 of the conventional convolution;

[0070] The memory access amount of the conventional convolution is: h×w×2c + k 2 ×c 2 ≈h×w×2c; The memory access amount of PConv is: The ratio of the memory access amount of conventional convolution to PConv is: If then the memory access amount of PConv is 1 / 4 of the conventional convolution;

[0071] The feature fusion network is used to fuse multi-scale features. The feature fusion network consists of an SPPCSPC module, an ELANW module, a CBS module, an MP module, and a CoordConv module to form a top-down FPN and a bottom-up PAN; as Figure 3 shown, the implementation method of the CoordConv module is completed by connecting two additional i and j channels to the input channels. If the coordinate layer connected to the CoordConv and the weights of the convolution are not zero, the CoordConv module allows learning a function with a certain degree of translational dependence; if the coordinate layer connected to the CoordConv and the weights of the convolution are zero, it simulates a conventional convolutional layer;

[0072] The multi-scale detection head: performs detections on the feature maps downsampled by 4 times, 8 times, 16 times, and 32 times respectively, obtaining four-scale detection heads. That is, the 20*20 detection layer is used to detect large targets, the 40*40 detection layer is used to detect relatively large targets, the 80*80 detection layer is used to detect small targets, and the 160*160 detection layer is used to detect tiny targets, thereby improving the network's positioning ability for small-sized targets in complex road scenes;

[0073] Step Five: Using the coordinate loss L loc 、the object confidence loss L loc and the classification loss L cls to construct the overall loss function. The calculation formula of the overall loss function is:

[0074] Loss = λ1L cls + λ2L obj + λ3L loc ;

[0075] In the formula, λ1, λ2, and λ3 are all weight coefficients;

[0076] In the constructed loss function, the coordinate loss is the WIoU loss, and the object confidence loss and the classification loss use the binary cross-entropy loss with log (BCE With Logits Loss); the WIoU loss contains three versions, namely WIoUv1, WIoUv2, and WIoUv3. The present invention uses the WIoUv3 version, which is optimized based on WIoUv1 and WIoUv2. The relevant formula of WIoUv1 is as follows:

[0077] L IoU = 1 - IoUL IoU ;

[0078] L WIoUv1 = R WIoU L IoU ;

[0079]

[0080] In the formula, R WIoU ∈[0,e) will significantly amplify the L IoU of ordinary anchor boxes, and L IoU ∈[0,1] will significantly reduce the R WIoU of high-quality anchor boxes and significantly reduce its attention to the distance from the center point when the anchor box and the target box overlap well. W g , H g are the width and height of the minimum bounding rectangle respectively. * means separating W g , H g from the computational graph, and its role is to prevent R WIoUGenerate gradients that hinder convergence;

[0081] WIoUv2 constructs a monotonic focusing coefficient based on WIoUv1 The relevant formula is as follows:

[0082]

[0083] During the model training process, the gradient gain decreases as L IoU decreases. Therefore, the mean value of L IoU is introduced as a normalization factor:

[0084]

[0085] In the formula, is the average running value with momentum m. Dynamically updating the normalization factor keeps the gradient gain at a relatively high level overall;

[0086] WIoUv3 introduces a dynamic non - monotonic focusing coefficient based on WIoUv2. The relevant formula is as follows:

[0087]

[0088]

[0089] In the formula, β is the outlier, and α and δ are hyperparameters that control the gradient gain r, where α = 1.9 and δ = 3;

[0090] Step 6: First, send the dataset into the improved YOLOv7 object detection network model constructed in Step 4 for training, and output the bounding box positions, sizes, and object categories of each object in the image; then, perform backpropagation through the loss function constructed in Step 5 to update the weights, and iterate a predetermined number of rounds (300 rounds) to obtain the model training weights for complex road object detection;

[0091] The model training is configured with a 13th Gen Intel(R) Core(TM) i5-13600KF @ 3.5GHz processor, an NVIDIA GeForce RTX 4090 (24G video memory) graphics card, and 32G of memory; a Windows 10 Pro operating system, a Python 3.9.16 compilation language, a Pytorch 1.13.1 deep learning framework, and a CUDA 11.7 accelerated computing architecture. The parameter settings in the model training process use the SGD method to train for 300 epochs, the initial learning rate is set to 0.01, the batch size is set to 16, the momentum parameter is set to 0.937, and warm-up training is performed for 3 epochs. A series of data augmentation operations such as mixup, mosaic, and fliplr are used with a certain probability.

[0092] Step 7: Send the image to be detected into the trained detection model to obtain the test results. The detected results are framed by rectangular bounding boxes, completing the target detection in complex road scenes.

[0093] To verify the effectiveness of the present invention, multiple groups of experiments based on YOLOv7 are set up to verify the improvement of the performance of each module, and evaluation metrics such as the number of parameters (Parameters), the amount of computation (FLOPs), the accuracy (Percision), the recall rate (Recall), the mean average precision (mAP), and the number of frames per second (FPS) are selected. The corresponding calculation formulas are as follows:

[0094]

[0095]

[0096]

[0097]

[0098] Where TP represents the correctly detected bounding box, FP represents the misdetected bounding box, FN represents the missed detected bounding box, len(GTs) represents the number of all labeled bounding boxes, AP represents the detection accuracy of one target, N represents the number of detection categories, Frames represents the number of frames, and Time represents the detection time.

[0099] The experimental results are shown in Table 2. Among them, Group A is the original YOLOv7 model, Group B adds a small target detection layer based on Group A, Group C re-clusters the prior boxes using the K-means++ algorithm based on Group B, Group D uses the WIoU loss function based on Group C, Group E introduces CoordConv based on Group D, and Group F introduces the P-ELAN structure based on Group E.

[0100] Table 2 Performance improvement results of each improvement method

[0101]

[0102] It can be seen from Table 2 that after adding the small target detection layer, the mAP increased by 1%. When the prior boxes were re-clustered using K-means++ on the basis of the small target detection layer, the mAP increased by 1.2%. After replacing the loss function with WIoU on the basis of using the K-means++ algorithm, the mAP increased by 0.5%. After introducing CoordConv, the mAP increased by 0.7%. Finally, after lightweighting the backbone network through the P-ELAN structure, the mAP decreased by 0.8%, but the overall accuracy was improved by 2.6% compared with the original YOLOv7, and the number of parameters and the amount of computation decreased by 12% and 7% respectively. Among them, the mAP of Group C increased the most, indicating that the prior box size has a greater impact on the target recognition accuracy. Except for the obvious decrease in the accuracy of the Tricycle category in Group F, the accuracy of small targets in the other groups showed an upward trend, proving the effectiveness of each improved method of the present invention for targets in complex road scenarios.

[0103] To further verify the effectiveness of the method proposed in the present invention, the method proposed in the present invention was compared with algorithms such as SSD, Faster R-CNN, YOLOv3, YOLOv5, YOLOX, YOLOv6, YOLOv8, and RetinaNet in terms of mAP and FPS metrics on the SOAD10M dataset. The experimental results are shown in Table 3.

[0104] Table 3 Comparative experimental results

[0105] Algorithm mAP / % FPS SSD 46.5 59 Faster R-CNN 46.4 47 YOLOv3 51 79 YOLOv5l 54.9 87 YOLOX 41.2 87 YOLOv6l 56.5 50 YOLOv7 62.2 86 YOLOv8m 61.2 87 RetinaNet 28.4 40 Improved method 64.8 80

[0106] By comparing the experimental results of different methods in Table 3, it can be seen that the algorithm in this paper is significantly higher than other advanced detection algorithms in terms of the mAP metric, reaching 64.8%. The FPS is slightly lower than that of other advanced one-stage detection algorithms, but much higher than that of two-stage detection algorithms. The FPS of the algorithm in this paper is 80. Compared with YOLOv7, a little detection speed is sacrificed in exchange for higher detection accuracy, achieving a balance between speed and accuracy, and meeting the real-time and accuracy requirements of target detection in complex road scenarios.

[0107] As mentioned above, the above are only the specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by those skilled in the art within the technical scope disclosed by the present invention should be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.

Claims

1. A method for object detection in complex road scenes improved based on YOLOv7, characterized in that: Step 1: Obtain object images in complex road scenes and construct a dataset. Divide the road object dataset into a training set, a validation set, and a test set. Among them, the annotation files in the training set, validation set, and test set are all in.txt format. The content of the annotation files includes, in sequence: the id number corresponding to the category, the coordinates (x, y) of the center point of the normalized object bounding box, and the width w and height h of the normalized object bounding box; Step 2: Read the object images in complex road scenes obtained in Step 1, perform enhancement processing on the images, and align the enhanced images into pictures of the same size; Step 3: Use the K-Means++ clustering algorithm to analyze the sizes of the annotation boxes of the training samples and generate four groups of prior boxes with different sizes; Step 4: Construct an improved YOLOv7 object detection network model. The improved YOLOv7 object detection network model includes a feature extraction network, a feature fusion network, and a multi-scale detection head, where: The feature extraction network is a stack of CBS, P-ELAN, and MP modules, with a total of 32 times downsampling; The feature fusion network is used to fuse multi-scale features. The feature fusion network consists of an SPPCSPC module, an ELANW module, a CBS module, an MP module, and a CoordConv module to form a top-down FPN and a bottom-up PAN; The multi-scale detection head: Detect on the feature maps downsampled by 4 times, 8 times, 16 times, and 32 times respectively to obtain detection heads of four scales; Step Five: Using the coordinate loss L loc , the target confidence loss L loc and the classification loss L cls to construct the overall loss function. The calculation formula of the overall loss function is as follows: Loss = λ1L cls + λ2L obj + λ3L loc ; In the formula, λ1, λ2, and λ3 are all weight coefficients; In the constructed loss function, the coordinate loss is the WIoU loss, and the object confidence loss and classification loss use the binary cross-entropy loss with log; Step 6: First, send the dataset into the improved YOLOv7 object detection network model constructed in Step 4 for training, and output the bounding box position, size, and object category of each object in the image; then, perform backpropagation through the loss function constructed in Step 5 to update the weights, and iterate a predetermined number of rounds to obtain the model training weights for complex road object detection; Step 7: Send the image to be detected into the trained detection model to obtain the test result, and the detected result is framed by a rectangular bounding box to complete object detection in complex road scenes.

2. The object detection method for complex road scenes improved based on YOLOv7 according to claim 1, characterized in that: In Step 2, the image enhancement processing includes the following three aspects: 1), Data enhancement uses HSV enhancement: Adjust the hue, saturation, and brightness of the image; 2), Geometric transformation enhancement: including random rotation, random translation, random scaling, and random flipping; 3), Picture-level pixel enhancement: mosaic data enhancement or mixup data enhancement.

3. A method for detecting objects in complex road scenes improved based on YOLOv7 according to claim 1, characterized in that: Step 3 includes the following steps: First, the total number of prior boxes is set to 12; then, the K-means++ clustering algorithm is used to perform clustering analysis on the object bounding boxes labeled in the dataset: The K-means++ algorithm first randomly selects a point as the first clustering center, and then selects other points as new clustering centers in the form of probability, so that the points farther away from the selected clustering centers have a higher probability of being selected. Repeat this process until all clustering centers are selected, and prior boxes suitable for targets in complex road scenarios are obtained.

4. A method for detecting targets in complex road scenes improved based on YOLOv7 according to claim 1, characterized in that: In Step 4: The P-ELAN module is composed of an ordinary convolutional layer and a partial convolutional layer PConv. Among them, the partial convolutional layer performs conventional convolutional operations on some channels in the input feature map, and the remaining channels remain unchanged and perform Identity operations. The specific steps are as follows: For a convolutional kernel of size k, if the input feature map has a size of h×w and c channels, and the sizes and number of channels of the input and output feature maps are the same, the computational cost of a regular convolution is: h×w×k 2 ×c 2 ; The computational cost of PConv is: The ratio of the computational cost of regular convolution to that of PConv is: If then the computational cost of PConv is 1 / 16 of that of regular convolution; The memory access volume of conventional convolution is: h × w × 2c + k 2 × c 2 ≈ h × w × 2c; The memory access volume of PConv is: The ratio of the memory access volume of conventional convolution to that of PConv is: If Then the memory access volume of PConv is 1 / 4 of that of conventional convolution.

5. A method for detecting objects in complex road scenes improved based on YOLOv7 according to claim 1, characterized in that: In Step 4: The implementation method of the CoordConv module is completed by connecting two additional i and j channels to the input channels. If the coordinates layer connected to CoordConv and the weights of the convolution are not zero, the CoordConv module allows learning functions with a certain degree of translational dependence; if the coordinates layer connected to CoordConv and the weights of the convolution are zero, it simulates an ordinary convolutional layer.

6. A method for detecting objects in complex road scenes improved based on YOLOv7 according to claim 1, characterized in that: In Step 5: The WIoU loss is the WIoUv3 loss, where: In the formula, β is the outlier, and α and δ are hyperparameters that control the gradient gain r, α = 1.9, δ = 3.

Citation Information

Patent Citations

  • Occluded scene target detection method for pose estimation

    CN115100405A

  • PCB surface defect detection method based on improved YOLOv5 algorithm

    CN116309427A