Lightweight model and attention mechanism pest detection model and training method
By improving the CassavaSegNet model of the YOLOv8-Seg architecture and combining it with the lightweight MobileViT backbone network and BiFPN, the problem of insufficient generalization ability in cassava pest and disease detection was solved, achieving a balance between high accuracy and low latency, and improving the fine-grained segmentation ability of diseased areas.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-03
- Publication Date
- 2026-04-10
AI Technical Summary
Existing deep learning technologies lack generalization ability in cassava pest and disease identification and detection, making it difficult to achieve a balance between high accuracy and low latency, unable to achieve fine-grained segmentation, and limited in detection capability in complex scenarios.
The lightweight MobileViT backbone network is used to replace CSPDarknet53. Combined with the Global Feature Fusion (GFC) module and the Coordinate Attention (CA) mechanism, a Bidirectional Feature Pyramid Network (BiFPN) is adopted in the neck network. Data augmentation techniques such as sharpening filtering, random elastic deformation and color dithering are used to improve the CassavaSegNet model of YOLOv8-Seg architecture.
While maintaining a real-time inference speed of 0.04s/image, the accuracy and robustness of the model were improved, achieving pixel-level accurate segmentation of cassava leaf lesions, enhancing the model's generalization and robustness, and showing good balance between precision and recall across disease categories.
Smart Images

