Rice pest and disease target detection algorithm based on Mamba and YOLOv8
By using the Mamba and YOLOv8 rice pest and disease target detection algorithms, combined with multi-scale feature fusion and global context modeling, the problems of low efficiency and insufficient accuracy in rice pest and disease detection are solved, and high-precision pest and disease identification and trend prediction are achieved.
Patent Information
- Application Number
- CN202510940563.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-09
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2045-07-09
AI Technical Summary
Existing technologies for rice disease and pest detection have problems such as low efficiency, poor real-time performance, insufficient adaptability to complex environments, and insufficient accuracy in detecting small targets. In particular, it is difficult to achieve high-precision identification in complex backgrounds.
A rice pest and disease target detection algorithm based on Mamba and YOLOv8 is adopted. RGB images of rice fields are collected and preprocessed through terminal devices. The MedVSSM module is combined with the algorithm to extract multi-scale local detail features and global long-range dependencies. The C2F-MedVSSM module is used for cross-layer information transmission and feature fusion. The Mamba module is embedded in the YOLOv8 backbone for global context modeling, and finally the target detection box and category are generated.
It significantly improves detection accuracy under complex lighting and occlusion conditions, reduces data transmission pressure, supports historical data statistics and pest and disease trend prediction, and provides a decision-making basis for agricultural disaster prevention and mitigation.
Smart Images

