Tomato leaf disease detection method based on improved YOLOV8

By improving the YOLOV8 model structure and introducing a transfer learning strategy, the problems of missed detection and false detection in tomato leaf disease detection were solved, and the detection accuracy and generalization ability were improved. It is suitable for the accurate detection of early blight, late blight and gray mold.

CN121582199APending Publication Date: 2026-02-27ANHUI POLYTECHNIC UNIV MECHANICAL & ELECTRICAL COLLEGE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511740265.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-25
Publication Date
2026-02-27

AI Technical Summary

Technical Problem

The existing YOLO V8 model has problems in detecting diseases on tomato leaves, such as high false negative rate for small target diseases, high false positive rate for similar diseases, and weak generalization ability in natural environment.

Method used

By optimizing the YOLOV8 model structure, adding an Upsample-Concat-C2f small object detection layer and a Triplet Attention mechanism, and combining it with a transfer learning strategy, a G-YOLO V8 model was constructed to improve the attention to local features of lesions and the model's generalization ability in natural environments.

Benefits of technology

It significantly improves the detection accuracy of small-target diseases and the ability to distinguish similar diseases, reduces the false negative rate and the false positive rate, shortens the model training cycle, and meets the detection needs in agricultural planting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121582199A_ABST
    Figure CN121582199A_ABST
Patent Text Reader

Abstract

The invention discloses a tomato leaf disease detection method based on improved YOLOV8. The method comprises the following steps: acquiring tomato leaf images of different disease degrees of common data set data and self-built data set data; the method comprises the following steps: constructing an improved YOLO V8 model, adding an Upsample-Concat-C2f small target detection layer, recovering high-resolution information of a superficial layer feature map through up-sampling, introducing a Triplet Attention triple attention mechanism, and improving the attention on local features of scabs; pre-training the improved model by using a public data set, quickly learning general characteristics of tomato leaf diseases, performing fine tuning by using a self-built data set, and improving the generalization ability of the model in a natural environment through transfer learning; and outputting a final detection result through the trained model. According to the method, the small target detection precision can be effectively improved, and accurate detection of early blight, late blight and gray mold is realized.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of agricultural intelligent detection and computer vision, and particularly relates to a tomato leaf disease detection method based on improved YOLOV8. BACKGROUND

[0002] Tomato is an important crop for food security and agricultural economy. During the growth of tomato, it is prone to be attacked by early blight, late blight, gray mold and other diseases. These diseases have the characteristics of fast transmission, small early lesion ratio, and overlapping symptoms of similar diseases (such as water-stained lesions of late blight and gray mold). Traditional manual detection has high omission rate and cannot meet the precise prevention and control needs of large-scale planting.

[0003] In recent years, deep learning target detection technology has become the core means of tomato leaf disease detection. In the prior art, YOLO series models are widely used due to their real-time advantages. For example, a model improved based on YOLO V5 improves the small target detection capability by introducing a feature pyramid network (FPN), but the discrimination accuracy of similar diseases is insufficient. The YOLO V7-tiny model is adapted to mobile terminals through lightweight modification, but sacrifices 10%-15% of the detection accuracy. The original YOLO V8 model balances the detection speed and accuracy, but still has two key defects:

[0004] 1. Loss of small target disease features: Early lesion pixels have low occupancy. After multi-layer down-sampling by the YOLO V8 backbone network, the subtle features such as lesion edges and textures are diluted. The down-sampling process further reduces the pixel occupancy of early lesions in the feature map from 0.8%-1.2% of the original image, and the final omission rate is as high as more than 25%.

[0005] 2. Difficulty in distinguishing similar diseases: The early blight has overlapping features such as the texture of the mold layer of gray mold and the transition zone features of the water-stained edge of late blight and healthy tissue. The original model relies on global feature classification and cannot capture local differences, with a false detection rate of more than 18%.

[0006] In addition, although some improved models in the prior art can improve feature attention, they do not optimize the attention module structure for the morphological characteristics of tomato leaf diseases. At the same time, most models do not combine the small sample characteristics of agricultural scenes, and have insufficient generalization ability in natural environments, making it difficult to meet the detection needs in actual planting. SUMMARY

