A tomato leaf disease detection method based on dynamic context perception and multi-scale feature fusion

CN122551060APending Publication Date: 2026-08-11TIANJIN UNIVERSITY OF TECHNOLOGY
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-10
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

[0006]针对现有番茄叶片病害检测方法中存在的多源数据标准不统一、病害目标尺度差异明显、病斑纹理细节容易丢失、不同尺度病斑信息融合过程中语义对齐不充分等问题,本发明提供一种基于动态上下文感知与多尺度特征融合的番茄叶片病害检测方法,以提高复杂农业场景下番茄叶片病害的检测精度、鲁棒性以及泛化能力

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122551060A_ABST
    Figure CN122551060A_ABST
Patent Text Reader

Abstract

This invention discloses a method for detecting tomato leaf diseases based on dynamic context awareness and multi-scale feature fusion. The method unifies and annotates multiple existing tomato leaf disease image data sources to construct a multi-morphological tomato leaf disease dataset. Based on this, a tomato leaf disease detection model is established, using YOLOv8 as the baseline architecture. Dynamic context awareness C2f modules are introduced into the P3, P4, and P5 layers of the backbone network to enhance the detail texture, diffusion area, and edge features of lesions. A highly efficient multi-scale attention module with bi-branch adaptive gating is embedded in the neck network to enhance the regional response of small and medium-sized target diseases. A dynamically adaptive offset-adjusted upsampling unit is deployed in the feature recovery stage to improve cross-scale feature recovery and spatial alignment capabilities. The SIoU loss function is used to optimize the bounding box regression accuracy during the training stage. This invention improves the detection accuracy, robustness, and generalization ability of tomato leaf diseases in complex backgrounds.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer vision and intelligent agriculture technology. It integrates deep learning image processing and target detection techniques to propose a target recognition method for detecting tomato leaf diseases. This method constructs a Diverse Morphology Tomato Leaf Disease Dataset (DMTLD) based on multiple existing crop disease image data sources. By combining image preprocessing, data standardization, multi-scale feature fusion, dynamic upsampling, and target detection model training and inference, it achieves automatic identification and precise localization of tomato leaf diseases in different agricultural scenarios. It can be applied to intelligent disease monitoring, field early warning, intelligent identification and analysis, and disease-aided diagnosis systems in both protected agriculture and open-field planting environments. Background Technology

[0002] Tomato leaf disease detection is a computer vision task that enables the automatic identification and localization of diseases in field or greenhouse agriculture environments. It is widely used in agricultural production management, disease monitoring and early warning, precision plant protection, and intelligent diagnosis. This task typically requires automated analysis of acquired leaf images to provide accurate location and category information for diseased areas within the images. However, the complex lighting conditions, severe background interference, varied leaf postures, and significant differences in disease morphology present considerable technical challenges for practical applications of tomato leaf disease detection.

[0003] With the development of deep learning technology, object detection methods based on convolutional neural networks have been increasingly applied to the field of agricultural disease identification. Existing research typically constructs deep feature extraction networks to encode multi-level features in input images and combines classification and localization branches to achieve disease detection tasks. These methods have achieved good results in general object detection tasks and have been introduced into agricultural visual scenes. However, due to significant differences between agricultural images and natural scene images in terms of object distribution, background complexity, and disease manifestations, directly applying existing detection models often fails to achieve ideal recognition performance.

[0004] Building upon this, tomato leaf diseases exhibit more complex feature distributions in real-world scenarios. On one hand, different diseases differ in scale, showing significant diversity in color distribution, texture structure, and boundary morphology. On the other hand, leaves in natural environments often exhibit bending, overlapping, and partial occlusion, compounded by variations in light intensity, shadow interference, and complex background factors, further weakening the discriminative features of diseased areas. Under these circumstances, existing methods often struggle to effectively model multiple morphological features during feature extraction and representation, easily leading to missing local details or insufficient response in key areas, thus affecting the accuracy and stability of detection results. To address these issues, some methods improve detection performance by increasing the number of network layers or expanding feature representation capabilities. While this improves detection results to some extent, it also increases the scale of model parameters, requiring a comprehensive trade-off between detection accuracy and computational efficiency during actual deployment.