Figure CN120472149B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of target detection, and in particular to a rice disease and insect pest target detection algorithm based on Mamba and YOLOv8. Background Art
[0002] Rice is one of the world's most important food crops, and its yield is directly related to food security. However, widespread pests and diseases such as rice blast, bacterial blight, rice planthoppers, and the rice stem borer seriously impact rice yield and quality. Traditional pest and disease identification relies on manual observation by agricultural technicians, which is not only inefficient and costly, but also susceptible to human experience, resulting in large subjective errors and poor universality. With the development of artificial intelligence and image recognition technologies, pest and disease identification methods based on deep learning are gradually becoming mainstream.
[0003] However, traditional rice pest and disease detection relies primarily on manual inspections or fixed-threshold image processing techniques, which suffer from low efficiency, poor real-time performance, and insufficient adaptability to complex environments. For example, manual inspections are limited by geographic scope and subjective judgment, making it difficult to achieve rapid and accurate monitoring of large rice fields. Traditional image processing methods (such as single-spectral threshold segmentation or edge detection) are susceptible to interference from factors such as lighting variations and crop occlusion, resulting in high rates of missed detection. Furthermore, while existing deep learning models (such as YOLOv8) perform well in object detection, their ability to model the correlation between disease areas and environmental factors across large distances is limited, and the detection accuracy of small targets (such as early lesions or insect eggs) is insufficient.
[0004] In summary, existing methods still have obvious shortcomings in small target detection in complex backgrounds, model computational efficiency and generalization ability of agricultural scenarios. In view of this, a rice pest and disease target detection algorithm based on Mamba and YOLOv8 is proposed. Summary of the Invention
[0005] The purpose of this invention is to provide a rice pest and disease target detection algorithm based on Mamba and YOLOv8 to solve the problems of "insufficient small target detection in complex backgrounds, model calculation efficiency and agricultural scene generalization ability".
[0006] To solve the above technical problems, the present invention provides a rice pest and disease target detection algorithm based on Mamba and YOLOv8, comprising the following steps:
[0007] S1. Collecting an RGB image of a rice field through a terminal device and preprocessing the RGB image to generate an abnormal RGB image;
[0008] S2. Input the abnormal RGB image into the MedVSSM module, and extract multi-scale local detail features (including 80×80 low-level edge texture, 40×40 mid-level morphological features, and 20×20 high-level semantic features) through a convolutional neural network. Input the 20×20 high-level semantic features into the Mamba state space model, capture the global dependency between distant disease areas through the state transition matrix and the input matrix, and output high-level global features.
[0009] S3. Input the multi-scale local detail features (80×80, 40×40) and high-level global features (20×20) into the C2F-MedVSSM module, dynamically adjust the weights of feature maps at different levels (low-level 80×80, middle-level 40×40, high-level 20×20) through the cross-layer information transmission mechanism, calculate the adaptive weights of low-level and high-level features in combination with the channel attention mechanism, and then perform cross-layer semantic enhancement and path aggregation through the feature pyramid network and path aggregation network to generate an optimized multi-scale feature map;
[0010] S4. Input the optimized multi-scale feature map into the YOLOv8 module, use the Mamba module in the YOLOv8 Backbone to perform global context modeling on the high-level features, and generate the target detection box, category and confidence through the detection head;
[0011] S5. Apply non-maximum suppression to remove redundant target detection frames, output the final pest and disease detection results, and visualize and store them.
[0012] As a further improvement of this technical solution, the terminal device is an agricultural drone or a fixed monitoring station; and the preprocessing is performed on an edge computing device or a cloud server.
[0013] As a further improvement of the present technical solution, in step S1, the preprocessing includes:
[0014] S1.1. Construct a pest and disease database containing spectral threshold ranges and morphological characteristic parameters based on historical pest and disease data;
[0015] S1.2. Compare the RGB image with the spectral threshold in the database to generate a preliminary anomaly mask;
[0016] S1.3. Perform Canny edge detection and HSV color segmentation on the RGB image, and superimpose the segmentation result with the preliminary anomaly mask to generate a comprehensive anomaly mask;
[0017] S1.4. Perform a morphological closing operation on the integrated anomaly mask to fill the empty areas and expand the pixel boundaries by a preset value to form a preliminary RGB image.
[0018] S1.5. Perform geometric enhancement, color enhancement, noise simulation, size normalization, and illumination correction on the preliminary RGB image in sequence to form an abnormal RGB image.
[0019] As a further improvement of the present technical solution, the construction of the pest and disease database in step S1.1 includes: extracting the key spectral threshold range of each type of pest and disease through a support vector model; using a morphological analysis algorithm to extract the area, edge curvature and texture distribution characteristics of the pest and disease area, and storing them as matchable database entries.
[0020] As a further improvement of the present technical solution, in step S2, the workflow of the MedVSSM module includes:
[0021] S2.1. Extract local detail features of the insect body and lesions in the comprehensive abnormality mask through a convolutional neural network, and input the high-level semantic features of the local detail features into the Mamba state space model;
[0022] S2.2. The long-range dependency of the integrated anomaly mask in the anomaly RGB image is captured by the Mamba state space model. Its state space equation is: ,in, is the state vector at time t, is the state transition matrix, indicating the transition from the previous state The change to the current state, is the input matrix, is the input signal, reflecting the input features of the rice field image; is the noise term;
[0023] S2.3. The inter-region dependency coefficient is dynamically adjusted through the MedVSSM module to fuse local detail features with global long-distance dependency features to generate multi-scale features.
[0024] As a further improvement of this technical solution, in step S2.3,
[0025] The formula for dynamically adjusting the inter-region dependency coefficient is: , is the inter-region dependency coefficient, which is used to measure the strength of association between different regions in the image. is the trainable attention parameter, is the feature vector of the current layer;
[0026] The local detail features are fused with the global long-distance dependency features through weighted summation. The formula is: ,in, is the multi-scale feature output by the MedVSSM module, is the activation function, are model parameters, including the state transition matrix of the Mamba state space model , input matrix , noise term , convolutional neural network convolution kernel weights and bias terms and trainable attention parameters ;
[0027] The local detail features include the insect body outline, lesion texture and edge curvature information; the global long-distance dependence features include the correlation between diseased areas and the influence of environmental factors.
[0028] As a further improvement of the present technical solution, in step S3, the workflow of the C2F-MedVSSM module includes:
[0029] S3.1. Dynamically adjust the weights of feature maps at different levels through a cross-layer information transfer mechanism.
[0030] S3.2. Calculate the weights of low-level features and high-level features by combining the channel attention mechanism. The formula is: , is the adaptive weight of low-level and high-level features, is the trainable attention parameter, is the feature vector of the current layer;
[0031] S3.3. Input the weighted feature map into the feature pyramid network and path aggregation network architecture, and generate an optimized multi-scale feature map through top-down semantic enhancement and bottom-up path aggregation.
[0032] As a further improvement of this technical solution, the specific implementation of the feature pyramid network and path aggregation network architecture includes:
[0033] S3.3.1. Upsample high-level semantic features through a feature pyramid network and concatenate them with low-level detail features to generate a pyramid feature map.
[0034] S3.3.2. Use the path aggregation network to perform convolutional alignment on the underlying edge features and concatenate them with the high-level semantic features to generate a path aggregation feature map.
[0035] S3.3.3. Perform bilinear interpolation on the pyramid feature map and the path aggregation feature map, adjust the pyramid feature map and the path aggregation feature map to the same size, and then splice them.
[0036] As a further improvement of this technical solution, the YOLOv8 module includes:
[0037] S4.1. Embed the Mamba module in the YOLOv8 Backbone for global context modeling.
[0038] S4.2. Generate target detection boxes, categories, and confidence levels using the multi-scale feature maps output by the C2F-MedVSSM module.
[0039] As a further improvement of this technical solution, the post-processing of step S5 includes:
[0040] S5.1. Remove overlapping object detection frames through non-maximum suppression and retain the object detection frame with the highest confidence.
[0041] S5.2. Transmit the test results to the cloud database to support historical data statistics and pest and disease trend prediction;
[0042] S5.3. Display the test results in real time through mobile terminals or web pages, and trigger abnormal alarms.
[0043] Compared with the prior art, the present invention has the following beneficial effects:
[0044] This rice pest and disease target detection algorithm based on Mamba and YOLOv8 uses the Mamba state space model to capture long-range dependencies between disease areas (such as disease diffusion paths and the impact of environmental humidity on pests and diseases). It combines convolutional neural networks to extract local detailed features such as insect body contours and lesion textures. Dynamic weight adjustment is used to achieve global-local feature fusion, significantly improving detection accuracy under complex lighting and occlusion conditions.
[0045] In this rice pest and disease target detection algorithm based on Mamba and YOLOv8, lightweight operations such as spectral threshold comparison and Canny edge detection are implemented through edge computing devices (such as drone-mounted chips) in the preprocessing stage, reducing data transmission pressure; cloud servers complete the construction of pest and disease databases and model training, support historical data statistics and pest and disease trend prediction, and provide decision-making basis for agricultural disaster prevention and mitigation. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 Schematic diagram of the method of the present invention. DETAILED DESCRIPTION
[0047] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0048] At present, traditional rice pest and disease detection mainly relies on manual inspections or image processing technology based on fixed thresholds, which has problems such as low efficiency, poor real-time performance, and insufficient adaptability to complex environments. For example, manual inspections are limited by geographical scope and subjective judgment, making it difficult to achieve rapid and accurate monitoring of large areas of rice fields; and traditional image processing methods (such as single spectral threshold segmentation or edge detection) are easily affected by factors such as lighting changes and crop occlusion, resulting in a high rate of missed detection. In addition, although existing deep learning models (such as YOLOv8) perform well in target detection, their ability to model the correlation between distant disease areas and environmental factors is limited, and the detection accuracy of small targets (such as early lesions or insect eggs) is insufficient;
[0049] For this reason, see Figure 1 As shown, the object of the present invention is to provide a rice pest and disease target detection algorithm based on Mamba and YOLOv8, and the rice pest and disease target detection algorithm based on Mamba and YOLOv8 includes the following steps:
[0050] S1. Collecting an RGB image of a rice field through a terminal device and preprocessing the RGB image to generate an abnormal RGB image;
[0051] S2. Input the abnormal RGB image into the MedVSSM module, extract multi-scale local detail features (including 80×80 low-level edge texture, 40×40 mid-level morphological features, and 20×20 high-level semantic features) through a convolutional neural network, input the high-level semantic features in the multi-scale local detail features into the Mamba state space model, capture the global dependency between distant disease areas through the state transition matrix and the input matrix, and output the global long-distance dependency features;
[0052] S3. Input the local detail features and global long-distance dependency features into the C2F-MedVSSM module, dynamically adjust the weights of feature maps at different levels through the cross-layer information transmission mechanism, calculate the adaptive weights of low-level and high-level features in combination with the channel attention mechanism, and then perform cross-layer semantic enhancement and path aggregation through the feature pyramid network and path aggregation network to generate an optimized multi-scale feature map;
[0053] S4. Input the optimized multi-scale feature map into the YOLOv8 module, use the Mamba module in the YOLOv8 Backbone to perform global context modeling on the high-level features, and generate the target detection box, category and confidence through detection;
[0054] S5. Apply non-maximum suppression to remove redundant target detection frames, output the final pest and disease detection results, and visualize and store them.
[0055] This rice pest and disease target detection algorithm based on Mamba and YOLOv8 uses the Mamba state space model to capture long-range dependencies between disease areas (such as disease diffusion paths and the impact of environmental humidity on pests and diseases). It then uses a convolutional neural network to extract local detail features such as insect body contours and lesion textures. Dynamic weight adjustment is used to achieve global-local feature fusion, significantly improving detection accuracy under complex lighting and occlusion conditions. Furthermore, in the preprocessing stage, lightweight operations such as spectral threshold comparison and Canny edge detection are implemented using edge computing devices (such as drone-mounted chips), reducing data transmission pressure. Cloud servers complete the construction of pest and disease databases and model training, supporting historical data statistics and pest and disease trend forecasting, providing a decision-making basis for agricultural disaster prevention and mitigation.
[0056] Further introduction to step S1:
[0057] 1. Data collection (terminal equipment: agricultural drones / fixed monitoring points): Agricultural drones or fixed monitoring stations are used to capture images of rice fields. The images are saved in RGB format and uploaded to edge computing devices or cloud servers via wireless communication (such as WiFi / 5G) to achieve real-time data acquisition.
[0058] 2. Data Preprocessing (Edge Computing Devices / Servers): Based on the characteristics of rice pest and disease images, a customized image preprocessing process is designed to improve model robustness and detection accuracy. Specifically, it includes:
[0059] S1.1. Construct a pest and disease database containing spectral threshold ranges and morphological characteristic parameters based on historical pest and disease data. Construction of the pest and disease database includes: extracting the key spectral threshold ranges for each type of pest and disease using a support vector model; extracting the area, edge curvature, and texture distribution characteristics of the pest and disease area using a morphological analysis algorithm, and storing them as matchable database entries;
[0060] S1.2, compare the RGB image with the spectral threshold in the database to generate a preliminary anomaly mask;
[0061] S1.3. Perform Canny edge detection and HSV color segmentation on the RGB image, and superimpose the segmentation result with the preliminary anomaly mask to generate a comprehensive anomaly mask;
[0062] S1.4. Perform morphological closing operations on the integrated anomaly mask to fill the empty areas and expand the pixel boundaries by a preset value to form a preliminary RGB image.
[0063] S1.5. Performing geometric enhancement, color enhancement, noise simulation, size normalization, and illumination correction on the preliminary RGB image in sequence to form an abnormal RGB image;
[0064] Among them, geometric enhancement: random rotation (0-90°) and horizontal / vertical flipping enhance the model's adaptability to different viewing angles and field layouts; color enhancement: HSV channel adjustment (saturation, brightness) + adaptive histogram equalization (CLAHE) improves the visual contrast of the diseased area; noise simulation: Gaussian noise and motion blur are introduced to enhance the model's robustness to blur and jitter in the actual shooting environment; background interference modeling: MixUp, CutMix and other enhancement methods are used to simulate the visibility of targets in complex backgrounds; size normalization: the image is scaled to 640×640, and the Letterbox strategy is used to maintain the target ratio to avoid the impact of deformation on detection accuracy; illumination correction includes image denoising and dynamic fill light. Image denoising: bilateral filtering and non-local mean (NLM) filtering are used to remove background noise; dynamic fill light: the Retinex algorithm is introduced to improve the ability to express details in shadows and low-light areas.
[0065] To achieve accurate superposition of the segmentation results and the preliminary anomaly mask, in step S1.3, feature overlay is first performed on the edge intensity map generated by Canny edge detection and the color segmentation map generated by HSV color segmentation in step S1.3.1. This determines the areas of pest morphology and leaf lesions in the edge intensity map and the areas of pest color and leaf discoloration in the color segmentation map.
[0066] Since the preliminary anomaly mask, edge intensity map feature area, and color segmentation map feature area are derived from different processing logics (the mask area is generated based on screening conditions, the edge intensity map is derived from contour feature extraction, and the color segmentation map is based on color space difference recognition), there are essential differences in the feature expressions of the three: the mask area may contain semantic segmentation results based on prior knowledge, the edge intensity map focuses on contour information with significant gradient changes, and the color segmentation map focuses on the division of areas with color gamut differences. This heterogeneity of multimodal features makes the traditional method of relying on the superposition method of unified feature point anchoring of RGB images ineffective. Fundamentally, this is because the feature areas of different modalities may lack direct correspondence at the pixel level. For example, the pest and disease area marker in the mask may not contain the gradient information that edge detection focuses on, and the heterochromatic area of color segmentation may not completely overlap with the contour of the edge intensity map.
[0067] In the case of such incompatible feature spaces, if the traditional overlay method is directly used, the missing anchor points will lead to misalignment of regional boundaries or overlapping deviations. Therefore, in step S1.3.2, the edge contours of each region are extracted: through the edge extraction operation, the three heterogeneous feature regions are converted into a unified geometric contour representation (mask region edge box, edge intensity map feature region edge box, color segmentation map feature region edge box). The advantage of this processing method is that the edge, as a universal geometric feature across modalities, can objectively describe the spatial boundaries of each region. Regardless of the differences in its internal features (semantic labels, gradient intensity, color values), the region range can be defined by a closed edge box, thereby establishing a spatial alignment benchmark between different feature regions, providing a unified mathematical model basis for subsequent correction and splicing based on geometric features;
[0068] Considering that the RGB image may contain incomplete areas of pest morphology, leaf spots, pest colors, and leaf heterochromia due to leaf occlusion or incomplete leaf photography at the image edge, in step S1.3.3, after the mask area edge frame, the edge intensity map feature area edge frame, and the color segmentation map feature area edge frame are constructed, the area, edge curvature, and texture distribution characteristics of similar pest areas are matched according to the database entries in the pest database. Based on the area, edge curvature, and texture distribution characteristics of the pest areas, the incomplete edge frames in the mask area edge frame, the edge intensity map feature area edge frame, and the color segmentation map feature area edge frame are corrected so that the shape of the edge frame conforms to the area, edge curvature, and texture distribution characteristics of the pest area, thereby forming a theoretically complete edge frame.
[0069] Finally, in step S1.3.4, the edge frames refined in step S1.3.3 are combined into a comprehensive edge frame. During the combination, the intersection of the three edge frames, the intersection of the two edge frames, and the inflection points of the individual edge frames are found as anchor points. The corresponding pixels on the RGB image are determined by the anchor points, and a comprehensive anomaly mask is generated by superimposing them on the RGB image.
[0070] Lightweight adaptation, combined with model pruning and quantization (FP16 / INT8), improves the efficiency of model deployment on agricultural edge devices (such as drones and ARM architecture embedded platforms). Inference is accelerated using OpenCV+TensorRT to ensure real-time processing capabilities;
[0071] Third, label data generation: Manual labeling is performed using tools such as LabelImg and Roboflow to generate object detection boxes in the YOLO format. Labels are transformed during the enhancement process, and super-resolution preprocessing is introduced for small objects. Combined with active learning strategies, this improves labeling efficiency and sample quality.
[0072] Further introduction to step S2:
[0073] First, local detail feature extraction, integrating the advantages of CNN for local detail extraction, accurately modeling local abnormal structures such as spots and insect body textures, achieving local-global feature complementarity, and improving robustness against small targets and complex scenes. The Mamba module takes advantage of the state space mechanism and introduces a convolutional neural network (CNN) to enhance local feature extraction. In MedVSSM, the design of the Mamba module is as follows: ,in, is the multi-scale feature output by the MedVSSM module, is the activation function, are model parameters, including the state transfer matrix , input matrix , noise term , convolutional neural network convolution kernel weights and bias terms and trainable attention parameters ;
[0074] The local detail features of the insect body and lesions in the comprehensive abnormality mask are extracted through a convolutional neural network, and the high-level semantic features in the local detail features are input into the Mamba state space model.
[0075] Second, global long-range dependency feature extraction (MedVSSM module): MedVSSM is constructed based on the improved Mamba module, using a state-space mechanism to model long-range dependencies and capture remote disease contextual information in rice field images. In rice field images, diseased areas may be relatively small and scattered, and are often affected by long-range contextual factors such as surrounding vegetation, lighting, and terrain. While traditional CNNs excel at extracting local features, they struggle to capture associations between long-range regions. For example, similar lesions may appear on distant leaves, or the humidity in one area may cause the spread of a disease in another. In these cases, the ability to model long-range dependencies is crucial.
[0076] Mamba is a novel sequence modeling framework based on the State Space Model (SSM). Essentially, it uses a linear time-invariant system structure to model the dependencies between inputs of arbitrary length. Its state space equation is: ,in, is the state vector at time t, is the state transition matrix, indicating the transition from the previous state The change to the current state, is the input matrix, is the input signal, reflecting the input features of the rice field image; is the noise term;
[0077] The formula for dynamically adjusting the inter-region dependency coefficient is: , is the inter-region dependency coefficient, which is used to measure the strength of association between different regions in the image. is the trainable attention parameter, is the feature vector of the current layer;
[0078] In order to capture the dependencies between distant regions, MedVSSM adopts a weighted summation mechanism in the state space, which reflects the mutual influence of distant diseases by dynamically adjusting the dependencies between regions. The long-distance dependency modeling form in the state space is as follows: ,in, is the status information of other areas in the image, The inter-regional dependency coefficient is used to measure the correlation strength between different regions in the image. N is the number of all regions in the image. Through this weighted summation method, the model can adaptively capture the long-range dependency relationship between diseased areas in the rice field.
[0079] Through this design, Mamba can effectively integrate local details and global dependency features, improving its ability to accurately identify rice field pests and diseases, especially in complex scenarios.
[0080] In MedVSSM, CNNs are used for local feature extraction, while state-space models are responsible for capturing long-range dependencies in the image. This combined network structure retains local information while leveraging global context, thereby improving the detection accuracy of small objects. This mechanism effectively addresses the local dependency issues of traditional convolutional neural networks in rice field images, particularly when the diseased areas are small or distributed over long distances, thereby improving detection accuracy and robustness.
[0081] Local detail features include insect body outline, lesion texture and edge curvature information; global long-range dependent features include the correlation between diseased areas and the influence of environmental factors;
[0082] Further introduction to step S3:
[0083] In agricultural pest and disease target detection, rice pests and diseases manifest themselves in diverse forms. Lesions, insect bodies, and distribution areas can vary in scale. In particular, small targets (such as rice planthoppers) are often overwhelmed by background information. Therefore, effectively fusing multi-scale features while ensuring the detection accuracy of small targets is key to improving detection performance. To address this challenge, a multi-scale feature fusion scheme combining C2F-MedVSSM with FPN+PAN is proposed.
[0084] First, cross-layer information transfer and dynamic feature recalibration are achieved through C2F-MedVSSM. The C2F-MedVSSM (Cross-layer Feature Fusion Agricultural Disease Visual State Space Model) module uses a cross-layer information transfer mechanism to dynamically adjust and recalibrate features at multiple scales. Specifically, C2F-MedVSSM builds a dynamically adjusted multi-scale feature network to transfer information between different layers, ensuring that features of both small and large objects are fully extracted and utilized. This module works as follows: ,in, is the state vector of multi-scale features, representing a certain moment The image features, is the adaptive weight of low-level and high-level features, is the local feature at that moment, the feature extracted by CNN. Through this mechanism, C2F-MedVSSM can enhance the synergy of features at each layer and avoid the information loss of the bottom-level features in traditional convolutional neural networks;
[0085] Second, it provides top-down semantic enhancement through the Feature Pyramid Network (FPN). FPN is a multi-scale feature fusion method commonly used in object detection. Its core concept is to enhance high-level semantic features through a top-down structure to better integrate low-level detail information. In rice pest and disease detection, since different targets have different scales, FPN can enhance high-level semantic features through a top-down approach and fuse these features with low-level detail features.
[0086] The operation of FPN is achieved through the following process:
[0087] 1. Top-down semantic enhancement: High-level features are passed to low-level layers, the number of channels is adjusted through 1x1 convolution, and upsampling is performed to enhance the semantic information of low-level features.
[0088] 2. Cross-layer fusion: Perform bilinear interpolation on the pyramid feature map and the path aggregation feature map, adjust the pyramid feature map and the path aggregation feature map to the same size, then splice and merge them, and fuse them through horizontal connections to form a richer multi-scale feature representation.
[0089] This method can help the model better identify pest and disease targets of different sizes and shapes, especially in the detection of small targets such as rice planthoppers, thereby improving the detection accuracy of the model.
[0090] Third, PAN (Path Aggregation Network) is used to aggregate low-level textures into higher levels. PAN is another multi-scale feature fusion method that primarily enhances feature representation through the interaction of low-level and high-level features. In object detection, low-level features typically contain rich edge and texture information but are relatively weak in semantic expression. High-level features, on the other hand, contain higher-level semantic information but may lack edge detail. PAN, through the interactive aggregation of low-level and high-level features, strengthens overall object perception, particularly for small object recognition.
[0091] The operation process of PAN is as follows:
[0092] 1. Path aggregation: The low-level texture information is transferred to the higher-level feature map through path aggregation for feature enhancement.
[0093] 2. Cross-scale interaction: Combining low-level and high-level feature maps, the information flow in target detection is enhanced through weighted summation or splicing operations, thereby effectively improving the ability to identify small pests and diseases.
[0094] Through this path aggregation design, PAN can effectively eliminate the detection difficulty caused by different target sizes and improve the performance of the model in complex scenarios.
[0095] Fourth, the cross-scale attention mechanism is used to further improve the detection capability of small targets. The core idea of the cross-scale attention mechanism is to adaptively adjust the fusion weights of features at different scales according to the scale of the target, ensuring that small targets (such as rice planthoppers) can be fully represented in low-level features, while large targets can be more strongly semantically expressed in high-level features. The specific attention mechanism is implemented by the following formula: ,in, is the adaptive weight of low-level and high-level features at a given target scale, is a trainable attention parameter, is the feature vector of the current layer. In this way, the model can dynamically adjust the feature fusion method according to the size of the target, ensuring that the performance of small targets is not neglected.
[0096] Further introduction to step S4:
[0097] In this solution, the Mamba module (Visual State Space Model, VSSM) is incorporated into the Backbone of YOLOv8 to enhance the model's global perception capabilities, particularly its ability to model long-range dependencies. Traditional YOLO networks rely solely on convolutional layers to extract local features, but in complex image scenes, long-range dependencies and global context are crucial for identifying pests and diseases. Therefore, embedding the Mamba module into the Backbone effectively improves YOLOv8's ability to capture long-range pests in images. The inference process is as follows:
[0098] Input image: The input image data has been preprocessed and is ready to be processed by the network;
[0099] Backbone local feature extraction (enhanced rice disease sensitive features): extracts local features from images through traditional convolution operations and identifies basic image information;
[0100] Mamba module global modeling (capturing remote associations of rice diseases): Extracted local features are fed into the Mamba module for global modeling, capturing contextual information between distant disease areas. This step enhances global dependencies within the image, facilitating the processing of complex pest and disease targets.
[0101] C2F-MedVSSM cross-scale fusion (rice disease small target enhancement): Through the C2F-MedVSSM module, multi-scale features are combined for dynamic recalibration to achieve more accurate small target recognition;
[0102] YOLOv8 module: After feature processing in the previous steps, YOLOv8 outputs the target detection frame, category, and confidence level. For example, by combining the drone's GPS positioning information, the target detection frame coordinates are mapped to actual geographic coordinates. The categories are the disease labels of the main cultivated varieties in Sichuan (such as Yixiangyou 2115 being susceptible to rice blast and Chuanyou 6203 being susceptible to sheath blight), with a total of 12 categories (8 diseases + 3 insect pests + background).
[0103] Finally, the results are output and post-processed (terminal device / visualization module). For scenarios with overlapping rice leaves, NMS technology (softening coefficient of 0.5) is used to avoid missing overlapping disease spots. The test results are visualized and written to the database simultaneously to support subsequent statistics, early warning, and tracking. For example, the test results are superimposed with a pseudo-color mask (red for rice blast and yellow for sheath blight), and the diseased areas are marked on the agricultural GIS map. The results are also written to the cloud database simultaneously, and the fields include: test time, variety type, disease level (light / moderate / severe), and environmental parameters (humidity > 80% triggers an early warning).
[0104] In summary, the workflow of this solution is as follows:
[0105] 1. Use agricultural drones or monitoring stations to collect images of rice fields;
[0106] 2. Upload the captured image to the server or edge device and perform the pre-processing process;
[0107] 3. Perform data enhancement and illumination / size normalization on the image;
[0108] 4. Input the preprocessed image into the MedVSSM module to extract global and local multi-scale features;
[0109] 5. Multi-scale feature fusion and dynamic recalibration through the C2F-MedVSSM module;
[0110] 6. Use the improved YOLOv8Head for target detection and output category and positioning information;
[0111] 7. Apply non-maximum suppression (NMS) to remove redundancy and complete the final recognition;
[0112] 8. The test results are visualized and stored in the database or transmitted to the cloud;
[0113] 9. Users can view identification information and historical records through the APP / webpage;
[0114] 10. Support automatic alarm and pest and disease trend prediction to serve agricultural production decision-making.
[0115] The above shows and describes the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The above embodiments and descriptions are merely preferred examples of the present invention and are not intended to limit the present invention. Various changes and improvements may be made to the present invention without departing from the spirit and scope of the present invention. Such changes and improvements fall within the scope of the present invention. The scope of protection claimed in the present invention is defined by the appended claims and their equivalents.
Claims
1. Rice pest and disease target detection algorithm based on Mamba and YOLOv8, characterized by: The following steps are involved: S1. Collecting an RGB image of a rice field through a terminal device and preprocessing the RGB image to generate an abnormal RGB image; S2. Input the abnormal RGB image into the MedVSSM module, extract multi-scale local detail features through a convolutional neural network, input the high-level semantic features in the multi-scale local detail features into the Mamba state space model, capture the global dependency between distant disease areas through the state transition matrix and the input matrix, and output the global long-distance dependency features; S3. Input the local detail features and global long-distance dependency features into the C2F-MedVSSM module, dynamically adjust the weights of feature maps at different levels through the cross-layer information transmission mechanism, calculate the adaptive weights of low-level and high-level features in combination with the channel attention mechanism, and then perform cross-layer semantic enhancement and path aggregation through the feature pyramid network and path aggregation network to generate an optimized multi-scale feature map; S4. Input the optimized multi-scale feature map into the YOLOv8 module, use the Mamba module in the YOLOv8 Backbone to perform global context modeling on the high-level features, and generate the target detection box, category and confidence through detection; S5. Apply non-maximum suppression to remove redundant target detection frames, output the final pest and disease detection results, and visualize and store them.
2. The rice pest and disease target detection algorithm based on Mamba and YOLOv8 according to claim 1, characterized in that: The terminal device is an agricultural drone or a fixed monitoring station; preprocessing is performed on an edge computing device or a cloud server.
3. The rice pest and disease target detection algorithm based on Mamba and YOLOv8 according to claim 1, characterized in that: In step S1, preprocessing includes: S1.
1. Construct a pest and disease database containing spectral threshold ranges and morphological characteristic parameters based on historical pest and disease data; S1.
2. Compare the RGB image with the spectral threshold in the database to generate a preliminary anomaly mask; S1.
3. Perform Canny edge detection and HSV color segmentation on the RGB image, and superimpose the segmentation result with the preliminary anomaly mask to generate a comprehensive anomaly mask; S1.
4. Perform a morphological closing operation on the integrated anomaly mask to fill the empty areas and expand the pixel boundaries by a preset value to form a preliminary RGB image. S1.
5. Perform geometric enhancement, color enhancement, noise simulation, size normalization, and illumination correction on the preliminary RGB image in sequence to form an abnormal RGB image.
4. The rice pest and disease target detection algorithm based on Mamba and YOLOv8 according to claim 3, characterized in that: The construction of the pest and disease database in step S1.1 includes: extracting the key spectral threshold range of each type of pest and disease through a support vector model; using a morphological analysis algorithm to extract the area, edge curvature and texture distribution characteristics of the pest and disease area, and storing them as matchable database entries.
5. The rice pest and disease target detection algorithm based on Mamba and YOLOv8 according to claim 1, characterized in that: In step S2, the workflow of the MedVSSM module includes: S2.
1. Extract local detail features of the insect body and lesions in the comprehensive abnormality mask through a convolutional neural network, and input the high-level semantic features of the local detail features into the Mamba state space model; S2.
2. The long-range dependency of the integrated anomaly mask in the anomaly RGB image is captured by the Mamba state space model. Its state space equation is: ,in, is the state vector at time t, is the state transition matrix, indicating the transition from the previous state The change to the current state, is the input matrix, is the input signal, reflecting the input features of the rice field image; is the noise term; S2.
3. The inter-region dependency coefficient is dynamically adjusted through the MedVSSM module to fuse local detail features with global long-distance dependency features to generate multi-scale features.
6. The rice pest and disease target detection algorithm based on Mamba and YOLOv8 according to claim 5, characterized in that: In step S2.3, The formula for dynamically adjusting the inter-region dependency coefficient is: , is the inter-region dependency coefficient, which is used to measure the strength of association between different regions in the image. is the trainable attention parameter, is the feature vector of the current layer; The local detail features are fused with the global long-distance dependency features through weighted summation. The formula is: ,in, is the multi-scale feature output by the MedVSSM module, is the activation function, are model parameters, including the state transition matrix of the Mamba state space model , input matrix , noise term , convolutional neural network convolution kernel weights and bias terms and trainable attention parameters ; The local detail features include the insect body outline, lesion texture and edge curvature information; the global long-distance dependence features include the correlation between diseased areas and the influence of environmental factors.
7. The rice pest and disease target detection algorithm based on Mamba and YOLOv8 according to claim 1, characterized in that: In step S3, the workflow of the C2F-MedVSSM module includes: S3.
1. Dynamically adjust the weights of feature maps at different levels through a cross-layer information transfer mechanism. S3.
2. Calculate the weights of low-level features and high-level features by combining the channel attention mechanism. The formula is: , is the adaptive weight of low-level and high-level features, is the trainable attention parameter, is the feature vector of the current layer; S3.
3. Input the weighted feature map into the feature pyramid network and path aggregation network architecture, and generate an optimized multi-scale feature map through top-down semantic enhancement and bottom-up path aggregation.
8. The rice pest and disease target detection algorithm based on Mamba and YOLOv8 according to claim 7, characterized in that: The specific implementation of the feature pyramid network and path aggregation network architecture includes: S3.3.
1. Upsample high-level semantic features through a feature pyramid network and concatenate them with low-level detail features to generate a pyramid feature map. S3.3.
2. Use the path aggregation network to perform convolutional alignment on the underlying edge features and concatenate them with the high-level semantic features to generate a path aggregation feature map. S3.3.
3. Perform bilinear interpolation on the pyramid feature map and the path aggregation feature map, adjust the pyramid feature map and the path aggregation feature map to the same size, and then splice them.
9. The rice pest and disease target detection algorithm based on Mamba and YOLOv8 according to claim 1, characterized in that: The YOLOv8 module includes: S4.
1. Embed the Mamba module in the YOLOv8 Backbone for global context modeling. S4.
2. Generate target detection boxes, categories, and confidence levels using the multi-scale feature maps output by the C2F-MedVSSM module.
10. The rice pest and disease target detection algorithm based on Mamba and YOLOv8 according to claim 1, characterized in that: The post-processing of step S5 includes: S5.
1. Remove overlapping object detection frames through non-maximum suppression and retain the object detection frame with the highest confidence. S5.
2. Transmit the test results to the cloud database to support historical data statistics and pest and disease trend prediction; S5.
3. Display the test results in real time through mobile terminals or web pages, and trigger abnormal alarms.
Citation Information
Patent Citations
Colonoscope polyp image detection method based on Mamba and YOLOv8
CN118762009A
Improved YOLOv8-based high-voltage transmission line defect detection algorithm
CN119515821A