[0007] In view of the problems of high missing detection rate of tomato leaf small target disease, high mis-detection rate of similar diseases and weak natural environment generalization ability of the YOLO V8 model in the prior art, the application provides a tomato leaf disease detection method based on an improved YOLOV8, which realizes accurate detection of early blight, late blight and gray mold by optimizing the model structure and introducing a transfer learning strategy.

[0008] The application adopts the following technical scheme: a tomato leaf disease detection method based on an improved YOLOV8, comprising the following steps:

[0009] Step 1, tomato leaf disease dataset construction: collecting tomato leaf images of different disease degrees in public dataset data and self-built dataset, performing data labeling and preprocessing, and forming an original dataset;

[0010] Step 2, improved G-YOLO V8 model construction: based on the traditional YOLO V8 model, adding an Upsample-Concat-C2f small target detection layer, restoring the high-resolution information of the shallow feature map through upsampling, and introducing a TripletAttention triple attention mechanism to improve the attention degree to local features of disease spots;

[0011] Step 3, model training and transfer learning: pre-training the improved G-YOLO V8 model using a public dataset to quickly learn the general features of tomato leaf diseases; fine-tuning using a self-built dataset to improve the generalization ability of the model in a natural environment through transfer learning;

[0012] Step 4, disease detection: inputting a tomato leaf image to be detected, and outputting the final detection result through the trained G-YOLO V8 model.

[0013] As a preferred, the public dataset data includes: selected early blight, late blight and gray mold tomato leaf images; the self-built dataset includes: tomato leaf images of different light and different disease degrees; and the resolution of the two types of data pictures is uniformly adjusted to 1024x1024 pixels.

[0014] As a preferred, the data labeling and preprocessing method is as follows:

[0015] Labelme software is used for semantic segmentation labeling of all images, a quadrilateral annotation box is outlined along the disease spot contour, a JSON file containing disease categories and boundary coordinates is generated, and then the JSON file is converted into a YOLO format txt file; the txt file contains: category index, normalized center point coordinates and boundary box height-width ratio; the original dataset is expanded by using Mosaic data enhancement, rotation and color transformation, and the training set, the validation set and the test set are divided.

[0016] As a preferred, in step 2, the improved G-YOLO V8 model optimizes the original YOLO V8 from the following two dimensions:

[0017] 1. Add Upsample-Concat-C2f small target detection layer, the method is as follows:

[0018] After the 15th layer detection head of the traditional YOLO V8 model, add the Upsample-Concat-C2f module, extract the 160x160 size feature map output by the 12th layer of the backbone network, and increase the size to 320x320 through 2 times upsampling. The upsampling process uses bilinear interpolation.

[0019] 2. Introduce Triplet Attention three attention mechanism, the method is as follows:

[0020] Insert the Triplet Attention module after the C2f module of the YOLO V8 model backbone network, capture the channel-space dependency of the feature map through three branches:

[0021] (C, H) dimension branch: rotate the input feature map with dimensions CxHxW counterclockwise by 90° along the H axis, reduce the dimension to 2xHxC after Z-Pool maximum pooling and average pooling processing, and then generate attention weights through 7x7 convolution and batch normalization. After rotation recovery, it acts on the original feature map;

[0022] (C, W) dimension branch: rotate 90° counterclockwise along the W axis, repeat the Z-Pool and convolution operation, and capture the channel and width direction feature association;

[0023] (H, W) dimension branch: directly Z-Pool the feature map to 2xHxW, generate spatial attention weights through 7x7 convolution, and highlight the spatial position features of the lesion area.

[0024] The weights of the three branches are aggregated and then applied to the input feature map, so that the improved model pays more attention to the local features of the lesion, including the early blight ring and the gray mold layer, and distinguishes similar diseases.