[0005] Furthermore, existing tomato leaf disease image data mostly originates from different public datasets and actual collected samples. These different data sources exhibit significant differences in image acquisition equipment, shooting environment, and data organization methods, leading to substantial inconsistencies in resolution, clarity, and noise levels. Simultaneously, different datasets differ in their disease category classification standards and naming methods. Some datasets use coarse-grained annotations, providing only image-level labels, while others employ target-level annotations, lacking a unified standard. Directly using multi-source data for training easily leads to problems such as confused category definitions, inconsistent annotation standards, and unbalanced sample distribution, thus affecting the model's generalization ability and detection stability. Therefore, there is an urgent need to propose a target detection method that can standardize and organize multi-source heterogeneous tomato leaf disease image data, fully preserve the feature information of lesions in terms of color, texture, boundary structure, and multi-scale morphology during data construction, and combine multi-level feature modeling strategies for collaborative expression, in order to improve the model's recognition ability, detection accuracy, and application stability in complex agricultural scenarios. Summary of the Invention

[0006] To address the problems in existing tomato leaf disease detection methods, such as inconsistent multi-source data standards, significant differences in disease target scales, easy loss of lesion texture details, and insufficient semantic alignment during the fusion of lesion information at different scales, this invention provides a tomato leaf disease detection method based on dynamic context awareness and multi-scale feature fusion, in order to improve the detection accuracy, robustness, and generalization ability of tomato leaf diseases in complex agricultural scenarios.

[0007] To achieve the above objectives, the present invention adopts the following technical solution: a method for detecting tomato leaf diseases based on dynamic context awareness and multi-scale feature fusion, comprising the following steps:

[0008] 1. Constructing a Diverse Morphology Tomato Leaf Disease Dataset: Leaf disease samples from multiple existing tomato disease image data sources were integrated. The heterogeneous image data from multiple sources underwent filtering, deduplication, cropping, cleaning, disease category standardization, annotation format standardization, and manual annotation correction. Finally, a Diverse Morphology Tomato Leaf Disease Dataset (DMTLD) was constructed. The disease categories in this dataset include tomato blight, bacterial leaf spot, leaf mold, leaf miner, yellow leaf curl virus, and two-spotted spider mite, with a total of no fewer than 2300 images.

[0009] 2. Preprocess the multimorphic tomato leaf disease dataset: perform uniform size adjustment, normalization, data augmentation, and other operations on the input images, and divide them into training set, validation set, and test set according to the proportion, so that images from different sources meet the unified training input requirements.

[0010] 3. Establish a tomato leaf disease detection model based on dynamic context awareness and multi-scale feature fusion: The detection model includes a backbone network, a neck network, and a head.

[0011] Specifically, the backbone network introduces Dynamic Context-Aware blocks at layers P3, P4, and P5 to form Dynamic Context-Aware C2f (DCA_C2f) modules with the C2f module, which are used to enhance the texture, diffusion area, and edge direction features of lesions. The neck network uses Dynamic Adaptive Offset-Regulated Upsample (DAOUp) units to replace ordinary upsampling operations, which are used to improve the spatial alignment capability in the cross-scale feature recovery process. A dual-branch adaptive gated efficient multi-scale attention module (DAGEMA) is embedded in the neck network to enhance the attention response in small and medium-sized target lesion areas.

[0012] Furthermore, the dynamic context-aware C2f module is used to perform multi-branch contextual modeling of lesion features at different levels in the backbone network. Based on the feature splitting and splicing mechanism of the original C2f structure, this module introduces a Dynamic Context-Aware block. It extracts fine lesion textures, disease spread areas, and leaf vein edge directional features through local texture branches, dilated context branches, and directional stripe branches, respectively. Simultaneously, it utilizes global context information to generate dynamic branch weights, adaptively weighting and fusing features from different branches, thereby enhancing the model's ability to express tomato leaf diseases in terms of color changes, texture details, boundary morphology, and spatial spread characteristics.

[0013] Furthermore, the dynamically adaptive offset adjustment upsampling unit is used to dynamically recover and spatially align cross-scale features in the neck network. Unlike nearest neighbor interpolation upsampling, this unit adaptively generates a dynamic offset adjustment factor based on the input features and combines it with dynamic sampling offset to restore the feature map resolution, thereby alleviating the spatial misalignment problem between high-level semantic features and low-level detail features during the fusion process. Through this module, the alignment effect between lesion features at different scales can be improved, enabling the model to better fuse shallow lesion texture information and deep lesion semantic information.

