Corn disease detection method based on improved RT-DETR network

By improving the RT-DETR network, introducing the Shift-wise Convolution module and the HiLo Attention mechanism, and combining spatial multi-scale feature fusion, a lightweight maize disease detection model was constructed, which solved the problems of high model complexity and insufficient detection accuracy, and achieved efficient disease detection in resource-constrained environments.

CN120807424APending Publication Date: 2025-10-17CHANGCHUN UNIV OF SCI & TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510877642.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-27
Publication Date
2025-10-17

AI Technical Summary

Technical Problem

Existing technologies for corn disease detection suffer from problems such as high model complexity, high dependence on computational resources, and insufficient detection accuracy, making it difficult to achieve real-time deployment and high-precision detection, especially in resource-constrained agricultural fields.

Method used

An improved RT-DETR network was adopted, and the backbone network was optimized by introducing a Shift-wise Convolution module. Combined with the HiLo Attention efficient attention mechanism and spatial multi-scale feature fusion structure, a lightweight maize disease detection model was constructed to enhance the ability to identify diseased areas.

Benefits of technology

The model features a lightweight design, improving detection accuracy and real-time detection capabilities, particularly in identifying small-scale disease areas in complex farmland environments, making it suitable for resource-constrained agricultural equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120807424A_ABST
    Figure CN120807424A_ABST
Patent Text Reader

Abstract

The invention belongs to the field of deep learning plant disease detection, and particularly relates to a corn disease detection method based on an improved RT-DETR network. The method specifically comprises the following steps: S1, acquiring a to-be-detected corn disease data set; s2, optimizing a backbone network and a neck network of the RT-DETR network by using a Shift-wise Conversion module and a HiLo Attention efficient attention mechanism, and using a spatial multi-scale feature fusion structure as a feature extraction module of an optimized RT-DETR model; and S3, training and testing the model by using the corn disease public data set as input data of the disease detection model. In the training process, calculating an error between model output and a real label through a loss function, and carrying out iterative updating on model parameters based on the loss, so as to obtain a trained corn disease detection model; and S4, positioning and identifying the to-be-detected disease image based on the trained corn disease detection model to obtain a disease detection result of the to-be-detected corn disease image. On the basis of ensuring the detection precision, the lightweight design of the model structure is realized, and the real-time detection capability of the model in a computing resource limited environment is remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the field of deep learning plant disease detection, and particularly relates to a corn disease detection method based on an improved RT-DETR network. BACKGROUND

[0002] As one of the most important food crops in the world, corn is widely used in the food industry, feed industry and chemical manufacturing field, and plays an irreplaceable role in agricultural production. Although corn has good drought and cold tolerance, it is still susceptible to a variety of diseases during its growth cycle, especially corn rust, corn leaf spot and corn gray spot. These diseases have the characteristics of fast spread and great harm, often causing large-scale infection in a short time, and seriously affecting the yield and quality of corn. Traditional corn disease identification relies on manual experience, which is low in efficiency and high in misjudgment rate, and is difficult to meet the needs of modern agricultural production. In order to improve the recognition accuracy of corn diseases, some studies have introduced traditional machine learning methods, which realize automatic recognition by combining image features such as color and texture with classifiers. However, this method relies on manual feature extraction and has weak generalization ability, making it difficult to adapt to complex farmland environments.

[0003] In recent years, deep learning technology has been widely applied in crop disease detection and has achieved good results. Existing technologies in corn disease detection mainly include two methods: one adopts a complex deep learning model, which can achieve high recognition accuracy, but has a complex model structure, large number of parameters and high dependence on computing resources, making it difficult to meet the real-time deployment needs of edge devices in agricultural fields; the other method emphasizes the lightweight design of the model, which has advantages in computing efficiency and deployment flexibility, but often sacrifices detection accuracy at the cost of small-scale disease spots or fuzzy disease regions, limiting its practicality in complex farmland environments. SUMMARY

[0004] (I) Technical problems solved

[0005] In view of the above problems of the prior art, the present application provides a corn disease detection method based on an improved RT-DETR network, which introduces a lightweight backbone network of Shift-wise Convolution module to reduce redundant calculations, and integrates a HiLo Attention efficient attention mechanism in the neck network to enhance the recognition ability of disease regions, especially weak feature regions. In addition, a self-defined spatial multi-scale feature fusion structure is constructed as a feature extraction module of the optimized RT-DETR model to effectively suppress background interference and extract multi-scale disease features. Thus, while ensuring detection accuracy, the model is designed to be lightweight, improving the real-time detection capability of the model on resource-constrained devices.

