A jute pest detection method and system based on an improved YOLOv7 model

CN117911839BActive Publication Date: 2026-09-22WUHAN POLYTECHNIC UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410188311.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-02-20
Publication Date
2026-09-22
Estimated Expiration
2044-02-20

AI Technical Summary

Technical Problem

但是普通的YOLOv7算法在进行黄麻虫害检测时存在识别虫害时存在模型计算冗余、对原始图像特征提取不够充分,以及在小尺度目标检测时存在误检和漏检等问题

Benefits of technology

[0056]1、由于原始YOLOv7中,其神经网络结构存在一定量的冗余计算,导致了更多的浮点运算(FLOPs),从而增加了模型的延迟时间,基于上述因素,本文将YOLOv7骨干网络中高效聚合网络模块(ELAN)中四个3*3卷积模块替换为部分卷积,极大的减少了模块的运算量和内存访问次数。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117911839B_ABST
    Figure CN117911839B_ABST
Patent Text Reader

Abstract

The application provides a jute pest detection method and system based on an improved YOLOv7 model. In the efficient aggregation network module (ELAN) of the YOLOv7 backbone network, part of the convolution in the FasterNet network is introduced, effectively reducing the redundant calculation of the model and the number of memory access times, and improving the efficiency of extracting spatial features. A feature fusion module and a P6 detection layer are introduced in the YOLOV7. The feature fusion module can make full use of semantic features at different levels, so that the feature information in the new feature map is more closely related. The P6 detection layer expands the receptive field of the model, which can improve the perception ability of the network to global features. The improved model can effectively improve the calculation efficiency of the model, strengthen the feature extraction of the original image, and improve the detection accuracy of the model, and is used for jute pest detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of pest detection technology, and specifically relates to a method for detecting jute pests based on an improved YOLOv7 model and a system for detecting jute pests based on an improved YOLOv7 model. Background Technology

[0002] Jute, a natural cellulose fiber, has a history spanning thousands of years. Its use in applications such as rope weaving is second only to cotton, making it a significant representative of plant fibers. Jute is a versatile, durable, reusable, and cost-effective fiber, making it more desirable than synthetic fibers. Furthermore, jute stands out for its agricultural basis, sustainable annual production, biodegradability, and eco-friendliness.

[0003] However, despite these many advantages, jute production still faces numerous challenges, particularly the threat of pests. Pests such as beet armyworm larvae, jute armyworms, and yellow mites have been reported as major threats to the jute industry. In the face of these threats, the preferred pest control method is the use of insecticides due to their advantages of rapid action, scalability, and cost-effectiveness. However, most insecticides are only effective against specific pest species; therefore, indiscriminate use of insecticides often fails to achieve good results. Farmers often struggle to accurately identify the types of pests affecting them, which hinders jute production.

[0004] To address the real-world problems faced by jute growers, researchers are focusing on providing efficient, rapid, and accurate artificial intelligence (AI)-based solutions for early identification of jute pests. Identifying crop diseases and pests is one of the key challenges in modern agricultural development. Through the in-depth application of AI algorithms such as deep learning (DL) and transfer learning (TL), AI technology is closely integrated with modern agricultural techniques, bringing enormous potential for accurate identification of crop diseases and pests.

[0005] Currently, advanced object detectors such as YOLOv7 are widely recognized and considered one of the fastest and most accurate real-time object detection tools to date. However, the ordinary YOLOv7 algorithm has problems when detecting jute pests, including redundant model calculations, insufficient extraction of original image features, and false positives and false negatives when detecting small-scale targets. Summary of the Invention

[0006] To address the problems in the background technology, this paper proposes a jute pest detection method based on an improved YOLOv7 model. Partial convolutions from the FasterNet network are introduced into the Efficient Network Module (ELAN) of the YOLOv7 backbone, effectively reducing redundant computations and memory accesses, and improving the efficiency of spatial feature extraction. Furthermore, a feature fusion module and a P6 detection layer are introduced into YOLOv7. The feature fusion module fully utilizes semantic features at different levels, making the feature information in the new feature maps more closely connected. The P6 detection layer expands the model's receptive field, improving the network's ability to perceive global features. The improved model effectively enhances computational efficiency, strengthens feature extraction from the original image, improves detection accuracy, and is applied to jute pest detection.

[0007] To achieve the above objectives, the technical solution presented in this paper is as follows:

[0008] A method for detecting jute pests based on an improved YOLOv7 model includes the following steps: constructing a jute pest detection model based on an improved YOLOv7 model, wherein the improved YOLOv7 model includes an efficient aggregation network module (ELAN) with partial convolution, a feature fusion module and a P6 detection layer module, a WIoU loss function and a YOLOv7 network model; acquiring jute pest images of different scenes and types to form an original dataset; performing sample augmentation on the original data to form a training dataset, and dividing the training dataset into a training dataset and a test dataset; inputting the training dataset into the jute pest detection model based on the improved YOLOv7 model for training, continuously adjusting the relevant training parameters, comparing the results of multiple training iterations using an accuracy metric, and saving the jute pest detection model based on the improved YOLOv7 model with the best performance; using the jute pest detection model based on the improved YOLOv7 model to identify the jute pest images to be detected, and obtaining the location and type of pests in the images.