[0014] Furthermore, the efficient multi-scale attention module with dual-branch adaptive gating is used to enhance the attention of small- and medium-scale disease features before the detection head input. This module first extracts enhanced features through an efficient multi-scale attention structure, then uses the original features and enhanced features together to generate adaptive gating weights, and dynamically fuses the original features and attention-enhanced features according to the gating weights. Subsequently, the original features and the gating fused features are combined in a dual-branch manner and integrated into channels. This module can enhance the response capability of small lesions and weakly textured disease areas on tomato leaves while preserving the stability of the original detection features, and reduce the adverse effects of complex backgrounds, leaf vein textures, and changes in light intensity on the detection results.

[0015] 4. Iteratively train the detection model based on the SIoU (SCYLLA Intersection over Union) loss function: replace the original CIoU loss function with the SIoU loss function to enhance the joint constraints on angle, center distance, shape difference and overlapping area during the bounding box regression process, and improve the accuracy of disease target localization.

[0016] 5. Disease detection of tomato leaves based on the trained detection model: Input the tomato leaf image to be detected into the trained target detection model, and output the category, confidence level and target bounding box position coordinates of the disease target to realize automatic identification and accurate localization of tomato leaf diseases.

[0017] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0018] (1) This invention improves the stability of model training by constructing a multimorphic tomato leaf disease dataset DMTLD, performing unified screening, unified category mapping and unified annotation standard processing on multi-source heterogeneous images.

[0019] (2) The DCA_C2f module enables the model to simultaneously focus on small spots, patchy lesions, leaf vein edges and disease spread areas through dynamic weighted fusion, thereby improving the ability to represent complex disease morphology.

[0020] (3) DAOUp uses a dynamic offset adjustment factor to adaptively control the sampling offset amplitude, which alleviates the spatial misalignment problem in the cross-scale feature fusion process and improves the alignment ability between shallow detail features and deep semantic features.

[0021] (4) The DAGEMA module enhances the response of small and medium-sized target disease areas through adaptive gating fusion between the original features and the EMA enhanced features, thereby improving the model's anti-interference ability in complex backgrounds.

[0022] (5) Experiments show that the method achieved a mAP of 70.2% on a multimorphic tomato leaf disease dataset and realized real-time detection on an embedded platform. Brief description of the attached figures

[0023] Figure 1 This is an overall flowchart of the present invention; Figure 2 This is a schematic diagram of the specific disease categories in the multimorphic tomato leaf disease dataset of this invention; Figure 3 This is a schematic diagram of the overall structure of the tomato leaf disease detection model in this invention; Figure 4 This is a schematic diagram of the module structure of the efficient multi-scale attention mechanism (DAGEMA) with dual-branch adaptive gating in this invention. Figure 5 This is a schematic diagram of the tomato leaf disease detection results in this invention. Detailed Implementation

[0024] The technical solution of the present invention will be further described below with reference to the accompanying drawings and specific implementation examples.

[0025] like Figure 1As shown, the present invention provides a tomato leaf disease detection method based on dynamic context awareness and multi-scale feature fusion. The overall process includes the following steps: First, construct a multimorphic tomato leaf disease dataset DMTLD; then, preprocess the dataset and divide the data proportionally; next, establish a tomato leaf disease detection model based on dynamic context awareness and multi-scale feature fusion; then, train the model based on the SIoU loss function; finally, use the trained model to perform disease detection on the tomato leaf images to be detected.

[0026] Step 1: Construct a dataset of multimorphic tomato leaf diseases.

[0027] The multimorphic tomato leaf disease dataset DMTLD in this embodiment integrates leaf disease samples from multiple existing tomato disease image data sources. It standardizes the heterogeneous image data from multiple sources, specifically including image filtering, deduplication, cropping, cleaning, disease category unification, annotation format unification, and manual fine-tuning or annotation correction. Finally, the multimorphic tomato leaf disease dataset DMTLD is constructed. Specifically, step 1 includes the following: 1. Screen leaf disease image samples from multiple tomato disease image data sources; 2. Clean the image samples, removing duplicates, severely blurred images, samples with unclear disease types, and healthy leaf samples that were mistakenly included; 3. Implement a unified mapping for disease names from different data sources and establish a unified category system; 4. Manually review and correct existing labeled samples, and perform detailed manual labeling on unlabeled samples; 5. Finally, the annotation files of different formats are converted to form a unified annotation format.