[0006] (II) Technical Solution

[0007] The present application specifically adopts the following technical solutions to achieve the above-mentioned purposes:

[0008] A corn disease detection method based on an improved RT-DETR network, comprising the following steps:

[0009] S1: Obtain a corn leaf disease image to be detected.

[0010] S2: Optimize the backbone network and neck network of the RT-DETR network using the Shift-wise Convolution module and the HiLo Attention efficient attention mechanism, and use a spatial multi-scale feature fusion structure as the feature extraction module of the optimized RT-DETR model to construct a corn disease detection model.

[0011] S3: Use a corn disease public dataset as input data for the disease detection model to train and test the model; during the training process, calculate the error between the model output and the true label using a loss function, and iteratively update the model parameters based on the loss to obtain a trained corn disease detection model.

[0012] S4: Based on the trained corn disease detection model, locate and identify the leaf disease image to be detected to obtain the disease detection result of the corn disease image to be detected.

[0013] As a preferred solution, before training the corn disease detection model using the corn disease public dataset as input, the following steps are included: manually labeling the four types of disease images in the public dataset, including corn leaf spot disease, corn leaf blight, corn rust, and corn gray spot disease; performing size adjustment, normalization processing, and data enhancement operations on the labeled corn disease image data; and dividing the processed dataset into a training set, a validation set, and a test set according to a predetermined ratio for subsequent model training and performance evaluation.

[0014] As a preferred solution, the corn disease detection model includes a backbone network, a neck network, and a spatial multi-scale feature fusion module:

[0015] The backbone network uses ResNet-18 as the baseline structure and includes three Conv modules, a MaxPool2d module, and four Basic_Block modules connected in sequence. The convolution operation in the original Basic_Block is replaced with Shift-wise Convolution to form a SwConv_Block module, which is used to reduce computational redundancy and enhance the feature extraction capability for small-scale disease areas.

[0016] The neck network is an all-in-dimension feature interaction module (AIFI), which adopts an efficient attention mechanism (HiLo Attention) to replace a multi-head self-attention structure to realize separation modeling of high-frequency and low-frequency features, wherein the high-frequency path adopts high-resolution attention to capture small target detail features, and the low-frequency path enhances global semantic expression through window pooling, thereby improving the modeling capability of fine-grained features of corn diseases;

[0017] The spatial multi-scale feature fusion module is composed of a high-level screening feature fusion pyramid network (HS-FPN) and a position-sensitive feature enhancement module (RMT), the HS-FPN fuses multi-scale features by combining global pooling and channel attention mechanisms, and the RMT adopts a spatial attenuation matrix based on Manhattan distance and its attention decomposition form to encode the position of the fused features to enhance the spatial modeling capability;

[0018] The multi-scale features extracted by the backbone network are first subjected to efficient attention modeling by the feature interaction module, and then input to the spatial multi-scale feature fusion module for fusion enhancement, and the output fused features are used for the detection head network to complete accurate positioning and identification of disease areas.

[0019] As a preferred solution, the processing process of the SwConv_Block module includes:

[0020] The input feature map is shifted (Shift) according to a preset direction, the original feature map is moved by a fixed step at a pixel level in a horizontal direction or a vertical direction to obtain a plurality of shifted feature maps, then group convolution operations composed of a plurality of small-size convolution kernels are applied to the shifted feature maps respectively to extract features of local regions, a pruning strategy is used to sparsify the group convolution structure, only the convolution channels that significantly contribute to the output are retained to reduce invalid calculations, the outputs of the plurality of shifted convolution paths are aggregated, the information of each direction is integrated by splicing or weighted fusion to enhance the modeling capability of long-range dependencies and small targets, and finally, a normalization layer and an activation function layer are connected after the feature aggregation to normalize and nonlinearly activate the output features to form the final output feature map of the SwConv_Block module, which is input to subsequent layers of the backbone network.

[0021] The output of the SwConv_Block module is shown in the following formula:

[0022]

[0023] Δp=g(kh,k),(k∈[0,f(kw,kh,A)]);

[0024] where ∏ represents all predetermined non-overlapping small convolutions. A represents the size of the small convolution kernel. kw and kh represent the attention width and attention height, respectively. f(kw, kh, A) represents a function related to (kw, kh, A). Δp represents the weight and feature offset.

