Agricultural insect pest monitoring system and agricultural insect pest detection method
By introducing deep learning models with SEAttention and ShuffleAttention attention mechanisms, the problems of low accuracy in crop pest identification and real-time monitoring have been solved, achieving efficient, real-time, and accurate pest monitoring that is adaptable to different crops and environmental conditions.
Patent Information
- Application Number
- CN202510278410.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-10
- Publication Date
- 2026-01-13
AI Technical Summary
Existing technologies have low accuracy in identifying crop pests, making real-time monitoring difficult. Furthermore, existing machine learning models lack generalization ability and cannot adapt to pest identification for different crops, different growth stages, and different environmental conditions.
An agricultural pest monitoring system combining deep learning models is adopted, which introduces SEAttention channel attention mechanism and ShuffleAttention spatial attention mechanism. Channel attention focuses on important information in feature channels, and spatial attention focuses on the importance of different regions in the image, thereby enhancing detection accuracy and adaptability to complex backgrounds.
It improves the accuracy of pest identification and real-time monitoring capabilities, enhances the model's generalization ability, reduces deployment costs and latency, and achieves efficient and real-time pest monitoring.
Smart Images

Figure CN121330337A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image data processing, in particular to an agricultural pest monitoring system, an agricultural pest detection method, equipment and a storage medium. BACKGROUND
[0002] With the development of computer vision and artificial intelligence technology, image recognition technology is often used in the prior art to monitor crop diseases and pests. However, due to the large number of pest species and different forms of different plants of crops, and the influence of environmental factors, the recognition accuracy is difficult to reach the ideal level. Secondly, the pest monitoring system based on image recognition usually needs to transmit the image to the center server for processing, which has network delay and cannot realize real-time monitoring. Moreover, the existing machine learning model usually needs a large amount of labeled data for training, and it is difficult to adapt to pest identification under different crops, different growth stages and different environmental conditions, resulting in insufficient generalization ability.
[0003] Therefore, the present application provides an agricultural pest monitoring system and an agricultural pest detection method to solve the above technical problems. SUMMARY
[0004] The main purpose of the present application is to provide an agricultural pest monitoring system and an agricultural pest detection method, which combines a deep learning model for image enhancement, introduces a double attention mechanism combining SEAttention channel attention mechanism and ShuffleAttention spatial attention mechanism, focuses on important information in different feature channels through channel attention, thereby improving the recognition ability of pests, focuses on the importance of different regions in the image through spatial attention, accurately locates the position of pests on the leaf, enhances the accuracy of detection and the adaptability to complex background, to solve the technical problems proposed in the background art.
[0005] The present application solves the above technical problems by adopting the following technical solutions:
[0006] An agricultural pest monitoring system comprises an image acquisition module, an image preprocessing module and a feature extraction module connected in sequence, and further comprises a double attention mechanism module and a pest classification module, wherein:
[0007] The double attention mechanism module is used for filtering the feature dimension and allocating the spatial weight of the image feature data processed by the feature extraction module, so as to improve the classification recognition accuracy of the pest classification module.
[0008] The pest classification module is used for learning and processing the data processed by the double attention mechanism module in the YOLOv8 convolutional neural network, so as to identify and classify the pest features in the data image.
[0009] Preferably, the specific operation process of feature dimension filtering and spatial weight distribution in the dual attention mechanism module includes:
[0010] L1. Cascade the channel attention mechanism and the spatial attention mechanism in sequence;
[0011] L2. Dynamically learn the importance of each feature channel through the channel attention mechanism to obtain channel attention weights, suppress irrelevant channel noise in the original feature map F through the channel attention weights, and strengthen pest-related features to obtain an optimized feature map F';
[0012] L3. Use the spatial attention mechanism to dynamically allocate spatial weights to focus on pest areas by calculating group information interaction and cross-group information interaction, further optimize the feature map F' processed in step L2 through the spatial weights, and obtain a feature map
[0013] L4. Add the feature map processed in step L3 to the original feature map F through residual connection, retain the original information, and relieve gradient disappearance, so as to obtain the fused final feature map F final , the expression is:
[0014] Preferably, the specific operation process in step L2 includes:
[0015] L21. Input a feature map F∈R C×H×W , where C is the number of channels, and H×W is the spatial size;
[0016] L22. Perform global average pooling on the feature map F to compress the spatial information of each channel into a scalar description, and generate a channel description vector z∈R C , the specific calculation expression is:
[0017]
[0018] where F c (i,j) is the value at position (i,j) and channel c, H and W are the height and width of the input image respectively, and z c is the global average pooling result of channel c, representing the global feature of the channel;
[0019] L23. Input the channel description vector z into a bottleneck structure composed of two fully connected layers to learn the nonlinear relationship between channels and generate channel attention weights, the specific calculation expression of the channel attention weight vector A c is:
[0020] A c =σ(W2·δ(W1·z))
[0021] wherein W1 and W2 are full connection layer weight matrices, δ(·) is a ReLU activation function, and σ(·) is a Sigmoid function used to normalize the weights to the interval [0, 1];
[0022] W1∈R C / r×C is a first layer weight matrix used to realize channel dimension compression, and W2∈R C×C / r is a second layer weight matrix used to restore the channel dimension, and r represents a compression ratio, and r = 16;
[0023] L24. Channel attention weights A c are multiplied with the original feature map F channel by channel to obtain a channel attention optimized feature map F'.
[0024] Preferably, the specific operation process of the L3 step includes:
[0025] L31. The channel attention optimized feature map F'∈R C×H×W is evenly divided into G groups along the channel dimension, and each group of feature maps is denoted as F' g ∈R C / G×H×W , wherein C is the number of channels, and H x W is the spatial size;
[0026] L32. Spatial attention weights A g are calculated for each group of features F' s,g to generate spatial importance scores for each pixel, and high score areas correspond to leaf edges or fruit surfaces where pests are likely to appear;
[0027] L33. Spatial attention weights A s,g are multiplied with the corresponding group of feature maps F' g element by element to obtain weighted features
[0028] L34. The weighted features of all groups are spliced along the channel dimension to obtain a spliced optimized feature map and a channel Shuffle operation is performed, wherein
[0029] Preferably, the specific operation process of the L32 step includes:
[0030] Step 1. The mean μ g and variance of the gth group of features along the channel dimension are calculated.
[0031]
[0032] wherein G represents the number of spatial attention groups, F' g,c (i,j) is the value at position (i,j) and channel c, and μg (i,j) and respectively represent the mean and variance of the g-th group of features at position (i,j), and μ g (i,j)∈R 1×H×W , H×W is the spatial dimension;
[0033] Step 2. The mean and variance are spliced, and a spatial weight matrix A is generated through a 1×1 convolution layer s,g , and normalized by a Sigmoid function, A s,g is the g-th group of spatial attention weight matrix, and the expression formula is:
[0034]
[0035] wherein, A s,g ∈R 1×H×W , H×W is the spatial dimension, μ g and respectively represent the mean and variance of the g-th group of features in the channel dimension.
[0036] An agricultural pest detection method using any of the above agricultural pest monitoring systems for agricultural pest detection, comprising:
[0037] S1. Selecting an image acquisition device of agricultural pests according to a predetermined condition, and collecting agricultural crop images;
[0038] S2. Denoising, enhancing, cropping and size adjusting the collected image data to improve the quality of the image data;
[0039] S3. According to the preset information, extracting feature data for pest identification from the processed image based on a convolutional neural network;
[0040] S4. Optimizing the extracted feature data information through spatial and channel weighting through a double attention mechanism;
[0041] S5. According to the features processed by the double attention mechanism, training and identifying the types of pests and diseases through a convolutional neural network.
[0042] In another aspect, the present application also discloses a computer readable storage medium storing a computer program, which is executed by a processor to establish the above-mentioned agricultural pest monitoring system to perform the steps of the above-mentioned agricultural pest detection method.
[0043] In still another aspect, the present application also discloses a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the computer program is executed by the processor to make the processor establish the agricultural pest monitoring system as described above to perform the steps of the agricultural pest detection method as described above.
[0044] From the above technical solution, the present application provides an agricultural pest monitoring system and an agricultural pest detection method. Compared with the prior art, the present application has the following advantages:
[0045] 1. The present application can enhance the image feature extraction capability by setting a double attention mechanism module in the agricultural pest monitoring system, thereby improving the recognition accuracy of pests. Finally, it can effectively deal with the problem of various types and different forms of crop diseases and insect pests.
[0046] 2. The present application can dynamically learn the importance of each feature channel by introducing SEAttention channel attention mechanism and ShuffleAttention spatial attention mechanism in the double attention mechanism module and cascading them in turn, so as to suppress irrelevant channel noise and strengthen pest-related features. Finally, it can improve the ability to capture pest features and solve the technical problems of low recognition accuracy and high small target missing rate of traditional methods in complex backgrounds, providing an efficient and reliable intelligent solution for precision agriculture.
[0047] 3. The present application can dynamically allocate spatial weights to focus on pest areas by using spatial attention mechanism for grouping calculation and cross-group information interaction, thereby achieving the effect of accurately positioning the position of pests on the leaf. Finally, it can significantly enhance the detection accuracy and adaptability to complex backgrounds.
[0048] 4. The present application can retain original information and alleviate gradient vanishing by adding the optimized feature map to the original feature map through residual connection, thereby achieving the advantage of fusing multi-layer features. Finally, it can further improve the stability and generalization ability of model training.
[0049] 5. The present application can identify and classify pest features in data images in real time by combining YOLOv8 convolutional neural network for learning and processing, overcoming the delay problem of traditional server-based processing and realizing efficient and real-time pest monitoring.
[0050] 6. The channel attention mechanism executes the information aggregation through the spatial dimension, captures the global statistical characteristics of each channel, and learns the nonlinear relationship between the channels to generate attention weights, while multiplying the channel attention weights with the original feature map channel by channel to realize the weighted enhancement of the feature channel, so as to significantly improve the response strength of the pest-sensitive channel, improve the effect of the spatial attention mechanism through grouping calculation and cross-group information interaction, and facilitate dynamic allocation of spatial weights to focus on the pest area.
[0051] 7. The application can rearrange the channel order according to a fixed rule by splicing the weighted features of all groups along the channel dimension to realize feature reorganization and channel Shuffle, so as to break the barriers between groups, promote cross-group feature interaction, and enhance the overall model's ability to capture multi-scale pest features.
[0052] It should be understood that the content described in this part is not intended to identify key or important features of the embodiments of the application, nor is it used to limit the scope of the application. Other features of the application will become apparent from the following description. Of course, any product implementing the application does not necessarily need to achieve all the advantages mentioned above. BRIEF DESCRIPTION OF DRAWINGS
[0053] The drawings accompanying this specification are included to provide a further understanding of the application. The illustrative embodiments of the application and its description serve to explain the application. They do not, however, limit the application. In the drawings:
[0054] Figure 1 The system module framework of the application is shown as a whole;
[0055] Figure 2 The SEAttention part structure of the double attention mechanism model of the application is shown Figure 1 ;
[0056] Figure 3 The ShuffleAttention part structure of the double attention mechanism model of the application is shown Figure 2 . DETAILED DESCRIPTION
[0057] The technical solutions in the embodiments of the application will be described in detail below with reference to the drawings accompanying the embodiments of the application. Obviously, the described embodiments are only part of the embodiments of the application, not all. The embodiments and features in the embodiments can be combined with each other without conflict. Based on the embodiments in the application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the application.
[0058] In the embodiments, see the detailed descriptionFigures 1 to 3 .
[0059] As Figure 1 shown. The agricultural pest monitoring system proposed by the embodiment of the application comprises an image acquisition module, an image preprocessing module, a feature extraction module, a double attention mechanism module and a pest classification module connected in sequence. Among them:
[0060] (1) The image acquisition module is used to capture image data of crops through an intelligent camera and a drone.
[0061] It needs to be explained that in agricultural monitoring, the camera is usually installed at a specific position in the farmland, such as in a greenhouse, around an automatic control system, or in a certain hot area in the field. The camera can provide high-resolution images to facilitate detailed observation of crops in a specific area and identify early symptoms of pests and diseases. Different image acquisition methods have a significant impact on image quality and subsequent data processing. At this time, the image preprocessing module and the feature extraction module need to be adjusted accordingly according to the collection equipment of the image acquisition module to ensure the accuracy of the recognition result.
[0062] (2) The image preprocessing module is used to optimize the collected image data so that the subsequent feature extraction and classification recognition can be more efficient and accurate. The purpose is to remove unnecessary information, enhance key features, and adjust the size and quality of the image according to the needs so that it can better adapt to subsequent processing.
[0063] The specific operation steps include:
[0064] (a) Image denoising: using a denoising algorithm, according to the statistical characteristics of the pixels in the image, removing the noise signals that do not meet the expectations. Common denoising methods include mean filtering, median filtering, Gaussian filtering, etc. These methods remove high-frequency noise in the image through smoothing processing, retaining important low-frequency information.
[0065] (b) Image enhancement: used to improve the contrast, brightness, etc. of the image, so that the characteristics of pests and diseases are more prominent. In farmland monitoring, image enhancement technology can improve the visibility of early signs of pests and diseases that may appear on the leaves, fruits or stems of crops. Common enhancement techniques include histogram equalization, Laplacian sharpening, etc. These methods can effectively improve the clarity of the image, making subsequent feature extraction more accurate.
[0066] (c) Cropping and size adjustment: regional processing of the image according to the needs of specific applications, removing specific irrelevant areas of image acquisition, and only retaining the part related to pest and disease monitoring. Therefore, the size adjustment of the image can facilitate the adaptation of device processing capacity or improve data transmission efficiency.
[0067] In practical applications, these preprocessing methods can be flexibly selected according to different monitoring needs to maximize the effect of subsequent image analysis.
[0068] (3) Feature extraction module, for converting the image from the original pixel space to the feature space convenient for analysis and classification, so as to extract valuable features from the processed image, which are used for subsequent pest identification and classification.
[0069] It should be noted that the types and manifestations of pests are different, and the application of traditional image processing methods and modern deep learning methods in feature extraction has its own advantages.
[0070] In traditional image processing methods, feature extraction often relies on edge detection, texture analysis, color histogram, shape feature, etc.: for example, by detecting the edge of the crop leaf, it can be determined whether there are signs of pests; or by extracting the texture features of the farmland, the health status of the soil can be analyzed.
[0071] Further, deep learning methods can be used to automatically learn features in images and abstract high-level feature representations layer by layer. Convolutional neural networks can extract features at different levels at each layer of the image, from the initial edge features to more complex texture, shape and other high-level features, thereby improving the accuracy of pest identification. At this time, the deep learning feature extraction method has a significant advantage in dealing with complex pest identification, especially under large-scale data set training, the model can obtain strong generalization ability.
[0072] (4) Dual attention mechanism module, by enhancing the model's attention to key features, to improve the accuracy and efficiency of pest identification.
[0073] It should be noted that in traditional image recognition methods, the data after feature extraction is usually input as a unified feature vector to the classifier for analysis, however, images in agricultural pest identification often contain a large amount of irrelevant background information, and the pest itself may occupy a small area of the image.
[0074] Therefore, the dual attention mechanism module is used to filter the feature dimension and allocate the spatial weight of the image feature data processed by the feature extraction module, to improve the classification accuracy of the pest classification module. At this time, the dual attention mechanism module consists of channel attention (SEAttention) and spatial attention (ShuffleAttention), and its core is to optimize the feature channel and spatial area cooperatively, to enhance the model's attention ability to key features of pests, and the dual attention mechanism model constructed by this part is specifically shown in Figure 2 and Figure 3 .
[0075] Specifically, the operational process for feature dimension filtering and spatial weight allocation includes:
[0076] L1. Cascade the channel attention mechanism (SEAttention) and the spatial attention mechanism (ShuffleAttention) in sequence;
[0077] L2. The importance of each feature channel is dynamically learned through the channel attention mechanism to obtain the channel attention weight. The irrelevant channel noise in the original feature map F is suppressed and the pest-related features are enhanced through the channel attention weight to obtain the optimized feature map F′.
[0078] The specific operating procedures include:
[0079] L21. Input feature map F∈R C×H×W Where C is the number of channels and H×W is the spatial size;
[0080] L22. Perform global average pooling on the feature map F to compress the spatial information of each channel into a scalar description, generating a channel description vector z∈R. C The specific calculation expression is as follows:
[0081]
[0082] Among them, F c (i,j) represents the value at position (i,j) and channel c, H and W are the height and width of the input image, respectively, and z c It is the global average pooling result of channel c, representing the global characteristics of that channel;
[0083] This operation captures the global statistical characteristics of each channel by aggregating information in the spatial dimension, such as abnormal color difference in the insect-infested area in the color channel or local damage features in the texture channel.
[0084] L23. Input the channel description vector z into a bottleneck structure consisting of two fully connected layers to learn the nonlinear relationships between channels and generate channel attention weights, the channel attention weight vector A. c The specific calculation expression is as follows:
[0085] A c =σ(W2·δ(W1·z))
[0086] Where W1 and W2 are both weight matrices of the fully connected layer, δ(·) is the ReLU activation function, used to introduce nonlinear transformation, and σ(·) is the Sigmoid function, used to normalize the weights to the [0,1] interval, representing the importance of each channel;
[0087] W1∈R C / r×CThis is the first-layer weight matrix, used to achieve channel dimension compression, W2∈R C×C / r This is the second-layer weight matrix, used to recover the channel dimension, where r represents the compression ratio and r = 16;
[0088] L24. Channel attention weights A c Multiplying the original feature map F channel by channel achieves weighted enhancement of the feature channels, resulting in the channel-attention-optimized feature map F′, which is:
[0089]
[0090] In practice, this operation can dynamically suppress irrelevant channels (such as the red channel of soil reflection and the brightness channel of shadow coverage) through global average pooling and bottleneck structure, while strengthening pest-sensitive channels (such as the HSV hue channel corresponding to the yellowing area of lesions and the LBP texture channel corresponding to the roughness of boreholes). This can significantly improve the response intensity of pest-sensitive channels. For example, in an RGB image, the yellowing area of leaves caused by aphid infestation has a weaker response in the green channel and a stronger response in the red channel. Channel attention automatically strengthens such differential features through weight allocation.
[0091] L3. Using a spatial attention mechanism, spatial weights are dynamically allocated to focus on pest-affected areas through grouped computation and cross-group information interaction. The feature map F′ processed in L2 is further optimized using spatial weights to obtain the feature map.
[0092] The specific operating procedures include:
[0093] L31. The feature map F′∈R after channel attention optimization C×H×W Divide the feature map into G groups (G=4 by default) along the channel dimension, and denote the feature map of each group as F′. g ∈R C / G×H×W Where C is the number of channels and H×W is the spatial size;
[0094] Grouping strategies reduce computational complexity and enable the model to learn complementary features in different subspaces.
[0095] L32. For each set of features F′ g Calculate the spatial attention weights A respectively s,g ,have:
[0096] Calculate the mean μ of the g-th feature along the channel dimension. g With variance have:
[0097]
[0098] Where G represents the number of spatial attention groups, F′g,c (i,j) represents the value at position (i,j) and channel c, μ g (i,j) and Let μ represent the mean and variance of the g-th feature at position (i,j), respectively, and μ g (i,j)∈R 1×H×W , H×W represents the spatial dimensions;
[0099] At this time, the mean μ g The variance is used to reflect the global characteristic strength of this spatial location. Used to characterize the degree of dispersion of feature distribution, the two together describe the salience of local regions;
[0100] The mean and variance are concatenated, and then a spatial weight matrix A is generated through a 1×1 convolutional layer. s,g And apply the Sigmoid function for normalization, A s,g Let g be the spatial attention weight matrix for the g-th group, expressed by the following formula:
[0101]
[0102] Among them, A s,g ∈R 1×H×W H×W represents the spatial dimensions, μ g and Let represent the mean and variance of the g-th feature in the channel dimension, respectively;
[0103] This step uses lightweight convolution operations to fuse statistics and generate spatial importance scores for each pixel. High-scoring areas correspond to leaf edges or fruit surfaces where pests may appear.
[0104] L33. Spatial attention weights A s,g With the corresponding group feature map F′ g Element-wise multiplication yields the weighted features. have:
[0105] L34. Weighted features of all groups By concatenating along the channel dimension, we obtain the optimized feature map. And perform a channel shuffle operation, which rearranges the channel order according to fixed rules, where
[0106] This operation achieves feature recombination and channel shuffle by concatenating the weighted features of all groups along the channel dimension. It can rearrange the channel order according to fixed rules, thereby breaking down barriers between groups, promoting cross-group feature interaction, and enhancing the model's overall ability to capture multi-scale pest features.
[0107] In summary, the grouping calculation strategy and channel shuffle operation enable the model to adaptively focus on high-incidence areas of pests, such as leaf edges and vein intersections, thus avoiding computational redundancy in the traditional sliding window method.
[0108] L4. The feature map processed in step L3 is connected via residual connections. Adding the fused feature map F to the original feature map F preserves the original information and alleviates gradient vanishing, thus obtaining the final fused feature map F. final The expression is:
[0109]
[0110] By using residual connections to add the optimized feature map to the original feature map, the original information can be preserved and gradient vanishing can be alleviated. This allows for the fusion of multi-layer features, further improving the stability and generalization ability of model training. It ensures that the model strengthens key features without losing basic details, thus enhancing its robustness in complex farmland environments.
[0111] Furthermore, since SEAttention prioritizes the optimization of feature channels and suppresses background interference, while ShuffleAttention subsequently focuses on spatial regions to locate pest targets, and the mechanism structure combined with cascaded processing can solve the technical problems of low recognition accuracy and high false negative rate of small targets in complex backgrounds of traditional methods, it provides an efficient and reliable intelligent solution for precision agriculture in the field of agricultural pest monitoring.
[0112] In the specific implementation process, by introducing SEAttention for channel dimension optimization and ShuffleAttention for spatial dimension focusing, the weights of each channel can be dynamically adjusted and high-incidence areas of pests can be automatically located, enhancing the image feature extraction capability, thereby reducing environmental interference and improving the accuracy of pest identification. Finally, it can effectively address the problem of numerous types and diverse forms of crop pests and diseases.
[0113] Furthermore, the measured data comparing the leaf lesion recognition performance of different methods in farmland environments, as shown in the table below, demonstrate that channel attention eliminates the influence of light intensity differences on color features by strengthening the brightness normalization channel (V channel) in the HSV space. Under cloudy or rainy weather, the leaf lesion recognition accuracy only decreased by 4.7% (compared to 21.5% for traditional methods), while spatial attention quantifies the local feature dispersion through variance statistics, automatically ignoring uniform background areas such as soil and agricultural film. Under different light conditions, the leaf lesion recognition accuracy is significantly higher than that of traditional methods. The dual-attention mechanism, through feature dimension filtering and spatial weight allocation, enables the model to achieve an average recognition accuracy (mAP) of 92.4% in variable farmland environments, a 12.7% improvement over the single-attention model (79.7%), meeting the needs of all-weather monitoring.
[0114]
[0115] Therefore, by setting up a channel-spatial dual attention mechanism in the agricultural pest monitoring system, it is possible to enhance the characteristics of pests and diseases and suppress irrelevant background information, thereby improving the recognition accuracy and promoting the evolution of agricultural pest monitoring technology from coarse-grained classification to pixel-level precise perception.
[0116] Furthermore, during the execution of the channel attention mechanism, information aggregation in the spatial dimension is used to capture the global statistical characteristics of each channel and learn the nonlinear relationship between channels to generate attention weights. At the same time, the channel attention weights are multiplied with the original feature map channel by channel to achieve weighted enhancement of the feature channels. This can significantly improve the response intensity of pest-sensitive channels, enhance the effect of spatial attention mechanism through group calculation and cross-group information interaction, facilitate the dynamic allocation of spatial weights to focus on pest areas, and thus accurately locate the position of pests on leaves, significantly enhancing detection accuracy and adaptability to complex backgrounds.
[0117] (5) Pest classification module, which is used to classify the features extracted from the image, determine whether the crop is affected by pests and diseases, and identify the specific pest species. In pest classification, the data processed by the dual attention mechanism module is processed in the YOLOv8 convolutional neural network, which can identify and classify pest features in the data image in real time, overcome the latency problem of traditional server-based processing, and realize efficient and real-time pest monitoring.
[0118] It should be added that the YOLOv8 convolutional neural network has powerful capabilities in the field of image processing. It can automatically learn and extract effective features from images, thus performing well in pest identification tasks. At the same time, through multiple convolutional layers, pooling layers, fully connected layers and other structures, the convolutional neural network can gradually learn and extract key feature information in images, ultimately achieving accurate pest classification.
[0119] Furthermore, it should be noted that the system's inter-leaf attention region focusing capability can adapt to different leaf morphologies: for narrow rice leaves, the model strengthens the weight of the longitudinal vein region; for broad corn leaves, it focuses on the serrated damage of the leaf margin. Moreover, the same model achieves an average accuracy of 85.3% on 10 crop test sets without structural redesign, thus achieving multi-crop compatibility. At the same time, through SEAttention parameter compression (reducing the number of parameters by 93.75%) and TensorRT acceleration (FP16 quantization), the model achieves an inference speed of 45 FPS on Jetson Nano edge devices with power consumption of <5W, reducing communication latency by 200ms compared to cloud solutions and saving 60% in hardware costs.
[0120] Therefore, the system adopts an adaptive multi-crop compatible design, which can adapt to multiple crops without changing the model structure. At the same time, it achieves lightweight edge deployment through parameter compression and hardware acceleration technology, which can reduce deployment costs and improve inference speed. This achieves the effect of supporting rapid adaptation of "one model for multiple crops". Farmers only need to upload a small number of new crop samples (<100 images) to complete fine-tuning, reducing expansion costs by 90% and helping small and medium-sized farmland to upgrade intelligently.
[0121] Meanwhile, the system also utilizes a lightweight dual-attention design and end-to-end acceleration technology. The bottleneck structure of SEAttention and the grouping strategy of ShuffleAttention reduce the FLOPs of the dual-attention module to only 1.3 times that of the baseline model (without attention), while achieving a 12.7% mAP improvement. This effectively balances computational efficiency and accuracy. Furthermore, knowledge distillation (ResNet50 teacher model → MobileNetV3 student model) is introduced during model training, and redundant parameters are removed during inference through channel pruning. The final model size is compressed to 12MB, suitable for remote updates via 4G networks. Thus, under the same hardware conditions, this system achieves an 8-fold speed improvement in pest monitoring compared to Faster R-CNN, and reduces the monitoring cost per hectare of farmland from 3.2 to 0.7. This significantly improves processing speed and reduces costs compared to models like Faster R-CNN, ultimately leading to a substantial decrease in the monitoring cost per hectare of farmland. This makes large-scale commercial applications possible. These improvements collectively promote the efficient, real-time, and accurate operation of the agricultural pest monitoring system, resulting in significant economic and social benefits.
[0122] On the other hand, the present invention also discloses an agricultural pest detection method, which uses the agricultural pest monitoring system of the above embodiments to detect agricultural pests, including:
[0123] S1. Select appropriate image acquisition equipment for agricultural pests based on preset monitoring requirements, including drones, smart cameras, and mobile devices to acquire images of agricultural crops;
[0124] At this point, select equipment based on the environment and needs to ensure image quality and provide reliable data for subsequent analysis;
[0125] S2. The collected image data is processed by denoising, enhancing, cropping and resizing to improve the image data quality. Denoising removes irrelevant interference and enhances image contrast, making the characteristics of pests and diseases more obvious. Cropping and resizing ensure that the image meets the requirements of subsequent analysis and improves the recognition accuracy.
[0126] S3. Based on preset information, extract features for pest identification from the shape, color, texture and other information in the preprocessed image using a convolutional neural network to improve the accuracy and robustness of identification.
[0127] S4. The extracted feature data information is optimized through spatial and channel weighting using a dual attention mechanism;
[0128] At this time, spatial attention focuses on key areas, and channel attention increases the weight of important features. This mechanism effectively filters out irrelevant information and improves the accuracy and efficiency of pest and disease identification, especially performing well in complex environments.
[0129] S5. Based on the features processed by the dual attention mechanism, a convolutional neural network is used to train and identify pest types, thereby improving the accuracy of pest classification.
[0130] In another aspect, the present invention also discloses a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to perform the steps of the method described above.
[0131] In another aspect, the present invention also discloses a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of the method described above.
[0132] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to establish the above-described agricultural pest monitoring system to execute the agricultural pest detection method described in the above embodiment.
[0133] It is understood that the system provided in the embodiments of the present invention corresponds to the method provided in the embodiments of the present invention, and the explanation, examples and beneficial effects of the relevant content can be referred to the corresponding parts of the above methods.
[0134] This application also provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, communication interface, and memory communicate with each other via the communication bus.
[0135] Memory, used to store computer programs;
[0136] When the processor executes the program stored in the memory, it establishes the above-mentioned agricultural pest monitoring system to implement the above-mentioned agricultural pest detection method.
[0137] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc.
[0138] The communication interface is used for communication between the aforementioned electronic devices and other devices.
[0139] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0140] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0141] It should also be noted that electronic devices include terminal devices, which can also be called terminals, user devices, mobile platforms, mobile terminals, etc. Terminal devices can be mobile phones, smart TVs, wearable devices, tablets, computers with wireless transceiver capabilities, virtual reality terminal devices, augmented reality terminal devices, wireless terminals in industrial control, wireless terminals in autonomous driving, wireless terminals in remote surgery, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, and so on. The embodiments of this application do not limit the specific technologies or device forms used in the terminal devices.
[0142] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium, or a semiconductor medium (e.g., a solid-state drive).
[0143] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
[0144] Furthermore, it should be noted that if any directional indication (such as up, down, left, right, front, back, etc.) is involved in the embodiments of the present invention, the directional indication is only used to explain the relative positional relationship and movement of each component in a specific posture. If the specific posture changes, the directional indication will also change accordingly.
[0145] Furthermore, if the embodiments of this invention involve descriptions such as "first" or "second," these descriptions are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined with "first" or "second" may explicitly or implicitly include at least one of those features. Additionally, the meaning of "and / or" throughout the text includes three parallel solutions; for example, "A and / or B" includes solutions A or B, or solutions that simultaneously satisfy A and B. Furthermore, in the embodiments of this invention, "multiple" refers to two or more. Moreover, the technical solutions of the various embodiments can be combined with each other, but this must be based on the ability of those skilled in the art to implement them. When the combination of technical solutions is contradictory or impossible to implement, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection claimed by this invention.
Claims
1. An agricultural pest monitoring system, comprising an image acquisition module, an image preprocessing module, and a feature extraction module connected sequentially, characterized in that, It also includes a dual attention mechanism module and a pest classification module, in which: The dual attention mechanism module is used to filter the feature dimensions and allocate spatial weights to the image feature data processed by the feature extraction module, so as to improve the classification and recognition accuracy of the pest classification module. The pest classification module is used to learn and process the data processed by the dual attention mechanism module in the YOLOv8 convolutional neural network in order to identify and classify pest features in the data images.
2. The agricultural pest monitoring system as described in claim 1, characterized in that, The specific operation process of feature dimension filtering and spatial weight allocation in the dual attention mechanism module includes: L1. Cascade the channel attention mechanism and the spatial attention mechanism sequentially; L2. The importance of each feature channel is dynamically learned through a channel attention mechanism to obtain channel attention weights. These weights are then used to suppress irrelevant channel noise in the original feature map F and enhance pest-related features, resulting in the optimized feature map F. ′ ; L3. Using a spatial attention mechanism, spatial weights are dynamically allocated to focus on pest-affected areas through grouped computation and cross-group information interaction. The feature map F processed in L2 is further optimized through spatial weights. ′ , to obtain feature map L4. The feature map processed in step L3 is connected via residual connections. Adding the fused feature map F to the original feature map F preserves the original information and alleviates gradient vanishing, thus obtaining the final fused feature map F. final The expression is:
3. The agricultural pest monitoring system as described in claim 2, characterized in that, The specific operational procedures in step L2 include: L21. Input feature map F∈R C×H×W Where C is the number of channels and H×W is the spatial size; L22. Perform global average pooling on the feature map F to compress the spatial information of each channel into a scalar description, generating a channel description vector z∈R. C The specific calculation expression is as follows: Among them, F c (i,j) represents the value at position (i,j) and channel c, H and W are the height and width of the input image, respectively, and z c It is the global average pooling result of channel c, representing the global characteristics of that channel; L23. Input the channel description vector z into a bottleneck structure consisting of two fully connected layers to learn the nonlinear relationships between channels and generate channel attention weights, the channel attention weight vector A. c The specific calculation expression is as follows: From c =σ(W2·δ(W1·z)) Where W1 and W2 are both weight matrices of the fully connected layer, δ(·) is the ReLU activation function, and σ(·) is the Sigmoid function, which is used to normalize the weights to the [0,1] interval; W1∈R C / r×C This is the first-layer weight matrix, used to achieve channel dimension compression, W2∈R C×C / r This is the second-layer weight matrix, used to recover the channel dimension, where r represents the compression ratio and r = 16; L24. Channel attention weights A c Multiply the original feature map F channel by channel to obtain the channel attention-optimized feature map F′.
4. The agricultural pest monitoring system as described in claim 3, characterized in that, The specific operation process of the L3 step includes: L31. Feature map F after channel attention optimization ′ ∈R C×H×W If the feature map is uniformly divided into G groups along the channel dimension, then the feature map of each group is denoted as F. g ′ ∈R C / G×H×W Where C is the number of channels and H×W is the spatial size; L32. For each set of features F g ′ Calculate the spatial attention weights A respectively s,g Spatial importance scores are generated for each pixel, with high-scoring areas corresponding to leaf edges or fruit surfaces where pests may appear. L33. Spatial attention weights A s,g Corresponding feature map F g ′ Element-wise multiplication yields the weighted features. L34. Weighted features of all groups By concatenating along the channel dimension, we obtain the optimized feature map. And perform a channel shuffle operation, where 5. The agricultural pest monitoring system as described in claim 1, characterized in that, The specific operation process of step L32 includes: Step 1. Calculate the mean μ of the g-th feature along the channel dimension. g With variance have: Where G represents the number of spatial attention groups, F g ′ ,c (i,j) represents the value at position (i,j) and channel c, μ g (i,j) and Let μ represent the mean and variance of the g-th feature at position (i,j), respectively, and μ g (i,j)∈R 1×H×W , H×W represents the spatial dimensions; Step 2. Concatenate the mean and variance, then generate the spatial weight matrix A through a 1×1 convolutional layer. s,g And apply the Sigmoid function for normalization, A s,g Let g be the spatial attention weight matrix for the g-th group, expressed by the following formula: Among them, A s,g ∈R 1×H×W H×W represents the spatial dimensions, μ g and Let represent the mean and variance of the g-th feature in the channel dimension, respectively.
6. A method for detecting agricultural pests, comprising using the agricultural pest monitoring system described in any one of claims 1-5 to detect agricultural pests, characterized in that, include: S1. Select an image acquisition device for agricultural pests according to preset conditions, and acquire images of agricultural crops; S2. Perform noise reduction, enhancement, cropping, and resizing on the acquired image data to improve image data quality; S3. Based on preset information, extract feature data for pest identification from the processed image using a convolutional neural network; S4. The extracted feature data information is optimized through spatial and channel weighting using a dual attention mechanism; S5. Based on the features processed by the dual attention mechanism, a convolutional neural network is used to train and identify the types of pests and diseases.
7. A computer-readable storage medium, characterized in that, The system contains a computer program that, when executed by a processor, causes the processor to perform the establishment of an agricultural pest monitoring system as described in any one of claims 1 to 5.
8. A computer device, characterized in that, It includes a memory and a processor, the memory storing a computer program, which, when executed by the processor, causes the processor to perform the establishment of an agricultural pest monitoring system as described in any one of claims 1 to 5.