[0009] According to an embodiment of the present invention, a jute pest detection model based on an improved YOLOv7 model is constructed, comprising the following steps: embedding the partially convolutional efficient aggregation network module (ELAN), feature fusion module, and P6 detection layer module into the YOLOv7 network model; and using the WIoU loss function as the loss function for bounding box regression to obtain the jute pest detection model based on the improved YOLOv7 model.

[0010] According to one embodiment of the present invention, the Efficient Aggregation Network Module (ELAN) with partially convolutional features is specifically used to: reduce the computational cost of the network without disrupting the original gradient path when processing large-scale data or large-scale computation; and simultaneously enhance feature representation by aggregating features from different layers of the network, enabling the network to capture richer contextual and detailed information. The specific steps are as follows:

[0011] Step 1: Construct a jute pest detection model based on an improved YOLOv7 model. This improved YOLOv7 model replaces the original efficient aggregation network module ELAN with a partially convolutional ELAN module. The ELAN module has two branches: the first branch uses a 1x1 convolution to change the number of channels, and the second branch first uses a 1x1 convolution module to change the number of channels, and then uses four 3x3 convolution modules for feature extraction. The partially convolutional ELAN module replaces these four 3x3 convolution modules with partially convolutional modules.

[0012] Step 2: Obtain images of jute pests in different scenes and of different types to form the original dataset;

[0013] Step 3: Perform sample augmentation on the original data to form a training dataset, and then divide the training dataset into a training dataset and a test dataset;

[0014] Step 4: Input the training set data into the jute pest detection model based on the improved YOLOv7 model for training, continuously adjust the relevant training parameters, compare the results of multiple training sessions using the accuracy index, and save the jute pest detection model with the best performance of the improved YOLOv7 model.

[0015] Step 5: Use the improved YOLOv7 model with the best performance to identify the jute pest detection model to identify the location and type of pests in the jute pest images.

[0016] Furthermore, the number of floating-point operations (FLOPs) for partial convolutions is only a fraction of that for regular convolutions. The memory access volume is only that of regular convolution.

[0017] Furthermore, the jute pest detection model based on the improved YOLOv7 model adds a feature fusion module between the Neck module and the Head module, and adds a P6 detection layer. The specific implementation process is as follows;

[0018] Step 21: Assume that the feature maps output by the Neck module of the YOLOv7 model are named M3, M4 and M5 in descending order of resolution. Then, downsample M5 to obtain M6.

[0019] Step 22: The four feature maps in Step 21 have the same resolution. Feature map M4 is selected as the baseline resolution. The lower resolution feature map is adjusted to the baseline resolution using the nearest neighbor interpolation algorithm, and the higher resolution feature map is adjusted to the baseline resolution using the max pooling method, resulting in N3, N4, N5 and N6.

[0020] Step 23: Use the averaging method to obtain the balanced features of the four feature maps, add the four feature maps according to their corresponding feature points and take the average to obtain the fused feature map;

[0021] Step 24: Refine the fused feature map using a non-local self-attention model;

[0022] Step 25: After obtaining the refined fused feature map, the same method as in step 2 but in reverse order is used to adjust the balanced semantic features. Specifically, first select the balanced feature with the same resolution size as M4 as R4, apply the max pooling method to the balanced feature to obtain R5 and R6, and adjust the resolution to the size of M5 and M6. Then, use the nearest neighbor interpolation algorithm to adjust the resolution of the balanced feature to R3 with the same size as M3.

[0023] Step 26: The fused feature maps R3, R4, R5, and R6 are adjusted by reparameterized convolution RepConv, and then 1×1 convolution is used to predict the three parts: confidence (objectness), class, and bounding box (bbox), resulting in detection layers P3, P4, P5, and P6.

[0024] Furthermore, the calculation formula for the Non-local self-attention model in step 24 is as follows:

[0025]

[0026] Let i be one of the positions in the output feature map, j be the index of all possible positions, x be the input signal, y be the output signal of the same magnitude as x, and f(x) be the input signal. i ,x j The ) function is a pairwise calculation function, and the pairwise function used is the EmbeddedGaussian function, the formula of which is shown below.

[0027]

[0028] Where θ(x) i ) and φ(x j) are respectively for x i and x j The linear transformation function, The normalization function is shown in the formula below.

[0029] g(x j ) is x j The linear change is given by the formula: g(x) j ) = W g x j W g It is the learned weight matrix.

[0030] Furthermore, the loss functions used in the jute pest detection model based on the improved YOLOv7 model include coordinate loss, target confidence loss, and classification loss.

[0031] Furthermore, the coordinate loss function used is the CIoU loss function, calculated as follows:

[0032]

[0033] Where, the Intersection over Union (IoU) represents the proportion of intersection between the predicted bounding box and the actual bounding box, ρ represents the Euclidean distance between the center point of the predicted bounding box and the center point of the actual bounding box, and b is the coordinate of the center point of the predicted bounding box. gt c represents the coordinates of the center point of the actual boundary. w c h The width and height of the minimum bounding rectangle (minimum common bounding rectangle) of the predicted bounding box and the true bounding box, w. gt h gt is the width and height of the actual bounding box, and w and h are the width and height of the predicted bounding box.

