A method and system for detecting leaf diseases in tomatoes based on MSCB-YOLOv11
By improving the YOLOv11 network structure and introducing MSES, EUCB, and LRSA modules, the YOLOv11 algorithm was optimized, solving the problems of small target lesion recognition accuracy and adaptability to complex scenarios. This resulted in efficient and accurate tomato disease detection, suitable for disease identification in greenhouse tomato settings.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- JIANGSU UNIV
- Filing Date
- 2026-03-16
- Publication Date
- 2026-07-03
Smart Images

Figure CN122335673A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of agricultural disease detection technology, and particularly relates to a method and system for detecting tomato leaf diseases based on the MSCB-YOLOv11 algorithm. MSCB is the name of the network structure improvement proposed in this invention. Its name comes from the combination of the multi-scale edge information selection module MSES (Multi Scale Edge Information Select) and the efficient up-sampling convolution block EUCB (Efficient Up-sampling Convolution Block), where MS represents the multi-scale edge feature extraction mechanism and CB represents the convolution block structure. Background Technology
[0002] With the continuous development of agricultural informatization and intelligentization technologies, the rapid and accurate identification of crop diseases and pests has become an important means to ensure agricultural production safety and increase crop yield. Tomatoes, as a widely cultivated cash crop, are susceptible to various diseases during their growth, such as early blight, late blight, leaf mold, leaf spot, and viral diseases. Traditional methods of tomato disease identification mainly rely on manual visual judgment, which is not only inefficient and labor-intensive but also highly dependent on the experience of the personnel involved, making it difficult to meet the demands of modern agriculture for real-time, accurate, and large-scale disease identification. Therefore, utilizing computer vision and deep learning technologies to achieve automated identification of tomato diseases has become an important direction in current agricultural intelligentization research.
[0003] In recent years, target detection algorithms based on deep convolutional neural networks have made significant progress in the field of crop disease identification. Among them, the YOLO series of algorithms has attracted widespread attention due to its end-to-end detection structure and high real-time performance. However, in complex field environments, tomato disease images often suffer from complex backgrounds, large differences in lesion scale, indistinct disease features, and significant changes in illumination, resulting in shortcomings in the accuracy of existing models in identifying small target lesions and adaptability to complex scenes. Although the newly proposed YOLOv11 architecture has improved feature extraction capabilities and detection performance compared to previous models, its application in tomato disease identification tasks still has room for further optimization. Therefore, it is necessary to make targeted improvements to the YOLOv11-based network structure, taking into account the characteristics of tomato disease images, to enhance the model's ability to express multi-scale disease features and improve identification accuracy, thereby achieving efficient and accurate identification of tomato diseases. Summary of the Invention
[0004] This invention aims to solve the core technical challenge of balancing accuracy and real-time performance in tomato disease identification. Specifically, this study improves and optimizes the YOLOv11 model to accurately identify five types of diseases: early blight, late blight, leaf mold, leaf spot, and healthy leaves. While significantly improving disease identification accuracy, it effectively ensures the model's real-time detection efficiency and operational stability, meeting the needs for efficient and accurate disease identification in greenhouse tomato environments.
[0005] To achieve the objectives of this invention, a method for detecting tomato leaf diseases based on MSCB-YOLOv11 is provided, comprising the following steps:
[0006] Step 1: Collect image samples covering early blight, late blight, leaf mold, leaf spot, and healthy leaves of tomatoes. Perform preliminary classification on the collected images to construct an initial dataset for tomato disease detection.
[0007] Step 2: Perform preprocessing operations on the images in the initial dataset, including Mosaic-8 data augmentation, adaptive anchor box calculation, and label the disease areas in the preprocessed images.
[0008] Step 3: Use the existing YOLOv11 network model to train and validate the obtained tomato leaf disease dataset to obtain baseline values.
[0009] Step 4: Optimize the YOLOv11 network model using deep learning to obtain a tomato disease detection model.
[0010] Step 5: Use the tomato leaf disease dataset obtained in Step 1 to train and validate the tomato disease detection model obtained in Step 4.
[0011] Step 6: Compare the verification data obtained in Step 5 with the baseline value in Step 3, and obtain the tomato disease detection model after continuous improvement of YOLOv11.
[0012] In step 1 of this scheme, image samples of tomato diseases and healthy leaves are collected by on-site photography to construct an initial dataset; the initial dataset covers five types of targets: early blight, late blight, leaf mold, leaf spot, and healthy leaves.
[0013] In step 2 of this scheme, the image preprocessing operations specifically include vertical mirroring, horizontal mirroring, random rotation, and brightness adjustment; after the above preprocessing and data augmentation, the total sample size of the dataset is expanded to 11,976 images.
[0014] Furthermore, in step 2 of this scheme, the Labelimg annotation tool is used to accurately mark the diseased areas in the preprocessed tomato disease images.
[0015] In step 4 of this scheme, the YOLOv11 network model is optimized. Specifically, the C3k2 module in the network backbone is replaced with the self-developed C3k2-MSES module; the upsampling module in the network neck is replaced with the efficient upsampling convolution module EUCB; and the C2PSA module in the neck is replaced with the low-resolution self-attention module C2PSA-LRSA.
[0016] In step 4 of this scheme, the optimized tomato disease identification model is trained in the PyTorch deep learning framework.
[0017] The training process is as follows: The Labelimg annotation tool is used to label the diseased parts in the tomato disease images. The labeled tomato disease images are then saved in a designated folder. The model training parameters are then configured and training is started. The model training parameters are set as follows: the initial learning rate is set to 0.001, the batch size is set to 16, close_mosaic=0, the number of workers is set to 4, and the number of training rounds is set to 150.
[0018] In step 5 of this scheme, multi-dimensional evaluation metrics are introduced to comprehensively validate the performance of the tomato disease identification model. These metrics include mAP@0.5, mAP@0.5:0.95, Precision, Recall, F1 score, GFLOPS (Gross Floating Point Operations), and Params / M (millions of parameters). mAP@0.5 refers to the average precision across all categories when the IoU threshold is set to 0.5. mAP@0.5:0.95 refers to the average precision when the IoU threshold increases from 0.5 to 0.95 in increments of 0.05. Both metrics rely on precision and recall. GFLOPS measures the computational complexity of the model, and Params / M quantifies the number of parameters, together supporting a comprehensive evaluation of the model's performance.
[0019] As a further improvement to the above scheme, step four involves training the tomato detection model using training set data, specifically including the following steps:
[0020] Step 1: The network backbone layer first downsamples the input image step by step through the Conv module to generate feature maps of five different levels: P1, P2, P3, P4, and P5. After the C3k2-MSEC module completes multiple rounds of feature enhancement, it is input into the SPPF module to realize multi-scale pooling feature fusion. Then, the C2PSA-LRSA module is used to enhance channel-space attention feature extraction and output multi-dimensional feature vectors to subsequent modules.
[0021] Step 2: The feature vector output by Backbone enters the channel attention module, where the input feature vector needs to be processed first. It is represented as follows:
[0022]
[0023] In the formula: symbol This represents the total number of eigenvectors. Representing dimensional space, This indicates that all element components belong to the real number field.
[0024] In addition, it is necessary to obtain each feature vector at time t. weight The calculation is shown in the following formula:
[0025]
[0026] In the formula: It is the index of the eigenvector. This represents a multilayer perceptron. This represents the state at time t-1; after obtaining the weights, the model can filter the input feature vector sequence. After filtering, the following sequence was obtained:
[0027]
[0028] When the attention mechanism is soft attention, For linear weighting functions, when the attention mechanism is hard attention, This indicates that the feature vector is a discretized sample;
[0029] Step 3: The feature information after attention is applied is input into the model's Head layer. The feature representation is first optimized by the EUCB module, and then multi-scale feature mixing and combination is completed through feature concatenation and downsampling, and then passed to the Detect prediction layer.
[0030] Step 4: In the Detect prediction layer, the model uses CIoU as the loss function to comprehensively optimize the overlap of the tomato target boxes, the distance between the center points, and the aspect ratio regression accuracy.
[0031] Step 5: Quantitatively evaluate the training results using two metrics: F1 score and mAP. Finally, select the model weight file saved from the last generation as the final training result.
[0032]
[0033]
[0034]
[0035] in Indicates accuracy; Indicates recall rate; The number of correctly detected tomato targets (true positives). This indicates a false positive, indicating that the number of non-target tomatoes was mistakenly identified. The number of undetected tomato targets (false negatives) is represented by mAP, which is the mean precision, reflecting the overall performance of the model on the tomato detection task. Finally, the model weight file saved from the last generation is selected as the final training result.
[0036] The present invention provides a tomato leaf disease detection system based on MSCB-YOLOv11, comprising:
[0037] The image acquisition module is used to acquire images of tomato leaves;
[0038] The image preprocessing module is used for image enhancement and annotation;
[0039] The disease detection module has an embedded MSCB-YOLOv11 model trained using the above method.
[0040] The output module is used to output the disease detection results.
[0041] The expected beneficial effects of this invention are:
[0042] Compared with existing technologies, this invention provides a tomato disease detection method based on an improved YOLOv11 architecture. Based on the YOLOv11 architecture, it innovatively introduces a self-developed multi-scale edge information selection module (MSES) and integrates the DSM attention mechanism proposed at ICCV 2023. Simultaneously, it optimizes the network backbone and neck structure, achieving a synergistic improvement in detection accuracy, inference speed, and scene adaptability. It can be stably deployed on AI embedded devices, handheld devices, and fixed devices, demonstrating significant practical value. Its advantages are mainly reflected in the following four aspects:
[0043] (1) Improved precision in feature extraction. The self-developed MSES module can efficiently screen key features that are highly relevant to tomato disease detection from multi-scale edge information. Combined with the DSM attention mechanism's ability to focus on complex edges and high-frequency signal regions, it greatly improves the targeting and accuracy of feature selection. At the same time, by replacing the backbone network C3k2 with C3k2-MSBC, neck upsampling with EUCB, and C2PSA with C2PSA-LRSA, the network feature representation capability is further strengthened, effectively solving the problem of inaccurate detection of small-target diseases and diseases under complex backgrounds.
[0044] (2) Balanced detection performance. Based on the optimization of feature extraction and network structure, this method uses the CIoU loss function to optimize the target box regression accuracy, taking into account both the real-time performance of detection accuracy and inference speed. This not only breaks through the bottleneck of "difficulty in balancing accuracy and speed" in the detection of tomato diseases by traditional YOLO series models, but also improves the shortcomings of existing methods in adapting to complex scenarios such as changes in lighting and differences in shooting angle.
[0045] (3) Wide range of data adaptation. By using a variety of image preprocessing methods such as vertical mirroring, horizontal mirroring, random rotation, and brightness adjustment, combined with data augmentation strategies, the model can be adapted to tomato disease images at different growth stages and under different environmental conditions, which significantly improves the model's generalization ability and expands its applicability.
[0046] (4) Large-scale application scenarios. Compared with traditional detection methods that rely on human experience, this method can quickly and accurately identify five types of targets in tomatoes: early blight, late blight, leaf mold, leaf spot, and healthy leaves. The detection process is highly automated and can meet the disease inspection needs of large-scale tomato planting scenarios. At the same time, it provides technical support for the development and assembly of tomato disease inspection robots.
[0047] In summary, this invention effectively solves the problems of low accuracy, slow reasoning speed, and poor adaptability to complex scenarios in existing tomato disease detection methods. Through module innovation and structural optimization, it forms unique technical advantages and has important prospects for the promotion and application of intelligent detection of tomato diseases. Attached Figure Description
[0048] Figure 1 This is a flowchart of the solution.
[0049] Figure 2 Results of 150 rounds of YOLOv11n training
[0050] Figure 3 Structure diagram of MultiScaleEdgeInformationSelect (MSES)
[0051] Figure 4Structure diagram of the self-developed EdgeEnhancer module
[0052] Figure 5 DSM attention mechanism structure diagram
[0053] Figure 6 EUCB upsampling module structure diagram
[0054] Figure 7 For low-resolution self-attention LRSA structure
[0055] Figure 8 Structure diagram of MSCB-YOLOv11 Detailed Implementation
[0056] The specific embodiments of the present invention will be further described in detail below with reference to the accompanying drawings. To facilitate understanding of the present invention, a more comprehensive description will be given below with reference to the accompanying drawings, which illustrate typical embodiments of the invention. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein. Rather, these embodiments are provided to make the disclosure of the present invention more thorough and complete. Unless otherwise defined, all technical and scientific terms used in this invention have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention.
[0057] like Figure 1 As shown, a tomato disease detection method based on MSCB-YOLOv11 includes:
[0058] Step 1: Tomato Disease Image Collection and Initial Dataset Construction
[0059] Collect images of different types of tomato diseases and healthy leaves. The tomato diseases include early blight, late blight, leaf mold, and leaf spot, and the healthy leaves represent five categories of targets. First, define the target to be collected, which needs to cover the complete growth stages of the five categories (early, middle, and late stages of disease and different growth states of healthy leaves), ensuring that the images can reflect the typical characteristics and variations of each category.
[0060] Image collection employed a field shooting approach, involving on-site sampling and photography at tomato growing bases to obtain the most direct and realistic image data reflecting actual field conditions. A total of 3152 initial image samples were collected and processed. Subsequently, the initial dataset was scientifically divided into training, validation, and test sets: 2206 images for training, 631 for validation, and 315 for testing, used for model training, performance validation, and effectiveness testing, respectively. The shooting process carefully considered diverse environmental conditions to ensure the robustness of the training process and improve the model's performance in real-world applications: lighting conditions included sunny, cloudy, and low-light environments, with 60% of images taken in sunlight, 30% in cloudy conditions, and 10% in low-light conditions, adapting to common outdoor lighting variations; weather conditions were also varied, with 80% of images taken under clear skies, 10% in rain, and 10% in fog, simulating complex scenarios with reduced visibility, laying a solid data foundation for the model to adapt to different field environments.
[0061] Step 2: Image preprocessing and annotation, completing dataset expansion and standardization.
[0062] First, comprehensive preprocessing was performed on the collected images of diseased and healthy tomato leaves. Simultaneously, diseased areas were labeled and the dataset was expanded. The specific operations were as follows: First, multi-dimensional image preprocessing operations were carried out: image quality was improved and noise interference was reduced through vertical mirroring, horizontal mirroring, random rotation, and brightness adjustment. Then, the Mosaic-8 data augmentation strategy was used to generate new training samples, expanding the dataset size. Adaptive anchor box calculation was performed based on dataset features to improve the model's adaptability to selecting diseased areas on tomato leaves. The synergistic effect of these preprocessing and data expansion operations effectively increased the size of the training samples and enhanced the model's adaptability to complex field environments.
[0063] Next, the preprocessed images were precisely labeled: using the Labelimg labeling tool, diseased areas (early blight, late blight, leaf mold, and leaf spot) and healthy leaf areas in the images were marked one by one, and a unique category label was assigned to each target to ensure the accuracy and completeness of the labeled areas. After labeling, the image files and corresponding label information were organized and saved in YOLO format, and the label information was stored in a designated folder as a TXT file, forming a standardized data structure of one-to-one correspondence between "image" and "label".
[0064] After the above preprocessing and data augmentation, the total number of samples in the dataset was expanded to 11,976. The number of image samples for all five target categories met the requirements for model training and was used for model training, performance verification, and effect testing. Finally, a tomato disease detection dataset with diversity, completeness, and standardization was formed, providing high-quality data support for the subsequent training of the MSCB-YOLOv11 model.
[0065] Step 3: Training and benchmark acquisition based on the YOLOv11n benchmark model
[0066] The YOLOv11n model was selected as the benchmark (due to its small number of parameters and low computational cost, it can significantly shorten the training time and meet the need for rapid benchmark value acquisition). Training and validation were conducted using the tomato disease annotation dataset (total 11976 images, 2206 training images, 631 validation images, and 315 test images) preprocessed in step 2. The reliability of the benchmark values was ensured through a two-stage process of "preliminary validation + complete convergence," as detailed below:
[0067] First, we used the official Ultralytics YOLOv11n network as the baseline network (configuration file `yolo11n.yaml`, pre-trained weights `yolo11n.pt`). The training environment was based on the PyTorch framework, and the core parameters were kept consistent: initial learning rate 0.001, batch size 16, mosaic data augmentation disabled (close_mosaic=0), number of data loading workers 4, input image size 640×640, and loss function CIoU.
[0068] Further, preliminary training with early stopping (stopping after 40 rounds): Early stopping is enabled for preliminary training. At round 40, if the validation set metrics show no significant improvement, early stopping is triggered and training ceases. This stage only verifies the adaptability of YOLOv11n to the tomato disease dataset, confirming that the model can initially learn disease characteristics and ruling out data adaptation issues.
[0069] Furthermore, disable early stopping in the full training (150 rounds to ensure metric convergence). Disable the early stopping mechanism and set the total training rounds to 150. Figure 2 The YOLOv11n training results shown confirm that the model has fully converged. The changes in key metrics during the training process conform to convergence characteristics.
[0070] Loss metrics: `train / box_loss`, `train / cls_loss`, `train / dfl_loss` and the corresponding loss on the validation set all decreased steadily and then stabilized without drastic fluctuations;
[0071] Precision metrics: `metrics / precision(B)` and `metrics / recall(B)` gradually increased to a stable range, while `val / mAP50` and `val / mAP50-95` tended to converge after 120 rounds (fluctuation less than 0.005), proving that the model has learned sufficiently on the tomato disease detection task, without overfitting or underfitting.
[0072] Finally, after 150 rounds of training, the core metrics of the validation set were extracted as baseline values, including mAP@0.5, mAP@0.5:0.95, Precision, Recall, etc. At the same time, the computational cost (GFLOPs≈6.6) and parameter count (Params / M≈2.6) of the model were recorded to provide a reference for the performance comparison of the optimized model in the subsequent step 6.
[0073] Step 4: Optimize the YOLOv11 network model to obtain the MSCB-YOLOv11 tomato disease detection model adapted for small target detection.
[0074] To address the core pain points in tomato disease detection scenarios, such as low feature dimensionality of small target lesions (e.g., punctate lesions of tomato leaf spot and early blight lesions), easy obscuring of edge details by the background, and large differences in multi-scale distribution, as well as the problems of insufficient accuracy of the original YOLOv11 in detecting small targets and easy loss of small-scale information during feature fusion, this paper proposes a multi-module targeted optimization of the YOLOv11 network structure to construct the MSCB-YOLOv11 model. The core optimization strategy is as follows: replacing the C3k2 module in the YOLOv11 Backbone layer with the self-developed C3k2-MSES (multi-scale edge information selection module); replacing the original upsampling module in the Neck layer with EUCB (efficient and lightweight upsampling convolutional block); and replacing the C2PSA module at the end of the Backbone with C2PSA-LRSA (pyramid self-attention module with low-resolution self-attention). Through a three-layer optimization logic of "feature extraction enhancement + feature fusion fidelity preservation + attention-oriented focusing", the detection accuracy and inference efficiency of small target diseases are improved in a targeted manner.
[0075] Furthermore, the C3k2 module in the original YOLOv11 Backbone is mainly based on conventional convolution stacking, which is insufficient for extracting edge features of small target lesions at the 1-12 pixel level. This easily leads to the small lesion features being covered by invalid information such as leaf background and light noise. Therefore, it is replaced with the C3k2-MSES module, with the core objective of strengthening the edge feature extraction and effective feature selection of small targets at multiple scales.
[0076] like Figure 3The diagram shows the structure of MultiScaleEdgeInformationSelect (MSES). The core design logic of the C3k2-MSES module is "multi-scale pooling to cover the small target scale range + edge enhancement to strengthen detailed contours + dual-domain attention to filter high-value features". The specific structure and operation are as follows:
[0077] Step 1, Multi-scale Adaptive Pooling: The input feature map (size...) is processed... The features are distributed to four parallel branches, which are connected to `AdaptiveAvgPool2d` adaptive average pooling layers with pooling kernel parameters of 3, 6, 9, and 12, respectively, to achieve full scale coverage of small target lesions of different sizes. The output feature map of each branch is restored to channel dimension consistency after two 3×3 convolutions (stride 1, padding 1) to ensure compatibility with subsequent modules.
[0078] The second step, as Figure 4 The diagram shows the structure of the self-developed EdgeEnhancer module, which plays an edge enhancement role in the MSES module: it connects to the EdgeEnhancer submodule for each branch, and directionally enhances the edge details of small target lesions, solving the problem of blurred outlines of small lesions. Its core calculation logic is as follows:
[0079]
[0080] in, Input feature map for branch, 3×3 average pooling (used to reduce background noise). It uses 1×1 convolution (to achieve channel dimensionality reduction and dimensionality increase, and enhance feature representation). This is the feature map after edge enhancement; this operation highlights the edge contour by calculating the difference between the original feature and the pooling feature, making small target lesions "visible" from the background.
[0081] The third step, feature fusion and DSM dual-domain selection: upsample the enhanced feature maps of the four branches to the original input scale ( ), and concatenate it with the direct convolution branch that preserves the original texture information. The feature map is then connected to the DSM (Dual Domain Selection) attention module to filter high-value features. Its main structure is as follows: Figure 5 As shown, DSM suppresses invalid background features and focuses on effective features of small target lesions through dual weighting in both the spatial and channel domains. The core calculation is as follows:
[0082]
[0083] in, This is the spliced feature map. It is a 1×1 convolution (with 1 output channel). It is the Sigmoid activation function. This is the attention-weighted feature map.
[0084] Step 4, Feature Output: The DSM-weighted feature map is fused with channel information through a 1×1 convolution, outputting a feature map with the same dimensions as the original C3k2 module. This ensures the compatibility of the overall Backbone layer structure.
[0085] Furthermore, the upsampling module of the original YOLOv11 Neck layer uses conventional transposed convolution, which has problems such as large computational cost and the easy occurrence of "checkerboard artifacts" and feature distortion loss in small target features during the upsampling process. Therefore, it is replaced with EUCB efficient and lightweight upsampling convolution block. The core goal is to reduce computational cost while ensuring the integrity of small target features in the upsampling and feature fusion process.
[0086] like Figure 6 The diagram shows the structure of the EUCB upsampling module. The core design of the EUCB module is based on depthwise separable convolution, decomposing conventional convolution into "depthwise convolution + pointwise convolution". This significantly reduces the number of parameters and computational cost while improving the accuracy of small target feature fusion. Its core process is: 2×interpolation upsampling → 3×3 depthwise convolution → BN normalization → ReLU activation → 1×1 pointwise convolution; where the mathematical expressions for depthwise convolution and pointwise convolution are:
[0087] Depthwise convolution (single-channel spatial convolution, focusing on local features):
[0088]
[0089] Pointwise convolution (integrating cross-channel information to enhance global features):
[0090]
[0091] in, Indicates the input feature map at the th Each channel, location Eigenvalues at; Indicates the input feature map of the th Two-dimensional feature map of each channel; This indicates that the output feature map after depthwise convolution is at the th... Each channel, location Eigenvalues at; This indicates that the output feature map after pointwise convolution is at position Eigenvalues at; Indicates the first Each channel corresponds to a depthwise convolutional kernel; Represents the first step in pointwise convolution. Each channel weight parameter; This indicates the number of channels in the input feature map; Represents the spatial coordinates in the feature map; Indicates the channel index; This represents the convolution operation. Compared to the original transposed convolution, EUCB reduces the number of parameters by about 70% and the computational cost (FLOPs) by about 65%. At the same time, by replacing the transposed convolution with interpolation upsampling, it avoids the distortion of small target features caused by "checkerboard artifacts" and ensures that the features of small target lesions are not lost or blurred during the upsampling process.
[0092] Finally, the C2PSA module at the end of the original YOLOv11 Backbone uses full-resolution self-attention computation, which is insufficient for small targets and has high computational cost. Therefore, it is replaced by the C2PSA-LRSA module (a pyramid self-attention module that integrates low-resolution self-attention). The core objective is to target and enhance the attention weights of small-scale features while reducing computational complexity.
[0093] like Figure 7 The diagram shows a low-resolution self-attention LRSA structure. C2PSA-LRSA incorporates low-resolution self-attention (LRSA) into the original pyramid self-attention (PSA) structure. The specific operation is as follows:
[0094] Step 1, Feature downsampling: The input feature map ( Downsampling to a fixed low resolution ( =16, an effective representation of small target features), resulting in Query, Key, and Value matrices (all dimensions are 16). ,in (The number of channels after projection).
[0095] The second step is low-resolution self-attention calculation: Attention weights for small-scale features are calculated using scaled dot product attention, focusing on small target lesion features. The formula is as follows:
[0096]
[0097] in, , , They are respectively , , matrix, , , , This represents the total number of low-resolution spatial locations. This represents the dimension of the Key matrix (i.e., the number of channels at each position). The dimension of the Value matrix. This represents the transpose of the Key matrix. This is a scaling factor used to prevent the dot product result from becoming too large. Gradient vanishing The normalized exponential function converts the attention score into a probability distribution.
[0098] The third step is detail enhancement and upsampling: the attention-weighted feature map is upsampled to the original scale, and then local details are enhanced by a 3×3 depthwise separable convolution to avoid the loss of small target features caused by low resolution. Finally, the output is a feature map with the same dimensions as the original C2PSA module to ensure compatibility with the Neck layer.
[0099] After completing the replacement and optimization of the above three-layer modules, the result is as follows: Figure 8 The MSCB-YOLOv11 model shown retains the lightweight and high inference efficiency of YOLOv11, and solves the core pain points of small-target tomato disease detection (weak features, easy loss, background interference) through targeted module design. The model can be trained on the tomato disease annotation dataset after preprocessing in step 2.
[0100] Step 5: Training and Validation of the MSCB-YOLOv11 Tomato Disease Detection Model
[0101] For the MSCB-YOLOv11 tomato disease detection model constructed in step 4, the training environment and core parameters of the YOLOv11n benchmark model in step 3 were used to ensure the fairness of the comparison with the benchmark model and avoid variable interference. A total of 150 rounds of training were conducted based on the standardized tomato disease dataset preprocessed in step 2. After ensuring full convergence, multi-dimensional indicators were introduced to comprehensively verify the model performance. The final verification results are as follows: Precision=0.766, Recall=0.694, F1=0.728, mAP@0.5=0.75, mAP@0.5:0.95=0.463, GFLOPs=6.6, Params / M=2.66. All indicators were used for subsequent performance comparison with the benchmark model.
[0102] Step 6: Comparative analysis of model performance to determine the final tomato disease detection model.
[0103] Based on the validation results of MSCB-YOLOv11 in step 5, performance comparisons were made with the YOLOv11 benchmark model and currently popular YOLO derivative models. The technical effectiveness of the optimization scheme of this invention was verified through objective data. The specific comparisons are as follows:
[0104] Table 1 Comparison of the performance of MSCB-YOLO and YOLOv11:
[0105] ;
[0106] The performance comparison with the YOLOv11 benchmark model was conducted using the same tomato disease dataset, the same training environment, and the same evaluation criteria to ensure fairness. The specific comparison results are shown in the table below:
[0107] To compare the performance of currently popular YOLO derivative models, YOLOv12 and YOLOv13 were selected as comparison objects. All models were trained on the same tomato disease dataset and used the same evaluation criteria. The specific comparison results are shown in the table below:
[0108] Table 2 Comparison of YOLO series effects:
[0109] .
[0110] The present invention provides a tomato leaf disease detection system based on MSCB-YOLOv11, comprising:
[0111] The image acquisition module is used to acquire images of tomato leaves;
[0112] The image preprocessing module is used for image enhancement and annotation;
[0113] The disease detection module has an embedded MSCB-YOLOv11 model trained using the above method.
[0114] The output module is used to output the disease detection results.
[0115] In summary, through performance comparison with the benchmark model and popular YOLO derivative models, MSCB-YOLOv11 shows optimized performance in the core accuracy indicators of tomato disease detection, small target lesion detection performance, and training stability, and is determined as the final tomato disease detection model.
[0116] It should be understood that the above detailed description of the technical solutions of the present invention is illustrative rather than restrictive. The technical solutions described in each embodiment are not limited to their own disclosures, and the embodiments can be combined with each other to form new technical solutions. After reading the specification of this invention, those skilled in the art can modify the technical solutions of each embodiment or make equivalent substitutions for some of the technical features, and such modifications or substitutions will not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the present invention.
Claims
1. A tomato leaf disease detection method based on MSCB-YOLOv11, characterized in that, Includes the following steps: Step S1: Collect images of tomato leaves and construct an initial dataset containing early blight, late blight, leaf mold, leaf spot, and healthy leaves; Step S2: Preprocess and label the images in the initial dataset to obtain a standardized dataset; Step S3: Construct a tomato disease detection model based on the improved YOLOv11, denoted as the MSCB-YOLOv11 model; the improvements include: The C3k2 module in the YOLOv11 backbone network is replaced with the C3k2-MSES module, which is used for multi-scale edge information selection and feature enhancement. Replace the upsampling module in the YOLOv11 neck network with the EUCB module, which is a high-efficiency and lightweight upsampling convolutional block; Replace the C2PSA module in the YOLOv11 backbone network with the C2PSA-LRSA module, which is a pyramid self-attention module that integrates low-resolution self-attention. Step S4: Use the standardized dataset to train and validate the MSCB-YOLOv11 model to obtain a trained tomato disease detection model; Step S5: Input the tomato leaf image to be detected into the trained tomato disease detection model, and output the disease category and location information.
2. The MSCB-YOLOvl 1-based tomato leaf disease detection method according to claim 1, wherein, The preprocessing in step S2 includes: vertical mirroring, horizontal mirroring, random rotation, brightness adjustment, Mosaic-8 data augmentation, and adaptive anchor frame calculation.
3. The MSCB-YOLOvl 1-based tomato leaf disease detection method according to claim 1, wherein, The C3k2-MSES module includes: The multi-scale adaptive pooling layer performs scale coverage on the input feature map through four parallel branches with pooling kernels of 3, 6, 9, and 12. The EdgeEnhancer submodule enhances the edge features of small target lesions using the following formula: in, Input feature map for branch, 3×3 average pooling (used to reduce background noise). It uses 1×1 convolution (to achieve channel dimensionality reduction and dimensionality increase, and enhance feature representation). This is the feature map after edge enhancement; this operation highlights the edge contour by calculating the difference between the original feature and the pooling feature, making small target lesions "visible" from the background; The DSM dual-domain selection attention mechanism uses both spatial and channel domain weighting to filter high-value features.
4. The method for detecting tomato leaf diseases based on MSCB-YOLOv11 according to claim 1, characterized in that, The EUCB module is built based on depthwise separable convolution, and its processing flow includes: 2x interpolation upsampling, 3×3 depthwise convolution, batch normalization, ReLU activation function, and 1×1 pointwise convolution.
5. The method for detecting tomato leaf diseases based on MSCB-YOLOv11 according to claim 1, characterized in that, The C2PSA-LRSA module includes: The input feature map is downsampled to a fixed low resolution; Perform scaled dot product self-attention computation in low-resolution space; The attention-weighted feature map is upsampled to the original scale, and local details are supplemented by depthwise separable convolution.
6. The method for detecting tomato leaf diseases based on MSCB-YOLOv11 according to claim 1, characterized in that, The training parameters in step S4 are set as follows: initial learning rate 0.001, batch size 16, number of training rounds 150, input image size 640×640, and loss function CIoU.
7. The method for detecting tomato leaf diseases based on MSCB-YOLOv11 according to claim 1, characterized in that, The verification metrics in step S4 include: mAP@0.5, mAP@0.5:0.95, precision, recall, F1 score, floating-point computation and parameter count.
8. A tomato leaf disease detection system based on MSCB-YOLOv11, characterized in that, include: The image acquisition module is used to acquire images of tomato leaves; The image preprocessing module is used for image enhancement and annotation; A disease detection module, which embeds an MSCB-YOLOv11 model trained by the method described in any one of claims 1 to 7; The output module is used to output the disease detection results.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the tomato leaf disease detection method based on MSCB-YOLOv11 as described in any one of claims 1 to 7.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the tomato leaf disease detection method based on MSCB-YOLOv11 as described in any one of claims 1 to 7.