[0025] As a preferred, in step 3, the improved G-YOLO V8 model is pre-trained using a public dataset, with an initial learning rate of 0.001, Batch Size=8, and training rounds. The optimizer uses AdamW, and the loss function uses CIoU loss and cross-entropy loss. Freeze the first 50 layers of the backbone network, only train the detection head and the new module, and quickly learn the general features of tomato leaf diseases.

[0026] Fine-tuning was performed using a self-built dataset, all network layers were unfrozen, and a cosine annealing learning rate strategy was adopted to train for several epochs. Transfer learning was used to compensate for the insufficient sample size of the self-built dataset and improve the model's generalization ability in natural environments.

[0027] As a preferred embodiment, the disease detection method in step 4 is as follows:

[0028] Step 4.1: Input the tomato leaf image to be detected, with a resolution ≥ 512×512 pixels;

[0029] Step 4.2: Preprocess the input image: resize to 1024×1024 pixels, normalize pixel values ​​to [0,1], use OpenCV to remove image noise, and set the Gaussian blur kernel size to 3×3;

[0030] Step 4.3: Input the preprocessed image into the trained G-YOLO V8 model, output candidate detection boxes through forward propagation; use non-maximum suppression to filter overlapping boxes, and output the final detection results, including: disease category, confidence level, and lesion boundary coordinates.

[0031] The present invention also provides: an electronic device, comprising:

[0032] One or more processors;

[0033] A storage device on which one or more programs are stored;

[0034] When the one or more programs are executed by the one or more processors, the one or more processors implement any of the above-described methods for detecting tomato leaf diseases based on the improved YOLOV8.

[0035] The present invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps in any of the above-mentioned methods for detecting tomato leaf diseases based on the improved YOLOV8.

[0036] Compared with the prior art, the present invention, employing the above technical solution, has the following technical effects:

[0037] 1. Significantly improved accuracy in detecting small targets: On the test set, the recall rate for early lesions (area < 5% of leaf area) reached 94.3%, which is 22.2 percentage points higher than the original YOLO V8 (72.1%), solving the problem of missed detection of early diseases.

[0038] 2. Strong ability to distinguish similar diseases: The average detection accuracy of the method of this invention for early blight, late blight and gray mold is 97.8%, which is 5.6 percentage points higher than the original YOLO V8 (92.2%). The false detection rate is controlled within 6%, and the characteristics of the three diseases can be accurately distinguished.

[0039] 3. High training efficiency: The method of this invention shortens the model training cycle from 44.1 minutes in the original YOLO V8 to 38.8 minutes through transfer learning, while avoiding overfitting caused by small samples, and controlling the difference in accuracy between the training set and the test set to within 2%. Attached Figure Description

[0040] Figure 1 This is a flowchart of the tomato leaf disease detection method based on the improved YOLOV8 of the present invention;

[0041] Figure 2 This is a simplified diagram of the improved G-YOLO v8 network structure of this invention;

[0042] Figure 3 This is a simplified diagram of the small target detection layer structure of the present invention;

[0043] Figure 4 This is a simplified diagram of the triple attention mechanism network of the present invention;

[0044] Figure 5 This is a thermal comparison analysis diagram of various networks in an embodiment of the present invention;

[0045] Figure 6 This is a visual comparison chart of the various networks in the embodiments of the present invention. Detailed Implementation

[0046] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of the application will be further described in detail below with reference to the accompanying drawings. The described embodiments are only a part of the embodiments involved in this invention. All non-innovative embodiments based on these embodiments by other researchers in the art are within the protection scope of this invention. Furthermore, the step numbers in the embodiments of this invention are only set for ease of explanation and do not limit the order of the steps. The execution order of each step in the embodiments can be adaptively adjusted according to the understanding of those skilled in the art.

[0047] In one embodiment of the present invention, a method for detecting tomato leaf diseases based on an improved YOLO V8 is provided. By optimizing the model structure and introducing a transfer learning strategy, the method achieves accurate detection of early blight, late blight, and gray mold. Specifically, as follows... Figure 1 As shown, it includes three core steps: dataset construction, model improvement, and model training.