[0034] Furthermore, the WIoU loss function is used as the bounding box regression loss function instead of the CIoU loss function. The specific implementation is as follows:

[0035] (1) WIoU v1 introduces distance as a measure of attention. When the object box and the predicted box overlap within a certain range, the penalty of geometric metric is reduced, which enables the model to achieve better generalization ability. The formula for calculating WIoU v1 is as follows:

[0036]

[0037]

[0038] in, This represents the standard IOU loss function, used to measure the inconsistency between the predicted bounding box and the ground truth bounding box. x and y represent the coordinates of the predicted box, while x... gtand y gt The coordinates of the Ground Truth are represented, with the corresponding H and W values ​​representing the width and height of the two boxes, respectively.

[0039] (2) By constructing monotonic focusing coefficients Applying WIoU v2 to WIoU v1 effectively reduces the weight of simple samples in the loss value, taking into account... During model training, the value decreases as the model trains, leading to slower convergence. Therefore, a [missing information] is introduced. normalization using the average value The formula for WIoU v2 is as follows:

[0040]

[0041] Where γ is a hyperparameter;

[0042] (3) WIoU v3 defines outlier β to measure the quality of the anchor frame. Based on β, a non-monotonic focusing factor γ is constructed and applied to WIoU v1. The WIoU v3 formula is shown below:

[0043]

[0044] in, α and δ are hyperparameters, and β represents the anomaly level of the predicted bounding box. The formula for calculating β is: The smaller the anomaly degree β, the higher the quality of the anchor box. Therefore, using β to construct a non-monotonic focal number can assign a smaller gradient gain to the prediction box with larger outliers, effectively reducing the harmful gradients of low-quality training samples.

[0045] Furthermore, step 6 is included, which uses objective evaluation metrics to evaluate the effectiveness of the detection results. The objective evaluation includes prediction precision, recall, mAP@0.5, mAP@0.5:0.95, and GFLOPs.

[0046] This invention also proposes a jute pest detection system based on an improved YOLOv7 model, comprising the following units:

[0047] The model building unit is used to construct a jute pest detection model based on the improved YOLOv7 model. This improved YOLOv7 model replaces the original efficient aggregation network module ELAN with a partially convolutional ELAN module. The ELAN module has two branches: the first branch uses a 1x1 convolution to change the number of channels, and the second branch first uses a 1x1 convolution module to change the number of channels, and then uses four 3x3 convolution modules for feature extraction. The partially convolutional ELAN module replaces these four 3x3 convolution modules with partially convolutional modules.

[0048] The dataset acquisition unit is used to acquire images of jute pests from different scenes and types to form the original dataset.

[0049] The dataset partitioning unit is used to perform sample augmentation on the original data to form a training dataset, and to divide the training dataset into a training dataset and a test dataset.

[0050] The model training unit is used to input the training set data into the jute pest detection model based on the improved YOLOv7 model for training, continuously adjust the relevant training parameters, compare the results of multiple training sessions using the accuracy index, and save the jute pest detection model with the best performance of the improved YOLOv7 model.

[0051] The detection unit is used to identify jute pest detection images using the improved YOLOv7 model with optimal performance, and to obtain the location and type of pests in the jute pest images.

[0052] The present invention also provides a non-volatile computer storage medium storing computer-executable instructions that execute the above-described jute pest detection method based on the improved YOLOv7 model.

[0053] The present invention also provides a computer program product, which includes a computer program stored on a non-volatile computer storage medium. The computer program includes program instructions, which, when executed by a computer, cause the computer to perform the above-described jute pest detection method based on the improved YOLOv7 model.

[0054] The present invention provides an electronic device, comprising: at least one processor, and a memory communicatively connected to the at least one processor, wherein the memory stores instructions that are executed by the at least one processor to cause the at least one processor to perform a jute pest detection method based on an improved YOLOv7 model.

[0055] The beneficial effects of this invention are:

[0056] 1. Due to the redundant computation in the original YOLOv7 neural network structure, more floating-point operations (FLOPs) are generated, which increases the model latency. Based on the above factors, this paper replaces the four 3*3 convolutional modules in the Efficient Aggregation Network (ELAN) module of the YOLOv7 backbone network with partial convolutions, which greatly reduces the computational load and memory access frequency of the module.

[0057] 2. Improve the prediction network by introducing a feature fusion module and a P6 detection layer. The original YOLOv7 prediction network (Head) only has three detection layers: P3, P4, and P5. The model is lacking in feature extraction and multi-scale target recognition and detection capabilities. This paper adds a low-resolution feature map corresponding to the P6 detection layer to the prediction network and fuses all feature maps. The feature information in the new feature map is more closely related. Together with the newly added P6 detection layer, the model can capture the multi-scale features of the target more comprehensively, thereby improving the performance and accuracy of object detection to a certain extent.

[0058] 3. Improved Loss Function: Traditional methods using Intersection over Union (IoU) as the loss function sometimes lead to suboptimal results. For example, due to the small pixel base, smaller objects have a smaller weight in the IoU calculation, which may cause the model to ignore these smaller targets due to bias. This paper adopts the Wise-IoU (WIoU) loss function as the loss function for bounding box regression, which pays more attention to the aspect ratio, center distance, and overlapping area of ​​the bounding box. Moreover, a dynamic non-monotonic focusing mechanism is introduced, and a reasonable gradient gain allocation strategy is applied to evaluate the quality of the anchor box, effectively reducing the harmful gradients of the quality training samples and improving the network accuracy. Attached Figure Description