[0028] like Figure 2 As shown, the multimorphic tomato leaf disease dataset DMTLD covers six different types of tomato leaf diseases, specifically including tomato bacterial spot, tomato blight, tomato leaf mold, tomato leaf miner, tomato yellow leaf curl virus, and tomato two-spotted spider mite. In one embodiment, the total number of samples is no less than 2300, but is not limited to this. This dataset covers a variety of disease morphologies, including spot-like, patchy, yellowing, moldy, insect-induced linear, and mite-induced dot-like patterns, which is beneficial for improving the model's ability to learn complex disease manifestations.

[0029] Step 2: Preprocess the dataset and divide it proportionally.

[0030] After constructing the multimorphic tomato leaf disease dataset DMTLD, it was preprocessed, including adjusting the size of the input images, normalizing the image pixels, and performing data augmentation. Then, it was divided into training, validation, and test sets according to the proportions to generate standardized input samples suitable for model training and testing.

[0031] Step 3: Establish a tomato leaf disease detection model based on dynamic context awareness and multi-scale feature fusion.

[0032] The tomato leaf disease detection model constructed in this embodiment is as follows: Figure 3 As shown, the model comprises three parts: a backbone network, a neck network, and a detection head. Based on the YOLOv8 backbone network, the C2f modules in stages P3, P4, and P5 are removed and replaced with newly constructed dynamic context-aware C2f modules. A highly efficient multi-scale attention module with dual-branch adaptive gating is embedded in the neck network, and a dynamically adaptive offset-adjusted upsampling unit is deployed in the feature recovery stage.

[0033] For clarity, step 3 will be explained in more detail below.

[0034] Step 3.1: Backbone Network Feature Extraction

[0035] After the image is input into the backbone network, it first undergoes initial feature extraction through convolutional layers. The convolutional operation maps the original tomato leaf image to the basic feature space to obtain shallow edge and basic texture information. Subsequently, the shallow features enter the C2f module at layer P2 for basic feature encoding. After completing the feature extraction at layer P2, the features sequentially enter the three backbone feature extraction stages: P3, P4, and P5. As the network depth increases, the spatial resolution of the feature maps gradually decreases, the number of channels gradually increases, and the semantic expressive power of the model continuously improves. Specifically, layer P3 outputs a feature map with a downsampling factor of 8, mainly used to characterize small lesions and local texture anomalies; layer P4 outputs a feature map with a downsampling factor of 16, mainly used to characterize medium-scale lesions, localized spread areas, and more obvious leaf disease structures; layer P5 outputs a deep feature map with a downsampling factor of 32, mainly used to characterize deep semantic information such as large-area yellowing, mold spread, necrotic patches, and overall disease patterns.

[0036] Step 3.2: Dynamic Context-Aware C2F Module

[0037] To enhance the backbone network's ability to model complex lesion morphologies, this implementation introduces the DCA_C2f module in stages P3, P4, and P5. This module, based on the original C2f's feature splitting, step-by-step encoding, and channel splicing structure, introduces a dynamic context-aware modeling mechanism, enabling the network to adaptively extract local lesion texture, lesion diffusion area, and lesion edge features according to the lesion morphology in different input images.

[0038] Let the features input into the dynamic context-aware structure inside DCA_C2f be: The three types of feature responses are obtained through local texture branching, dilation context branching, and orientation stripe branching, respectively. The process is represented as follows: , , , in, This represents the output features of local texture branches. This indicates the output features of the dilated context branch. This indicates the output characteristics of the directional strip branch. Represents depthwise convolution; Depth convolution with dilation rate This indicates the size of the strip convolution kernel.