[0048] Step 1: Constructing a dataset of tomato leaf diseases.

[0049] Data collection: Two types of data were collected. The first was 1200 images each of early blight, late blight, and gray mold selected from the public dataset (PlantVillage) (the resolution was uniformly adjusted to 1024×1024 pixels). The second was a self-built dataset, which was taken in the soilless cultivation greenhouse of Shucheng County Agricultural Science Research Institute in Lu'an City, Anhui Province, using a Huawei Mate40 Pro (50 million pixels) under different lighting conditions and different disease severity, and the resolution was uniformly adjusted to 1024×1024 pixels.

[0050] Data annotation and preprocessing: The Labelme software was used to perform semantic segmentation and annotation on all images. Quadrilateral annotation boxes were drawn along the lesion outlines to generate JSON files containing disease categories (early blight-0, late blight-1, gray mold-2) and boundary coordinates. These files were then converted into YOLO format txt files (containing category index, normalized center point coordinates, and bounding box aspect ratio).

[0051] Further augmentation, rotation, and color transformation of the dataset were performed using Mosaic data augmentation, rotation, and color transformation, resulting in a training set of 7960 images, a validation set of 995 images, and a test set of 995 images.

[0052] Step 2: Improve the YOLO V8 model (G-YOLO V8) construction.

[0053] Specifically, this embodiment addresses the shortcomings of the original YOLO V8 by optimizing it from two dimensions, resulting in an improved G-YOLO V8 model, the structure of which is as follows: Figure 2 As shown.

[0054] Optimization 1: Add an Upsample-Concat-C2f small target detection layer, with the structure as follows: Figure 3 As shown.

[0055] After the 15th layer of the original YOLO V8 model's detector head (output feature map size 80×80), an Upsample-Concat-C2f module is added: extracts the 160×160 feature map output from the 12th layer of the backbone network, and increases the size to 320×320 through 2x upsampling.

[0056] The upsampling process uses bilinear interpolation. Let the pixel value of the input feature map be... Upsampled pixel values The calculation formula is: ; in, For bilinear interpolation weights, This is a row index.

[0057] In this embodiment, the principle for solving the problem of missed detection of small target diseases is as follows: the Upsample-Concat-C2f module recovers the high-resolution information of the 160×160 shallow feature map through upsampling. After being stitched with the 80×80 deep feature map, the pixel ratio of lesions increases from 0.8%-1.2% in the original model to 2.5%-3.0%. At the same time, the residual branch of the C2f module strengthens the propagation of subtle features and avoids feature loss caused by downsampling, so that the early lesion missed detection rate is reduced from 25% to below 8%.

[0058] Furthermore, a 1×1 convolution kernel was used to compress the number of channels in the upsampled feature map from 128 to 64.

[0059] Optimization 2: Introduce Triplet Attention mechanism, with the network structure as follows: Figure 4 As shown.

[0060] A Triplet Attention module is inserted at layer 8 of the YOLO V8 backbone network (after the C2f module). This module captures the channel-spatial dependencies of the feature maps through three branches.

[0061] (C,H) Dimensional Branch: The input feature map (dimension C×H×W) is rotated 90° counterclockwise along the H axis, reduced to 2×H×C by Z-Pool (max pooling and average pooling), and then attention weights are generated by 7×7 convolution and batch normalization. After rotation recovery, these weights are applied to the original feature map.

[0062] (C,W) Dimension Branch: Rotate 90° counterclockwise along the W-axis and repeat the Z-Pool and convolution operations above to capture the feature association between the channel and width directions. The Z-Pool can be expressed by the formula: ; in, For the input feature map, , The function represents max pooling and average pooling, and the subscript 0d indicates that the pooling operation is performed on the channel dimension (the 0th dimension).

[0063] (H,W) Dimensional Branch: Directly perform Z-Pool dimensionality reduction on the feature map to 2×H×W, and generate spatial attention weights through 7×7 convolution to highlight the spatial location features of the lesion region.