[0059] Figure 1 This is a flowchart illustrating the method of the present invention.

[0060] Figure 2 This is a schematic diagram of the structure of the Efficient Convergence Network Module (ELAN) introduced in this invention.

[0061] Figure 3 The overall structure diagram of the feature fusion module, the P6 detection layer neck network, and the prediction network (Head) introduced in this invention is shown. Detailed Implementation

[0062] The technical solution of the invention will be described below with reference to the accompanying drawings. The following embodiments are explanations of the invention and do not represent limitations on the invention.

[0063] This invention provides a method for detecting jute pests based on an improved YOLOv7 model, the basic process of which is as follows: Figure 1 As shown, it includes the following steps:

[0064] Step 1: Construct a jute pest detection model based on an improved YOLOv7 model. This model includes an efficient aggregation network module (ELAN) incorporating partial convolutions, a feature fusion module, a P6 detection layer, a WIoU loss function, and the YOLOv7 network model. Specifically, it includes the following steps:

[0065] Step 11: The YOLOv7 network reads the image from the input layer and preprocesses the image data. The image scale is adjusted to the size expected by the network (640*640*3) to meet the input requirements of the backbone network, and the image is normalized so that the pixel values ​​fall within a specific range.

[0066] Step 12: The preprocessed image is passed to the backbone network for feature extraction. This mainly includes an efficient aggregation network module (ELAN) with partial convolution and a max pooling module (MP). The MP module uses max pooling layers and 3×3 convolutional kernels with a stride of 2, then concatenates them. This not only obtains the maximum value information of local small regions obtained through max pooling, but also considers all the value information of local small regions through convolution operations. The ELAN module with partial convolution controls the shortest and longest gradient paths, enabling the network to... It can learn more features and has stronger robustness. The ELAN module has two branches. The first branch uses a 1x1 convolution to change the number of channels. The second branch first uses a 1x1 convolution module to change the number of channels, and then uses four 3x3 convolution modules for feature extraction. The ELAN module that introduces partial convolution replaces these four 3x3 convolution modules with partial convolution. Then, in the feature fusion operation, it uses partial convolution, which is an optimization of the regular convolution, greatly reducing the module's computational load and memory access frequency. Figure 2 This diagram illustrates the structure of an ELAN module with partial convolution. The specific steps of the partial convolution operation are as follows:

[0067] Step 121, the memory access formula for regular convolution can be expressed as follows:

[0068] h×w×2c+k 2 ×c≈h×w×2c

[0069] In the formula, h and w represent the length and width of the image, respectively, c represents the number of channels, and k represents the kernel size.

[0070] Step 122: Depthwise convolution is a commonly used method for optimizing backbone networks. Replacing conventional convolution with depthwise convolution may lead to a decrease in network accuracy. To compensate for the accuracy loss caused by depthwise convolution, the number of channels in the depthwise convolution needs to be increased from c to c', which is more than the number of channels c in conventional convolution. However, this increases the number of memory accesses, thereby increasing latency and reducing overall computation speed. The memory access of depthwise convolution can be expressed by the formula:

[0071] h×w×2c′+k 2 ×c′≈h×w×2c′

[0072] When c′>c, it is clear that the number of memory accesses for depthwise convolution is higher than that for regular convolution.

[0073] Step 123, the partial convolution proposed in the FasterNet network, can reduce redundant computation and memory accesses. FLOPs represent the number of floating-point operations. The FLOPs of a regular convolution can be expressed by the following formula:

[0074]

[0075] In ratio In general, the FLOPs of partial convolutions are only a fraction of those of regular convolutions. This results in a significant reduction in FLOPs. Simultaneously, the memory access volume of some convolutions is also significantly reduced compared to regular convolutions, as shown in the following memory access formula:

[0076]

[0077] when At that time, the memory access volume of partial convolution is only that of regular convolution.

[0078] Step 124: The fused features are then processed through additional convolutional layers to further refine and optimize these features;

[0079] Step 13: The features extracted from the backbone are fed into the neck network for feature extraction and fusion at different scales. An M6 feature map corresponding to the P6 detection layer is generated based on the deepest M5 feature map. All feature maps are fused, and the number of channels in the fused new feature maps at different scales is adjusted using reparameterized convolution (RepConv). Finally, a 1x1 convolution is used to predict the target's location and category. Figure 3 This diagram illustrates the overall structure of the Neck and Head sections after introducing the feature fusion module and the P6 detection layer. The specific steps for introducing the feature fusion module and the P6 detection layer are as follows:

[0080] Step 131: Perform convolution operation again on the feature map M5 with the lowest resolution to obtain a new feature map. There are a total of 4 feature maps, which are named M3, M4, M5 and M6 in descending order of resolution.

[0081] Step 132: Adjust the four feature maps in step 131 to the same resolution. Select feature map M4 as the baseline resolution. Use the nearest neighbor interpolation algorithm to adjust the lower resolution feature map to the baseline resolution, and use the max pooling method to adjust the higher resolution feature map to the baseline resolution, to obtain N3, N4, N5 and N6.