Figure CN120823475B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of deep learning, and particularly relates to a light-weight model and a pest and disease detection model with an attention mechanism and a training method, which are mainly applied to cassava. BACKGROUND
[0002] Cassava is an important food crop with important economic and nutritional value worldwide. Its cultivation is often severely affected by pests and diseases, leading to a significant decrease in yield, and thus adversely affecting farmers' income and food security. Therefore, cassava pest and disease control is very important. Traditional cassava pest and disease control mainly relies on manual inspection and chemical pesticides, which is time-consuming, labor-intensive and costly, and chemical pesticides have certain harm to the environment and human health. The application of visual detection methods based on machine vision and deep learning to cassava pest and disease detection can easily realize remote, intensive, comprehensive and real-time environmental protection and precise intelligent pest and disease monitoring, which is of great significance for the prevention and control of cassava pests and diseases.
[0003] In recent years, patenters have made some preliminary achievements in cassava pest and disease identification and detection by improving deep learning models. Some patents attempt to apply convolutional neural networks (CNN) to cassava pest and disease identification: Adeel et al. used an improved ResNet model to classify cassava diseases and achieved high accuracy in a laboratory environment, but lacked diversity and representativeness, and the model had insufficient generalization ability; Zhang et al. designed a cassava disease detection model based on the lightweight MobileNetV3 suitable for mobile terminals, which significantly reduced the computational complexity, although the lightweight model improved the computational efficiency, but the balance between high precision and low delay was still a challenge; some patents attempt to combine pest and disease identification with multi-task, Wang et al. proposed a cassava pest and disease detection model based on YOLOv4, which improved the detection accuracy through multi-scale feature fusion, but the adaptability to complex background and light changes was limited; in view of the problems of virtual focus and uneven color in cassava leaf images, patenters introduced data enhancement technology, Liu et al. enhanced the robustness of the model to low-quality images through random elastic deformation and color jittering technology, but lacked the ability of fine-grained segmentation of disease areas, and still could not meet the demand of accurate diagnosis.
[0004] As the patent with application number CN202410329224.0 discloses a cassava leaf disease classification, which is used for classifying cassava leaf images according to disease types or health states, and includes the following steps: S1, pre-processing a to-be-tested cassava leaf image to obtain a pre-processed image data set. S2, inputting the pre-processed image data set obtained in step S1 into a cassava leaf disease classification model, pre-training to obtain a pre-training model; EfficientNet-b4 is used as the main backbone network. S3, using the pre-training model to infer the pre-processed image data set, correcting the image data set, and removing the image data incorrectly classified in the image data set. S4, inputting the corrected image data set into the cassava leaf disease classification model again, re-training until the classification accuracy rate standard is reached, and obtaining a final cassava leaf disease classification model. S5, putting the pre-processed to-be-tested cassava leaf image into the cassava leaf disease classification model obtained in step S4 to perform disease classification and output the classification result.
[0005] As the patent with application number CN202210254211.2 discloses a cassava leaf disease classification method based on transfer learning, which is characterized by the following steps: (1) obtaining cassava leaf disease data, which is divided into 5 types, 4 of which are disease categories and 1 of which is a health category; the cassava leaf disease data includes a number of pictures of cassava leaf diseases and healthy pictures, as well as a csv file containing the name and corresponding label of each picture. (2) Divide the cassava leaf disease data obtained in step (1) into a training set and a test set. (3) Build a transfer learning model, train the transfer learning model using the training set obtained in step (2), and during the training process, use image processing and image enhancement methods to pre-process the data set obtained in step (2), and save the trained transfer learning model; wherein the transfer learning model uses the EfficientNet-B4 network in the timm library, and the EfficientNet-B4 network includes Stem, 7 blocks and Final layers, i.e. the last layer of the EfficientNet-B4 network. (4) Input the test set into the trained transfer learning model in step (3) to verify the generalization ability and accuracy of the trained transfer learning model. (5) Pre-process the to-be-classified cassava leaf disease data image and input it into the trained transfer learning model in step (4) to output the cassava leaf disease category to which the cassava leaf disease data belongs.
[0006] A patent with application number CN202110659758.6 discloses a cassava disease recognition method, which comprises the following steps: S1, collecting disease images of cassava leaves and classifying them; S2, preprocessing the classified disease images; S3, data augmentation is performed on the image data to form an image data set; S4, the image data set is divided into a training set, a validation set and a test set; S5, a network model is constructed, wherein the network model is based on an Efficientnet neural network, and the network model comprises one convolutional layer and two fully connected layers, the fully connected layer comprises a disease and pest classification layer, and each category in the disease and pest classification layer corresponds to a cassava disease and a healthy state; S6, the image data of the training set is put into the network model for training, and after each training, the image data of the validation set is used for verification until the training of the network model is completed; and S7, the image data in the test set is put into the network model for disease recognition.
[0007] As can be seen from the above patent, the existing technology is mainly based on Efficientnet neural network training. SUMMARY
[0008] In order to solve the problems of insufficient generalization ability of existing deep learning technology in the field of cassava disease and pest recognition detection, difficulty in achieving balance between high precision and low delay, inability to achieve fine-grained segmentation, and limited detection capability in complex scenes, and to realize accurate detection of cassava diseases and pests, the present patent proposes a cassava disease and pest high-precision segmentation model CassavaSegNet based on lightweight convolution and attention mechanism. The model uses point annotation to visualize the shape of the leaf, and performs data enhancement through sharpening filter, deconvolution technology, random elastic deformation and color jittering technology. The backbone network of the model uses a lightweight MobileViT, applies a neck network designed based on BiFPN, and uses a Decoupled Head of YOLOv8-Seg to separate tasks, which significantly improves the flexibility and accuracy of detection, realizes efficient and accurate segmentation of disease areas in cassava leaves, and provides important technical support for cassava disease and pest detection and prevention. The technical solution is as follows:
[0009] On the one hand, the present application provides a disease and pest detection model based on lightweight model and attention mechanism, which is based on YOLOv8-Seg and adjusted as follows:
[0010] (1) In the backbone network Backbone, the CSPDarknet53 is replaced by a lightweight MobileViT backbone network, the lightweight MobileViT backbone network comprising five layers of structures stacked in series, each layer of structure comprising a Conv2d and a MobileViTBlock module, the Conv2d and the MobileViTBlock module sequentially processing a feature map, and the third layer of structure, the fourth layer of structure and the fifth layer of structure respectively outputting a feature map to a coordinate attention module of a neck network.
[0011] (2) The neck network neck comprises a coordinate attention module, a global feature compressor module and 2-4 bidirectional feature pyramid networks BiFPN stacked in series, the coordinate attention module, the global feature compressor module and the bidirectional feature pyramid network BiFPN sequentially processing a feature map and outputting to a head network Head.
[0012] In another aspect, the embodiment of the present application also provides a training method of the foregoing lightweight model and the pest and disease detection model of the attention mechanism, the method comprising: S101: acquiring cassava disease image dataset; S102: performing data cleaning work on the dataset to eliminate irrelevant or poor quality images; S103: performing fine annotation using a computer vision annotation tool platform, and using SAM 2.0 as a core segmentation tool to accurately outline the outline of the cassava leaf and the diseased area during the annotation process to generate pixel-level segmentation labels; S104: performing data enhancement on the annotated data, the data enhancement comprising horizontal flip, sharpening filter, Gaussian blur, elastic deformation, color transformation and / or local magnification; and S105: training the cassava disease detection model through the data enhanced data.
[0013] The technical scheme provided by the embodiment of the application has the beneficial effects that: the patent aims at the precise detection demand of cassava diseases and pests, starts from the problems of low accuracy, poor real-time performance, high missed detection rate and the like of existing detection methods, and proposes a CassavaSegNet deep learning model improved based on a YOLOv8-Seg architecture. The model is based on the YOLOv8-Seg architecture, uses the decoupling detection head to separate the classification and regression tasks to improve the precision, and by introducing a lightweight MobileViT backbone network to replace the original CSPDarknet53, combining a global feature fusion module (GFC) and a coordinate attention mechanism (CA), the feature expression capability is enhanced while the parameter amount and the computational complexity are reduced. A bidirectional feature pyramid network (BiFPN) is used in the neck network to replace the original FPN structure, and the multi-scale feature fusion is optimized by fully mining the multi-scale features and context information. In addition, the model combines the segmentation capability of SAM2 and the target detection capability of YOLO-SEG, realizes shape adaptive labeling, and effectively shields the influence of the complex background on the detection precision. The patent uses various data enhancement technologies such as sharpening filtering, random elastic deformation and color jitter to enhance the training set, and effectively improves the generalization and robustness of the model. The experiment based on the Cassava_paper_dataset shows that: the improved model breaks through 0.9 in mAP@0.5 and stabilizes in the interval of 0.8-0.9 in mAP@[0.5:0.95] on the basis of maintaining the real-time inference speed of 0.04s / image, and the balance of the precision and recall rate indexes of each disease category is good. Through the lightweight structure and multi-module collaborative optimization, the model realizes the pixel-level precise segmentation of cassava leaf disease spots, and provides technical support with high precision and high efficiency for intelligent diagnosis of agricultural diseases. BRIEF DESCRIPTION OF DRAWINGS
[0014] Figure 1 is a CassavaSegNet model architecture principle diagram; Figure 2 is a principle block diagram of the existing YOLOv8-Seg; Figure 3 is a processing flowchart of the backbone network; Figure 4 is a principle diagram of the MobileViTBlock module of the patent; Figure 5 is a flowchart of the process of local feature extraction; Figure 6 is a flowchart of the process of global feature modeling; Figure 7 is a principle diagram of the standard MobileViTBlock module; Figure 8 is a CA module structure principle diagram; Figure 9 is a GFC module structure principle diagram; Figure 10 is a BiFPN module structure principle diagram; Figure 11 is a decoupling detection head structure principle diagram; Figure 12 is a sample diagram of various types of disease and pest samples;Figure 13 is a comparison example of traditional box annotation and point annotation; Figure 14 is a data augmentation example diagram; Figure 15 is a different curve diagram of the model; Figure 16 is a confusion matrix result; Figure 17 is a CassavaSegNet model effect diagram. DETAILED DESCRIPTION
[0015] In order to make the purpose, technical scheme and advantages of the present application clearer, the present application will be further described in detail below with reference to the drawings.
[0016] I. Related theory introduction
[0017] (1) YOLOv8-Seg
[0018] YOLOv8-Seg is an instance segmentation model developed by Ultralytics based on the YOLOv8 target detection framework. This model inherits the excellent characteristics of the YOLO series in terms of processing speed and detection accuracy, and is optimized for instance segmentation tasks, achieving an effective balance between inference efficiency and segmentation accuracy. One of the core tasks of this patent is to accurately locate and segment the disease and pest areas on cassava leaves at the pixel level. The function of YOLOv8-Seg to generate instance masks directly meets this key requirement. Its proven performance and relatively mature architecture make it a suitable baseline model that can be adapted to specific agricultural application scenarios. Therefore, YOLOv8-Seg is chosen as the basic architecture in this patent.
[0019] (2) MobileViT network
[0020] MobileViT is a lightweight visual backbone network, which integrates the effectiveness of convolutional neural networks (CNN) for local feature processing and the ability of visual Transformer (ViT) to capture global dependencies. This hybrid paradigm aims to balance the feature expression capability and computational efficiency of the model. MobileViT maintains excellent performance while exhibiting better lightweight characteristics, significantly reducing the number of model parameters and computational complexity (FLOPs). This makes it suitable for application scenarios with high efficiency requirements.
[0021] (3) Coordinate Attention (CA) module
[0022] Coordinate Attention (CA) is a kind of attention mechanism designed to improve the feature representation ability of mobile networks. Its core idea is to decompose channel attention into two parallel one-dimensional feature encoding processes: by performing global pooling along the horizontal and vertical directions of the input feature map respectively, it captures long-range dependencies with directionality and preserves precise location information. This mechanism enables the network to focus on a wider area with lower computational cost. The main basis for introducing the CA module in this patent is its lightweight nature and effectiveness in enhancing global feature perception. It is expected that the application of this module will improve the model's sensitivity and positioning accuracy for cassava disease spot features with different scales and location random distributions.
[0023] (4) BiFPN structure
[0024] Bidirectional Feature Pyramid Network (BiFPN) is a method designed to improve the efficiency of multi-scale feature fusion. The core of this structure is the introduction of a simplified bidirectional (top-down and bottom-up) cross-scale connection path, combined with a learning weight-based feature fusion strategy, to replace the simple addition or cascade in traditional FPN. This design promotes more effective interaction and information transmission between features of different levels. Considering the requirement for computational efficiency in practical applications, this patent uses BiFPN for multi-scale feature fusion. BiFPN can efficiently integrate feature information of different scales under limited computational resources, and generate feature maps with stronger semantic expression ability, thereby effectively improving the accuracy and robustness of cassava disease and pest detection. This enhanced feature representation ability is of great significance for improving the model's detection and segmentation performance.
[0025] (5) Decoupled Head Principle
[0026] The CassavaSegNet model architecture adopted in this patent is based on YOLOv8-Seg, which uses the widely used Decoupled Head design in the target detection field. The instance segmentation task needs to handle two sub-tasks of target classification and pixel-level mask prediction. These two sub-tasks have different focuses on feature representation: the classification task tends to use global and high-level semantic features, while the mask prediction needs to retain more low-level details and high-resolution spatial information to achieve accurate segmentation. The traditional Coupled Head uses shared feature representation to perform these two tasks simultaneously, which may cause potential conflicts in the optimization process. The Decoupled Head assigns independent processing branches to different tasks (such as classification, bounding box regression, mask coefficient prediction, etc. involved in YOLOv8-Seg), so that each branch can learn more suitable feature representation for its specific needs. CassavaSegNet follows the Decoupled Head structure of YOLOv8-Seg, and its design purpose is to use this task separation mechanism to optimize the feature learning paths of classification and mask generation respectively to meet the needs of accurate classification and fine mask prediction in the cassava leaf disease segmentation task.
[0027] II. Design ideas
[0028] Although YOLOv8-Seg has significant general performance advantages, it still faces challenges when directly applied to the specific and fine visual recognition task of cassava leaf disease. These challenges mainly include:
[0029] (1) Cassava disease spots often exhibit highly irregular shapes, variable sizes, and subtle color and texture differences with healthy leaf tissue, which puts higher demands on the model's feature recognition ability.
[0030] (2) In actual field environments, factors such as light changes, leaf overlaps, and complex backgrounds can introduce significant interference, which may affect the stability and effectiveness of feature extraction by standard models.
[0031] Therefore, the original feature extraction level, multi-scale feature fusion strategy, and detection head design of YOLOv8-Seg, while having general applicability, may not be the optimal configuration for capturing cassava disease-specific fine-grained features and suppressing related interference.
[0032] Based on the above analysis, to improve the specificity and robustness of the model in the task of cassava leaf disease segmentation, this patent proposes the CassavaSegNet model, whose overall structure is shown in Figure 1 The core innovation of this model lies in systematically optimizing and customizing the YOLOv8-Seg baseline architecture to significantly improve its performance in the task of pixel-level segmentation of cassava disease images.
[0033] The embodiment of the application provides a lightweight convolution and attention mechanism cassava disease detection model (named CassavaSegNet), which is based on YOLOv8-Seg, and the adjustment idea is as follows: based on the reservation of the YOLOv8-Seg instance segmentation task process and the decoupling head idea, CassavaSegNet performs significant structural optimization: the C2f and SPPF in the YOLOv8-Seg main part are replaced by the MobileViTBackbone (the core is MobileViTBlock) of CassavaSegNet, and the global modeling capability of the Transformer is introduced. The class FPN / PANet structure (Upsample, Concat, C2f) in the neck of YOLOv8-Seg is replaced by the BiFPN structure of CassavaSegNet as a whole, and CA and GFC modules are added in front of it for additional and targeted feature enhancement.
[0034] Referring to Figures 1-2 , the specific adjustment is as follows:
[0035] (1) In the main network Backbone, the CSPDarknet53 is replaced by the lightweight MobileViT main network, and the lightweight MobileViT main network includes five layers of structures stacked in series, each layer of structure including a Conv2d and a MobileViTBlock module, the Conv2d and the MobileViTBlock module sequentially processing the feature map, and the third layer of structure, the fourth layer of structure and the fifth layer of structure outputting feature maps (M*N*256, M*N*512 and M*N*1024, respectively) to the coordinate attention module of the neck network neck. Specifically, the spatial resolution of the feature map output by the third layer of structure (P3) is 1 / 8 of the original input image, and the feature channel number is 256. The spatial resolution of the feature map output by the fourth layer of structure (P4) is 1 / 16 of the original input image, and the feature channel number is 512. The spatial resolution of the feature map output by the fifth layer of structure (P5) is 1 / 32 of the original input image, and the feature channel number is 1024.
[0036] This adjustment aims to significantly reduce the model parameter quantity and the calculation complexity while improving the multi-scale representation capability of the network for cassava leaf disease characteristics. This provides more efficient and high-quality feature input for subsequent feature fusion and pixel-level segmentation tasks.
[0037] (2) The neck network includes a coordinate attention module, a global feature compressor module, and 2-4 bidirectional feature pyramid networks (BiFPNs) stacked in series, and the coordinate attention module, the global feature compressor module, and the bidirectional feature pyramid networks (BiFPNs) sequentially process the feature maps and output to the head network Head.
[0038] The processing flow of the new neck network integrates a feature enhancement stage. Specifically, after receiving the feature maps output by the backbone network, the coordinate attention (CA) mechanism is first applied to enhance the spatial positioning ability and long-distance dependency modeling of the features, and to enhance the model's attention to the precise boundaries of the lesions. Subsequently, the feature maps are input to the global feature compressor (GFC) module proposed in this patent. The GFC combines deformable convolution to adapt to the non-rigid deformation of the lesions, and integrates a dual attention mechanism (channel attention and spatial attention) to further refine and strengthen the feature information, making it contain richer and more discriminative disease-related features. The purpose of this stage is to improve the adaptability of the features to geometric changes and optimize their saliency before multi-scale feature fusion. The bidirectional feature pyramid network (BiFPN) replaces the original FPN structure of YOLOv8-Seg as the core fusion mechanism. The BiFPN constructs parallel bidirectional (top-down and bottom-up) cross-scale connection paths and introduces an adaptive weighted feature aggregation strategy based on fast normalization. Combined with the use of depthwise separable convolution to control the computational overhead, this design enables more efficient integration of semantic information and spatial details at different levels (including after feature enhancement processing), forming a multi-scale feature representation that is strongly robust and discriminative for cassava disease targets.
[0039] This patent follows the original decoupled head (Decoupled Head) structure of YOLOv8-Seg. This structure includes a detection branch for target classification and bounding box regression, and a segmentation branch for predicting mask coefficients (Mask Coefficients). By decoupling the prediction tasks, each branch can learn a more adaptive feature representation for its specific needs. The final instance segmentation mask is generated by mask assembly of the predicted mask coefficients and the mask prototypes (MaskPrototypes) generated by the neck network (or related layers). This optimization focuses on improving the boundary accuracy and overall fineness of the final segmentation mask generated based on the fused multi-scale features.
[0040] Among them, refer to Figures 4-7, MobileViTBlock module is adjusted based on the standard MobileViTBlock module. MobileViTBlock module is a composite processing unit that receives an input feature map and processes and enhances its features through its internal parallel branches (convolution branch processes local information, and Transformer branch processes global information), and finally outputs a feature map containing local and global enhanced features. After processing, the input and output feature maps of the module usually maintain the same spatial resolution, while the number of channels may change, depending on the design parameters of the module. The MobileViTBackbone of the present patent receives the original input image as input. The network performs step-by-step feature extraction and spatial downsampling on the input image through a series of processing stages containing MobileViTBlock modules. According to the architecture requirements of the CassavaSegNet model, the backbone network finally outputs multiple groups of feature maps of different scales, forming a feature pyramid to provide multi-scale feature representations for the subsequent neck network (BiFPN). These output feature maps correspond to different down-sampling levels and are used to capture multi-scale information of the image, especially the P3, P4, and P5 levels compatible with YOLOv8-Seg.
[0041] The MobileViTBlock module separately extracts local features and models global features, and then fuses the local details of local feature extraction and the global context information of global feature modeling while maintaining the same spatial resolution as the input.
[0042] Referring to Figure 5 , the process of local feature extraction is as follows: processing through a depth separable convolution 3*3, then cross-channel information fusion through a 1*1 convolution, then batch normalization and smoothing nonlinear transformation through a SiLU activation function, and finally adjusting to the target output dimension through a 1*1 convolution to extract local details.
[0043] Referring to Figure 6 , the process of global feature modeling includes: dividing the feature map into patches of size 2*2 for segmentation, converting the 2D feature into a sequence format for tensor rearrangement, then performing layer normalization, then performing 3-layer encoding processing through a Transformer encoder, and finally converting the sequence back to a 2D spatial structure for feature reorganization so that each position includes global context information.
[0044] The procedure for local feature extraction is as follows:
[0045] class MobileViTBlock(nn.Module):
[0046] def __init__(self, in_channels, out_channels,...):
[0047] # Local feature extraction branch
[0048] self.local_features = nn.Sequential(# Depthwise separable convolution
[0049] nn.Conv2d(in_channels, in_channels * expansion, # Channel expansion
[0050] kernel_size=3, stride=1, padding=1,
[0051] groups=in_channels,# Depthwise convolution
[0052] bias=False),
[0053] nn.BatchNorm2d(in_channels * expansion),
[0054] nn.SiLU(inplace=True),
[0055] # 1x1 point convolution
[0056] nn.Conv2d(in_channels*expansion, out_channels, kernel_size=1, stride=1, bias=False), nn.BatchNorm2d(out_channels).
[0057] The procedure for global feature modeling is as follows:
[0058] def forward(self, x):
[0059] # 1. Local feature extraction
[0060] local_features = self.local_features(x)
[0061] # 2. Prepare Transformer input - Unfold operation
[0062] B, C, H, W = local_features.shape
[0063] # Handle cases where the size cannot be divided by patch_size
[0064] if H % self.patch_size!=0orW % self.patch_size!=0:
[0065] local_features=F.pad(local_features,[0,self.patch_size-W% self.patch_size,0, self.patch_size-H % self.patch_size])
[0066] H, W=local_features.shape[-2:]
[0067] # 3. Convert the feature map to a sequence of patches
[0068] # Convert HxWxP to NxP format in the graph
[0069] patches=local_features.unfold(2,self.patch_size,self.patch_size)\
[0070] .unfold(3,self.patch_size,self.patch_size)
[0071] # patches shape: [B, C, H / p, W / p, p, p]
[0072] # 4. Rearrange to sequence format
[0073] patches=patches.contiguous().view(B,C,-1,self.patch_size*self.patch_size).transpose(1,2)
[0074] # patches shape: [B, num_patches, patch_dim]
[0075] # 5. Transformer processing
[0076] for layer in self.transformer_layers:
[0077] patches=layer(patches)
[0078] # 6. Fold operation - restore 2D structure
[0079] # Format conversion in the graph N x P -> H x W x P
[0080] patches = patches.transpose(1, 2).view(B, C, H / / self.patch_size, W / / self.patch_size, self.patch_size, self.patch_size)
[0081] # 7. Reorganize into feature maps
[0082] output = patches.permute(0, 1, 2, 4, 3, 5).contiguous()
[0083] output = output.view(B, C, H, W)
[0084] The specific procedure for feature reorganization is as follows:
[0085] # MobileViTBlock final output
[0086] def forward(self, x):
[0087] #... previous processing...
[0088] # Final 1x1 convolution to ensure the correct number of output channels
[0089] if hasattr(self, 'conv_1x1'):
[0090] output = self.conv_1x1(output)
[0091] # Optional residual connection
[0092] if self.use_residual and x.shape == output.shape:
[0093] output = output + x
[0094] return output
[0095] # Usage in the backbone
[0096] features = []
[0097] x = input_image
[0098] for stage_idx in range(5):
[0099] # Down-sampling convolution
[0100] x = self.conv_layers[stage_idx](x)
[0101] # MobileViTBlock processing
[0102] x = self.mvit_blocks[stage_idx](x)
[0103] # Collecting multi-scale features
[0104] if stage_idx >= 2: # Collect P3, P4, P5
[0105] features.append(x)
[0106] For comparison with the standard MobileViTBlock module, see Figure 4 and 7 The MobileViTBlock module of this patent is as follows:
[0107] For comparison with the standard MobileViTBlock module, see Figure 4 The MobileViTBlock module of this patent is as follows:
[0108] 1. Module composition: mainly composed of two convolution layers (`Conv-n×n`) and a Transformer, first extracting local features through convolution operation, then passing these local features to the Transformer module for global information encoding. In the output part of this module, local and global information are combined through `Concat` (concatenation operation), and finally these features are integrated through convolution operation.
[0109] 2. Information flow: data starts from the input image (size `H×W`), goes through convolution (local information) processing, and then enters the Transformer to obtain global information. After concatenating local and global information, a convolution integration is performed. The final output feature is `P4`.
[0110] 3. Transformer application: the Transformer encodes global information after the local features of the image are extracted. The specific process is: local features are transmitted to the Transformer through convolution to learn global information.
[0111] 4. Convolution operation: Two types of convolution are used, `Conv-n×n` (for local information encoding) and `Conv-1×1` (for output feature fusion). The former is used to capture local details, and the latter is used to integrate and output the final features.
[0112] Reference Figure 7 , the standard MobileViT Block module is as follows:
[0113] 1. Module composition: The entire MobileViT Block is divided into three main parts: Local Information Encoding, Global Information Encoding, and Feature Fusion. The Local Information Encoding part includes two convolution layers (`Conv-3×3` and `Conv-1×1`), and the Global Information Encoding part learns global features through a Transformer. The Feature Fusion part fuses local and global features through convolution operations (`Conv-3×3` and `Conv-1×1`) to generate the final output.
[0114] 2. Information flow: Data starts from the input image (size `H×W`), first performs local information encoding, and extracts local features after convolution. Then through the "Unfold" operation, the local features are flattened and sent to the Transformer for global feature learning. Finally, the "Fold" operation is used to restore the spatial structure of the image after the Transformer processing, and the feature fusion is performed.
[0115] 3. Transformer application: The Transformer is also used for global information encoding in this diagram. In the "Unfold" stage of the feature, the image is unfolded into a one-dimensional sequence, which is sent to the Transformer for global information processing.
[0116] 4. Convolution operation: `Conv-3×3` and `Conv-1×1` convolution operations are used, respectively in the local information encoding and global information fusion parts. This is similar to the convolution operation in this patent, but the form and number of convolution operations in the local feature extraction part have changed.
[0117] Main differences:
[0118] 1. Information flow path: The MobileViTBlock module of this patent directly extracts features through local convolution and then sends them into the Transformer. The standard MobileViTBlock module then expands and restores spatial features through the "Unfold" and "Fold" steps, and then performs Transformer encoding. This method has a different process for global information encoding.
[0119] 2. Structure design: The MobileViTBlock module of this patent uses a more direct convolution-Transformer combination to integrate local and global information. The standard MobileViTBlock module uses a more modular design, where local information and global information are processed through different paths (Unfold / Transformer / Fold), and then fused in the subsequent steps.
[0120] 3. Convolution layer configuration: The MobileViTBlock module of this patent uses `Conv-1x1` operation to integrate features after local feature extraction. The standard MobileViTBlock module uses `Conv-3x3` and `Conv-1x1` in local information encoding and feature fusion, and the fusion steps of local and global information are more explicit.
[0121] 4. Use of Transformer: Both structures use Transformer to extract global information, but in the MobileViTBlock module of this patent, Transformer is mainly used for global information learning after local feature extraction. The standard MobileViTBlock module design uses the unfolding operation (Unfold) to send features into the Transformer for global feature processing.
[0122] 5. Modularization and process design: The design of the MobileViTBlock module of this patent is simpler and more direct. The design of the standard MobileViTBlock module is more detailed and includes the Unfold and Fold processes, making the information flow and global information learning steps more clear and standardized.
[0123] The structures of the two MobileViTBlock are similar in core idea, both combining local feature learning and global information learning, but the design of the standard MobileViTBlock module is more systematic and modular, using Unfold and Fold technology to process global information, while the MobileViTBlock module of the present patent simplifies these processes and directly sends local features into the Transformer for global encoding. The two differ in the use of convolutional layers and the integration of Transformers.
[0124] The MobileViTBlock fuses the detailed capture of local convolution with the contextual understanding of global Transformer, enhancing the network's expression of cassava disease spot complex features, improving the robustness and discriminability of feature extraction, and providing high-quality feature representation for subsequent feature fusion and pixel-level segmentation. The MobileViTBackbone provides a feature extraction foundation for the CassavaSegNet model that balances efficiency and expressive power, supporting high-precision pixel-level segmentation of cassava leaf disease spots.
[0125] The coordinate attention module (CA) is enhanced by the coordinate attention (CA) mechanism, which strengthens feature representation by encoding precise spatial position information. The processing process of the coordinate attention module is as follows: one-dimensional pooling is performed along the horizontal and vertical directions of the feature map to obtain direction-aware features; the direction-aware features are integrated after convolution to generate attention weights along the horizontal and vertical directions; finally, the attention weights are applied to the original feature map to adaptively highlight key features in space.
[0126] Referring to Figure 8 , the specific processing process of the coordinate attention module is as follows:
[0127] 1. Input: The input feature map has a size of CxHxW, where: C: number of channels; H: height of the feature map; W: width of the feature map.
[0128] 2. Attention generation in spatial direction: X-direction attention: perform horizontal average pooling (Global Average Pooling in the X-direction) on the input feature map to obtain a Cx1xW feature map. Y-direction attention: perform vertical average pooling (Global Average Pooling in the Y-direction) on the input feature map to obtain a CxHx1 feature map.
[0129] 3. Attention map generation: For the horizontal pooling result (X direction), an attention map is generated by a 1x1 convolution. For the vertical pooling result (Y direction), another attention map is generated by a 1x1 convolution. The results of the two convolution operations are respectively passed through a Sigmoid activation function to obtain two attention maps ranging from 0 to 1, representing spatial attention in the X direction and the Y direction, respectively.
[0130] 4. Re-weighting: Finally, the input feature map is re-weighted in the X direction and the Y direction, respectively. The attention map in the X direction and the Y direction is multiplied by the corresponding part of the input feature map to enhance the model's attention to important features.
[0131] 5. Output: The final output feature map is weighted and has enhanced spatial representation, which can capture long-range spatial dependencies.
[0132] wherein the global feature compressor module (GFC) generates a feature representation with stronger robustness and expressiveness for the irregular morphology of cassava disease spots by fusing adaptive sampling and feature importance selection mechanisms for the target geometric shape. The module receives a feature map processed by CA and having a specific number of channels as input.
[0133] Specifically, referring to Figure 9 The processing process of the global feature compressor module is as follows:
[0134] Dynamic sampling: a 3x3 convolution operation is used to learn a set of two-dimensional offsets, and then feature normalization is performed and a nonlinear activation function is used to enhance the expression ability. The learned offsets then guide another 3x3 deformable convolution operation to perform dynamic sampling on the original input feature map, and the resulting feature map has the output channel number set by the module. Unlike traditional convolution using fixed sampling points, deformable convolution adjusts the sampling position according to the learned offsets, allowing it to more flexibly focus on the actual edges and key details of the target object (such as disease spots), effectively improving the module's ability to capture target geometric deformation.
[0135] Adaptive weighting: the feature map after dynamic sampling enters a parallel branch for double attention weighting to focus on important feature information. The branch includes a channel attention sub-module and a spatial attention sub-module. The channel attention sub-module learns the importance weight of each channel by aggregating the global information of the feature map, thereby strengthening the expression of key features in the channel dimension. The spatial attention sub-module learns a two-dimensional spatial attention mask by aggregating the channel information of the feature map to highlight important spatial regions on the feature map. The weights output by the channel attention sub-module and the spatial attention sub-module are then combined and applied to the feature map after dynamic sampling for adaptive weighting.
[0136] Residual connection: The original input feature map is added to the attention-weighted feature map through a residual connection structure. Residual connection helps smooth information transmission between network layers and alleviates difficulties in the training process.
[0137] The final output of the GFC module combines the advantages of spatial adaptive sampling, dual attention enhancement, and residual connection. The number of channels is consistent with the number of module output channels, and the spatial resolution remains consistent with the input. Through this design, the GFC module provides high-quality features with better discriminability and more robustness to deformation for subsequent multi-scale feature fusion in the neck network.
[0138] In this patent, in the neck network of the CassavaSegNet model, a key feature fusion module is constructed based on BiFPN. This module receives multi-scale feature maps output by the backbone network and processed by the feature enhancement stage (CA+GFC). These input feature maps will be processed through a stacked BiFPN structure. To achieve deeper feature refinement, this structure contains at least two layers of BiFPN modules in series. Specifically, the number of BiFPN is 2. In this multi-layer BiFPN stack, each BiFPN performs a bidirectional information flow and weighted fusion process. The implementation of information flow relies on efficient up-sampling and down-sampling operations, such as adjusting the spatial size of the feature map through interpolation or step convolution, so that features of different scales can be aligned for fusion. When performing feature aggregation, BiFPN uses learnable weights. These weights are assigned to each input feature branch participating in fusion and learned during model training. This learning-based weight fusion method allows the network to dynamically adjust the contribution ratio of different source features, avoiding the limitations of simple averaging or addition, and achieving more optimized feature integration. Through the series processing of multi-layer BiFPN, the feature map repeatedly experiences bidirectional information exchange and adaptive weighted fusion, significantly enhancing the robustness and discriminability of the fused features to the complex shape of cassava disease spots, fuzzy edges, and size changes.
[0139] wherein the bidirectional feature pyramid network BiFPN is a standard structure, and a working process of the bidirectional feature pyramid network BiFPN is as follows: 5 feature maps of different scales (num_features=5) from the last layer (bidirectional feature pyramid network BiFPN or GFC) are received and 2 cyclic fusion layers (num_layers=2) are constructed internally. The feature maps are weighted and fused in the top-down and bottom-up paths. The top-down path is: the highest scale feature map and the next highest scale feature map are weighted and fused first, and then the process is performed step by step downward; the bottom-up path is: the lowest scale feature map is taken as a starting point, and then the process is performed upward in turn, and the intermediate results obtained by the top-down process are interacted. Each fusion uses a learnable weight to align the features, and then the convolution is adjusted; the whole bidirectional fusion process is repeated in two cycles (num_layers=2) to continuously optimize the interaction and extraction of multi-scale information, so as to continuously optimize and extract important information.
[0140] Referring to Figure 10 , structure analysis of the bidirectional feature pyramid network BiFPN (referred to as BiFPN structure):
[0141] 1. Multi-scale feature maps: The nodes in the figure represent feature maps extracted from different levels, which are P7, P6, P5, P4, P3 and P2 respectively. These feature maps correspond to different resolutions, among which P7 is the finest granularity feature map and P2 is the coarsest granularity feature map.
[0142] 2. Bidirectional information flow: Top-Down: information is transmitted from high-resolution feature maps (such as P7) to low-resolution feature maps (such as P2). This helps low-resolution feature maps obtain more detailed information. Bottom-Up: information is transmitted from low-resolution feature maps (such as P2) to high-resolution feature maps (such as P7), which helps high-resolution feature maps capture global information.
[0143] 3. Weighted feature fusion: In the BiFPN structure, when fusing features of different scales, a learnable weighting mechanism is used instead of simply adding them together. The fusion weight between each feature map can be adaptively adjusted through the training process. This learnable weighting mechanism ensures that important information is not lost when fusing features of different scales, and optimizes the contribution of features of different scales.
[0144] 4. Feature reuse: In the BiFPN structure, there is cross information transmission and multiple fusions between multiple scale feature maps. After several rounds of fusion, each feature map can better represent the context information of different scales.
[0145] 5. Implementation: Backward pass and weighted fusion: Each P-layer feature map (P2 to P7) can be weighted fused in both top-down and bottom-up paths. For example, P6 can be top-down fused with P7 and bottom-up fused with P5, and then weighted synthesized. Repeated blocks: Each group of feature maps can go through multiple such weighted fusion processes to continuously optimize and extract important information. This is the repeated blocks mentioned in the figure.
[0146] 6. Final output: Through multiple weighted fusion, the BiFPN structure generates more refined and efficient feature maps, which will be further input into downstream target detection tasks such as object class prediction and box prediction.
[0147] After the multi-layer iterative processing of the BiFPN structure, the neck network outputs a set of highly fused and refined multi-scale feature maps that integrate rich semantic information and precise spatial details, providing high-quality input for subsequent detection heads and segmentation heads, and serving as the basis for the CassavaSegNet to achieve high-precision pixel-level detection and segmentation of cassava leaf disease spots. Compared with traditional FPN and PANet, the BiFPN structure can more accurately fuse features of different scales and achieve more efficient processing in terms of computation.
[0148] Among them, see Figure 11, the head network Head is used to receive the multi-scale feature maps processed by the neck network BiFPN module, and generate the final instance segmentation prediction results based on these feature maps. By assigning different prediction tasks to specialized processing branches, the learning efficiency and final performance of each task are improved. The head structure includes two parallel branches: a detection branch for determining instance location and class, and a segmentation branch for generating pixel-level segmentation information. The detection branch is responsible for predicting the bounding box position of potential lesion instances and their corresponding classes based on the input feature maps, thereby identifying specific target regions in the image that require further segmentation. Working in parallel with the detection branch is the segmentation branch, which is not directly outputting pixel-level mask images, but rather predicting a set of mask coefficients associated with each lesion instance identified by the detection branch. These coefficients are the parameters needed to construct the final mask. The final pixel-level instance segmentation mask is dynamically generated in a separate mask assembly stage. This key step involves efficiently combining the instance-specific mask coefficients predicted by the segmentation branch with mask prototypes generated in advance or extracted from the neck network output. Specifically, the head network Head includes:
[0149] a decoupled detection head for obtaining a detection branch for predicting the bounding box position of potential lesion instances and their classes, and a segmentation branch for predicting a set of mask coefficients for each lesion instance identified by the detection branch.
[0150] a mask generation module for dynamically generating the final pixel-level instance segmentation mask by combining the mask coefficients predicted by the segmentation branch with mask prototypes generated in advance or extracted from the neck network in a separate mask assembly stage.
[0151] By applying the decoupled head structure of YOLOv8-Seg, the CassavaSegNet model successfully decouples instance detection from mask information generation, and through the efficient combination mechanism of mask coefficients and prototypes, it realizes accurate and dynamic conversion from feature maps to pixel-level segmentation masks. This phased and specialized processing procedure is of great significance for improving the overall accuracy and ability to handle complex lesions of the model in the task of instance segmentation of cassava leaf diseases.
[0152] I. Dataset and data preprocessing
[0153] 1.1 Dataset
[0154] The patent uses the Leaf Disease Dataset (combination) project of the website kaggle as the experimental detection data, which defines 6 categories of cassava leaves, respectively: Cassava Bacterial Leaf Spot (CBLS), Cassava Brown Streak Disease (CBSD), Cassava Green Mottle (CGM), Cassava Mosaic Disease (CMD), Cassava Red Mite (CRM), and Healthy (healthy leaves). The patent uses 2255 leaf images in the dataset as samples, and some sample pictures are shown in Figure 12 .
[0155] The number of samples of each category of pests and diseases is shown in Table 1.
[0156] Table 1: Pest and disease category sample table
[0157]
[0158] 1.2 Data annotation
[0159] After obtaining the Cassava_paper_dataset dataset, first, the data cleaning work was carried out, and the images irrelevant to the patent task or with poor quality were removed. Subsequently, the computer vision annotation tool (CVAT) platform was used for fine annotation. In the annotation process, the advanced Segment Anything Model 2.0 (SAM 2.0) was used as the core segmentation tool. SAM 2.0 can generate high-precision target masks based on the point or frame prompts provided by the user. The patent uses this feature to accurately outline the contours of cassava leaves and disease spots, generating pixel-level segmentation labels, rather than traditional bounding box annotation. This segmentation mask-based annotation method can more accurately capture the irregular shape of the lesion, providing higher-quality supervision information for subsequent model positioning and recognition, and is more suitable for the needs of fine analysis of diseases compared to traditional bounding box annotation. The comparison between traditional bounding box annotation and point annotation is shown in Figure 13 .
[0160] To further enhance the model's generalization ability and robustness in real-world complex environments, specific data augmentation techniques were applied to the training data after annotation. The specific strategies include: using sharpening filter and deconvolution to alleviate potential image blur problems; applying random elastic deformation to simulate the natural morphological changes of leaves; implementing color jitter to simulate color differences under different lighting conditions. These enhancement methods effectively expand the diversity of the dataset, improve the performance stability of the model when facing low-quality images or environmental changes, and enhance the effect as shown in Figure 14
[0161] II. Experimental Section
[0162] 2.1 Experimental methods and parameters
[0163] The experimental environment uses the PyTorch framework and NVIDIA GeForce RTX 4060 GPU. The processed cassava leaf disease and pest dataset is used to train the model; automatic mixed precision training and image caching are enabled to speed up the training and data loading process; the AdamW optimizer is used to optimize the parameters; the cosine learning rate scheduler is enabled to optimize the loss function.
[0164] The optimal network parameters after multiple debugging are shown in Table 2.
[0165] Table 2 Network parameter table
[0166]
[0167] 2.2 Evaluation indicators
[0168] This patent uses F1 value, precision, mean average precision (mAP), recall and other indicators to objectively evaluate the performance of the model. Among them, mAP uses two indicators of mAP50 and mAP50-95, mAP50 is a measure of the model's detection and segmentation performance at an IoU threshold of 50%, reflecting the overall accuracy of the model; mAP50-95 is the average precision calculated under different IoU thresholds (50%-95%), which measures the performance stability and robustness of the model under multiple scales. Precision measures the proportion of true positive samples in the predicted positive samples, reflecting the false detection rate. Recall measures the proportion of correctly detected positive samples in the actual positive samples, reflecting the missed detection rate.
[0169] 2.3 Data augmentation experiment
[0170] In this experiment, the effectiveness of data augmentation in improving model performance is verified by comparing the model performance with and without data augmentation. Data augmentation techniques help the model generalize better, especially when the data volume is limited, by introducing diverse data transformations during training. Random rotation, horizontal flipping, sharpening filter, Gaussian blur, elastic transformation, color transformation, and local enlargement are used for data augmentation on the Cassava_paper_dataset dataset. The experiment is divided into two parts: no data augmentation and data augmentation. The no data augmentation part directly uses the original dataset for training, and the data augmentation part applies the above data augmentation techniques during training. The experimental results are shown in Table 3.
[0171] Table 3 Data augmentation experiment results
[0172]
[0173] Table 3 shows the comparison of model performance with and without data augmentation. From the results, it can be seen that data augmentation significantly improves the model's performance on various indicators. On the original dataset, the model's average precision is 90.7%, recall is 88.1%, mAP50 is 91.6%, and F1 score is 89.6%; while on the augmented dataset, these indicators are improved to 94.1%, 91.9%, 94.5%, and 93.0%, respectively. In terms of each class, the model after data augmentation has significant improvements in precision, recall, mAP50, and F1 score, especially in CBLS, CBSD, and CGM classes. This shows that data augmentation effectively improves the model's generalization ability and detection performance by increasing the diversity and robustness of the data. The experimental results fully demonstrate the effectiveness of data augmentation techniques in improving model performance.
[0174] 2.4 Ablation experiment
[0175] To verify the effectiveness of the improved modules, an ablation experiment was conducted on the model. It should be noted that the feature enhancement stage in this patent is composed of a coordinate attention (CA) module and a global feature compressor (GFC) module in series. In the presentation of the ablation experiment results, this combination module is simply referred to as "Hybrid Attention". The experiment evaluates the contribution of each module to the performance of the model by gradually adding or removing the MobileViT module, the BiFPN structure, and the Hybrid Attention. The experiment is based on the Cassava_paper_dataset dataset for training and testing, and the following 8 comparison models are designed: the baseline model, the model with only the MobileViT module, the model with only the BiFPN structure, the model with only the Hybrid Attention, the model with both MobileViT and BiFPN, the model with both MobileViT and Hybrid Attention, the model with both BiFPN and Hybrid Attention, and the model with all three MobileViT, BiFPN, and Hybrid Attention. This experiment uses these 8 models under the same conditions to obtain the F1 value, precision, average precision mAP, and recall rate of each group, as shown in Table 4.
[0176] Table 4 Ablation experiment data
[0177]
[0178] From the experimental data in the table, it can be seen that each improvement point (MobileViT, BiFPN, Hybrid Attention) of the model has a significant contribution to the performance. When MobileViT, BiFPN, or Hybrid Attention is introduced alone, the model improves in precision, recall rate, mAP50, and F1 value, with BiFPN having the most significant effect (F1 value from 87.5% to 89.1%). When these improvement points are used in combination, the performance is further improved, especially the combination of MobileViT and BiFPN (F1 value reaches 91.8%) and the combination of all three (F1 value reaches 93.0%), indicating that these improvement points have a synergistic effect. Finally, the complete model (MobileViT + BiFPN + Hybrid Attention) achieves the best performance in all indicators, proving the effectiveness of each component and the necessity of combination.
[0179] In addition, the experiments also compared the performances of the eight models on the Precision-Confidence curve, the Precision-Recall curve, the F1 Score-Confidence curve, and the Recall-Confidence curve, such as Figure 15The Precision-Confidence plot shows the precision of each model combination as a function of confidence. The horizontal axis represents confidence, and the vertical axis represents precision. As confidence increases, precision generally increases. The MobileViT+BiFPN+Hybrid Attention model combination (purple curve) consistently has the highest precision across a wide range of confidence levels, indicating that this model combination is the most accurate in identifying positive samples. The average precision (AP) values for each model combination listed in the legend show that the MobileViT+BiFPN+Hybrid Attention combination has the highest AP value (0.945), meaning it performs the best overall. The F1 Score-Confidence plot shows the F1 score of each model combination as a function of confidence. As confidence increases, the F1 score generally decreases, but remains relatively stable in the low confidence region (0 to 0.6). The MobileViT+BiFPN+Hybrid Attention combination (purple curve) consistently has the highest F1 score across a wide range of confidence levels, indicating that this model combination has the best balance between precision and recall. The Recall-Confidence plot shows the recall of each model combination as a function of confidence. As confidence increases, recall generally decreases. The MobileViT+BiFPN+Hybrid Attention combination (purple curve) consistently has the highest recall across a wide range of confidence levels, indicating that this model combination is the most effective at identifying positive samples even at high confidence thresholds. In the low confidence region (0 to 0.6), most model combinations have relatively stable recall, indicating that these models are robust in handling uncertainty and can identify a large portion of positive samples even at low confidence levels.
[0180] 2.5 Comparative Experiment
[0181] To verify the superiority of CassavaSegNet model in target detection and instance segmentation tasks, comparative experiments with other advanced models are conducted. In this experiment, under the same conditions, six representative advanced models are selected: Mask RCNN, CenterNet2, Sparse R CNN, YOLOv5-Seg, YOLOv7 and YOLOv8. The experiment still uses the Cassava_paper_dataset dataset for training and testing, and the F1 value, precision, average precision mAP, recall and detection time of each group are shown in Table 5.
[0182] Table 5 Comparative experimental data
[0183]
[0184] From the results of the comparative experiment, it can be seen that CassavaSegNet is significantly better than other models in various performance indicators. In terms of precision, recall, F1 value and mAP50, CassavaSegNet reached 94.1%, 91.9%, 93.0% and 94.5% respectively, far exceeding other models (such as YOLOv5-Seg's 81.7% precision and 84.2% mAP50). In addition, the detection time of CassavaSegNet is only 69.6 milliseconds, which is better than YOLOv5-Seg's 90.8 milliseconds and Mask R-CNN's 140.7 milliseconds, indicating that it has higher computational efficiency while maintaining high precision. In contrast, Mask R-CNN and CenterNet2 perform poorly in both precision and speed, while YOLOv7 and YOLOv8 are faster but their precision is significantly lower than CassavaSegNet. Overall, CassavaSegNet achieves the best balance between precision and speed, proving its superiority in target detection and instance segmentation tasks.
[0185] 2.6 Analysis of CassavaSegNet Model
[0186] To clarify the prediction results of CassavaSegNet model proposed in this patent for different disease and pest categories of cassava leaves, a confusion matrix is used to compare the true class and predicted class of the model for 7 disease and pest categories and background, as shown in Table 6. Figure 16 Figure 16 This shows the distribution of the accuracy of the CassavaSegNet model in detecting data. The values on the diagonal represent the proportion of correctly classified pests; the closer the value is to 1, the more accurate the model's prediction is for that category. The values off-diagonal represent the proportion of misclassified pests. The vertical axis corresponds to the original pest category, and the horizontal axis represents the pest category after prediction.
[0187] Depend on Figure 16 The CassavaSegNet model demonstrates excellent differentiation of cassava leaf disease and pest symptoms. Its predictions for CassavaBLS, CassavaGM, CassavaHL, and CassavaRM are nearly perfect, with accuracies of 0.90, 0.93, 0.93, and 0.92, respectively. However, its prediction accuracy for CassavaBSD is only 0.89, and the proportion of CassavaBSD misclassified as "background" is 0.12, indicating some confusion when distinguishing between CassavaBSD and "background." Looking at the diagonal values, the model performs very well across most categories, with a high average, indicating overall high classification accuracy, robustness, and good generalization performance. For categories with significant confusion, such as CassavaBSD and "background," further data collection, improved feature extraction methods, or model parameter adjustments could enhance the model's ability to differentiate between these categories. The following figure shows the final performance of this model across various disease and pest categories.
[0188] III. Conclusion
[0189] 3.1 This patent addresses the problems of low accuracy, poor real-time performance, and high false negative rate in cassava pest and disease detection. It proposes a high-precision segmentation model for cassava pests and diseases based on lightweight convolution and attention mechanisms, CassavaSegNet. The backbone network of the model uses the lightweight MobileViT to replace the original CSPDarknet53 structure. At the same time, GFC and CA modules are introduced to improve feature extraction capabilities and improve the neck network structure. BiFPN replaces the original FPN structure, making fuller use of multi-scale feature information, thereby improving the overall performance of the model.
[0190] 3.2 Extensive comparative and ablation experiments have demonstrated that the CassavaSegNet model significantly outperforms the original YOLOv8 model in various metrics. On the cassava disease and pest image test set, the average precision is 94.5%, the F1 score is 93.0%, and the recall rate is 91.9%. This indicates that the model achieves efficient and accurate segmentation of diseased areas in cassava leaves, providing effective support for early detection and precise monitoring of diseases.
Claims
1. A lightweight model and attention mechanism-based pest and disease detection model, characterized in that, Based on YOLOv8-Seg with the following adjustments: (1) In the backbone network, CSPDarknet53 is replaced by a lightweight MobileViT backbone network. The lightweight MobileViT backbone network includes a five-layer structure stacked in series. Each layer includes Conv2d and MobileViTBlock modules. The Conv2d and MobileViTBlock modules process the feature maps in sequence. The third, fourth and fifth layers output feature maps to the coordinate attention module of the neck network, respectively. (2) The neck network includes a coordinate attention module, a global feature compressor module, and 2-4 bidirectional feature pyramid networks (BiFPN) stacked in series. The coordinate attention module, the global feature compressor module, and the bidirectional feature pyramid network (BiFPN) process the feature map in sequence and output it to the head network (Head). The MobileViTBlock module is an adaptation of the standard MobileViTBlock module; The MobileViTBlock module performs local feature extraction and global feature modeling on the feature map, and then fuses the local details of the local feature extraction and the global context information of the global feature modeling while maintaining the same spatial resolution as the input. The process of local feature extraction is as follows: it is processed by depthwise separable convolution 3*3, then cross-channel information is fused by 1*1 convolution, then batch normalization is performed and smooth nonlinear transformation is performed by SiLU activation function, and finally 1*1 convolution is used to adjust to the target output dimension to extract local details. The global feature modeling process includes: dividing the feature map into 2*2 size patches for segmentation, converting the 2D features into sequence format for tensor rearrangement, then performing layer normalization, then performing 3-layer encoding processing through a Transformer encoder, and finally converting the sequence back into a 2D spatial structure for feature recombination so that each position includes global context information.
2. The pest and disease detection model according to claim 1, characterized in that, The spatial resolution of the feature map output by the third layer is 1 / 8 of the original input image, and the number of feature channels is 256; the spatial resolution of the feature map output by the fourth layer is 1 / 16 of the original input image, and the number of feature channels is 512; the spatial resolution of the feature map output by the fifth layer is 1 / 32 of the original input image, and the number of feature channels is 1024.
3. The pest and disease detection model according to claim 1, characterized in that, The processing procedure of the coordinate attention module is as follows: one-dimensional pooling is performed along the horizontal and vertical directions of the feature map to obtain orientation-aware features; after the orientation-aware features are integrated by the convolutional layer, attention weights along the horizontal and vertical directions are generated; finally, the attention weights are applied to the original feature map to adaptively highlight key features in space.
4. The pest and disease detection model according to claim 1, characterized in that, The processing procedure of the global feature compressor module is as follows: Dynamic sampling: A set of two-dimensional offsets is learned using a 3x3 convolution operation, then the features are normalized and the expressive power is enhanced by a non-linear activation function; the learned offsets then guide another 3x3 variable convolution operation to perform dynamic sampling on the original input feature map, so that the processed feature map has the number of output channels set by the module. Adaptive weighting: The dynamically sampled feature maps are simultaneously fed into a parallel branch for dual attention weighting; This parallel branch includes a channel attention submodule and a spatial attention submodule. The channel attention submodule learns the importance weight of each channel by aggregating global information from the feature map, thereby strengthening the expression of key features along the channel dimension. The spatial attention submodule learns a two-dimensional spatial attention mask by aggregating the channel information of the feature map to highlight important spatial regions on the feature map; the weights output by the channel attention submodule and the spatial attention submodule are then combined and applied to the dynamically sampled feature map for adaptive weighting. Residual connection: The original input feature map is added to and fused with the attention-weighted feature map through a residual connection structure.
5. The pest and disease detection model according to claim 1, characterized in that, The Bidirectional Feature Pyramid Network (BiFPN) receives five feature maps of different scales from the previous layer and constructs two recurrent fusion layers internally. The feature maps are weighted and fused in a top-down and bottom-up path. The top-down path involves weighted fusion of the highest-scale and second-highest-scale feature maps, proceeding downwards level by level. The bottom-up path starts from the lowest-scale feature map and fuses upwards sequentially, interacting with the intermediate results obtained from the top-down path. Each fusion uses learnable weights to align features, which are then adjusted via convolution; the entire bidirectional fusion process is repeated to continuously optimize the interaction and extraction of multi-scale information.
6. The pest and disease detection model according to claim 1, characterized in that, The number of Bidirectional Feature Pyramid Networks (BiFPNs) is 2.
7. The pest and disease detection model according to claim 1, characterized in that, The Head network includes: The detection head is decoupled to obtain a detection branch and a segmentation branch. The detection branch is used to predict the bounding box location and category of potential lesion instances, and the segmentation branch is used to predict a set of mask coefficients for each lesion instance identified by the detection branch. The mask generation module is used to dynamically generate the final pixel-level instance segmentation mask by combining the mask coefficients predicted by the segmentation branch with the mask prototypes pre-generated in the network or extracted from the neck network through an independent mask combination stage.
8. The training method for the lightweight model and attention mechanism-based pest detection model as described in any one of claims 1-7, characterized in that, The method includes; S101: Obtain the cassava disease image dataset; S102: Perform data cleaning on the dataset to remove irrelevant or low-quality images; S103: A computer vision annotation tool platform was used for fine annotation. During the annotation process, SAM 2.0 was used as the core segmentation tool to accurately delineate the contours of cassava leaves and diseased areas to generate pixel-level segmentation labels. S104: Perform or not perform data augmentation on the labeled data, and the data augmentation includes horizontal flipping, sharpening filtering, Gaussian blurring, elastic deformation, color transformation or local magnification; S105: Train the cassava disease detection model with data augmentation.
9. The training method according to claim 8, characterized in that, The cassava disease image dataset is the Cassava_paper_dataset from the Leaf Disease Dataset (combination) project on Kaggle. The dataset defines six types of cassava leaves: Cassava Bacterial Leaf Spot, Cassava Brown Streak Disease, Cassava Green Mottle, Cassava Mosaic Disease, Cassava Red Mite, and Healthy. The AdamW optimizer was used to optimize parameters, and a cosine learning rate scheduler was enabled to optimize the loss function. The batch size was 4, the number of iterations was 300, the initial learning rate was 0.005, the final learning rate multiplier was 0.02, the number of workers was 4, and the patience was 30.
Citation Information
Patent Citations
Cassava disease identification method
CN113408393A
Cassava leaf disease classification method and equipment based on transfer learning and storage medium
CN114663758A
Cassava leaf disease classification method, equipment and storage medium
CN118298218A