A lightweight pest target detection method based on depthwise separable convolution

By introducing deep separable convolution and attention mechanisms into the pest detection algorithm, combined with network pruning technology, the problem of difficult deployment of complex algorithms on mobile terminal devices is solved, and efficient detection performance of a lightweight pest target detection model is achieved, which is suitable for on mobile devices.

CN118279718BActive Publication Date: 2024-08-27JINQIU ERA IOT TECH GRP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410674661.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-29
Publication Date
2024-08-27
Estimated Expiration
2044-05-29

AI Technical Summary

Technical Problem

Existing pest detection algorithms based on deep learning are difficult to deploy on resource-constrained mobile terminal devices, mainly due to their complex parameters and computing requirements.

Method used

A lightweight pest target detection method based on depth-separable convolution is used to replace the backbone network and head network in the YOLOv8 model by designing the light insect unit module and the light insect downsampling module, combining the convolutional attention mechanism and the efficient attention mechanism. , perform network pruning and neuron pruning, reduce the number of parameters and calculation amount, and form the LP-YOLO model.

Benefits of technology

It achieves a significant reduction in model parameters and computational complexity while maintaining detection accuracy, improves inference speed, makes the model more suitable for mobile terminal devices, and can achieve real-time or near-real-time pest detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118279718B
    Figure CN118279718B
Patent Text Reader

Abstract

A lightweight pest target detection method based on deep separable convolution. The invention belongs to the field of image processing and image recognition technology, and specifically relates to the field of lightweight pest target detection technology. The YOLOv8 network structure is optimized, and the LP_U module and LP_D module are designed and applied to the YOLOv8 structure to form the LP‑YOLO(l) framework. Through pruning and fine-tuning strategies, a streamlined LP‑YOLO(s) model is obtained. The number of output channels and the amount of parameters are reduced during pruning, while the key weights are retained, and the final detection model is obtained through parameter training. These strategies improve the network efficiency and compactness. The invention solves the problem that pest detection is difficult to deploy on resource-constrained mobile terminal devices due to complex parameters and computing requirements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of image processing and image recognition, and specifically relates to the technical field of lightweight pest target detection. Background Art

[0002] With the widespread application of deep learning technology in the agricultural field, especially in the detection of crop pests, domestic and foreign scholars have proposed a variety of detection algorithms based on deep learning, which significantly improved the accuracy and efficiency of detection. In recent years, the YOLO series of algorithms has become a hot topic of research due to its efficient detection speed and good accuracy. As a representative algorithm for real-time target detection, the YOLO series has gone through a development process from YOLOv1 to YOLOv8. Among them, YOLOv4 and its subsequent versions have achieved significant improvements in performance. YOLOv4 has greatly improved the accuracy and speed of detection by introducing more data enhancement technologies, deeper network structures and new feature fusion strategies. Subsequently, YOLOv5 was further optimized in terms of ease of use and speed. Although it is not an official version, it has become a hot topic in the industry due to its excellent performance and wide community support. YOLOv6 and YOLOv7 are designed around the lightweight model and further performance improvement, especially in the detection of small targets. The latest YOLOv8 further strengthens the generalization ability and detection efficiency of the model on this basis, making it perform better in complex scenarios such as crop pest detection.

[0003] With the rapid development of machine vision and deep learning technology, in addition to the YOLO series, there are many other algorithms that have been widely studied in the field of crop pest detection. For example, algorithms such as Fast R-CNN, SSD and Mask R-CNN have also been applied to pest detection. These algorithms have their own advantages. For example, Mask R-CNN can not only detect pests, but also accurately segment pests, which helps to understand the specific distribution of pests.

[0004] Although the latest object detection algorithms based on deep learning and convolutional neural networks have demonstrated high accuracy and real-time performance in the field of pest detection, their complex parameters and computational requirements limit their application in daily scenarios. Therefore, it is challenging to deploy advanced object detection models on resource-constrained mobile terminal devices. Summary of the invention

[0005] In order to solve the problem that the previous pest detection is difficult to deploy on resource-constrained mobile terminal devices due to complex parameters and computing requirements, the present invention proposes a lightweight pest target detection method based on deep separable convolution, which includes the following steps:

[0006] S1. Data collection and division:

[0007] Collect pest images and divide them into training set and validation set;

[0008] S2. Model construction, specifically:

[0009] S21. Use the self-designed light worm unit module to replace the cross-stage fusion module in the YOLOv8 model backbone network, and use the self-designed light worm downsampling module to replace the convolution module in the YOLOv8 model backbone network and head network. The replaced model is named LP-YOLO(l) model.

[0010] The light insect unit module performs channel splitting, feature extraction, feature combination, attention allocation and channel shuffling operations respectively;

[0011] S22. The number of output channels of the light worm downsampling module and the light worm unit module in the LP-YOLO(l) model is halved, and the number of detection heads of the LP-YOLO(l) model is reduced from three to two. The resulting model is named the LP-YOLO(s) model.

[0012] The light worm downsampling module performs feature extraction, feature combination, attention allocation and channel shuffling operations respectively;

[0013] S3, model adjustment: first train the LP-YOLO(l) model, and then use the trained weights to adjust the LP-YOLO(s) model;

[0014] S4, model training: input the data of the training set into the adjusted LP-YOLO(s) model for training to obtain model parameters that meet the requirements, and verify the effect through the validation set;

[0015] S5. Perform pest target detection using the LP-YOLO(s) model trained in step S4.

[0016] Furthermore, the collected pest images are from the IP102 dataset.

[0017] Furthermore, the operation of the feature map in the light insect unit module is specifically as follows: first, a channel splitting operation is performed to divide the feature map data into two branch inputs, and the feature map data in one branch passes through: convolution layer, batch normalization layer, activation layer, depth-separable convolution layer, batch normalization layer, convolution layer, batch normalization layer and activation layer in sequence, and then feature-joined with the other branch, and then passes through the efficient attention mechanism layer, and then output after a channel shuffling operation.

[0018] Furthermore, the efficient attention mechanism layer is composed of an efficient channel attention mechanism and a spatial attention mechanism.

[0019] Furthermore, the operation of the feature map in the light worm downsampling module is specifically as follows: without performing channel splitting, the feature map data is fed to two branches at the same time, wherein the feature map data in one branch passes through: depthwise separable convolution layer, batch normalization layer, convolution layer, batch normalization layer and activation layer in sequence; wherein the feature map data in the other branch passes through: convolution layer, batch normalization layer, activation layer, depthwise separable convolution layer, batch normalization layer, convolution layer, batch normalization layer and activation layer in sequence; then the two branches perform feature union, then pass through the convolutional attention mechanism layer, and finally perform channel shuffling operation before output.

[0020] The beneficial effect of the method described in the present invention is: in order to make YOLOv8 lightweight while maintaining accuracy as much as possible, two lightweight modules, a LowPrecision_Unit module (hereinafter referred to as LP_U module) and a LowPrecision_DownSampleUnit module (hereinafter referred to as LP_D module) that integrate depthwise separable convolution, are designed to replace the network to make the network lightweight.

[0021] In order to focus on the key information in the input data by assigning different weights to the input data and ignore unimportant details, two attention mechanisms, the Convolutional Block Attention Module (CBAM) and the independently designed Efficient Channel and Spatial attention (ECSA) mechanism, are adopted.

[0022] In order to further reduce the parameter scale and complexity of the network, network pruning technology was introduced. First, for the backbone network, we adopted a weight pruning strategy to halve the number of output channels of the light worm unit module and the light worm downsampling module with a higher repetition frequency, thereby removing inefficient weights while significantly reducing the number of parameters and the amount of calculation, and extracting fine-grained details at different spatial scales; in the neck and head network parts, neuron pruning and connection pruning techniques were mainly used. In view of the fact that the structure of the original network in this part is too complex and not suitable for lightweight networks, the connection structure of the neck and head network was simplified, and the number of detection heads was reduced from three to two. These pruning measures effectively improved the inference speed and made the network structure more sparse.

[0023] The final model for lightweight pest target detection exhibits excellent convergence and detection performance, and in the test, it achieves superior target detection performance with the lightest model. This technical effect will be demonstrated in the form of test data in the subsequent specific implementation examples. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 This is the YOLOv8 model structure diagram;

[0025] Figure 2 It is the structure diagram of ECSA mechanism;