[0039] To enable the model to adaptively adjust the contribution ratios of the three branches according to different disease morphologies, dynamic branch weights are generated using global contextual information from the input features. The expression for this dynamic weight is: , in, This indicates a global average pooling operation. and This represents two 1×1 convolution operations. Represents a non-linear activation function. Represents the normalization function. , and These represent the dynamic weights corresponding to the local texture branch, the dilation context branch, and the directional stripe branch, respectively.

[0040] Based on the above dynamic weights, the features of the three branches are weighted and fused: , in, This represents the context-aware features after dynamic fusion. This indicates element-wise multiplication.

[0041] Subsequently, the fused features Channel integration is performed after 1×1 convolution, and spatial location enhancement is achieved through lightweight coordinate attention. Finally, it is combined with the original input features. Perform residual connections to obtain the output features of the dynamic context-aware structure: , in, This represents a 1×1 convolution operation used for channel integration. This indicates a lightweight coordinate attention enhancement operation.

[0042] The DCA_C2f module can enhance the detailed texture of tomato leaf diseases, the spread area of ​​lesions, and the edge features of lesions at different semantic levels, thereby improving the model's ability to represent complex lesion morphologies.

[0043] Step 3.3: DAGEMA Attention Enhancement

[0044] like Figure 4 As shown, a highly efficient multi-scale attention module (DAGEMA) with dual-branch adaptive gating is embedded in the feature fusion stage of the neck network. The features in this stage contain detailed texture information at high resolution while retaining some semantic expressive power, providing important feature support for the detection of small lesions, local texture anomalies, and medium-scale disease areas. Therefore, introducing an attention enhancement module at this location can more effectively improve the response capability of small and medium-sized target disease areas.

[0045] First, define the original features input to the DAGEMA module as follows: To reduce the computational complexity of attention and enhance the feature modeling capability within local regions, the input features are first divided into several groups according to the channel dimension, and efficient multi-scale attention modeling is performed within each group. Enhanced features are obtained through an efficient multi-scale attention enhancement branch: , in, This indicates an efficient multi-scale attention enhancement operation.

[0046] Then, the original features With enhanced features The weights are concatenated and then adaptively gated weights are generated using 1×1 convolution and activation functions. , in, This indicates that gated generation of convolutions, This indicates a channel splicing operation. This represents the Sigmoid activation function.

[0047] Based on the gating weights, the original features and enhanced features are dynamically fused. This process does not directly replace the original features with enhanced features, but rather uses gating weights to control the fusion ratio between the two, the expression of which is: , in, This indicates the features after gating fusion. This indicates element-wise multiplication.

[0048] Finally, a dual-branch output fusion structure is constructed. The original features... Features of gating integration The DAGEMA module concatenates the features along the channel dimension, preserving both the original detection features and the attention enhancement features in the output. Then, it performs channel integration on the concatenated features through output convolution to obtain the final output features of the DAGEMA module. Its expression is: , in, This represents a 1×1 convolution that integrates the output channels.

[0049] By introducing the DAGEMA module in the feature fusion stage of the neck network, the model can further enhance the attention response of small- and medium-scale tomato leaf disease areas while preserving the stability of the original detection features. This improves the ability to identify small spots, weak textured lesions, and low-contrast disease areas, and reduces the adverse effects of complex backgrounds, leaf vein textures, and changes in light on the detection results.

[0050] Step 3.4: DAOUp Unit

[0051] In this implementation, a Dynamically Adaptive Offset Adjusted Upsampling (DAOUp) unit is used to replace the original nearest neighbor interpolation in the feature recovery stage of the neck network. DAOUp adaptively generates a dynamic offset adjustment factor based on the input features and combines it with the dynamic sampling offset to complete the upsampling feature recovery.

[0052] Let the characteristics of the input upsampling unit be: First, a dynamic offset adjustment factor is generated based on the input features: , in, This represents the dynamic offset adjustment factor, used to control the adjustment range of the sampling offset. This represents a 1×1 convolution operation used to generate the dynamic offset adjustment factor. This indicates a global average pooling operation. This represents a smoothing nonlinear function, used to ensure that the dynamic offset adjustment factor is positive.

[0053] Furthermore, a dynamic sampling offset is generated based on the input features, and its calculation process is expressed as follows: , in, Indicates dynamic sampling offset, This indicates that the offset generation convolution is used to predict the offset of the sampling position. This indicates an offset-range modulated convolution, used to constrain the effective range of the sampling offset. This represents the Sigmoid activation function. Indicates the initial sampling position offset; This indicates element-wise multiplication.