[0064] The weights of the three branches are averaged and aggregated and then applied to the input feature map, which increases the model's attention to local features of lesions (such as early blight ring patterns and gray mold layer) by 35%, effectively distinguishing similar diseases.

[0065] In this embodiment, the principle for solving the problem of false detection of similar diseases is as follows: The three branches of the Triplet Attention module focus on the dependencies in the channel-height (C,H), channel-width (C,W), and spatial (H,W) dimensions, respectively. For example, the texture gradient of the ring structure of early blight in the (H,W) dimension is greater than that of gray mold, and the color difference (RGB value difference of 15-20) of the water-soaked edge of late blight in the (C,H) dimension is greater than that of healthy tissue. The module highlights these differences by assigning weights, thereby reducing the false detection rate of similar diseases from 18% to below 6%.

[0066] Step 3: Model training and transfer learning.

[0067] Pre-training phase: The improved G-YOLO V8 model was pre-trained using the public dataset (PlantVillage) with the following parameters: initial learning rate 0.001, batch size = 8, training epochs = 200, the optimizer used was AdamW (weight decay coefficient 0.0005), and the loss function was CIoU loss + cross-entropy loss; the parameters of the first 50 layers of the backbone network were frozen, and only the detection head and the newly added modules were trained to quickly learn the general features of tomato leaf diseases.

[0068] Fine-tuning phase: Load pre-trained weights, fine-tune using a self-built dataset, unfreeze all network layers, adopt a cosine annealing learning rate strategy (decreasing from 0.001 to 0.00001), and train for 200 epochs; use transfer learning to compensate for the insufficient sample size of the self-built dataset and improve the model's generalization ability in natural environments.

[0069] In this embodiment, the principle for solving the problem of weak generalization ability is as follows: transfer learning obtains the general features of tomato leaves through pre-training on public datasets, and then fine-tunes them with self-built datasets, so that the detection accuracy fluctuation of the model in different environments is reduced from ±12% to ±3%, which meets the detection needs of actual planting scenarios.

[0070] Step 4: Disease detection.

[0071] Input the tomato leaf image to be detected (JPEG / PNG format supported, resolution ≥ 512×512 pixels); preprocess the image: resize to 1024×1024 pixels, normalize pixel values ​​to [0,1], and use OpenCV to remove image noise (Gaussian blur kernel size 3×3).

[0072] The preprocessed image is input into the trained G-YOLO V8 model, and candidate detection boxes are output through forward propagation. Non-maximum suppression (NMS) is used to filter overlapping boxes (IOU threshold 0.5), and the final detection results are output: disease category (early blight / late blight / gray mold), confidence score (≥0.5), and lesion boundary coordinates.

[0073] Furthermore, the tomato leaf disease detection method based on the improved YOLOV8 of this invention is compared with existing technologies (original YOLO V8, improved YOLO V5, YOLO V7-tiny), and the experimental environment parameters of the deep neural network are set as shown in Table 1 below.

[0074] Table 1 Experimental environment parameters for deep neural networks

[0075] Set model accuracy metrics, including:

[0076] Precision is used to evaluate the accuracy of a model's predictions. Precision P is defined as the ratio of the number of correctly predicted positive samples to the total number of samples predicted as positive, as shown in the following formula: ;

[0077] Recall represents the proportion of all true positive samples that the model correctly predicts as positive. The formula is as follows: ;

[0078] Mean Average Precision (mAP) is used to evaluate the overall detection performance of the model. It is the average AP across all detection categories and is calculated as follows:

[0079] in, This indicates a true positive (the number of positive samples that were correctly detected). This indicates a false positive (the number of positive samples that are incorrectly detected, i.e., the number of negative samples that are mistakenly identified as positive samples). This indicates a false negative (the number of positive samples that were not detected, i.e., the number of positive samples that were mistakenly identified as negative samples). This represents the average accuracy (AP) of the i-th type of disease. This indicates the total number of disease categories detected.

[0080] The performance comparison of each network model is shown in Table 2 below; the heatmap and visualization comparison charts of each network model are shown below. Figure 5 and Figure 6 As shown.