[0026] Figure 3 This is the LP_U module structure diagram;

[0027] Figure 4 This is the LP_D module structure diagram;

[0028] Figure 5 This is the LP-YOLO(s) model structure diagram. DETAILED DESCRIPTION

[0029] The technical solution of the present invention will be described clearly and completely below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the protection scope of the present invention.

[0030] The structure diagram of the YOLOv8 model is as follows Figure 1 As shown, the present embodiment designs LP_U and LP_D modules and applies them to the YOLOv8 structure to form an LP-YOLO(l) framework. Through pruning and fine-tuning strategies, a streamlined LP-YOLO(s) model is obtained. The number of output channels and the amount of parameters are reduced during the pruning process while retaining key weights. These strategies improve network efficiency and compactness, forming an LP-YOLO(s) model of five scales, including n, s, m, l and x. In practical applications, technicians can select any of the five categories of LP-YOLO(s) models according to specific needs.

[0031] The ECSA mechanism is a combination of two attention mechanisms: the Efficient Channel Attention (ECA) mechanism and the Spatial Attention Module (SAM) mechanism. Figure 2 The structure of the ECSA mechanism is shown.

[0032] The designed LP_U module structure is as follows Figure 3 First, a channel split operation is performed to process the input function, and the feature map data is divided into two branch inputs. The feature map data in one branch passes through: 1×1 convolution layer (1×1Conv), batch normalization layer (Batch Normalization

[0033] The network is composed of a set of four branches: a first branch, a second branch, and a second branch. The first branch is a convolutional layer, a 1×1 convolutional layer, a batch normalization layer, an activation layer (using ReLU activation function), a depthwise separable convolution layer (DWConv, where the stride is 1), a batch normalization layer, a 1×1 convolutional layer, a batch normalization layer, an activation layer (using ReLU activation function), and then feature concatenation (Concat) with another branch, and then passes through the efficient attention (ECSA) mechanism layer, and then the output is output after the channel shuffle operation.

[0034] The 1×1 convolution layer here is designed to reduce the number of channels in the feature map, thereby further reducing the complexity of the depth-separable convolution. After the connection operation, the feature map will pass through the ECSA mechanism layer, which can strengthen the emphasis on key information, thereby improving the accuracy of the model. Finally, the channel shuffle operation is used to further achieve the interaction between channels. Using the LP_U module to replace the cross-stage fusion module in the YOLOv8 backbone network (this module is recorded as the C2f module in the YOLOv8 backbone network) can significantly reduce the number of parameters while maintaining excellent performance.

[0035] Figure 4 The LP_D module shown in is a new lightweight downsampling module designed to replace the convolution module in the YOLOv8 backbone network (this module is recorded as the Conv module in the YOLOv8 backbone network). First, instead of channel splitting, the feature map data is fed to two branches at the same time. The feature map data in one branch passes through the following steps: depthwise separable convolution layer (the stride is 2), batch normalization layer, 1×1 convolution layer, batch normalization layer, and activation layer (using ReLU activation function); the feature map data in the other branch passes through the following steps: 1×1 convolution layer, batch normalization layer, activation layer (using ReLU activation function), depthwise separable convolution layer (the stride is 2), batch normalization layer, 1×1 convolution layer, batch normalization layer, and activation layer (using ReLU activation function); then the two branches perform feature concatenation (Concat), and then pass through the Convolutional Block Attention Module (CBAM) layer, and then perform channel shuffling operation on the output to further enhance the feature representation capability.

[0036] In order to improve the YOLOv8 network and make it lightweight while maintaining accuracy, we propose LP_U and LP_D modules. The LP_U module replaces the cross-stage fusion module in the backbone network of the YOLOv8 model, and the LP_D module replaces the convolution module in the backbone network and head network of the YOLOv8 model. We name the replaced model as the LP-YOLO(l) model. Like the YOLOv8 model, the LP-YOLO(l) model and the LP-YOLO(s) model obtained after network pruning have five scales: n, s, m, l and x. The three hyperparameters d, w and r in the network of different scales are different. Table 1 shows the corresponding relationship between different hyperparameters in models of different scales.

[0037] Table 1:

[0038]

[0039] Table 2 shows the network structure of LP-YOLO(l), where N represents the number of repetitions of the module (N is rounded up). Images represents the input layer, SPPF represents the fast spatial pyramid pooling module, Concat represents the feature joint layer, Upsample represents the upsampling layer, and Detect represents the detection head, all of which are original modules in YOLOv8.

[0040] In the source level, -1 represents the previous level, and other numbers represent the corresponding level numbers in the level number. The values ​​of the hyperparameters d and w refer to Table 1.

[0041] Table 2:

[0042]

[0043] In order to further reduce the parameter scale and complexity of the model, network pruning technology is introduced. First, for the LP-YOLO(l) model backbone network, a weight pruning strategy is adopted to halve the number of output channels of the LP_D module and LP_Unit module with high repetition frequency, thereby removing inefficient weights and significantly reducing the number of parameters and the amount of calculation. At the same time, the network can capture richer feature information and extract fine-grained details at different spatial scales.

[0044] In the neck and head network of the LP-YOLO(l) model, neuron pruning and connection pruning techniques are mainly used. Since the structure of the original YOLOv8 model in this part is too complex and not suitable for lightweight networks, the modules of the neck network of the LP-YOLO(l) model are reduced, specifically the cross-stage fusion module (C2f) is reduced from 3 to 1, and the connection order between it and the head network is adjusted, thereby reducing the number of detection heads from the original three to two. These pruning measures effectively improve the inference speed and make the network structure more sparse.

[0045] The model after the above pruning is called LP-YOLO(s) model. Figure 5 Represents the network structure of the LP-YOLO(s) model, where the number of repetitions of different modules refers to N in Table 3 (N is rounded up). In Table 3, -1 in the source level represents the previous level, and other numbers represent the corresponding level numbers in the level number. The values ​​of the hyperparameters d and w refer to Table 1. Table 3 shows the network structure of LP-YOLO(s) and the connection relationship between each level.

[0046] Table 3:

[0047]

[0048] Furthermore, LP-YOLO(s) is adjusted by first training the LP-YOLO(l) model and then using the weights obtained from the training to adjust the LP-YOLO(s) model. The weights refer to the values ​​of all parameters in the LP-YOLO(l) model after training. These values ​​are used to adjust the corresponding parameters in the LP-YOLO(s) model. The adjusted LP-YOLO(s) model exhibits excellent convergence and detection performance.

[0049] The detection model of this embodiment is compared with other target detection networks and lightweight networks: the experimental environment is Python 3.8.0 and Pytorch 1.12.1. The graphics card model is 3090, and the unified computing device architecture CUDA version is CUDA 11.3.

[0050] In order to demonstrate the effectiveness of the proposed lightweight pest target detection method with deep separable convolution in pest detection, it was compared with several state-of-the-art target detection networks in an experimental environment. Among them, YOLOv5n, YOLOv8n, YOLOX-L, Faster-RCNN, SSD300 and RetinaNet were selected for comparative experiments. The comparison results are shown in Table 4. Compared with the lightest YOLOv5n in other networks, the LP-YOLO series (i.e., LP-YOLO(l)n and LP-YOLO(s)n, where n represents one of the five scales of n, s, m, l and x, because this network is improved from YOLOv8, it inherits its characteristic of having five scales) provided in this embodiment is the lightest model. LP-YOLO(l)n reduces the number of parameters by 0.25M, the floating point operation volume by 1.0G, and the delay by 0.4 milliseconds. LP-YOLO(s)n further reduces the weights based on LP-YOLO(l)n, reducing the number of parameters by 64.1%, while also significantly reducing the amount of floating-point operations and latency indicators. In terms of detection efficiency, the mAP50 of LP-YOLO(s)n (mAP50 represents the average accuracy at an IoU threshold of 0.5 for positioning problems in target detection) exceeds Faster-RCNN, SSD300, and RetinaNet. It is only 0.8% lower than YOLOv8n, which has the highest mAP50 value. Through comparative experiments, the superiority of the LP-YOLO series network as a lightweight target detection network is verified.

[0051] Table 4:

[0052]

[0053] In order to adapt to mobile terminal devices and facilitate experiments, the n-size model in the YOLOv8 and LP-YOLO series models is mainly used. In order to evaluate the lightweight and performance of the LP-YOLO series network we designed, LP-YOLO(s) and LP-YOLO(l) were compared with other advanced lightweight networks on the IP102 dataset.

[0054] The backbone of YOLOv8n is replaced with four classic lightweight networks: MobileNetV3-Small, MobileNetV3-Large, ShuffleNetV2-x1, and ShuffleNetV2-x2. Under the same experimental conditions and hyperparameters, these models are trained together with LP-YOLO(s)n and LP-YOLO(l)n. At the same time, the lightweight versions of the YOLO series, YOLOv5n and YOLOv8n, are also added to participate in the comparative experiment. The comparison results are shown in Table 5. Compared with yolov8n, which uses MobileNetv3 and ShuffleNetv2 as the backbone model, LP-YOLO(l)n and LP-YOLO(s)n show more superior lightweight characteristics, making them more suitable for mobile terminal devices while maintaining a high mAP value. It can be seen that the performance of LP-YOLO(l)n is not inferior to other lightweight networks. After network pruning, LP-YOLO(s)n is lighter than other classic lightweight networks while maintaining high mAP.

[0055] Table 5:

[0056]

[0057] Compared with YOLOv8n, LP-YOLO(s)n only reduces mAP by 0.8%, reduces the number of parameters by 70.2%, and increases FPS by 40.7%. LP-YOLO(s)n is particularly suitable for pest detection on mobile devices. Because it uses lightweight design and network pruning technology, the model significantly reduces the number of parameters and improves computational efficiency while maintaining high detection performance, which enables it to achieve real-time or near real-time pest detection on mobile devices, providing a convenient and efficient solution for agricultural production and pest control.

Claims

1. A lightweight pest target detection method based on depthwise separable convolution, characterized in that: The method comprises the following steps: S1. Data collection and division: Collect pest images and divide them into training set and validation set; S2. Model construction, specifically: S21. Use the self-designed light worm unit module to replace the cross-stage fusion module in the YOLOv8 model backbone network, and use the self-designed light worm downsampling module to replace the convolution module in the YOLOv8 model backbone network and head network. The replaced model is named LP-YOLO(l) model. The operation of the feature map in the light insect unit module is specifically as follows: first, a channel splitting operation is performed to divide the feature map data into two branch inputs, and the feature map data in one branch passes through: convolution layer, batch normalization layer, activation layer, depth-separable convolution layer, batch normalization layer, convolution layer, batch normalization layer and activation layer in sequence, and then performs feature combination with the other branch, and then passes through the efficient attention mechanism layer, and then performs channel shuffling operation and output; The operation of the feature map in the light worm downsampling module is specifically as follows: without performing channel splitting, the feature map data is fed into two branches at the same time, wherein the feature map data in one branch passes through: depth-separable convolution layer, batch normalization layer, convolution layer, batch normalization layer and activation layer in sequence; wherein the feature map data in the other branch passes through: convolution layer, batch normalization layer, activation layer, depth-separable convolution layer, batch normalization layer, convolution layer, batch normalization layer and activation layer in sequence; then the two branches perform feature combination, then pass through the convolution attention mechanism layer, and finally perform channel shuffling operation before output; S22. The number of output channels of the light worm downsampling module and the light worm unit module in the LP-YOLO(l) model is halved, and the number of detection heads of the LP-YOLO(l) model is reduced from three to two. The resulting model is named the LP-YOLO(s) model. S3, model adjustment: first train the LP-YOLO(l) model, and then use the trained weights to adjust the LP-YOLO(s) model; S4, model training: input the data of the training set into the adjusted LP-YOLO(s) model for training to obtain model parameters that meet the requirements, and verify the effect through the validation set; S5. Perform pest target detection using the LP-YOLO(s) model trained in step S4.

2. The lightweight pest target detection method based on depthwise separable convolution according to claim 1 is characterized in that: The collected pest images are from the IP102 dataset.

3. The lightweight pest target detection method based on depthwise separable convolution according to claim 2 is characterized in that: The efficient attention mechanism layer is composed of an efficient channel attention mechanism and a spatial attention mechanism.

4. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 3 are implemented.

5. A computer-readable storage medium for storing computer instructions, characterized in that: When the computer instructions are executed by a processor, the steps of the method according to any one of claims 1 to 3 are implemented.