[0082] Step 133: Use the averaging method to obtain the balanced features of the four feature maps. Add the four feature maps together according to their corresponding feature points and take the average.

[0083] Step 134, Feature Fusion, using a Non-local self-attention model for refinement. The calculation formula is shown below:

[0084]

[0085] Let i be one position in the output feature map, and j be the index of all possible positions. f(x) i ,x j The pairwise function is a pairwise calculation function. The pairwise function used in this article is the Embedded Gaussian function, and its formula is shown below.

[0086]

[0087] Where θ(x) i ) and φ(x j ) are respectively for x i and x j The linear transformation function, The normalization function is shown in the formula below.

[0088] g(x j ) is x j The linear change is given by the formula: g(x) j ) = W g x j W g It is the learned weight matrix.

[0089] Step 135, obtain the fused feature map: Use the same method as in step 132 but in reverse order to adjust the balanced semantic features. Specifically, first select the balanced feature with the same resolution size as M4 as R4, apply the max pooling method to the balanced feature to obtain R5 and R6, and adjust the resolution to the size of M5 and M5. Then use the nearest neighbor interpolation algorithm to adjust the resolution of the balanced feature to R3 with the same size as M3.

[0090] Step 136: The fused feature maps R3, R4, R5, and R6 are adjusted for the number of channels through reparameterized convolution (RepConv). Then, 1×1 convolution is used to predict the three parts: objectness, class, and bounding box, resulting in detection layers P3, P4, P5, and P6. By introducing the feature fusion module and the P6 detection layer, the model's ability to extract image features and its accuracy in identifying jute pests in complex backgrounds will be significantly improved.

[0091] Step 14: Modify the loss function by replacing the CIoU loss function with the WIoU (Wise-IoU) loss function. The WIoU loss function introduces a dynamic non-monotonic focusing mechanism and applies a reasonable gradient gain allocation strategy to evaluate the quality of the anchor boxes, effectively reducing harmful gradients in quality training samples. The specific implementation steps of WIoU are as follows:

[0092] Step 141: The loss function of the YOLOv7 network consists of coordinate loss, object confidence loss, and classification loss. The coordinate loss function uses the CIoU loss function. However, CIoU does not consider aspect ratio as a penalty factor in the loss function. If the aspect ratios of the ground truth bounding box and the predicted bounding box are the same, but their width and height values ​​are different, the penalty term cannot reflect the true difference between the two boxes. Therefore, the CIoU loss function is very sensitive to small object positional deviations, which will reduce the detection performance of the network model. Its calculation formula is as follows:

[0093]

[0094] Where, the Intersection over Union (IoU) represents the proportion of intersection between the predicted bounding box and the actual bounding box, ρ represents the Euclidean distance between the center point of the predicted bounding box and the center point of the actual bounding box, and b is the coordinate of the center point of the predicted bounding box. gt c represents the coordinates of the center point of the actual boundary. w c h The width and height of the minimum bounding rectangle (i.e., the minimum common bounding rectangle) of the predicted bounding box and the true bounding box, w gt h gt is the width and height of the actual bounding box, and w and h are the width and height of the predicted bounding box.

[0095] Step 142: The WIoU (Wise-IoU) loss focuses more on the aspect ratio, center distance, and overlapping regions of the bounding boxes, and introduces a dynamic non-monotonic focusing mechanism. WIoU applies a reasonable gradient gain allocation strategy to evaluate the quality of the anchor boxes. There are three versions of WIoU: WIoU v1 is designed based on the attention-based prediction box loss, while WIoU v2 and WIoU v3 introduce a focusing coefficient by constructing gradient gains and using algorithmic methods on this basis.

[0096] WIoU v1 introduces distance as a metric for attention. When the object box and the predicted box overlap within a certain range, reducing the penalty for geometric metric improves the model's generalization ability. The formula for calculating WIoU v1 is shown below:

[0097]

[0098]

[0099] in, The standard IOU loss function measures the inconsistency between the predicted bounding box and the ground truth bounding box. x and y represent the coordinates of the predicted box, while x... gt and y gt The coordinates of the Ground Truth are represented, with the corresponding H and W values ​​representing the width and height of the two boxes, respectively.

[0100] By constructing monotonic focusing coefficients Applying WIoU v2 to WIoU v1 effectively reduces the weight of simple samples in the loss value, taking into account... During model training, the value decreases as the model trains, leading to slower convergence. Therefore, a [missing information] is introduced. normalization using the average value The formula for WIoU v2 is as follows:

[0101]

[0102] Where γ is a hyperparameter;

[0103] WIoU v3 defines outlier β to measure anchor frame quality, constructs a non-monotonic focusing factor γ based on β, and applies γ to WIoU v1. The WIoU v3 formula is shown below:

[0104]

[0105] in, α and δ are hyperparameters, and β represents the anomaly level of the predicted bounding box. The formula for calculating β is: The smaller the anomaly degree β, the higher the quality of the anchor box. Therefore, using β to construct a non-monotonic focal number can assign a smaller gradient gain to the prediction box with larger outliers, effectively reducing the harmful gradients of low-quality training samples.