[0081] Table 2 Performance Comparison of Various Network Models

[0082] As can be seen, the detection accuracy of small targets in this application is significantly improved. On the test set, the recall rate for early lesions (area < 5% of leaf area) reached 94.3%, an improvement of 22.2 percentage points compared to the original YOLO V8 (72.1%), solving the problem of missed detection of early diseases. At the same time, the ability to distinguish similar diseases is significantly enhanced. The average detection accuracy of early blight, late blight, and gray mold reached 97.8%, an improvement of 5.6 percentage points compared to the original YOLO V8 (92.2%), with the false positive rate controlled within 6%, accurately distinguishing the characteristics of the three diseases. The training efficiency is also significantly improved. Through transfer learning, the model training cycle is shortened from 44.1 minutes in the original YOLO V8 to 38.8 minutes, while avoiding overfitting caused by small samples. The accuracy difference between the training set and the test set is controlled within 2%.

[0083] In summary, this invention constructs an Upsample-Concat-C2f module for small-target diseases on tomato leaves, enhancing the expression of subtle features through upsampling, feature splicing, and residual purification; a Triplet Attention module adapted for distinguishing similar diseases captures local differences in lesions through three-dimensional attention weight allocation; and this application also solves the problem of small-sample generalization in agricultural scenarios through a transfer learning strategy of pre-training on public datasets and fine-tuning on self-built datasets. It is suitable for detecting early blight, late blight, and gray mold, especially for detecting small-target diseases (lesion area < 5% of leaf area) and in natural environments.

[0084] In this embodiment of the invention, an electronic device is also provided, comprising: one or more processors; a storage device storing one or more programs thereon; when the one or more programs are executed by the one or more processors, the one or more processors implement the tomato leaf disease detection method based on the improved YOLOV8 described in the above embodiments.

[0085] In this embodiment of the invention, a computer-readable storage medium is also provided, on which a computer program is stored. When the program is executed by a processor, it implements the steps of the tomato leaf disease detection method based on the improved YOLOV8 in the above embodiments.

[0086] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A method for detecting leaf diseases in tomatoes based on an improved YOLOv8, characterized in that, Includes the following steps: Step 1: Construction of Tomato Leaf Disease Dataset: Collect tomato leaf images of different disease severity from public datasets and self-built datasets, perform data annotation and preprocessing, and form the original dataset; Step 2: Improved YOLO V8 model construction: Based on the traditional YOLO V8 model, an Upsample-Concat-C2f small target detection layer is added. The high-resolution information of the shallow feature map is recovered by upsampling, and the Triplet Attention mechanism is introduced to improve the attention to the local features of lesions, resulting in the improved G-YOLO V8 model. Step 3, Model Training and Transfer Learning: The improved G-YOLO V8 model is pre-trained using a public dataset to quickly learn the general characteristics of tomato leaf diseases; Fine-tuning was performed using a self-built dataset, and the model's generalization ability in natural environments was improved through transfer learning. Step 4, Disease Detection: Input the tomato leaf image to be detected, and output the final detection result through the trained G-YOLO V8 model.

2. The method for detecting tomato leaf diseases based on the improved YOLOv8 according to claim 1, characterized in that, The public dataset includes images of tomato leaves with early blight, late blight, and gray mold that have been selected; the self-built dataset includes images of tomato leaves under different lighting conditions and with different disease severity; the resolution of both types of images is uniformly adjusted to 1024×1024 pixels.

3. The method for detecting tomato leaf diseases based on the improved YOLOv8 according to claim 1, characterized in that, The data annotation and preprocessing methods are as follows: All images were semantically segmented and labeled using Labelme software. Quadrilateral bounding boxes were drawn along the lesion contours to generate JSON files containing lesion categories and boundary coordinates. These JSON files were then converted into YOLO format txt files. The txt files contained: category index, normalized center point coordinates, and bounding box aspect ratio. The original dataset was augmented using Mosaic data augmentation, rotation, and color transformation. The dataset was then divided into training, validation, and test sets.