[0025] As a preferred solution, the neck network processing procedure based on the HiLo Attention efficient attention mechanism comprises:

[0026] The multi-scale feature maps from the backbone network output are grouped, and part of the attention heads are allocated to the high-frequency path (Hi-Fi), which extracts high-frequency detail features in the image by dividing local windows and calculating the attention relationship between Tokens within the window, especially for small target disease area information; the remaining attention heads are allocated to the low-frequency path (Lo-Fi), which obtains a low-frequency representation by performing an average pooling operation on the local window, and globally models each query position and the pooled key to capture large-scale context information; linear projection, attention weight calculation and feature weighting fusion are performed on the high-frequency path and the low-frequency path respectively, and the output results of the two are spliced along the channel dimension to form a complete attention enhanced feature map; finally, the spliced attention features are input into the subsequent Transformer encoding layer for intra-scale feature interaction and fusion to improve the model's representation ability for complex morphological and weak feature regions of corn diseases.

[0027] The output of the neck network based on the HiLo Attention efficient attention mechanism is shown in the following formula:

[0028]

[0029] HiLo(X)=[Hi-Fi(X);Lo-Fi(X)];

[0030] where N represents the number of Tokens in the HiLo attention layer, D represents the number of hidden dimensions, and s represents the window size.

[0031] As a preferred solution, the spatial multi-scale feature fusion module processing procedure comprises:

[0032] Multi-scale feature maps are extracted from the backbone network, and global average pooling and global maximum pooling operations are respectively performed on each level of feature map, the two pooling results are fused to obtain the channel level semantic response; then 1x1 convolution is used to compress the channel of the fused feature map to unify the dimension, combined with the Sigmoid activation function to generate the channel attention weight, and weighted with the original feature map by channel, used to enhance the key channel response; the high-level feature map is up-sampled by bilinear interpolation to make its size consistent with the low-level feature map, so as to perform scale alignment and fusion; the high-level feature map and the low-level feature map after attention weighting are weighted and fused to strengthen the information related to the disease area in the low-level detail feature; the fused feature map is input into the position perception module RMT, and RMT constructs a spatial decay matrix based on Manhattan distance to model the dependency relationship between different spatial positions in the feature map, and improve the perception ability of the spatial distribution of the disease area; the attention mechanism is decomposed in the horizontal and vertical directions, and the attention weight is calculated and fused into the feature map, so as to realize low-complexity spatial modeling, and finally output the fused and enhanced feature map for subsequent disease detection.

[0033] (III) Technical effects

[0034] Compared with the prior art, the present application provides a corn disease detection method based on an RT-DETR network, which has the following technical effects:

[0035] The present application replaces the standard ResNet structure in the original RT-DETR network with the SwConv-ResNet backbone network, realizing the lightweight and high efficiency of the model. The SwConv module introduces a shift convolution strategy in the residual structure, effectively reducing the model parameter quantity and calculation overhead through sparse connection and structure optimization, while retaining the key feature extraction capability. Compared with the traditional residual block, this structure reduces the model complexity while improving the detection performance, significantly improving the deployment feasibility of the model in agricultural edge devices, especially for real-time corn disease detection in resource-constrained environments.

[0036] The present application introduces an efficient attention mechanism in the neck network to enhance the extraction ability of small targets and weak feature regions. The attention mechanism separates and fuses high and low frequency features, guiding the network to focus on the fine-grained differences of the disease spot area, effectively alleviating the problem of unclear feature expression caused by small disease spot size, fuzzy edge or similar color texture, thereby improving the recognition accuracy of the model for small disease targets and similar disease categories.

[0037] The application provides a spatial multi-scale feature fusion module for replacing a traditional single-scale feature fusion mode. The module enhances the positioning perception ability of the disease area in the multi-scale space by fusing shallow detail features and deep semantic information, thereby improving the robustness and detection accuracy of the model in a complex background. The module has good adaptability and stability in an agricultural scene with serious background noise interference and uneven distribution of disease spots. BRIEF DESCRIPTION OF DRAWINGS

[0038] Figure 1 A corn disease detection method flowchart based on an improved RT-DETR network is disclosed.

[0039] Figure 2 A corn disease detection model network overall structure diagram is disclosed.

[0040] Figure 3 A comparison diagram of the effects of the original network and the improved network is disclosed. DETAILED DESCRIPTION