[0106] Step 143: Replace the CIoU loss function with the WIoU v3 loss function, which has a two-layer attention mechanism and a dynamic non-monotonic FM mechanism. FM is a static focusing mechanism. WIoU v3 can effectively improve the overall performance of the model by balancing the learning of low-quality samples and high-quality samples.

[0107] Step 2: Obtain images of jute pests in different scenes and of different types to form the original dataset.

[0108] Specifically, this invention collected images of nine types of pests that seriously damage jute production by analyzing reports released by my country's Ministry of Agriculture and Rural Affairs regarding the damage caused by various pests. Original images were obtained from Baidu Image Library, Google Image Library, and the open dataset website Kaggle.

[0109] Step 3: Perform sample augmentation on the original data to form a training dataset, and then divide the training dataset into a training dataset and a test dataset.

[0110] Specifically, data augmentation methods using content and geometric transformations were applied to expand the jute pest dataset based on the original data. These methods included random image cropping, horizontal flipping and translation / rotation, color jittering, and Gaussian blurring. To reduce the impact of dataset partitioning on the experiment, a random partitioning method was used, dividing the augmented dataset into training and validation sets in an 8:2 ratio. The "LabelImg" software was used to annotate each image in the dataset, clearly marking the true bounding boxes of the pests.

[0111] Step 4: Input the training set data into the jute pest detection model based on the improved YOLOv7 model for training. Use the accuracy index to compare the results of multiple training sessions and save the jute pest detection model with the best performance of the improved YOLOv7 model.

[0112] Specifically, the relevant training parameters, such as the number of iterations and learning rate, are continuously adjusted and the training is repeated. Mean accuracy (mAP) is used as the evaluation metric to evaluate the results of multiple training iterations, and the optimal rice pest detection model fused with a deformable convolutional neural network is saved. The formula for calculating mAP is shown below.

[0113]

[0114] AP is the average precision of a class, and its value is the area enclosed by the PR (Precision Recall) curve on the coordinate axis and the x-axis and y-axis. N represents the number of all pest classes in the dataset.

[0115] Step 5: Use the jute pest detection model based on the improved YOLOv7 model to identify the pest images to be detected, and obtain the location and type of pests in the jute pest images to be detected.

[0116] Specifically, in the head part of the network, the network predicts the pest features of jute pest images, generates bounding boxes and predicts object categories, and finally displays the detection results from the image, including the rectangle of the pest location and the pest category and classification score (classification confidence).

[0117] To better illustrate the effectiveness of this invention, the detection performance of the improved YOLOv7 and the original YOLOv7 on the dataset used in this invention was compared, and the results are shown in Table 1.

[0118] Table 1 compares the detection accuracy of YOLOv7.

[0119]

[0120] In the table, Precision and Recall can comprehensively evaluate the results of four scenarios when detecting bounding boxes: correct prediction of positive samples (TP), incorrect prediction of positive samples (TN), correct prediction of negative samples (FP), and incorrect prediction of negative samples (FN). The F1 score represents the harmonic mean of precision and recall. When dealing with imbalanced data, it provides a single metric that simultaneously considers the model's precision and recall. Its calculation principle is shown in the formula below.

[0121]

[0122]

[0123]

[0124] This invention also uses mAP@0.5 and mAP@0.5:0.95 to evaluate the model's detection accuracy, and GFLOPs to measure the model's computational complexity. mAP (mean accuracy) evaluates the model's prediction accuracy at various recall rates using different IoU thresholds, reflecting the model's localization and classification detection capabilities. mAP@0.5 and mAP@0.95 are calculated at IoU thresholds of 0.5 and 0.95, respectively, while mAP@0.5:0.95 is calculated and averaged over IoU thresholds ranging from 0.5 to 0.95 (with a step size of 0.05), providing a more stringent evaluation standard and demonstrating the model's performance changes under different IoU thresholds. The calculation formula is shown below.

[0125]

[0126]

[0127]

[0128]

[0129] In the formula, m represents the number of categories, n represents the number of targets predicted in a single category, and P(r) represents the precision value with recall r. mAP@r represents the mAP value at a specific IoU threshold r.

[0130] Based on the mAP calculations obtained from the tests, compared with the original YOLOv7 algorithm, the improved jute pest identification and detection model of this invention improved precision and recall by 3.45% and 1.76% respectively, and achieved mAP@0.5 of 95.68% and mAP@0.5:0.95 of 67.11%, which are improvements of 2.24% and 3.25% respectively compared with YOLOv7. GFLOPs decreased from 105.3 to 88.4, a reduction of 16.05%; F1 score increased from 94.19 to 96.77%, a total improvement of 2.58%. Therefore, the network model proposed in this invention shows a certain degree of improvement in the identification accuracy of various jute pests on the jute pest dataset.

[0131] In practical implementation, the method provided by this invention can be implemented automatically via software, or the corresponding system can be implemented in a modular manner. This invention provides a jute pest detection system based on an improved YOLOv7 model, comprising the following units:

[0132] The model building unit is used to construct a jute pest detection model based on the improved YOLOv7 model. This improved YOLOv7 model replaces the original efficient aggregation network module ELAN with a partially convolutional ELAN module. The ELAN module has two branches: the first branch uses a 1x1 convolution to change the number of channels, and the second branch first uses a 1x1 convolution module to change the number of channels, and then uses four 3x3 convolution modules for feature extraction. The partially convolutional ELAN module replaces these four 3x3 convolution modules with partially convolutional modules.