[0054] Finally, the input features are subjected to grid sampling based on the dynamic sampling offset to obtain the upsampled output features. Its expression is: , in, This represents a bilinear sampling operation based on a sampling grid. Indicates the location of the original sampling grid.

[0055] DAOUp can adaptively adjust the sampling position based on the content of input features at different levels, enabling higher-level semantic features to better align with lower-level detailed features when restoring spatial resolution. This module helps alleviate spatial misalignment problems during cross-scale fusion and improves the stability of locating small lesions and blurred-edge lesions on tomato leaves.

[0056] Step 4: Train the model based on the SIoU loss function.

[0057] After the detection model is built, the preprocessed training samples are input into the model for iterative training. This invention uses the SIoU loss function instead of the original CIoU loss function to enhance the constraints of angle, distance, and shape factors on the bounding box regression process. The SIoU loss function formula is: , in, Indicates distance cost. Indicates the cost of shape.

[0058] The overall training loss is expressed as: , in, Represents classification loss, Indicates the distribution focus loss. , and These represent the weight coefficients of the bounding box loss, classification loss, and distribution focus loss, respectively.

[0059] Step 5: Use the trained model to detect tomato leaf diseases.

[0060] The trained target detection model is used to perform target detection tasks. Images of tomato leaf diseases to be detected are input into the trained model, which outputs the detection results, including the category label of the diseased target, the target confidence score, and the bounding box coordinates, thus achieving automatic identification and accurate localization of tomato leaf diseases. Experimental results show that the method of this invention achieves an mAP of 70.2% on the DMTLD dataset. Figure 5 As shown.

[0061] The specific embodiments described herein are merely illustrative of the spirit of the invention. Those skilled in the art to which this invention pertains may make various modifications or additions to the described specific embodiments or use similar methods to substitute them, without departing from the spirit of the invention or exceeding the scope defined by the appended claims.

Claims

1. A method for tomato leaf disease detection based on dynamic context awareness and multi-scale feature fusion, characterized in that, Comprising the following steps: (1) Constructing a multi-form tomato leaf disease dataset: integrating leaf disease samples in multiple existing tomato disease image data sources, screening, deduplicating, cropping, cleaning, unifying disease categories, unifying annotation formats, and manually correcting, finally constructing a multi-form tomato leaf disease dataset DMTLD; (2) Preprocessing the multi-form tomato leaf disease dataset: uniformly adjusting the size of the input image, normalizing, data enhancement, and dividing into training set, validation set and test set according to the proportion; (3) Establishing a tomato leaf disease detection model based on dynamic context perception and multi-scale feature fusion: the detection model includes a backbone network, a neck network and a detection head; wherein a dynamic context perception C2f module is used in the backbone network, a double-branch adaptive gated efficient multi-scale attention module is embedded in the neck network, and a dynamic adaptive offset adjustment up-sampling unit is deployed in the feature recovery stage; (4) Iteratively training the detection model based on the SIoU loss function; (5) Disease detection of tomato leaves based on the trained detection model: input the tomato leaf image to be detected into the trained target detection model, output the class, confidence and target bounding box position coordinates of the disease target, and realize automatic recognition and accurate positioning of tomato leaf diseases.

2. The method for tomato leaf disease detection based on dynamic context awareness and multi-scale feature fusion according to claim 1, characterized in that: Step (1) The multi-form tomato leaf disease dataset DMTLD covers 6 different tomato leaf diseases, including tomato bacterial spot disease, tomato blight, tomato leaf mildew, tomato leaf miner disease, tomato yellowing leaf curl virus disease and tomato two-spotted spider mite disease, with a total sample number of not less than 2300; The dataset covers spot-shaped, block-shaped, yellowing-shaped, mold layer-shaped, insect damage line-shaped and mite damage point-shaped disease forms, which is conducive to improving the learning ability of the model to complex disease manifestations.