4. The method for detecting tomato leaf diseases based on the improved YOLOv8 according to claim 1, characterized in that, In step 2, an Upsample-Concat-C2f small target detection layer is added, as follows: After the 15th layer of the traditional YOLO V8 model's detector head, an Upsample-Concat-C2f module is added to extract the 160×160 feature map output from the 12th layer of the backbone network. This feature map is then upsampled by a factor of 2 to 320×320. The upsampling process uses bilinear interpolation, and the input feature map pixel values ​​are... Upsampled pixel values The calculation formula is: ; in, For bilinear interpolation weights, For row indexing, a 1×1 convolution kernel is used to compress the number of channels in the upsampled feature map from 128 to 64.

5. The method for detecting tomato leaf diseases based on the improved YOLOv8 according to claim 1, characterized in that, In step 2, the Triplet Attention mechanism is introduced, as follows: A Triplet Attention module is inserted after the C2f module in the YOLO V8 model backbone network, which captures the channel-spatial dependencies of the feature maps through three branches: (C,H) Dimensional Branch: The input feature map of dimension C×H×W is rotated 90° counterclockwise along the H axis, and after being processed by Z-Pool max pooling and average pooling, the dimension is reduced to 2×H×C. Attention weights are then generated by 7×7 convolution and batch normalization, and applied to the original feature map after rotation recovery. (C,W) Dimensional Branch: Rotate 90° counterclockwise along the W axis, repeat the Z-Pool and convolution operations, and capture the feature association between the channel and the width direction; (H,W) Dimensional Branch: Directly perform Z-Pool dimensionality reduction on the feature map to 2×H×W, and generate spatial attention weights through 7×7 convolution to highlight the spatial location features of the lesion region; The weights of the three branches are averaged and aggregated before being applied to the input feature map, thereby enhancing the model's attention to local features of lesions, including early blight ring patterns and gray mold layer, and distinguishing similar diseases.

6. The method for detecting tomato leaf diseases based on the improved YOLOv8 according to claim 5, characterized in that, In step 2, the Z-Pool processing is performed using the following formula: ; in, For the input feature map, , The function represents max pooling and average pooling, and the subscript 0d indicates that pooling is performed on the channel dimension.

7. The method for detecting tomato leaf diseases based on the improved YOLOv8 according to claim 1, characterized in that, In step 3, the improved G-YOLO V8 model is pre-trained using a public dataset. The initial learning rate is set to 0.001, the batch size to 8, and the number of training rounds. The optimizer is AdamW, and the loss function is CIoU loss and cross-entropy loss. The parameters of the first 50 layers of the backbone network are frozen, and only the detection head and the newly added modules are trained to quickly learn the general characteristics of tomato leaf diseases. Fine-tuning was performed using a self-built dataset, all network layers were unfrozen, and a cosine annealing learning rate strategy was adopted to train for several epochs. Transfer learning was used to compensate for the insufficient sample size of the self-built dataset and improve the model's generalization ability in natural environments.

8. The method for detecting tomato leaf diseases based on the improved YOLOv8 according to claim 1, characterized in that, The method for detecting the disease is as follows: Step 4.1: Input the tomato leaf image to be detected, with a resolution ≥ 512×512 pixels; Step 4.2: Preprocess the input image: resize to 1024×1024 pixels, normalize pixel values ​​to [0,1], use OpenCV to remove image noise, and set the Gaussian blur kernel size to 3×3; Step 4.3: Input the preprocessed image into the trained G-YOLO V8 model and output candidate detection boxes through forward propagation; Non-maximum suppression is used to filter overlapping boxes, and the final detection results are output, including: disease type, confidence level, and lesion boundary coordinates.

9. An electronic device, characterized in that, include: One or more processors; A storage device on which one or more programs are stored; When the one or more programs are executed by the one or more processors, the one or more processors implement the tomato leaf disease detection method based on the improved YOLOV8 as described in any one of claims 1 to 8.

10. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the steps in the tomato leaf disease detection method based on the improved YOLOV8 as described in any one of claims 1 to 8.