[0041] The technical solutions in the embodiments of the application will be described clearly and completely below with reference to the drawings in the embodiments of the application. Obviously, the described embodiments are only part of the embodiments of the application, rather than all the embodiments of the application. Based on the embodiments in the application, all other embodiments obtained by those skilled in the art without creative work fall within the protection scope of the application.

[0042] EMBODIMENT

[0043] Figure 1 A corn disease detection method based on an improved RT-DETR network is disclosed, aiming at the problem that the existing target detection model is difficult to realize high-precision disease detection in a resource-limited environment, comprising the following steps:

[0044] S1: acquiring a corn disease image to be detected.

[0045] S2: using a Shift-wise Convolution module and a HiLo Attention high-efficiency attention mechanism to optimize the backbone network and the neck network of the RT-DETR network, so as to reduce redundant calculation and enhance the recognition ability of the corn disease area, especially the weak feature area, and using a spatial multi-scale feature fusion structure as a feature extraction module of the optimized RT-DETR model, for effectively suppressing background interference and extracting multi-scale disease features, and constructing a corn disease detection model.

[0046] S3: Use the corn disease public dataset as the input data of the disease detection model, train and test the model; in the training process, the error between the model output and the true label is calculated through the loss function, and the model parameters are iteratively updated based on the loss, so as to obtain the trained corn disease detection model.

[0047] S4: Based on the trained corn disease detection model, the plant disease image to be detected is positioned and recognized, and the disease detection result of the corn disease image to be detected is obtained.

[0048] In recent years, deep learning technology has been widely used in crop disease detection field and good results have been achieved. The existing technology in corn disease detection is mainly divided into two methods: one kind adopts complex deep learning model, although it can realize higher recognition accuracy, but the model structure is complex, the parameter quantity is large, and the dependence degree of calculation resource is high, which is difficult to meet the real-time deployment demand of edge device in agricultural field; the other method emphasizes the lightweight design of the model, although it has advantages in calculation efficiency and deployment flexibility, but often at the cost of detection accuracy, it is difficult to effectively identify small scale disease spot or boundary fuzzy disease area, which limits its practicability in complex farmland environment.

[0049] In order to solve the above problems, the present application proposes a corn disease detection method based on improved RT-DETR network. The method uses the Shift-wise Convolution module and HiLo Attention efficient attention mechanism to optimize the backbone network and neck network of RT-DETR network, and uses the spatial multi-scale feature fusion structure as the feature extraction module of the optimized RT-DETR model, so as to obtain the corn disease detection model.

[0050] The corn disease detection method based on improved RT-DETR network is described in more detail as follows:

[0051] 1. Constructing corn disease dataset

[0052] The corn disease image sample dataset selected and analyzed by the present application mainly comes from the open source platform PlantVillage, and covers four common corn disease types: corn leaf spot, corn leaf blight, corn rust and corn gray spot, a total of 2000 images. For different disease types, the open source labeling tool LabelImg is used for manual labeling, wherein the corn leaf spot is labeled as "0", the corn leaf blight is labeled as "1", the corn rust is labeled as "2", and the corn gray spot is labeled as "3". During the labeling process, the disease area in each image is accurately framed, and a labeling file containing disease category and corresponding bounding box coordinate information is generated. After completing the labeling, the image data is uniformly preprocessed, including size adjustment, normalization and various forms of data enhancement operations, such as random cropping, blurring, brightness adjustment, noise addition and image flipping, etc., and finally expanded to 5600 image samples. Then the complete dataset is randomly divided into training set, validation set and test set according to the ratio of 8:1:1, containing 4480, 560 and 560 images respectively, to ensure that the data division has good contrast and reproducibility, facilitating standardized comparison with existing research, so as to build a corn disease detection dataset suitable for model training and performance evaluation.

[0053] 2. Corn disease detection model

[0054] As shown in Figure 2 , in the present example, the corn disease detection model includes a backbone network, a neck network and a spatial multi-scale feature fusion network;

[0055] The backbone network takes ResNet-18 as the baseline structure, including 3 Conv modules, MaxPool2d modules and 4 Basic_Block modules connected in turn. Replace the convolution operation in the original Basic_Block with Shift-wiseConvolution to form SwConv_Block module, which is used to reduce computational redundancy and enhance the feature extraction capability for small-scale disease areas;