[0133] The dataset acquisition unit is used to acquire images of jute pests from different scenes and types to form the original dataset.

[0134] The dataset partitioning unit is used to perform sample augmentation on the original data to form a training dataset, and to divide the training dataset into a training dataset and a test dataset.

[0135] The model training unit is used to input the training set data into the jute pest detection model based on the improved YOLOv7 model for training, continuously adjust the relevant training parameters, compare the results of multiple training sessions using the accuracy index, and save the jute pest detection model with the best performance of the improved YOLOv7 model.

[0136] The detection unit is used to identify jute pest detection images using the improved YOLOv7 model with optimal performance, and to obtain the location and type of pests in the jute pest images.

[0137] Based on all the above embodiments, a complete method for detecting jute pests can be formed.

[0138] The specific embodiments described herein are merely illustrative of the principles and implementation methods of the present invention. The above examples are only intended to help understand the method and core ideas of the present invention; furthermore, those skilled in the art to which this invention pertains can make various modifications or additions to the described specific embodiments or use similar methods to replace them, but without departing from the spirit of the present invention or exceeding the scope defined by the appended claims.

Claims

1. A method for detecting jute pests based on an improved YOLOv7 model, characterized in that, The steps include the following: Step 1: Construct a jute pest detection model based on an improved YOLOv7 model. This improved YOLOv7 model replaces the original efficient aggregation network module ELAN with a partially convolutional ELAN module. The ELAN module has two branches: the first branch uses a 1x1 convolution to change the number of channels, and the second branch first uses a 1x1 convolution module to change the number of channels, and then uses four 3x3 convolution modules for feature extraction. The partially convolutional ELAN module replaces these four 3x3 convolution modules with partially convolutional modules. The jute pest detection model based on the improved YOLOv7 model adds a feature fusion module between the Neck module and the Head module, and adds a P6 detection layer. The specific implementation process is as follows: Step 21: Assume that the feature maps output by the Neck module of the YOLOv7 model are named M3, M4 and M5 in descending order of resolution. Then, downsample M5 to obtain M6. Step 22: The four feature maps in Step 21 have the same resolution. Feature map M4 is selected as the baseline resolution. The lower resolution feature map is adjusted to the baseline resolution using the nearest neighbor interpolation algorithm, and the higher resolution feature map is adjusted to the baseline resolution using the max pooling method, resulting in N3, N4, N5 and N6. Step 23: Use the averaging method to obtain the balanced features of the four feature maps, add the four feature maps according to their corresponding feature points and take the average to obtain the fused feature map; Step 24: Refine the fused feature map using a non-local self-attention model; Step 25: After obtaining the refined fused feature map, adjust the balanced semantic features using the same method as in Step 22, but in reverse order. Specifically, first select the balanced feature with the same resolution size as M4 as R4, then apply max pooling to the balanced feature to obtain R5 and R6, and adjust the resolution to M5. Size 6, then use the nearest neighbor interpolation algorithm to adjust the balanced feature resolution to and respectively. 3 of the same size 3; Step 26, merge the feature maps 3. R4, R5, and R6 are adjusted by reparameterized convolution RepConv channel number, and then 1×1 convolution is used to predict the three parts of confidence objectness, class and bounding box, to obtain detection layers P3, P4, P5 and P6; Step 2: Obtain images of jute pests in different scenes and of different types to form the original dataset; Step 3: Perform sample augmentation on the original data to form a training dataset, and then divide the training dataset into a training dataset and a test dataset; Step 4: Input the training set data into the jute pest detection model based on the improved YOLOv7 model for training, continuously adjust the relevant training parameters, compare the results of multiple training sessions using the accuracy index, and save the jute pest detection model with the best performance of the improved YOLOv7 model. Step 5: Use the improved YOLOv7 model with the best performance to identify the jute pest detection model to identify the location and type of pests in the jute pest images.

2. The method for detecting jute pests based on an improved YOLOv7 model as described in claim 1, characterized in that: The number of floating-point operations (FLOPs) for partial convolution is only a fraction of that for regular convolution. The memory access volume is only that of regular convolution. .

3. The method for detecting jute pests based on an improved YOLOv7 model as described in claim 1, characterized in that: The calculation formula for the Non-local self-attention model in step 24 is shown below: set up It is one of the positions in the output feature map. Here, x is the index of all possible positions, y is the input signal, and y is the output signal of the same magnitude as x. The function is a pairwise computation function, using the Embedded Gaussian function, whose formula is shown below. in and They are respectively for and The linear transformation function, The normalization function is shown in the formula below. g ( )yes The linear change is expressed by the formula: ,in It is the learned weight matrix.

4. The method for detecting jute pests based on an improved YOLOv7 model as described in claim 1, characterized in that: The loss functions used in the jute pest detection model based on the improved YOLOv7 model include coordinate loss, target confidence loss, and classification loss.

