Cotton disease and insect pest identification method, system, equipment and medium
By optimizing the YOLOv8 model through lightweight networks and feature fusion technology, the problems of high computational cost and insufficient real-time performance of cotton pest and disease identification models are solved, achieving efficient and accurate pest and disease detection, which is suitable for embedded devices and complex environments.
Patent Information
- Application Number
- CN202511147946.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-16
- Publication Date
- 2025-11-18
AI Technical Summary
Existing cotton pest and disease identification models require a large amount of computation and cannot meet real-time requirements, resulting in poor identification results and limiting their widespread application in agriculture.
We employ a lightweight GhostShiftNet network as the backbone, introduce a Triplet attention mechanism and a multi-scale feature fusion module, and combine it with an improved YOLOv8 object detection model. Through feature pyramids and top-down feature fusion, we generate multi-scale information feature maps and optimize the model using the SIoU loss function and Dynamic Pruning algorithm.
It improves the accuracy and positioning precision of cotton pest and disease identification, reduces the number of computational parameters, enhances the real-time performance and detection speed of the model, is suitable for resource-constrained embedded devices, and meets the pest and disease detection needs in complex cotton field environments.
Smart Images

Figure CN120976977A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of pest and disease identification technology, and in particular to a method, system, device and medium for identifying cotton pests and diseases. Background Technology
[0002] Cotton is an important economic crop and one of the world's most important textile raw materials. However, in cotton production, pest and disease infestation is one of the main factors affecting cotton yield and quality. Diseases such as cotton aphids, bollworms, thrips, anthracnose, Verticillium wilt, and angular leaf spot hinder cotton growth. The occurrence of cotton pests and diseases is influenced by factors such as climate, soil, variety, cultivation methods, fertilization, and irrigation, resulting in spatiotemporal variability, nonlinearity, and randomness. Different pests and diseases occur sequentially or simultaneously at different growth stages of cotton, making their occurrence patterns and disaster mechanisms difficult to accurately grasp, thus posing challenges to cotton pest and disease control. Therefore, timely, accurate, and comprehensive identification of cotton pest and disease occurrence, providing a scientific basis for pest and disease control, is crucial for achieving timely control of cotton pests and diseases.
[0003] By utilizing modern information technology and intelligent equipment, real-time monitoring, remote management, and intelligent early warning of cotton diseases and pests can be achieved, effectively reducing the risk and losses associated with cotton disease and pest outbreaks. New computer technologies, such as convolutional neural networks, have been successfully applied to the field of disease and pest detection. By identifying and locating targets in input images, target determination is achieved, providing a theoretical basis for subsequent disease and pest control.
[0004] In pursuit of higher recognition accuracy, existing target detection models used in the field of pest and disease detection are often designed to be more complex, which further increases the amount of computation and processing time, making it impossible to meet the requirements of real-time performance. As a result, there is no good way to identify pests and diseases, the recognition results are poor, and the possibility of its widespread application in the field of agriculture is limited. Summary of the Invention
[0005] The purpose of this invention is to address the shortcomings of the prior art by providing a method, system, device, and medium for identifying cotton diseases and pests, thereby solving the problems in the prior art.
[0006] This invention specifically provides the following technical solution: a method for identifying cotton diseases and pests, comprising: Collect images of cotton diseases and pests; Extract different categories of cotton pest and disease features from cotton pest and disease images, obtain the weighted enhanced representation of each cotton pest and disease feature, and assign different categories of cotton pest and disease features to the corresponding levels in the feature pyramid according to the weighted enhanced representation; Using a top-down approach, the highest-level features in the feature pyramid are upsampled, and after the upsampling operation, they are added element-wise with the features of adjacent levels through horizontal connections to form a primary feature fusion map. Based on the dynamic evaluation of the set candidate region size, the optimal feature level in the primary feature fusion map is selected, and the features of adjacent levels are weighted and fused through the optimal feature level to generate feature maps of different sizes containing multi-scale information. Target detection and decoding are performed on feature maps of different sizes to obtain cotton pest and disease identification results.
[0007] Preferably, the cotton pest and disease images are input into an improved YOLOv8 target detection model to obtain cotton pest and disease identification results. The improved YOLOv8 target detection model includes: The system employs a lightweight GhostShiftNet network as the feature extraction part of the backbone network, introduces a Triplet attention mechanism into the backbone network, adds a multi-scale feature fusion module to the neck structure, and sets up a detection head.
[0008] Preferably, the lightweight GhostShiftNet network includes a GhostShiftConv module and a C3GhostShift module, and uses the lightweight GhostShiftNet network as the feature extraction part of the backbone network, specifically: Replace the CBS module of the original YOLOv8 model backbone network with the GhostShiftConv module; design the C3GhostShift module to replace the C3 module of the original YOLOv8 model backbone network.
[0009] Preferably, after constructing the improved YOLOv8 object detection model, it also includes: The ground truth bounding boxes for cotton pest and disease detection are obtained. Positive samples matching the ground truth bounding boxes are selected from the target detection results. The cross-entropy of the class predictions is calculated, and the summation of all positive samples is averaged to obtain the final classification loss. The classification loss is... The specific expression is: ; in, Indicates the number of positive samples; Represents the set of positive samples; Indicates the total number of categories; This represents the true label of the c-th class for the i-th sample; This represents the predicted probability of the i-th sample in the c-th class. Obtain the predicted bounding boxes for cotton pest and disease detection after target detection and decoding. Calculate the cross-entropy loss based on the matching between the predicted and ground truth bounding boxes, and assign different weights to different detection layers to obtain the confidence loss. Among them, confidence loss The specific expression is: ; in, This represents the loss of confidence in small targets. This represents the confidence loss for medium-sized targets. This indicates a loss of confidence in a large target. The SIoU loss function is used to calculate the losses of the ground truth bounding box and the predicted bounding box, which are then used as the bounding box loss. This bounding box loss is then used as the localization loss. ; ; in, This represents the bounding box predicted by the model. Represents the true bounding box. Indicates the exponential parameter; Through the classification loss Confidence loss and positioning loss The improved YOLOv8 object detection model was optimized.
[0010] Preferably, the step of performing target detection and decoding on feature maps of different sizes to obtain cotton pest and disease identification results includes: Target detection is performed on feature maps of different sizes to obtain prediction tensors, and the prediction tensors are decomposed into bounding box parameters, confidence scores, and class probabilities. The center coordinate offset in the bounding box parameters is normalized by the Sigmoid function, and the actual width and height are calculated by exponential transformation in combination with the baseline size of the predefined anchor box. Finally, the relative coordinates are mapped to the absolute coordinates of the input image to generate the geometric parameters of the prediction box. After normalizing the class probabilities using the Softmax function, the class with the highest probability is selected as the pest / disease type label. At the same time, a threshold is set based on the confidence level to filter out prediction results with low confidence, thus obtaining the final prediction box. For the final predicted bounding boxes, a non-maximum suppression algorithm is used. The overlap between predicted bounding boxes is measured based on the intersection-over-union ratio (IoU). Predicted bounding boxes with confidence scores higher than a set threshold and overlap scores lower than a set threshold are retained. The final output includes the detection results containing absolute coordinates, pest / disease category, and confidence score, thus determining the pest / disease category in the current target detection task.
[0011] Preferably, the weighted enhanced representation of each cotton disease and pest feature is obtained as follows: By capturing the cross-dimensional interaction between the channel dimension and the spatial dimension in cotton disease and pest features, weighted enhanced representations of different categories of cotton disease and pest features are obtained.
[0012] This invention provides a cotton pest and disease identification system, comprising: The acquisition module is used to acquire images of cotton diseases and pests and obtain a dataset of disease and pest images. The feature extraction module is used to extract different categories of cotton pest and disease features from cotton pest and disease images, and obtain the weighted enhanced representation of each cotton pest and disease feature. Based on the weighted enhanced representation, the different categories of cotton pest and disease features are assigned to the corresponding levels in the feature pyramid. The feature fusion module is used to upsample the highest-level features in the feature pyramid from a top-down perspective, and after the upsampling operation, it adds the features of the adjacent levels to the features of the adjacent levels through horizontal connections to form a primary feature fusion map. Based on the dynamic evaluation of the set candidate region size, the optimal feature level in the primary feature fusion map is selected, and the adjacent feature levels are weighted and fused through the optimal feature level to generate feature maps of different sizes containing multi-scale information. The identification module is used to perform target detection and decoding on feature maps of different sizes to obtain cotton pest and disease identification results.
[0013] The present invention provides a computer device, including a memory and a processor. The memory stores a program, and when the program is executed by the processor, the processor performs the steps of the above-described method for identifying cotton pests and diseases.
[0014] The present invention provides a storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the above-described method for identifying cotton pests and diseases.
[0015] Compared with the prior art, the present invention has the following significant advantages: 1. This invention extracts features from cotton pest and disease images and obtains weighted representations (feature pyramids) of different features to improve the feature weights for small and dense targets. At the same time, by fusing different scales in the feature pyramid, the optimal feature level is dynamically calculated based on the size of the set candidate region. The features of adjacent levels in the preliminary fused feature map are weighted and fused to generate feature maps of different sizes containing multi-scale information. This enhances the feature fusion effect of multiple categories of cotton pests and diseases, reduces feature loss, and lowers the false negative and false positive rates of different categories of detected targets.
[0016] 2. This invention uses a lightweight backbone network for feature extraction and incorporates a TripletAttention mechanism module into the backbone network to improve model detection accuracy while reducing the number of computational parameters and enhancing real-time performance. Furthermore, it combines AUGFPN with the original model's neck structure to improve feature fusion. The SIOU bounding box loss function is introduced to adjust the detection box based on the size of the target, effectively improving the accuracy and localization precision of cotton pest and disease detection. This invention fully considers the difficulties in collecting pest and disease data from the underside of leaves, low detection accuracy, and weak real-time performance in real cotton fields. It can reduce the number of model parameters while maintaining detection accuracy, effectively improving computational speed and real-time performance, providing theoretical research and technical support for cotton pest and disease target detection in practical scenarios. Attached Figure Description
[0017] Figure 1 This is a schematic diagram of the model training and detection process for a cotton pest and disease identification method provided by the present invention; Figure 2 This is a diagram of the GhostShiftConv and C3GhostShift modules provided in an embodiment of the present invention; Figure 3 This is a diagram of the AUGFPN module provided in an embodiment of the present invention; Figure 4 This is a schematic diagram of the SIOU bounding box loss function provided in an embodiment of the present invention; Figure 5 This is a flowchart of the Dynamic Pruning algorithm provided in an embodiment of the present invention; Figure 6 This is a schematic diagram comparing the cotton pest and disease detection effects of the method provided in this embodiment of the invention with existing methods; wherein... Figure 6 (a1)- Figure 6 (a5) are images of cotton aphids, cotton bollworms, cotton thrips, Verticillium wilt, and angular leaf spot from the original images, respectively. Figure 6 (b1)- Figure 6 (b5) shows images of cotton aphids, cotton bollworms, cotton thrips, Verticillium wilt, and angular leaf spot treated with Faster RCNN-ResNet50, respectively. Figure 6 (c1)- Figure 6 (c5) shows images of cotton aphids, cotton bollworms, cotton thrips, Verticillium wilt, and angular leaf spot treated with YOLOV5. Figure 6 (d1)- Figure 6 (d5) are images of cotton aphids, cotton bollworms, cotton thrips, Verticillium wilt, and angular leaf spot treated with YOLOX, respectively. Figure 6 (e1)- Figure 6(e5) are images of cotton aphids, cotton bollworms, cotton thrips, Verticillium wilt, and angular leaf spot treated with YOLOV8, respectively. Figure 6 (f1)- Figure 6 (f5) shows the cotton aphid, cotton bollworm, cotton thrips, Verticillium wilt, and angular leaf spot treated with Lightweight-cotton-YOLOV8, respectively. Figure 7 This is a schematic diagram of the detection device structure provided in an embodiment of the present invention; Figure 8 This is a side view of the detection device structure provided in an embodiment of the present invention; Figure 9 This is a top view of the detection device structure provided in an embodiment of the present invention; Figure 10 This is a flowchart illustrating a method for identifying cotton pests and diseases provided by the present invention. Detailed Implementation
[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0019] like Figure 1 and Figure 10 As shown in this embodiment, a method for identifying cotton diseases and pests includes the following steps: Step S1: Collect images of cotton diseases and pests to obtain a dataset of disease and pest images.
[0020] S101 uses a USB camera to collect images of common cotton pests and diseases in the field, including three major cotton pests: cotton aphids, cotton bollworms, and cotton thrips, as well as two common cotton diseases: Verticillium wilt and angular leaf spot. The image resolution is 3024*4032 pixels. A total of 8330 cotton pest images were collected, and 5244 usable cotton pest and disease images were obtained after screening.
[0021] S102, using the Labelme software, the categories and locations of cotton pests and diseases in the images were labeled. Each labeled image generated an XML file containing information such as image width, height, cotton pest and disease category, and bounding box coordinates. The labeled dataset was then divided into training, validation, and test sets in a 7:2:1 ratio.
[0022] According to the cotton pest and disease identification method provided by the present invention, the step of hybrid data augmentation includes: Randomly select two images and resize them to the same value.
[0023] Determine the cropping region ratio based on the Beta distribution, and paste the cropped region of one image into another image.
[0024] Image labels are mixed according to the proportion of the cropped region.
[0025] The post-processing operation outputs the blended bounding box set and category labels.
[0026] According to the cotton pest and disease identification method provided by the present invention, the step of adaptively calculating the anchor frame includes: Obtain the width and height of all images in the common cotton pests and diseases dataset.
[0027] Perform scaling operations on the image to ensure that the width and height of the input image meet the image size requirements.
[0028] Bounding box size filtering retains bounding boxes whose width and height are both no less than two pixels.
[0029] n anchor boxes were obtained using the k-means clustering algorithm.
[0030] The width and height of the anchor frame are randomly mutated using a snake optimization algorithm. If the mutation effect is excellent, the anchor frame is assigned a value; otherwise, it is skipped. The default mutation count is 1000 times.
[0031] According to the cotton pest and disease identification method provided by the present invention, the step of adaptively scaling the image includes: Determine the target size and original image information, calculate the scaling ratio, and dynamically calculate the adaptive scaling ratio by integrating the original size and target size to scale the image.
[0032] The image is scaled using an interpolation algorithm, and the gray pixels that need to be filled to change the size are calculated. The pixels are then filled to the edge with the larger shrinkage ratio.
[0033] Images of cotton diseases and pests are input into an improved YOLOv8 object detection model to obtain cotton disease and pest identification results. The improved YOLOv8 object detection model includes: An improved YOLOv8 object detection model was constructed, including using a lightweight GhostShiftNet network as the feature extraction part of the backbone network, introducing a Triplet attention mechanism into the backbone network, adding a multi-scale feature fusion module to the neck structure, and setting up a detection head.
[0034] The YOLOv8 model input mainly includes three modules: hybrid data augmentation, Latterbox anchor scaling, and adaptive optimization anchor calculation.
[0035] like Figure 2As shown, the lightweight GhostShiftNet network includes the GhostShiftConv module and the C3GhostShift module. The GhostShiftConv module replaces the CBS module of the original YOLOv8 model backbone network; the C3GhostShift module is designed to replace the C3 module of the original YOLOv8 model backbone network.
[0036] Step S2: Extract different categories of cotton pest and disease features from the cotton pest and disease images, and obtain the weighted enhanced representation of each cotton pest and disease feature. Assign different categories of cotton pest and disease features to the corresponding levels in the feature pyramid according to the weighted enhanced representation.
[0037] By capturing the cross-dimensional interaction between the channel dimension and the spatial dimension in cotton disease and pest features, weighted enhanced representations of different categories of cotton disease and pest features are obtained.
[0038] Step S3: Using a top-down approach, upsample the highest-level features in the feature pyramid. After upsampling, add the features of adjacent levels element-wise through horizontal connections to form a primary feature fusion map. Residual connections are used to preserve the global information of the original high-level features. Based on a dynamic evaluation of the set candidate region size, the optimal feature level in the primary feature fusion map is selected. The optimal feature level is then used to weight and fuse features of adjacent levels, generating feature maps of different sizes containing multi-scale information. By mean averaging precision mAP The evaluation is performed using the following expression: ; ; in, Represents the maximum number of categories. Indicates the first i Average precision across all categories. i Indicates the number of categories. N This indicates the number of predicted boxes sorted by confidence level; Indicates the first k Recall rate at the time of prediction; Indicates the first k The accuracy of predictions.
[0039] By combining neck structure features with a multi-scale feature fusion module to fuse features at different scales in the feature pyramid, feature maps of different sizes containing multi-scale information are generated, including: A consistency supervision mechanism is adopted to ensure that the feature maps after lateral connections contain similar semantic information.
[0040] Perform residual feature enhancement operations to reduce the information loss of the highest-level features in the feature pyramid in a residual manner.
[0041] Using soft RoI selection allows for better utilization of feature information at different pyramid levels.
[0042] After constructing the improved YOLOv8 object detection model, it also includes: The model output loss is calculated as follows: The ground truth bounding boxes for cotton pest and disease detection are obtained. Positive samples matching the ground truth bounding boxes are selected from the target detection results. The cross-entropy of the class predictions is calculated, and the summation of all positive samples is averaged to obtain the final classification loss. The classification loss is... The specific expression is: ; in, Indicates the number of positive samples; Represents the set of positive samples; Indicates the total number of categories; Indicates the first i The first sample c Realistic label (0 or 1); Indicates the first i The first sample c Class prediction probability.
[0043] Obtain the predicted bounding boxes for cotton pest and disease detection after target detection and decoding. Calculate the cross-entropy loss based on the matching between the predicted and ground truth bounding boxes, and assign different weights to different detection layers to obtain the confidence loss. Among them, confidence loss The specific expression is: ; in, This represents the loss of confidence in small targets. This represents the confidence loss for medium-sized targets. This indicates a loss of confidence in a large target.
[0044] like Figure 4 As shown, the SIoU loss function is used to calculate the loss of the ground truth box and the predicted box, which is used as the bounding box loss, and the bounding box loss is used as the localization loss. The specific expression is: ; in, This represents the bounding box predicted by the model. Represents the true bounding box. This represents the exponential parameter.
[0045] Through the classification loss Confidence loss and positioning loss The improved YOLOv8 object detection model was optimized.
[0046] in: ; ; ; ; in, , The width and height of the minimum bounding box; The actual width and height of the bounding box; To control parameters, adjust the transition speed; modify The parameter value is used to adjust the scaling of small targets; , This represents the width of the overlapping area between the bounding box and the ground truth box; This represents the area where the predicted bounding box and the ground truth bounding box do not intersect.
[0047] The replacement of the feature extraction part with GhostShiftNet includes: replacing the CBS module of the original YOLOv8 model backbone network with the GhostShiftConv module; and designing the GhostC2f module to replace the C2f module of the original YOLOv8 model backbone network.
[0048] The GhostShiftConv structure first uses convolution to control the number of parameters, then divides the feature map into two equal halves. One half generates a new feature map through bit shifting operations, and finally the two feature maps are concatenated. GhostC2f mainly uses Ghostneck to replace the original Bottleneck module, thereby reducing the number of computational parameters in the model.
[0049] According to the cotton pest and disease identification method provided by the present invention, the lightweight GhostShiftNet network replacement step includes: Replace the CBS module in the original YOLOv8 model backbone network with the GhostShiftConv module.
[0050] Design the C3GhostShift module to replace the C3 module in the original YOLOv8 model backbone network.
[0051] The Triplet Attention mechanism enhances feature representations by capturing cross-dimensional interactions between channels and spatial dimensions, and is evaluated using mean average precision (mAP) according to the first formula: ; in, Indicates the number of categories. Calculations are performed using the second formula: ; In the formula, N This indicates the number of predicted boxes sorted by confidence level; Indicates the first k Recall rate at the time of prediction; Indicates the first k The accuracy of predictions.
[0052] like Figure 3 As shown, the information transfer strategy of the neck structure combined with the AUGFPN module is as follows: a consistency supervision mechanism is adopted to ensure that the feature maps after lateral connection contain similar semantic information; residual feature enhancement operation is performed to reduce the loss of information of the highest level features in the feature pyramid in a residual manner; soft RoI selection is used to better utilize feature information of different pyramid levels.
[0053] like Figure 5 As shown, based on the optimized YOLOv8 model, the Dynamic Pruning algorithm is used to remove redundant channels in the model, construct the LWC-YOLOv8 model, and output the detected cotton pest and disease results. The Dynamic Pruning algorithm consists of three steps: identification of prunable layers, model pruning, and generation of the pruned model.
[0054] The beneficial effects of this embodiment are as follows: Considering the model's practical application scenario of detecting pests and diseases in complex cotton fields, it is necessary to improve detection accuracy while ensuring real-time performance and being able to be implemented in resource-constrained embedded devices. A model compression method based on the Dynamic Pruning algorithm is designed to balance model size and recognition accuracy, meeting the requirements for embedded device implementation.
[0055] The steps for removing redundant parameters from a model using the Dynamic Pruning algorithm include: Identify pruning layers, sort all channels by importance score from smallest to largest, mark low-importance channels, determine pruning ratios, and generate pruning strategies.
[0056] The LWC-YOLOv8 model is pruned based on the pruning strategy obtained in the previous step, and low-importance channels are removed.
[0057] The pruned channel mask is fixed, and adding or removing channels is not allowed; only the remaining weights are updated.
[0058] Step S4: Perform target detection and decoding on feature maps of different sizes to obtain cotton pest and disease identification results.
[0059] The detection head uses three prediction feature layers of different sizes to perform target detection on the input feature map and obtain the prediction results of the three feature maps. The prediction results are then decoded to determine the pest category and the positions of multiple prediction boxes.
[0060] Target detection is performed on feature maps of different sizes to obtain prediction tensors, and the prediction tensors are decomposed into bounding box parameters, confidence scores, and class probabilities.
[0061] The center coordinate offset in the bounding box parameters is normalized by the Sigmoid function, and the actual width and height are calculated by exponential transformation in combination with the baseline size of the predefined anchor box. Finally, the relative coordinates are mapped to the absolute coordinates of the input image to generate the geometric parameters of the prediction box.
[0062] After normalizing the class probabilities using the Softmax function, the class with the highest probability is selected as the pest / disease type label. At the same time, a threshold is set based on the confidence level to filter out prediction results with low confidence, thus obtaining the final prediction box.
[0063] For the final predicted bounding boxes, a non-maximum suppression algorithm is used. The overlap between predicted bounding boxes is measured based on the intersection-over-union ratio (IoU). Predicted bounding boxes with confidence scores higher than a set threshold and overlap scores lower than a set threshold are retained. The final output includes the detection results containing absolute coordinates, pest / disease category, and confidence score, thus determining the pest / disease category in the current target detection task.
[0064] The following paragraphs detail the parameter settings and results of the experiment in this embodiment.
[0065] All experiments in this invention were conducted on the same device, which was configured with a Linux operating system, an Intel(R) Xeon(R) Silver 4214R CPU, an NVIDIA A800 GPU, and Python as the training language. Based on the hardware configuration, the hyperparameters were set as follows: 200 epochs, a batch size of 32, and a single GPU was used to train the model.
[0066] To verify the advantages of the pruned LWC-YOLOv8 model in detecting common cotton diseases and pests, a comparative experiment was conducted with advanced object detection models based on a self-built dataset of common cotton diseases and pests, demonstrating the model's object detection and localization capabilities across different cotton disease and pest categories.
[0067] Table 1 Performance Comparison of Different Object Detection Models As can be clearly seen from the information in Table 1, the pruned LWC-YOLOv8 model has a size of 4.3 MB and an mAP of 85.8%, reducing the model size while maintaining good detection accuracy. Secondly, the standard for real-time detection speed of embedded models is typically 30 FPS. The model proposed in this invention achieves a detection speed of 101.3 FPS, far exceeding the standard and meeting the real-time requirements for cotton pest and disease detection in complex cotton field environments. The target detection network Faster R-CNN-ResNet50 is a two-stage detection model with high generation accuracy and heavy model weights, but its detection accuracy is slightly lower than that of the LWC-YOLOv8 model. The rest are single-stage target detection models, with the YOLOv5 model performing the worst, especially in small target detection tasks such as cotton aphid detection, where the accuracy is only 53.4%. In addition to the table, this invention uses the Gradient-weighted ClassActivation Mapping (Grad-CAM) algorithm to multiply the calculated gradient with the output of the corresponding feature layer, and then performs a weighted average of the results to generate a heatmap. This heatmap shows which image regions are most important for the model to predict specific categories. Brighter colors in the image indicate a higher correlation with common cotton pests and diseases, providing a visual basis for the model's detection results. Figure 6 This is a heatmap comparison of the pest and disease identification effects of the method and the advanced target detection model in this invention.
[0068] In summary, the method described in this invention can improve the detection speed and accuracy of cotton pest and disease identification models, and has good prospects for widespread application. This method solves the problems of large parameter count, slow response speed, and low identification accuracy in cotton pest and disease detection models. Its practical application is of great significance for farmers to take timely and effective pest and disease control strategies, and promotes the high-quality development of the cotton industry.
[0069] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0070] The cotton pest and disease identification system based on the LWC-YOLOv8 model provided by this invention is described below. This invention proposes a cotton pest and disease identification system, which includes: a data acquisition module, a feature extraction module, a dataset acquisition module, and a detection module.
[0071] The system comprises the following modules: an acquisition module for collecting cotton pest and disease images to obtain a pest and disease image dataset; a feature extraction module for extracting different categories of cotton pest and disease features from the images and obtaining a weighted enhanced representation for each feature, then assigning these features to corresponding levels in the feature pyramid according to their weighted enhanced representations; a feature fusion module for upsampling the highest-level features in the feature pyramid using a top-down approach, and then adding them element-wise with adjacent level features via horizontal connections after the upsampling operation to form a primary feature fusion map; a dynamic evaluation of the set candidate region size to select the optimal feature level in the primary feature fusion map, and then weightedly fusing adjacent level features using the optimal feature level to generate feature maps of different sizes containing multi-scale information; and a recognition module for performing target detection and decoding on the feature maps of different sizes to obtain cotton pest and disease recognition results.
[0072] The above system is implemented using a cotton field inter-row pest and disease detection device. Figures 7-9 This diagram illustrates a cotton field inter-row pest and disease detection device. The device comprises: a detection chassis 1, a mobile power supply 2, a motor drive module 3, a main control module 4, a 4G / GNSS communication module 5, a camera module 6, a robotic arm module 7, a lithium battery 8, a motor 9, and a mobile app 10. The detection chassis 1 includes two side plates 11, two L-shaped connectors 12, two drive wheel modules 13, two driven wheel modules 14, and two tracks 15. The motor 9 is located below the chassis and connected to the drive wheels 13. The main control module 4 is located above the detection chassis 1 and connected to the robotic arm module 7 via DuPont wires. The robotic arm module 7 includes a communication module 16, a horizontal servo motor 17, and two vertical servos 18. The camera module 6 is mounted at the top of the robotic arm module 7 and is connected to the main control module 4 via CSI. The two output ports of the motor drive module 3 are connected to the motor 9, and the input is connected to the main control module 4 via male and female wires. The lithium battery 8 is located at the front of the detection chassis and supplies power to the motor drive module 3. The main control module 4 is powered by the power bank 2. The 4G / GNSS communication module 5 is located above the power bank 2 and is connected to the main control module 4 via a USB interface. The main control module 4 processes the video frames captured by the camera 6 and transmits the video stream containing the cotton pest and disease identification results to the mobile APP 10. If the number of cotton pests and diseases identified on cotton plants within a certain range exceeds a set threshold, an early warning SMS is sent, and the current latitude and longitude information is recorded and sent through the 4G / GNSS module 5. The mobile APP 10 uses 4G communication to control the motion of the detection equipment, the rotation of the robotic arm, and the real-time transmission of the video stream, realizing the remote monitoring and early warning function for cotton pests and diseases.
[0073] In addition, the main control module is equipped with an LWC-YOLOv8 model to receive information from the camera module and complete the cotton pest and disease identification method based on the LWC-YOLOv8 model.
[0074] The present invention also provides a computer device, including a memory and a processor, wherein the memory stores a program, and when the program is executed by the processor, the processor performs the steps of a cotton pest and disease identification method.
[0075] According to the disclosed embodiments, the computer device can communicate with one or more external devices (e.g., keyboard, pointing device, Bluetooth communication, etc.) or with any device that enables the computing device to communicate with one or more other computing devices (e.g., router, demodulator, etc.).
[0076] The above description, in conjunction with specific preferred embodiments, provides a more detailed explanation of the present invention. For those skilled in the art, various simple deductions or substitutions can be made without departing from the concept of the present invention, and all such deductions or substitutions should be considered to fall within the scope of protection of the present invention.
Claims
1. A method for identifying cotton diseases and pests, characterized in that, include: Collect images of cotton diseases and pests; Extract different categories of cotton pest and disease features from cotton pest and disease images, obtain the weighted enhanced representation of each cotton pest and disease feature, and assign different categories of cotton pest and disease features to the corresponding levels in the feature pyramid according to the weighted enhanced representation; Using a top-down approach, the highest-level features in the feature pyramid are upsampled, and after the upsampling operation, they are added element-wise with the features of adjacent levels through horizontal connections to form a primary feature fusion map. Based on the dynamic evaluation of the set candidate region size, the optimal feature level in the primary feature fusion map is selected, and the features of adjacent levels are weighted and fused through the optimal feature level to generate feature maps of different sizes containing multi-scale information. Target detection and decoding are performed on feature maps of different sizes to obtain cotton pest and disease identification results.
2. The method for identifying cotton diseases and pests as described in claim 1, characterized in that, The cotton pest and disease images are input into an improved YOLOv8 target detection model to obtain cotton pest and disease identification results. The improved YOLOv8 target detection model includes: The system employs a lightweight GhostShiftNet network as the feature extraction part of the backbone network, introduces a Triplet attention mechanism into the backbone network, adds a multi-scale feature fusion module to the neck structure, and sets up a detection head.
3. The method for identifying cotton diseases and pests as described in claim 2, characterized in that, The lightweight GhostShiftNet network includes a GhostShiftConv module and a C3GhostShift module. It uses the lightweight GhostShiftNet network as the feature extraction part of the backbone network, specifically: Replace the CBS module of the original YOLOv8 model backbone network with the GhostShiftConv module; design the C3GhostShift module to replace the C3 module of the original YOLOv8 model backbone network.
4. The method for identifying cotton diseases and pests as described in claim 2, characterized in that, After constructing the improved YOLOv8 object detection model, it also includes: The ground truth bounding boxes for cotton pest and disease detection are obtained. Positive samples matching the ground truth bounding boxes are selected from the target detection results. The cross-entropy of the class predictions is calculated, and the summation of all positive samples is averaged to obtain the final classification loss. The classification loss is... The specific expression is: ; in, Indicates the number of positive samples; Represents the set of positive samples; Indicates the total number of categories; This represents the true label of the c-th class for the i-th sample; This represents the predicted probability of the i-th sample in the c-th class; Obtain the predicted bounding boxes for cotton pest and disease detection after target detection and decoding. Calculate the cross-entropy loss based on the matching between the predicted and ground truth bounding boxes, and assign different weights to different detection layers to obtain the confidence loss. Among them, confidence loss The specific expression is: ; in, This represents the loss of confidence in small targets. This represents the confidence loss for medium-sized targets. This indicates a loss of confidence in a large target. The SIoU loss function is used to calculate the losses of the ground truth bounding box and the predicted bounding box, which are then used as the bounding box loss. This bounding box loss is then used as the localization loss. ; ; in, This represents the bounding box predicted by the model. Represents the true bounding box. Indicates the exponential parameter; Through the classification loss Confidence loss and positioning loss The improved YOLOv8 object detection model was optimized.
5. The method for identifying cotton diseases and pests as described in claim 1, characterized in that, The process of performing target detection and decoding on feature maps of different sizes to obtain cotton pest and disease identification results includes: Target detection is performed on feature maps of different sizes to obtain prediction tensors, and the prediction tensors are decomposed into bounding box parameters, confidence scores, and class probabilities. The center coordinate offset in the bounding box parameters is normalized by the Sigmoid function, and the actual width and height are calculated by exponential transformation in combination with the baseline size of the predefined anchor box. Finally, the relative coordinates are mapped to the absolute coordinates of the input image to generate the geometric parameters of the prediction box. After normalizing the class probabilities using the Softmax function, the class with the highest probability is selected as the pest / disease type label. At the same time, a threshold is set based on the confidence level to filter out prediction results with low confidence, thus obtaining the final prediction box. For the final predicted bounding boxes, a non-maximum suppression algorithm is used. The overlap between predicted bounding boxes is measured based on the intersection-over-union ratio (IoU). Predicted bounding boxes with confidence scores higher than a set threshold and overlap scores lower than a set threshold are retained. The final output includes the detection results containing absolute coordinates, pest / disease category, and confidence score, thus determining the pest / disease category in the current target detection task.
6. The method for identifying cotton diseases and pests as described in claim 1, characterized in that, The weighted enhanced representation for obtaining each cotton disease and pest feature is specifically as follows: By capturing the cross-dimensional interaction between the channel dimension and the spatial dimension in cotton disease and pest features, weighted enhanced representations of different categories of cotton disease and pest features are obtained.
7. A cotton pest and disease identification system, characterized in that, include: The data acquisition module is used to acquire images of cotton diseases and pests. The feature extraction module is used to extract different categories of cotton pest and disease features from cotton pest and disease images, and obtain the weighted enhanced representation of each cotton pest and disease feature. Based on the weighted enhanced representation, the different categories of cotton pest and disease features are assigned to the corresponding levels in the feature pyramid. The feature fusion module is used to upsample the highest-level features in the feature pyramid from a top-down perspective, and after the upsampling operation, it adds the features of the adjacent levels to the features of the adjacent levels through horizontal connections to form a primary feature fusion map. Based on the dynamic evaluation of the set candidate region size, the optimal feature level in the primary feature fusion map is selected, and the adjacent feature levels are weighted and fused through the optimal feature level to generate feature maps of different sizes containing multi-scale information. The identification module is used to perform target detection and decoding on feature maps of different sizes to obtain cotton pest and disease identification results.
8. A computer device, characterized in that, The method includes a memory and a processor, wherein the memory stores a program that, when executed by the processor, causes the processor to perform the steps of the cotton pest and disease identification method as described in any one of claims 1 to 6.
9. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the cotton pest and disease identification method according to any one of claims 1 to 6.