[0056] The neck network is an intra-scale feature interaction module AIFI, which uses an efficient attention mechanism HiLo Attention to replace the multi-head self-attention structure to realize the separation modeling of high-frequency and low-frequency features. The high-frequency path uses high-resolution attention to capture small target detail features, and the low-frequency path enhances global semantic expression through window pooling, thereby improving the modeling capability of fine-grained features of corn diseases;

[0057] The spatial multi-scale feature fusion module consists of a high-level screening feature fusion pyramid network (HS-FPN) and a position-sensitive feature enhancement module (RMT). HS-FPN fuses multi-scale features by combining global pooling with a channel attention mechanism. RMT uses a spatial attenuation matrix based on Manhattan distance and its attention decomposition form to positionally encode the fused features to enhance spatial modeling capabilities.

[0058] The multi-scale features extracted by the backbone network are first subjected to efficient attention modeling via the feature interaction module, and then input into the spatial multi-scale feature fusion module for fusion enhancement. The output fusion features are used by the detection head network to accurately locate and identify the diseased area.

[0059] This example uses RT-DETR as the base model. The backbone integrates the SwConv_Block module to optimize ResNet-18. Shift-wise convolution is combined with residual blocks to reduce computational overhead and achieve efficient feature extraction. The neck network consists of an AIFI-HiLo module. By introducing HiLo Attention, the AIFI-HiLo module aims to extract and preserve high- and low-frequency information in the image through an efficient attention mechanism, thereby improving the recognition of weak feature areas. The spatial multi-scale feature fusion module then integrates disease features at multiple levels and scales, cross-fusing the output features of the backbone network with the features encoded by the AIFI-HiLo module. This significantly enhances the network's feature extraction capabilities, thereby improving the detection of small maize disease targets. Finally, the decoder with an auxiliary prediction head generates bounding boxes and confidence scores, resulting in the final detection results.

[0060] The following is a detailed introduction to the Shift-wise Convolution module, the HiLo Attention module, and the spatial multi-scale feature fusion module:

[0061] 2.1, Shift-wise Convolution shift convolution module

[0062] The backbone network of the RT-DETR model in this example uses the ResNet-18 baseline architecture, consisting of three Conv modules, a MaxPool2d module, and four Basic_Block modules connected in sequence. The convolution operations in the original Basic_Block are replaced with shift-wise convolution to form the SwConv_Block module, which reduces computational redundancy and enhances feature extraction for small-scale diseased areas.

[0063] Shifted convolution first determines the focus range of information in the local region by specifying a rectangular region with a specific focus length and focus width. Within this region, convolution kernels with a size smaller than or equal to the focus width are selected and appropriately distributed to achieve effective fusion of information. This process enables the convolutional neural network to better capture long-range dependencies and complex spatial features while retaining hardware-friendly computational efficiency. The formula can be expressed as:

[0064]

[0065] Δp=g(kh,k),(k∈[0,f(kw,kh,A)]);

[0066] where ∏ represents all predetermined non-overlapping small convolutions. A represents the size of the small convolution kernel. kw and kh represent the focus width and focus height, respectively. f(kw,kh,A) represents a function related to (kw,kh,A). Δp represents the weight and feature offset.

[0067] Traditional convolution operations usually require a large amount of computation and parameters, while shifted convolution uses pruning techniques to sparsify the convolution kernel, retaining only the parts that contribute most to the output, thereby reducing the computational complexity and storage requirements of the model. By integrating shifted convolution into the backbone network, this example can significantly reduce the overall computational and memory requirements, simplify the backbone network structure, and improve the model inference efficiency. This integration not only speeds up the feature extraction process, but also significantly reduces resource consumption, making the model more efficient during inference.

[0068] 2.2、HiLo Attention high-efficiency attention module

[0069] In the disease detection task, corn diseases usually appear as scattered leaf spots and complex spots of various shapes. Due to the small size and sparse distribution of the target, it is easy to be ignored by the large-scale feature extraction module. In this example, the HiLo Attention efficient attention module is introduced in the neck network part, which can more effectively capture information of different scales, which is crucial to improve the performance of small target detection. HiLo Attention groups the multi-scale feature maps output from the backbone network, and allocates part of the attention heads (Head) to the high-frequency path (Hi-Fi). By dividing the local window and calculating the attention relationship between the Tokens within the window, it is used to extract high-frequency detail features in the image, especially the information of small target disease area. The remaining attention heads are allocated to the low-frequency path (Lo-Fi), which obtains the low-frequency representation by performing average pooling operation on the local window, and globally models each query position and the pooled key to capture large-scale context information. Linear projection, attention weight calculation and feature weighting fusion are performed on the high-frequency path and the low-frequency path respectively, and the output results of the two are spliced along the channel dimension to form a complete attention enhanced feature map. Finally, the spliced attention features are input into the subsequent Transformer encoding layer for intra-scale feature interaction and fusion, to improve the model's representation ability for complex morphology and weak feature regions of corn diseases.

