A lightweight target detection method based on improved YOLOv5M
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-20
- Publication Date
- 2026-08-14
AI Technical Summary
[0005]针对yolo v5m目标检测算法参数量大、计算复杂度高、检测速度慢和平均检测精度较低的问题,本发明提供一种基于改进yolo v5m的轻量化目标检测方法,以解决上述技术问题
[0022]由于采用了上述技术方案,本发明具有如下的优点:对yolo v5m算法进行了轻量化处理;采用堆叠两支路轻量化激励模块形成的骨干网络,在检测头使用SIoU损失监督边界框的回归,降低了参数量和计算复杂度,同时提高了检测速度和平均检测精度。
Smart Images

Figure CN118675026B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of target detection technology, and in particular to a lightweight target detection method based on an improved YOLOv5M. Background Technology
[0002] With the gradual development of computer vision, object detection algorithms have become a popular area in the field. Object detection algorithms form the foundation for other advanced vision tasks, such as instance segmentation and object tracking. In recent years, the rapid development of deep learning has further propelled the vigorous development of object detection algorithms. However, as the average detection accuracy of these algorithms increases, problems arise. In practical fields such as robotics and autonomous driving, object detection algorithms need to be executed promptly under limited resources. Higher detection accuracy, however, leads to a higher number of parameters and greater computational complexity. Therefore, lightweighting of object detection algorithms is necessary. Lightweighting refers to reducing the number of parameters and computational complexity in the convolutional neural network part through methods such as model pruning and structural optimization, while preserving the average detection accuracy as much as possible. Therefore, lightweighting of object detection algorithms is essential.
[0003] The YOLOv5M object detection algorithm uses a backbone network, neck, and detection head structure. The backbone network extracts image features, the neck integrates the features from the backbone network, and the detection head predicts the final result. The backbone network uses CSPDarkNet-53, a fully convolutional neural network, to extract deep features of the image. The neck uses CSP-PANet. In the detection head, 1×1 standard convolutions are used for the final prediction. The loss function uses binary cross-entropy loss to supervise classification and CIOU Loss to supervise bounding box regression.
[0004] The existing YOLO v5m object detection algorithm has a large number of parameters, high computational complexity, and a relatively slow detection speed with low average detection accuracy. Summary of the Invention
[0005] To address the problems of large parameter count, high computational complexity, slow detection speed, and low average detection accuracy in the YOLO v5m target detection algorithm, this invention provides a lightweight target detection method based on an improved YOLO v5m algorithm to solve the aforementioned technical problems.
[0006] This invention discloses a lightweight target detection method based on an improved YOLOv5M, which includes:
[0007] Step 1: Stack two lightweight excitation modules to form a new backbone network to extract image features;
[0008] Step 2: Using CSP-PANet as the neckline, the extracted image features are fused;
[0009] Step 3: Use the detection head with SIoU loss to supervise the bounding box loss to perform target detection on the fused image.
[0010] Furthermore, in step 1:
[0011] The two-branch lightweight excitation module is divided into two parallel branches; the first branch includes a series-connected 3×3 group of convolutions and a 1×1 standard convolution, and the second branch includes a series-connected 1×1 standard convolution, a 3×3 group of convolutions, an excitation module, and a 1×1 standard convolution.
[0012] The two branches are merged by using concatenation and then concatenated with a 3×3HS-depth-separable convolution and a 1×1HS-standard convolution in sequence.
[0013] Multiple lightweight two-branch excitation modules are stacked as feature extractors, covering targets of three scales: large, medium, and small. For small targets, one lightweight two-branch excitation module needs to be stacked; for medium targets, M lightweight two-branch modules need to be stacked; and for large targets, N lightweight two-branch modules need to be stacked. M is greater than 1 and less than N.
[0014] Furthermore, the 3×3 convolutions in the first branch are used to reduce the number of network parameters, and the 1×1 standard convolutions are used to reduce the dimensionality of the number of channels.
[0015] Furthermore, the 1×1 standard convolution in the second branch is used to reduce the number of channels, and the 3×3 group convolution is used to reduce the number of network parameters.
[0016] Furthermore, an activation module is added to the second branch, which uses an adaptive average pooling layer to adaptively calculate the kernel size and the step size for each movement, averages the input information in the height and width directions, and then cascades the global information.
[0017] Afterwards, a 1×1 convolutional layer is used to manipulate the number of channels; a batch normalization layer is used to speed up the training and convergence of the network; a ReLU6 function is used to limit the maximum value of the output to prevent numerical explosion; then separation is required, which forms two branches. Each branch is subjected to a 1×1 standard convolution and a sigmoid function to map the output of the ReLU6 function before separation to the range of 0 to 1. After obtaining the coefficients of the two branches, they are multiplied and then output.
[0018] Finally, a 3×3HS-depthseparable convolution and a 1×1HS-standard convolution are concatenated, and the depthseparable convolution is used to reduce the number of parameters in the network.
[0019] Furthermore, the HS of the HS-depth-separable convolution and the HS-standard convolution is HardSwish, using a piecewise linear function instead of Swish.
[0020] Furthermore, in step 3:
[0021] In the detection head part, a 1×1 standard convolutional non-decoupled detection head is used as the output, which is responsible for the final prediction and regression. The regression part uses SIoU loss, and the classification part uses binary cross-entropy loss.
[0022] Due to the adoption of the above technical solution, the present invention has the following advantages: the YOLO v5m algorithm has been lightweighted; a backbone network formed by stacking two-branch lightweight excitation modules is adopted, and SIoU loss is used to supervise the regression of the bounding box in the detection head, which reduces the number of parameters and computational complexity, while improving the detection speed and average detection accuracy. Attached Figure Description
[0023] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments recorded in the embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings.
[0024] Figure 1 This is a schematic diagram of the two-branch lightweight excitation module according to an embodiment of the present invention;
[0025] Figure 2 A schematic diagram showing the addition of an excitation module to the second branch of this embodiment of the invention;
[0026] Figure 3 This is a schematic diagram of the improved YOLOv5M backbone network structure according to an embodiment of the present invention.
[0027] Figures 4(a) and 4(b) are comparison images of the visualization effects of a lightweight target detection model based on YOLO v5m and an improved YOLO v5m model according to an embodiment of the present invention.
[0028] Figures 5(a) and 5(b) are comparison diagrams of the visualization effects of another lightweight target detection model based on YOLO v5m and an improved YOLO v5m model according to an embodiment of the present invention.
[0029] Figure 6 This is a flowchart illustrating a lightweight target detection method based on an improved YOLOv5M according to an embodiment of the present invention. Detailed Implementation
[0030] The present invention will be further described in conjunction with the accompanying drawings and embodiments. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. All other embodiments obtained by those skilled in the art should fall within the protection scope of the present invention.
[0031] See Figure 6 This invention provides an embodiment of a lightweight target detection method based on an improved YOLOv5m. In actual business scenarios, target detection models need to be executed promptly on resource-limited platforms. However, the traditional YOLOv5m algorithm is designed for general target detection, with a high number of parameters, high computational complexity, and low detection accuracy.
[0032] Therefore, this invention improves upon YOLOv5m, providing a lightweight target detection method based on improved YOLOv5m, comprising the following steps:
[0033] The target detection model based on YOLOv5m is improved by adding a two-branch lightweight activation module to the backbone network. The two-branch lightweight activation module is divided into two branches, which run in parallel. The first branch consists of a cascaded 3×3 group convolution and a 1×1 standard convolution. The second branch consists of a cascaded 1×1 standard convolution, a 3×3 group convolution, an activation module, and a cascaded 1×1 standard convolution. The two branches are merged using concatenation and then concatenated with a 3×3HS-depthseparable convolution and a 1×1HS-standard convolution. Multiple two-branch lightweight activation modules are stacked as feature extractors, covering targets of three scales: large, medium, and small. Detection is then performed based on the improved target detection model.
[0034] Furthermore, the first branch consists of a 3×3 group convolution and a 1×1 standard convolution concatenated together, and the second branch consists of a 1×1 standard convolution, a 3×3 group convolution, an activation module, and a 1×1 standard convolution concatenated together. After concatenation, it is concatenated with a 3×3 HS-depth separable convolution and a 1×1 HS-standard convolution.
[0035] Preferably, the small target section stacks one two-branch lightweight excitation module, the medium target section stacks seven multi-branch lightweight modules, and the large target section stacks ten multi-branch lightweight modules.
[0036] In specific business scenarios, achieving lightweight processing of object detection models requires modifications to the backbone network. Traditional YOLOv5m uses stacked convolutional layers to obtain the final backbone network, and the number of object detection model parameters is reflected in the size of the backbone network. Based on this idea, a two-branch lightweight excitation module was designed, referencing... Figure 1The first branch concatenates 3×3 group convolutions and 1×1 standard convolutions. The 3×3 group convolutions reduce the number of network parameters, and the 1×1 standard convolutions reduce the number of channels. The second branch concatenates a 1×1 standard convolution, a 3×3 group convolution, an activation module, and a 1×1 standard convolution. The 1×1 standard convolution is used to reduce the number of channels, and the 3×3 group convolutions reduce the number of network parameters. While group convolutions achieve the effect of reducing the number of parameters, they lose local feature information. Therefore, an activation module is added to the second branch, such as... Figure 2 As shown, an adaptive average pooling layer adaptively calculates the kernel size and stride for each move, averaging the input information in the height and width directions to obtain global information, which is then concatenated. Next, a 1×1 standard convolution is used to manipulate the number of channels. A batch normalization layer accelerates network training and convergence, preventing gradient explosion and overfitting. A ReLU6 activation function limits the maximum output value. Separation is then performed; each branch is processed by a 1×1 standard convolution and a sigmoid function to map the result to between 0 and 1, and the coefficients are multiplied for output. Finally, a 3×3 HS-depthseparable convolution and a 1×1 HS-standard convolution are concatenated. The depthseparable convolution further reduces the number of network parameters. The HS in the HS-depthseparable convolution and HS-standard convolution uses HardSwish, replacing Swish with a piecewise linear function, improving computational efficiency and ensuring low computational cost while improving network accuracy.
[0037] The improved YOLOv5m backbone network structure is as follows: Figure 3 As shown, the small target part stacks one two-branch lightweight excitation module, the medium target part stacks seven multi-branch lightweight modules, and the large target part stacks ten multi-branch lightweight modules, which are finally fused by SPPF.
[0038] As shown in Table 1, the lightweight target detection model based on the improved YOLO v5m proposed in this invention is superior to the original YOLO v5m in terms of parameter quantity, computational complexity, detection speed and detection accuracy. The parameter quantity is reduced by 23.1%, the detection speed is increased by 10.4%, the computational complexity is reduced by 11.6%, and the detection accuracy is 0.2 higher than that of YOLO v5m.
[0039] Table 1 Algorithm Performance Comparison Table
[0040]
[0041] Figure 4 shows a comparison of the visualization effects of YOLO v5m and the lightweight target detection model based on the improved YOLO v5m proposed in this invention. Comparing Figure 4(a) and Figure 4(b), in the case of a single target, neither YOLO v5m nor the improved YOLO v5m has any missed detections or false detections. However, YOLO v5m only scores 0.79, while the improved YOLO v5m scores 0.92, which is higher than YOLO v5m. Comparing Figure 5(a) and Figure 5(b), YOLO v5m only detects kites and birds, but misses boats. The improved YOLO v5m not only detects kites and birds, but also does not miss boats.
[0042] To address the issues of high parameter count, computational complexity, slow detection speed, and low average detection accuracy in the YOLO v5M algorithm, this method employs a backbone network formed by stacking two lightweight excitation modules. SIoU loss is used in the detection head to supervise the regression of the bounding box, achieving the beneficial effects of reducing parameter count and computational complexity while improving detection speed and average detection accuracy.
[0043] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the specific implementation of the present invention. Any modifications or equivalent substitutions that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A lightweight target detection method based on an improved YOLOv5M, characterized in that, include: Step 1: Stack two lightweight excitation modules to form a new backbone network to extract image features; In step 1: the two-branch lightweight activation module is divided into two parallel branches; the first branch includes a cascaded 3×3 group convolution and a 1×1 standard convolution, and the second branch includes a cascaded 1×1 standard convolution, a 3×3 group convolution, an activation module, and a 1×1 standard convolution; the two branches are merged using concatenation and then concatenated with a 3×3HS-depthseparable convolution and a 1×1HS-standard convolution in sequence; multiple two-branch lightweight activation modules are stacked as feature extractors, covering targets of large, medium, and small scales; for small targets, one two-branch lightweight activation module needs to be stacked, for medium targets, M two-branch lightweight modules need to be stacked, and for large targets, N two-branch lightweight modules need to be stacked; where M is greater than 1 and less than N; in the second... An activation module is added to the branch, using an adaptive average pooling layer to adaptively calculate the kernel size and stride for each move, averaging the input information in the height and width directions to obtain global information before concatenation. Then, a 1×1 convolutional layer operates on the number of channels. A batch normalization layer accelerates the training and convergence of the network, and a ReLU6 function limits the maximum output value. Separation is then performed, forming two branches. Each branch undergoes a 1×1 standard convolution and a sigmoid function to map the output after the ReLU6 function to the range of 0 to 1. The coefficients of the two branches are obtained, multiplied, and then output. Finally, a 3×3 HS-depthseparable convolution and a 1×1 HS-standard convolution are concatenated, using the depthseparable convolution to reduce the number of network parameters. Step 2: Using CSP-PANet as the neckline, the extracted image features are fused; Step 3: Use the detection head with SIoU loss to supervise the bounding box loss to perform target detection on the fused image; In step 3: In the detection head part, a 1×1 standard convolutional non-decoupled detection head is used as the output, which is responsible for the final prediction and regression. The regression part uses SIoU loss, and the classification part uses binary cross-entropy loss.
2. The method according to claim 1, characterized in that, The 3×3 convolutions in the first branch are used to reduce the number of network parameters, and the 1×1 standard convolutions are used to reduce the dimensionality of the number of channels.
3. The method according to claim 1, characterized in that, The 1×1 standard convolution in the second branch is used to reduce the number of channels, and the 3×3 group convolution is used to reduce the number of network parameters.
4. The method according to claim 1, characterized in that, The HS in the HS-depth-separable convolution and HS-standard convolution is HardSwish, which uses a piecewise linear function instead of Swish.