3. The method for tomato leaf disease detection based on dynamic context awareness and multi-scale feature fusion according to claim 1, characterized in that: The specific processing procedure of the dynamic context perception C2f module in step (3) is as follows: first, suppose that the features input into the internal dynamic context perception structure of the DCA_C2f are , three types of feature responses are obtained through the local texture branch, the inflation context branch and the direction strip branch respectively, and the respective output features , and are obtained; second, in order to enable the model to adaptively adjust the contribution proportion of the three branches according to different disease morphologies, the dynamic branch weight is generated by using the global context information of the input features, and the expression is as follows: , wherein, denotes a global average pooling operation, and denotes two 1x1 convolution operations, denotes a nonlinear activation function, denotes a normalization function, , and denote dynamic weights corresponding to the local texture branch, the dilated context branch and the direction strip branch, respectively; then, based on the above dynamic weights, the three types of branch features are weighted and fused, and the expression is: , wherein, denotes the dynamically fused context-aware feature, denotes element-wise multiplication; finally, the fused feature is integrated by 1x1 convolution, and enhanced by light coordinate attention in spatial position, and finally concatenated with the original input feature is connected by residual, and the output feature of the dynamic context-aware structure is obtained: , wherein, denotes a 1x1 convolution operation for channel integration, denotes a lightweight coordinate attention enhancement operation.

4. The method for tomato leaf disease detection based on dynamic context awareness and multi-scale feature fusion according to claim 1, characterized in that: The specific processing procedure of the double-branch adaptive gating high-efficiency multi-scale attention module in step (3) is as follows: first, define the original feature input to the module as In order to reduce the attention calculation complexity and enhance the feature modeling capability in the local region, the input feature is first divided into several groups according to the channel dimension, and high-efficiency multi-scale attention modeling is performed in each group. The input feature After the high-efficiency multi-scale attention enhancement branch, the enhanced feature is obtained: , wherein, denotes a high-efficiency multi-scale attention enhancement operation; subsequently, the original feature is spliced with the enhanced feature and adaptive gating weights are generated through 1x1 convolution and activation function, and the expression is: , wherein, denotes a gating generation convolution, denotes a channel concatenation operation, denotes a Sigmoid activation function; based on the gating weight, the original features and the enhanced features are dynamically fused, and the process is not to directly replace the original features with the enhanced features, but to control the fusion ratio between the two by using the gating weight, and the expression is: , wherein, denotes the gated fused feature, denotes element-wise multiplication; finally, a dual-branch output fusion structure is constructed to fuse the original feature and the gated fused feature is spliced in the channel dimension, so that the output retains the original detection feature and the attention enhanced feature at the same time, and then the spliced feature is integrated in the channel through output convolution to obtain the final output feature , and its expression is: , wherein, denotes a 1 x 1 convolution that integrates the output channels.

5. The method for tomato leaf disease detection based on dynamic context awareness and multi-scale feature fusion according to claim 1, characterized in that: The specific processing procedure of the dynamic adaptive offset adjustment up-sampling unit in step (3) is as follows: first, let the input feature of the up-sampling unit be First, a dynamic offset adjustment factor is generated according to the input feature: , wherein, denotes a dynamic offset adjustment factor for controlling the adjustment amplitude of the sampling offset, denotes a 1x1 convolution operation for generating the dynamic offset adjustment factor, denotes a global average pooling operation, denotes a smooth nonlinear function for ensuring the dynamic offset adjustment factor is positive; further, a dynamic sampling offset is generated according to the input feature, and the calculation process thereof is represented as: , wherein, denotes a dynamic sampling offset, denotes an offset generating convolution for predicting an offset for a sampling position, denotes an offset range modulating convolution for constraining the range of action of the sampling offset, denotes a Sigmoid activation function, denotes an initial sampling position offset; denotes an element-wise multiplication; Finally, grid sampling is performed on the input features according to the dynamic sampling offset to obtain up-sampling output features The expression is: , wherein, represents a bilinear sampling operation based on the sampling grid; represents the original sampling grid position.

6. The method for tomato leaf disease detection based on dynamic context awareness and multi-scale feature fusion according to claim 1, characterized in that: Step (4) The SIoU loss function formula is: , wherein, denotes a distance cost, denotes a shape cost; the overall training loss is denoted as: , wherein, denotes a classification loss, denotes a distribution focal loss, , and denote weight coefficients of the bounding box loss, the classification loss, and the distribution focal loss, respectively.