[0070] The output of the neck network based on the HiLo Attention efficient attention mechanism is shown in the following formula:

[0071]

[0072] HiLo(X)=[Hi-Fi(X);Lo-Fi(X)];

[0073] Where N represents the number of Tokens in the HiLo attention layer, D represents the number of hidden dimensions, and s represents the window size.

[0074] Using efficient attention instead of traditional multi-head self-attention can better handle long-distance dependencies and capture context information in the image, thereby improving the understanding of weak feature regions. Therefore, the AIFI module combined with efficient attention performs better when processing targets of different sizes. This improved method can achieve accurate disease positioning across sizes in corn leaf disease detection, thereby significantly improving detection accuracy and enhancing the generalization ability to new data and new tasks.

[0075] 2.3, spatial multi-scale feature fusion module

[0076] In a complex farmland environment, corn diseases are easily disturbed by other cluttered backgrounds such as vegetation, light and obstructions, resulting in unobtrusive target features, making it difficult to extract effective features. The traditional feature pyramid network uses a series of downsampling and upsampling operations to predict diseases at different scales. This prediction method has limited effect on improving accuracy and also increases the complexity of the model. In order to reduce background noise interference, the feature pyramid model and feature fusion mechanism are optimized and adjusted, and a spatial multi-scale feature fusion network is innovatively proposed.

[0077] The spatial multi-scale feature fusion module extracts multi-scale feature maps from the backbone network, and performs global average pooling and global maximum pooling operations on each level of feature map respectively. The two pooling results are fused to obtain the channel-level semantic response. Then, 1x1 convolution is used to compress the fused feature map to unify the dimension, combined with the Sigmoid activation function to generate channel attention weights, and weighted with the original feature map channel by channel to enhance the key channel response. The high-level feature map is upsampled using the bilinear interpolation method to make its size consistent with the low-level feature map, so as to perform scale alignment and fusion; the high-level feature map after attention weighting is weighted and fused with the low-level feature map to strengthen the information related to the disease area in the low-level detail feature; the fused feature map is input into the position perception module RMT, and RMT constructs a spatial decay matrix based on Manhattan distance to model the dependency relationship between different spatial positions in the feature map, improving the perception ability of the spatial distribution of the disease area; the attention mechanism is decomposed in the horizontal and vertical directions, and the attention weights are calculated and fused into the feature map, so as to realize low-complexity spatial modeling, and finally output the fused and enhanced feature map for subsequent disease detection.

[0078] 3. Training of the corn disease detection model

[0079] In the model training process, a series of key parameters are set, such as input image size, prior box size, target class number, initial learning rate and its adjustment strategy, etc. The corn leaf disease image data after labeling and preprocessing is input into the improved disease detection model for training. In the training stage, the model performance is continuously evaluated using the validation set, and the loss function is used to optimize the boundary box regression error. The model parameters are dynamically updated by minimizing the loss function, thereby improving the detection accuracy.

[0080] In the specific application of the present example, first, the ArgumentParser library is used to define and parse various input parameters required by the model. Then, the torch library is called to load the pre-trained improved RT-DETR model and perform initialization operations. After that, standardization processing steps are performed on the input image, including size scaling, normalization, etc. The image data is converted to Tensor format that meets the input requirements of the neural network. After the model receives the processed image Tensor, it performs forward inference to obtain the disease detection result. Finally, the post-processing module is used to analyze the model output, including boundary box coordinate restoration and confidence threshold filtering, etc. Finally, the detected disease area is displayed in a visual form on the image, and the detection result is saved for subsequent analysis and verification.

[0081] 4. Model deployment and verification