5. The method for detecting jute pests based on an improved YOLOv7 model as described in claim 4, characterized in that: The coordinate loss function used is the CIoU loss function, and the calculation formula is as follows: Wherein, the Intersection over Union (IoU) represents the proportion of intersection between the predicted bounding box and the actual bounding box. This represents the Euclidean distance between the center point of the predicted bounding box and the center point of the ground truth bounding box. It predicts the coordinates of the center point of the bounding box. These are the coordinates of the center point of the actual boundary. , The width and height of the minimum bounding rectangle (i.e., the minimum common bounding rectangle) between the predicted bounding box and the true bounding box are calculated. , These are the width and height of the actual boundary. and It predicts the width and height of the bounding box.

6. The method for detecting jute pests based on an improved YOLOv7 model as described in claim 5, characterized in that: The WIoU loss function is used instead of the CIoU loss function for bounding box regression. The specific implementation is as follows: (1) WIoU v1 introduces distance as a measure of attention. When the object box and the predicted box overlap within a certain range, the penalty of geometric metric is reduced to enable the model to achieve better generalization ability. The formula for calculating WIoU v1 is as follows: in, This represents the standard IOU loss function, used to measure the inconsistency between the predicted bounding box and the ground truth bounding box. and This represents the coordinates of the predicted bounding box, while and Represents the coordinates of the Ground Truth, and the corresponding... H and W The values ​​represent the width and height of the two boxes, respectively; (2) By constructing monotonic focusing coefficients Applying WIoU v2 to WIoU v1 effectively reduces the weight of simple samples in the loss value, considering... During model training, the value decreases as the model trains, leading to slower convergence. Therefore, a [missing information] is introduced. normalization using the average value The formula for WIoU v2 is as follows: in, It is a hyperparameter; (3) WIoU v3 defines outliers To measure the quality of the anchor frame, based on Constructing non-monotonic focusing factors and will The formulas for WIoU v1 and WIoU v3 are shown below: in, , and It's a hyperparameter. The degree of anomalousness of the predicted bounding box is indicated by the following formula: abnormality The smaller the value, the higher the quality of the anchor frame; therefore, utilizing... Constructing a non-monotonic focal number allows for the allocation of smaller gradient gains to prediction boxes with larger outliers, effectively reducing harmful gradients from low-quality training samples.

7. The method for detecting jute pests based on an improved YOLOv7 model as described in claim 1, characterized in that: It also includes step 6, which uses objective evaluation metrics to evaluate the effectiveness of the detection results. The objective evaluation includes prediction precision, recall, mAP@0.5, mAP@0.5:0.95, and GFLOPs.

8. A jute pest detection system based on an improved YOLOv7 model, characterized in that, Includes the following units: The model building unit is used to construct a jute pest detection model based on the improved YOLOv7 model. This improved YOLOv7 model replaces the original efficient aggregation network module ELAN with a partially convolutional ELAN module. The ELAN module has two branches: the first branch uses a 1x1 convolution to change the number of channels, and the second branch first uses a 1x1 convolution module to change the number of channels, and then uses four 3x3 convolution modules for feature extraction. The partially convolutional ELAN module replaces these four 3x3 convolution modules with partially convolutional modules. The jute pest detection model based on the improved YOLOv7 model adds a feature fusion module between the Neck module and the Head module, and adds a P6 detection layer. The specific implementation process is as follows: Step 21: Assume that the feature maps output by the Neck module of the YOLOv7 model are named M3, M4 and M5 in descending order of resolution. Then, downsample M5 to obtain M6. Step 22: The four feature maps in Step 21 have the same resolution. Feature map M4 is selected as the baseline resolution. The lower resolution feature map is adjusted to the baseline resolution using the nearest neighbor interpolation algorithm, and the higher resolution feature map is adjusted to the baseline resolution using the max pooling method, resulting in N3, N4, N5 and N6. Step 23: Use the averaging method to obtain the balanced features of the four feature maps, add the four feature maps according to their corresponding feature points and take the average to obtain the fused feature map; Step 24: Refine the fused feature map using a non-local self-attention model; Step 25: After obtaining the refined fused feature map, adjust the balanced semantic features using the same method as in Step 22, but in reverse order. Specifically, first select the balanced feature with the same resolution size as M4 as R4, then apply max pooling to the balanced feature to obtain R5 and R6, and adjust the resolution to M5. Size 6, then use the nearest neighbor interpolation algorithm to adjust the balanced feature resolution to and respectively. 3 of the same size 3; Step 26, merge the feature maps 3. R4, R5, and R6 are adjusted by reparameterized convolution RepConv channel number, and then 1×1 convolution is used to predict the three parts of confidence objectness, class and bounding box, to obtain detection layers P3, P4, P5 and P6; The dataset acquisition unit is used to acquire images of jute pests from different scenes and types to form the original dataset. The dataset partitioning unit is used to perform sample augmentation on the original data to form a training dataset, and to divide the training dataset into a training dataset and a test dataset. The model training unit is used to input the training set data into the jute pest detection model based on the improved YOLOv7 model for training, continuously adjust the relevant training parameters, compare the results of multiple training sessions using the accuracy index, and save the jute pest detection model with the best performance of the improved YOLOv7 model. The detection unit is used to identify jute pests in images of jute pests using an improved YOLOv7 model with optimal performance, and to obtain the location and type of pests in the images of jute pests to be detected.

Citation Information

Patent Citations

  • Rapid pest detection method based on improved YOLO V4

    CN114220035A

  • Litchi disease and insect pest detection method based on improved EfficentDet

    CN114898359A