[0082] In this embodiment, the trained improved model is deployed to a mobile device, the optimal weight file saved during the training process is loaded, and the test set images in the corn disease image dataset are input into the model for inference. The model generates the boundary box coordinates, class labels, and corresponding confidence scores of each disease target through feature extraction and multi-scale fusion in the detection layer (Detect Head). Then, the non-maximum suppression (NMS) algorithm is used to eliminate duplicate and redundant candidate boxes, and the most representative detection results are retained. Finally, the detection results are visualized in the form of images and can be saved locally for subsequent viewing. In addition, the processed corn disease test images are input into the deployed improved RT-DETR model, and the model will output the specific position (boundary box coordinates), class label, and confidence score of each detected disease target. The detection results can be displayed in real time through the mobile terminal, making it easy for users to intuitively understand the disease distribution and achieve intelligent monitoring and auxiliary decision-making of diseases.

[0083] In terms of model performance evaluation, the detection effect is quantitatively analyzed through key indicators such as mean average precision (mAP), recall rate (Recall), and frame rate (FPS). The experimental results show that the improved RT-DETR model has excellent performance in the corn disease detection task, especially in the recognition of small disease spots, and has good practicality and deployment value. The terminal output detection result is shown in Figure 3 , users can realize real-time monitoring and image management of corn diseases through the device interface.

[0084] 5. Review

[0085] The present example invents a corn disease detection method based on an improved RT-DETR network, which improves and optimizes different task levels for corn disease detection. First, SwConv-ResNet integrates the SwConv block into the backbone network, reducing the model parameters. In addition, the efficient attention mechanism promotes the interaction between high and low layer features, enabling the model to sensitively capture subtle differences between small targets and backgrounds. The proposed spatial multi-scale feature fusion module optimizes the use of effective features within the detection network, solving the problem of complex background interference. This method has the characteristics of lightweight design, high detection accuracy, and is easy to deploy on intelligent cameras or agricultural unmanned aerial vehicle devices.

[0086] Finally, it should be pointed out that the above examples are only used to illustrate the technical solutions of the present application and are not limiting. Although the present application has been described by referring to the preferred embodiments of the present application, it should be understood by those skilled in the art that various changes can be made in form and detail without departing from the spirit and scope of the present application as defined by the appended claims.

Claims

1. A corn disease detection method based on an improved RT-DETR network, characterized in that: The steps include: S1: Obtain the corn disease image to be detected; S2: Use the Shift-wise Convolution module and HiLo Attention efficient attention mechanism to optimize the backbone network and neck network of the RT-DETR network, and use the spatial multi-scale feature fusion structure as the feature extraction module of the optimized RT-DETR model to build a corn disease detection model; S3: Using a public corn disease dataset as input data for a disease detection model to train and test the model; During the training process, the error between the model output and the true annotation is calculated through the loss function, and the model parameters are iteratively updated based on the loss to obtain the trained corn disease detection model; S4: Positioning and identifying the plant disease image to be detected based on the trained corn disease detection model to obtain a disease detection result of the corn disease image to be detected.

2. The corn disease detection method based on the improved RT-DETR network according to claim 1, characterized in that: Before using the corn disease public dataset as input for training the disease detection model, the following steps are included: The four types of disease images contained in the public dataset, namely corn leaf spot, corn leaf blight, corn rust and corn gray spot, were manually annotated; the annotated corn disease image data were resized, normalized and data augmented; and the processed dataset was divided into training set, validation set and test set according to a preset ratio for subsequent model training and performance evaluation.

3. The corn disease detection method based on the improved RT-DETR network according to claim 1, characterized in that, The corn disease detection model includes a backbone network, a neck network and a spatial multi-scale feature fusion module; The backbone network uses ResNet-18 as the baseline structure, including three Conv modules, a MaxPool2d module, and four Basic_Block modules connected in sequence. The convolution operation in the original Basic_Block is replaced with Shift-wiseConvolution to form the SwConv_Block module, which is used to reduce computational redundancy and enhance the feature extraction capability of small-scale disease areas. The neck network is an intra-scale feature interaction module AIFI, which uses the efficient attention mechanism HiLo Attention to replace the multi-head self-attention structure to achieve separate modeling of high- and low-frequency features. The high-frequency path uses high-resolution attention to capture small target details, while the low-frequency path enhances global semantic expression through window pooling, thereby improving the modeling ability of fine-grained features of corn diseases. The spatial multi-scale feature fusion module consists of a high-level screening feature fusion pyramid network (HS-FPN) and a position-sensitive feature enhancement module (RMT). HS-FPN fuses multi-scale features by combining global pooling with a channel attention mechanism. RMT uses a Manhattan distance-based spatial attenuation matrix and its attention decomposition form to positionally encode the fused features to enhance spatial modeling capabilities. The multi-scale features extracted by the backbone network are first subjected to efficient attention modeling via the feature interaction module, and then input into the spatial multi-scale feature fusion module for fusion enhancement. The output fusion features are used by the detection head network to accurately locate and identify the diseased area.

4. The corn disease detection method based on the improved RT-DETR network according to claim 3, characterized in that: The processing of the SwConv_Block module includes: The input feature map is shifted in a preset direction, and the original feature map is moved pixel-wise in the horizontal or vertical direction with a fixed step size to obtain multiple shifted feature maps; then, a group convolution operation consisting of multiple small-sized convolution kernels is applied to the shifted feature maps to extract features from local areas; the group convolution structure is sparsely processed using a pruning strategy, and only the convolution channels that contribute significantly to the output are retained to reduce invalid calculations; the outputs of multiple shifted convolution paths are feature aggregated, and information in various directions is integrated through splicing or weighted fusion to enhance the modeling ability of long-range dependencies and small targets; finally, after feature aggregation, the normalization layer and activation function layer are connected to normalize and nonlinearly activate the output features to form the final output feature map of the SwConv_Block module, which is input to the subsequent layers of the backbone network. The output of the SwConv_Block module is shown in the following formula: Δp=g(kh,k),(k∈[0,f(kw,kh,A)]); Where Π represents all predefined non-overlapping small convolutions. A represents the size of the small convolution kernel. kw and kh represent the attention width and attention height, respectively. f(kw,kh,A) represents the function related to (kw,kh,A). Δp represents the weight and feature offset.

5. The corn disease detection method based on the improved RT-DETR network according to claim 3, characterized in that: The neck network processing process based on the HiLo Attention efficient attention mechanism includes: The multi-scale feature maps output from the backbone network are grouped, and some attention heads are assigned to the high-frequency path (Hi-Fi). By dividing the local window and calculating the attention relationship between tokens within the window, they are used to extract high-frequency detail features in the image, especially information on small target disease areas; the remaining attention heads are assigned to the low-frequency path (Lo-Fi), and low-frequency representations are obtained by performing average pooling operations on the local window. Global modeling is performed on each query position and the pooled key to capture a wide range of contextual information; linear projection, attention weight calculation and feature weighted fusion are performed on the high-frequency path and the low-frequency path respectively, and the output results of the two are spliced ​​along the channel dimension to form a complete attention-enhanced feature map; finally, the spliced ​​attention features are input into the subsequent Transformer encoding layer for interaction and fusion of intra-scale features to improve the model's representation ability of complex morphologies and weak feature areas of corn diseases; The output of the neck network based on the HiLo Attention efficient attention mechanism is shown in the following formula: HiLo(X)=[Hi-Fi(X); Lo-Fi(X)]; Where N represents the number of tokens in the HiLo attention layer, D represents the number of hidden dimensions, and s represents the window size.

6. The corn disease detection method based on the improved RT-DETR network according to claim 3, characterized in that: The spatial multi-scale feature fusion module processing process includes: Multi-scale feature maps are extracted from the backbone network. Global average pooling and global maximum pooling operations are performed on each level of the feature map, and the two pooling results are fused to obtain channel-level semantic responses. 1×1 convolution is then used to compress the fused feature maps to unify their dimensions. Channel attention weights are generated by combining them with the sigmoid activation function and weighted with the original feature maps channel by channel to enhance the key channel responses. High-level feature maps are upsampled using bilinear interpolation to keep their size consistent with that of low-level feature maps for scale alignment and fusion. The attention-weighted high-level feature maps are weightedly fused with low-level feature maps to enhance the information related to the diseased area in the low-level detailed features. The fused feature maps are input into the position-aware module (RMT). The RMT constructs a spatial attenuation matrix based on the Manhattan distance to model the dependencies between different spatial positions in the feature map, improving the perception of the spatial distribution of the diseased area. The attention mechanism is decomposed horizontally and vertically, and the attention weights are calculated and fused into the feature map to achieve low-complexity spatial modeling. Finally, the fused and enhanced feature maps are output for subsequent disease detection.

Citation Information

Cited By

  • Crop disease detection model construction method based on high-resolution prior

    CN121616607A