A wolfberry pest detection method and system based on a GQ-DETR model

CN123015556APending Publication Date: 2026-10-30CHANGSHU INSTITUTE OF TECHNOLOGY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611508829.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-28
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0005]本申请实施例通过提供一种基于GQ-DETR模型的枸杞害虫检测方法及系统,解决了现有技术中枸杞害虫检测方法在复杂田间背景下存在浅层细节丢失、尺度内交互不足和跨尺度背景噪声传播,导致误检、漏检和定位不稳定的技术问题,可提高检测的准确性和稳定性

Benefits of technology

1、本申请通过尺度内交互模块将自适应池化、多尺度池化、局部增强和低分辨率Token注意力计算结合起来,在控制计算量的前提下增强深层语义特征的上下文表达;本申请通过双向交叉门控融合模块对相邻尺度特征进行选择性融合,减少低层背景噪声向高层语义特征传播;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123015556A_ABST
    Figure CN123015556A_ABST
Patent Text Reader

Abstract

The application discloses a GQ-DETR model-based Chinese wolfberry pest detection method and system, acquires a Chinese wolfberry field image and pre-processes the image; inputs the image into a GQ-DETR model, performs shallow feature extraction, two-stage learnable down-sampling and channel self-adaptive adjustment through a fine-grained fidelity front-end module, and retains pest boundary and insect body contour information; performs multi-scale local enhancement and intra-scale attention interaction in a low-resolution Token space through a scale intra-interaction module, and enhances context features; performs spatial alignment, bidirectional cross-gate fusion, coordinate constraint fusion and residual compensation on adjacent scale features through a bidirectional cross-gate fusion module, and suppresses background noise; and a detection decoding module outputs pest categories and target frame positions. The application can reduce false detection, missed detection and unstable positioning in a complex field background, improve detection accuracy and stability, and is suitable for Chinese wolfberry field monitoring and plant protection inspection scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of smart agriculture and computer vision technology, and in particular to a method and system for detecting pests in wolfberry plants based on the GQ-DETR model. Background Technology

[0002] Detection of pests in wolfberry plants is a key technology in smart agriculture pest control. Its core task is to locate and classify pests from images collected in the field, providing decision support for precise pesticide application and pest monitoring. Currently, the mainstream technologies in target detection mainly include detection models based on convolutional neural networks (CNNs) and those based on attention mechanisms. CNN models typically employ an architecture combining multi-level feature extraction and multi-scale feature fusion. They acquire feature representations from different receptive fields through a backbone network, then integrate cross-scale information via feature pyramids or path aggregation networks, finally outputting target category and location information through region proposals or direct regression. Attention mechanism models, on the other hand, model global contextual dependencies through self-attention operations, exhibiting stronger modeling capabilities when dealing with issues such as target occlusion and scale changes.

[0003] The application scenario for detecting pests in wolfberry plants is unique. In real field environments, pest targets generally exhibit large scale variations, weak texture features, and colors that are similar to the background. Simultaneously, visual interference factors such as leaf vein textures, branch and leaf edge contours, and light spot reflections caused by uneven lighting are densely distributed, easily leading to false responses from detection models. When the aforementioned detection models are directly deployed in wolfberry field scenarios, the shallow feature extraction stage typically employs rapid downsampling operations with large step sizes to reduce feature map resolution and computational cost. However, this approach may compress fine-grained information such as pest boundaries and textures, reducing the separability of foreground and background in shallow features, thus affecting the accurate localization of target boundaries by subsequent detection heads. In the deep semantic feature processing stage, intra-scale contextual interactions are usually performed on lower-resolution feature maps, where the spatial details and boundary cues of pests have already been weakened by the preceding downsampling process. If standard self-attention operations are then performed on higher-resolution feature maps, the computational cost will increase significantly. The cross-scale feature fusion stage of the neck network typically employs a simple linear weighted fusion method. This approach lacks explicit feature selection and noise suppression mechanisms, allowing background noise such as leaf vein texture and branch edges carried in low-level features to be easily transmitted to high-level semantic features for subsequent classification and regression calculations. The limitations of these stages compound in complex field scenarios, potentially leading to technical problems such as false positives, false negatives, and unstable pest target localization in the detection model.

[0004] Therefore, how to improve the accuracy and reliability of wolfberry pest detection in complex field environments has become a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0005] This application provides a method and system for detecting pests in wolfberry based on the GQ-DETR model. This solves the technical problems in existing wolfberry pest detection methods in complex field backgrounds, such as loss of shallow details, insufficient intra-scale interaction, and cross-scale background noise propagation, which lead to false detection, missed detection, and unstable localization. This method can improve the accuracy and stability of detection.

[0006] This application provides a method for detecting pests in wolfberry based on the GQ-DETR model, including the following steps: Acquire field images of wolfberries to be detected, and preprocess the wolfberry field images to obtain the model input image; The input image of the model is input into the GQ-DETR model, which is based on the RT-DETR model and includes a fine-grained fidelity front-end module, an intra-scale interaction module, a bidirectional cross-gated fusion module, and a detection and decoding module. The fine-grained high-fidelity front-end module performs shallow feature extraction and learnable downsampling on the model input image, and performs channel adaptive adjustment on the shallow features to obtain shallow features that retain the pest boundary and insect body outline information. The intra-scale interaction module is used to perform multi-scale local enhancement and intra-scale attention interaction on deep semantic features to obtain enhanced contextual features. The bidirectional cross-gated fusion module performs spatial alignment, bidirectional cross-gated fusion, coordinate constraint fusion, and residual compensation on adjacent scale features to obtain multi-scale fused features with background noise suppression. The multi-scale fused features are input into the detection and decoding module, which outputs the category information and target box location information of wolfberry pests. The fine-grained fidelity front-end module, the intra-scale interaction module, and the bidirectional cross-gated fusion module are sequentially applied to the shallow feature extraction, intra-scale context modeling, and cross-scale feature fusion stages of the GQ-DETR model, enabling the GQ-DETR model to simultaneously possess shallow detail preservation, intra-scale semantic enhancement, and cross-scale background noise suppression capabilities.

[0007] Preferably, in the fine-grained fidelity front-end module, two levels of learnable downsampling units process the input features sequentially. Each level of learnable downsampling unit includes a deep convolutional unit with a stride of two and a pointwise convolutional unit. The two levels of learnable downsampling units are connected in series to form a shallow output feature with a total stride of four.

[0008] Preferably, the fine-grained fidelity front-end module further includes a channel gating unit, which performs global average pooling on the shallow output features to obtain a channel description vector; performs channel compression mapping, nonlinear activation, channel restoration mapping and Sigmoid normalization on the channel description vector in sequence to obtain channel weights; and multiplies the channel weights with the shallow output features channel by channel to obtain the shallow features after channel adaptive adjustment.

[0009] Preferably, in the scale-interaction module, the query branch determines the pooling scale based on the aspect ratio of the input feature: when the width of the input feature is greater than its height, a pooling scale is used where the width dimension of the output is greater than the height dimension; when the height of the input feature is greater than its width, a pooling scale is used where the height dimension of the output is greater than the width dimension; when the width and height of the input feature are equal, a pooling scale is used where the height dimension and width dimension of the output are equal; the query branch pools the input feature and maps it to obtain the query feature.

[0010] Preferably, in the scale-interaction module, the key-value branch performs multi-scale pooling and local enhancement on the input features to obtain key features and value features; the attention interaction unit performs dot product attention calculation based on the query features, key features and value features in the low-resolution token space to obtain attention output; the attention output is rearranged and upsampled to restore the original spatial resolution of the input features, then residually fused with the input features, and outputs enhanced context features through a convolutional feedforward unit.

[0011] Preferably, in the bidirectional cross-gated fusion module, the spatial alignment unit is used to adjust the high-level features and low-level features in adjacent scales to the same spatial size. When upsampling, nearest neighbor interpolation is used in combination with convolution thinning, and when downsampling, convolution with a stride of two is used.

[0012] Preferably, in the bidirectional cross-gating fusion module, the spatial attention unit is used to generate a low-level spatial attention map and a high-level spatial attention map based on the low-level features and the spatially aligned high-level features, respectively; the cross-gating unit uses the high-level spatial attention map generated from the spatially aligned high-level features to perform element-wise weighted adjustment on the low-level features, and uses the low-level spatial attention map generated from the low-level features to perform element-wise weighted compensation on the spatially aligned high-level features.

[0013] Preferably, in the bidirectional cross-gated fusion module, the coordinate attention unit performs spatial aggregation on the low-level and high-level features after cross-gated fusion along the height and width directions, respectively, to generate height direction position weights and width direction position weights, and applies the height direction position weights and width direction position weights to the cross-gated features to obtain fused features with directional position constraints.

[0014] Preferably, in the bidirectional cross-gated fusion module, the residual compensation unit is used to supplement the low-level structure information into the fusion output to obtain multi-scale fusion features suppressed by background noise.

[0015] This application also proposes a wolfberry pest detection system based on the GQ-DETR model, used to perform the wolfberry pest detection method based on the GQ-DETR model described above, comprising: The image acquisition module is used to acquire field images of the goji berries to be detected. The preprocessing module is used to preprocess the wolfberry field images to obtain the model input image; the GQ-DETR detection module is used to input the model input image into the GQ-DETR model and output the category information and target box location information of wolfberry pests. The result output module is used to output the category information and the target box position information.

[0016] One or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages: 1. This application combines adaptive pooling, multi-scale pooling, local enhancement, and low-resolution token attention computation through an intra-scale interaction module to enhance the contextual representation of deep semantic features while controlling computational load; this application selectively fuses features at adjacent scales through a bidirectional cross-gating fusion module to reduce the propagation of low-level background noise to high-level semantic features. 2. This application reduces the excessive compression of small and weakly textured targets by traditional fast downsampling through a fine-grained fidelity front-end module, preserving fine-grained information such as pest boundaries, insect outlines, and low-level textures. The shallow detail features output by the fine-grained fidelity front-end module, the enhanced context features output by the intra-scale interaction module, and the noise-suppressed multi-scale fusion features output by the bidirectional cross-gated fusion module form a continuous collaboration before detection and decoding. This enables the GQ-DETR model to simultaneously obtain shallow boundary preservation, deep semantic enhancement, and cross-scale background noise suppression capabilities, thereby improving the detection stability and target box localization stability of wolfberry pests in complex field backgrounds. This invention can improve the accuracy, recall, and localization stability of wolfberry pest detection in complex field backgrounds, while also taking into account deployment adaptability in edge device or server environments. Attached Figure Description

[0017] Figure 1 This is a flowchart of the wolfberry pest detection method based on the GQ-DETR model according to an embodiment of the present invention; Figure 2 This is a diagram illustrating the architecture of a wolfberry pest detection system based on the GQ-DETR model, according to an embodiment of the present invention. Figure 3This is an overall framework diagram of the GQ-DETR model according to an embodiment of the present invention; Figure 4 This is a schematic diagram of the fine-grained fidelity front-end module FGP-Stem according to an embodiment of the present invention; Figure 5 This is a schematic diagram of the MLA-AIFI intra-scale interaction module structure according to an embodiment of the present invention; Figure 6 This is a schematic diagram of the bidirectional cross-gated fusion module BCGF structure according to an embodiment of the present invention. Detailed Implementation

[0018] To better understand the above technical solutions, the following will provide a detailed explanation of the technical solutions in conjunction with the accompanying drawings and specific implementation methods.

[0019] like Figure 1 As shown, this embodiment of the invention provides a method for detecting wolfberry pests based on the GQ-DETR model. The method acquires images of wolfberry fields through an image acquisition device, and then sequentially passes them through a preprocessing module, a fine-grained fidelity front-end module FGP-Stem, an intra-scale interaction module MLA-AIFI, a bidirectional cross-gated fusion module BCGF, and a detection and decoding module. Finally, it outputs the category information and target box location information of the wolfberry pests.

[0020] like Figure 2 As shown in the figure, an embodiment of the present invention provides a wolfberry pest detection system based on the GQ-DETR model, including an image acquisition module, a preprocessing module, a GQ-DETR detection module, and a result output module. The image acquisition module acquires field images of wolfberries to be detected. The preprocessing module preprocesses the wolfberry field images to obtain the model input image. The GQ-DETR detection module inputs the model input image into the GQ-DETR model to output the category information and target bounding box location information of the wolfberry pests. The result output module outputs the category information and target bounding box location information to the application-side storage and communication module.

[0021] Step S01: Obtain the field image of the wolfberry to be detected, and preprocess the wolfberry field image to obtain the model input image.

[0022] Images of goji berry fields can be captured using cameras deployed at goji berry plantations. These cameras can be visible light cameras or multispectral cameras, and the data collection period can cover all stages of goji berry growth, including the spring budding stage, the summer fruiting stage, and the autumn harvesting stage. The captured images include goji berry plants, leaves, fruits, and any pests that may be present, while the background will contain complex field environmental factors such as soil, weeds, other crops, and changes in light intensity.

[0023] The collected images of wolfberry fields were preprocessed. First, the images were uniformly adjusted to the size required for model input; then, the pixel values ​​of the images were normalized; finally, the processed images were converted into tensor format and input into the GQ-DETR model.

[0024] Step S02: Input the model input image into the GQ-DETR model. The GQ-DETR model is based on the RT-DETR model and includes a fine-grained fidelity front-end module, an intra-scale interaction module, a bidirectional cross-gated fusion module, and a detection and decoding module.

[0025] The overall framework of the GQ-DETR model is as follows: Figure 3 As shown, the model is an improvement based on the RT-DETR model. The left side of the model is the main feature extraction area, which includes FGP-Stem and four cascaded BasicBlocks; the middle is the hybrid coding and neck fusion area, which includes multiple modules such as MLA-AIFI, BCGF, RepC3 and Conv; the right side is the decoding area, which includes IOU-aware QuerySelection and Decoder & Head.

[0026] Step S03: The fine-grained high-fidelity front-end module performs shallow feature extraction and learnable downsampling on the model input image, and performs channel adaptive adjustment on the shallow features to obtain shallow features that retain the pest boundary and insect body outline information.

[0027] The structure of the fine-grained fidelity front-end module FGP-Stem is as follows: Figure 4 As shown, this module is used for shallow feature extraction and learnable downsampling of the model input image, and for channel adaptive adjustment of the shallow features. It includes two cascaded learnable downsampling units and channel gating units DW1 and DW2, which internally employ a dual-branch residual structure.

[0028] In the first-level learnable downsampling unit, the input features first pass through the first-level deep convolutional unit DW1, with a kernel size of 3×3 and a stride of 2. This deep convolution extracts local texture and boundary structure information while reducing spatial resolution. Then, it passes through the first-level pointwise convolutional unit PW1, with a kernel size of 1×1, used for cross-channel feature mixing and channel dimension shaping. The number of output channels can be expanded or compressed. The structure of the second-level learnable downsampling unit is similar to the first level. The input features are processed by the second-level deep convolutional unit DW2 and the second-level pointwise convolutional unit PW2. The two levels of learnable downsampling units are concatenated to form a shallow output feature with a total stride of 4. The spatial resolution of the output feature is 1 / 4 of the input image.

[0029] Let the front-end input feature be X. The two-stage downsampling process of FGP-Stem can be represented as:

[0030] Where X represents the front-end input feature, DW1 and DW2 represent deep convolutional units with a stride of 2, PW1 and PW2 represent pointwise convolutional units, and P2 represents shallow output features with a total stride of 4.

[0031] The channel gating unit (SE) is embedded at the end of the PW2 module to perform adaptive channel adjustment on the shallow output features. Specifically, global average pooling is performed on the shallow output features to obtain channel description vectors, which represent the global statistical information of each channel. Channel description vectors are then subjected to channel compression mapping, nonlinear activation, channel restoration mapping, and sigmoid normalization to obtain channel weights. These channel weights are then multiplied channel-by-channel with the shallow output features to achieve feature recalibration. The channel gating unit enhances the channel responses corresponding to pest boundaries, insect outlines, and local textures, while suppressing background interference channel responses corresponding to leaf vein textures, branch and leaf edges, and light reflection. Since wolfberry pests typically possess unique physical characteristics and color textures, the channel gating unit can adaptively highlight these discriminative features and suppress interference from complex field backgrounds.

[0032] After processing by the fine-grained fidelity front-end module, the output shallow features retain the pest boundary and insect body outline information, while having appropriate channel response intensity, providing high-quality shallow feature input for subsequent deep feature extraction and intra-scale interaction.

[0033] Step S04: The deep semantic features are enhanced by multi-scale local enhancement and intra-scale attention interaction through the intra-scale interaction module to obtain the enhanced context features.

[0034] The dot product attention calculation for the intra-scale interaction module can be represented as:

[0035] Where Q represents the query feature, K represents the key feature, V represents the value feature, d represents the feature dimension, and A represents the attention output. The attention output A is rearranged and upsampled to restore the original spatial resolution of the input features, and then residually fused with the input features.

[0036] The structure of the scale-interactive module MLA-AIFI is as follows: Figure 5As shown, the intra-scale interaction module MLA-AIFI includes a query branch, a key-value branch, and an attention interaction unit. The query branch is used to pool and map the input features to obtain query features. The key-value branch is used to perform multi-scale pooling and local enhancement on the input features to obtain key features and value features. The attention interaction unit is used to perform intra-scale attention interaction based on the query features, key features, and value features. This is used to perform multi-scale local enhancement and intra-scale attention interaction on deep semantic features to obtain enhanced context features. This module receives deep features S4 from the backbone network as input and outputs enhanced context features F4.

[0037] In the scale-interaction module, the query branch determines the pooling scale based on the aspect ratio of the input features: when the width of the input feature is greater than its height, a pooling scale is used where the width dimension of the output is greater than the height dimension; when the height of the input feature is greater than its width, a pooling scale is used where the height dimension of the output is greater than the width dimension; when the width and height of the input feature are equal, a pooling scale is used where the height dimension and width dimension of the output are equal. This adaptive pooling strategy can dynamically adjust the spatial distribution of attention calculation according to the different morphological characteristics of wolfberry pests.

[0038] Step S05: The adjacent scale features are spatially aligned, bidirectionally cross-gated, fused by coordinate constraints, and compensated for by the bidirectional cross-gated fusion module to obtain multi-scale fused features with background noise suppression.

[0039] The query branch adaptively pools the input features and obtains the query feature Q through a linear mapping. The key-value branch performs multi-scale pooling on the input features to capture local contextual information at different ranges. Then, local enhancement is performed through depthwise convolution with a kernel size of 3×3 to enhance the expressive power of local features. Finally, the key feature K and value feature V are obtained through a linear mapping.

[0040] The attention interaction unit is used to calculate the correlation between query feature Q and key feature K in the low-resolution token space, and to perform a weighted summation of value feature V based on the correlation.

[0041] The fused features are processed by Layer Normalization (LN) and then input into a Convolutional Feedforward (Conv-FFN) unit for further feature transformation. The Conv-FFN unit consists of two convolutional layers: the first layer increases the channel dimension using expansion coefficients, and the second layer restores the original channel dimension; the kernel size is 1×1. The output of the Conv-FFN unit is then normalized, ultimately outputting the enhanced contextual features F4.

[0042] The structure of the bidirectional cross-gating fusion module BCGF is as follows: Figure 6As shown, a multi-scale fused feature with background noise suppression is obtained by spatial alignment, bidirectional cross-gating, coordinate constraint fusion, and residual compensation of adjacent scale features. The bidirectional cross-gating fusion module BCGF receives low-level and high-level features from the backbone network or intra-scale interaction modules as input. Low-level features have high spatial resolution and low semantic level, such as features from shallow networks; high-level features have low spatial resolution and high semantic level, such as features from deep networks.

[0043] Let the low-level feature be L, the aligned high-level feature be H′, and the low-level spatial attention map be M. L The high-level spatial attention map is M. H The cross-guided process can be represented as:

[0044] in, This represents the low-level features after being modulated by high-level semantic gating. This represents the characteristics of the high-rise buildings after low-level spatial gating compensation, and ⊙ represents element-by-element multiplication.

[0045] The spatial alignment unit Align is used to adjust high-level features and low-level features in adjacent scales to a consistent spatial size.

[0046] The Spatial Attention Unit (SS) generates low-level spatial attention maps and high-level spatial attention maps based on low-level features and spatially aligned high-level features, respectively. The spatial attention map is obtained by performing global average pooling in the channel dimension, followed by convolution and sigmoid activation in the spatial dimension. The convolution kernel size is 3×3, and the output is a single-channel spatial weight map.

[0047] The cross-gating unit (SE) uses high-level spatial attention maps to perform element-wise weighted adjustment on low-level features, and uses low-level spatial attention maps to perform element-wise weighted compensation on spatially aligned high-level features. Through this bidirectional cross-gating mechanism, high-level features can absorb detailed information from low-level features, while low-level features can learn from the semantic guidance of high-level features. At the same time, cross-gating enables bidirectional information flow and feature enhancement.

[0048] The coordinate attention unit (CA) spatially aggregates the low-level and high-level features after cross-gating along both the height and width directions. The height-oriented coordinate attention first performs global average pooling along the width dimension to generate a feature vector in the height direction, then generates height-oriented positional weights through convolution and a sigmoid function. Similarly, the width-oriented coordinate attention first performs global average pooling along the height dimension to generate a feature vector in the width direction, then generates width-oriented positional weights through convolution and a sigmoid function. Finally, the height and width positional weights are multiplied element-wise and applied to the cross-gated features to obtain a fused feature with directional positional constraints.

[0049] The residual compensation unit Skip supplements the fusion output with low-level structural information. Through residual connections, it directly transmits the original information of low-level features to the output, ensuring that no low-level details are lost during the fusion process. The output of the residual compensation is a multi-scale fusion feature with background noise suppression. This feature contains both high-level semantic information and retains low-level details, while suppressing the propagation of background noise through a bidirectional cross-gating mechanism.

[0050] The residual compensation process can be expressed as:

[0051] in, Indicates multi-scale fusion features, This represents the residual compensation feature formed by low-level structural information. The low-level structural information may include pest edges, outlines, local textures of the insect body, or spatial cues related to the target bounding box localization.

[0052] Step S06: Input the multi-scale fusion features into the detection and decoding module, and output the category information and target box location information of wolfberry pests.

[0053] The detection and decoding module outputs the category information and target bounding box location information of wolfberry pests based on multi-scale fusion features. The module employs an IOU-aware Query Selection strategy to select high-quality query vectors, which are then classified and regressed using the decoder head.

[0054] The output candidate detection results include pest category, target box center coordinates, target box width and height, and confidence score. Pest categories include inchworms, large green leafhoppers, mud beetles, black mirid bugs, black round horned bugs, red-spotted blister beetles, red long bugs, red-edged longhorn beetles, yellow-spotted mosquitoes, thrips, hairy flea beetles, psyllids, fruit flies, small cutworms, aphids, Indian meal borers, and fruit borers, among other common pests of wolfberry.

[0055] When the confidence score is lower than the preset confidence threshold, the corresponding candidate detection results are filtered out; when the confidence score is not lower than the preset confidence threshold, the corresponding candidate detection results are retained as the detection results for wolfberry pests.

[0056] To verify the technical effectiveness of the wolfberry pest detection method based on the GQ-DETR model described in this invention, the applicant conducted experimental verification based on a self-built wolfberry pest field image dataset. The experiments mainly describe the dataset construction, experimental environment and parameter configuration, evaluation indicators, ablation experiments, comparative experiments, and visualization analysis. The following experimental results are used to explain the technical effectiveness of this invention and do not constitute a limitation on the scope of protection of the claims.

[0057] This embodiment uses seventeen common pests in wolfberry production as detection targets, including inchworms, large green leafhoppers, leafhoppers, black mirid bugs, black round horned bugs, red-spotted blister beetles, red long bugs, red-edged longhorn beetles, yellow-spotted mosquitoes, thrips, flea beetles, psyllids, fruit flies, small cutworms, aphids, Indian meal borers, and fruit borers. Data sources may include field photos, publicly authorized images, images collected by inspection equipment, or supplementary images after manual screening, to cover different lighting conditions, background textures, occlusion states, and pest size variations.

[0058] During the image screening and cleaning stage, images that are extremely blurry, duplicate samples, missing targets, have unclear permission status, or whose annotation quality does not meet the training requirements are removed, while samples with complex backgrounds such as leaf vein texture, branch and leaf occlusion, and light reflection are retained.

[0059] During the annotation stage, a target detection annotation tool is used to annotate the pest targets in the image with rectangular boxes. The annotation format can be YOLO format, COCO format, VOC format, or other formats that can be recognized by the target detection training framework.

[0060] In one specific experimental setup, the dataset was divided into a training set, a validation set, and a test set in a ratio of 8:1:1, with 7154 images in the training set, 887 images in the validation set, and 912 images in the test set, for a total of 8953 images.

[0061] The statistics of the dataset are shown in Table 1.

[0062] Table 1. Statistics of the self-built wolfberry pest dataset

[0063] The experiment was conducted under the Windows 11 operating system, with an Intel Core i7-12700K processor as the CPU and an NVIDIA GeForce RTX 4070 Ti Super GPU with 16GB of video memory.

[0064] During training, the input image size was set to 640×640, the training period was set to 300, the batch size was set to 4, and the initial learning rate was set to 0.0001.

[0065] The main experimental parameters are configured as shown in Table 2.

[0066] Table 2 Experimental Environment and Parameter Settings

[0067] To comprehensively evaluate the model's detection capabilities, this embodiment uses Precision, Recall, mAP@0.5, mAP@0.5:0.95, GFLOPs, and FPS as evaluation metrics.

[0068] Precision reflects the proportion of real targets in the detection box that are predicted by the model as pests, while Recall reflects the proportion of real pests that are successfully detected.

[0069] In one evaluation method, Precision and Recall are calculated as follows: ,

[0070] Wherein, TP represents a sample that is predicted as the target and is consistent with the label, FP represents a sample that is predicted as the target but is actually the background, and FN represents a sample that is predicted as the background but is actually the target.

[0071] AP represents the average precision of a certain category under different confidence thresholds, and mAP represents the mean of the average precision after averaging the AP of all categories.

[0072] mAP@0.5 represents the average accuracy when the IoU threshold is 0.5, and mAP@0.5:0.95 represents the combined result of the average accuracy at multiple IoU thresholds from 0.5 to 0.95.

[0073] ,

[0074] GFLOPs represent the computational cost of the model, while FPS represents the inference speed of the model. Both are used to illustrate the computational overhead and real-time performance of the model in a real-world deployment scenario.

[0075] To verify the effectiveness of each improved module, this embodiment uses RT-DETR-R18 as the baseline model and introduces FGP-Stem, MLA-AIFI and BCGF modules on a self-built dataset to conduct ablation experiments.

[0076] For ease of explanation, FGP-Stem is denoted as A, MLA-AIFI as B, and BCGF as C. Experimental groups such as baseline model, single module, dual module combination, and three module combination are set up.

[0077] The results of the ablation experiment are shown in Table 3.

[0078] Table 3 Ablation experiment results on the self-built dataset

[0079] As shown in Table 3, the baseline model has a Precision of 89.5%, a Recall of 81.3%, a mAP@0.5 of 84.5%, and a mAP@0.5:0.95 of 62.8%, respectively. The computational cost is 58.4 GFLOPs and the inference speed is 87.7 FPS.

[0080] After introducing the FGP-Stem module, the model's mAP@0.5 increased to 85.4%, mAP@0.5:0.95 increased to 63.9%, GFLOPs decreased to 51.8, and FPS increased to 99.1, indicating that learnable downsampling and shallow detail preservation can balance detection accuracy and inference efficiency.

[0081] After introducing the MLA-AIFI module, the model recall increased from 81.3% to 82.8%, indicating that multi-scale context modeling within the scale is beneficial for enhancing the target detection capability in complex backgrounds.

[0082] After introducing the BCGF module, the model mAP@0.5:0.95 improved from 62.8% to 64.1%, indicating that bidirectional cross-gating fusion has a positive effect on improving cross-scale localization quality and target box stability.

[0083] When the three modules FGP-Stem, MLA-AIFI and BCGF are introduced simultaneously, the model's Precision, Recall, mAP@0.5 and mAP@0.5:0.95 reach 91.6%, 83.3%, 86.7% and 65.0% respectively, all of which are higher than the baseline model.

[0084] Compared to the baseline model, the full model improved precision, recall, mAP@0.5, and mAP@0.5:0.95 by 2.1, 2.0, 2.2, and 2.2 percentage points, respectively, while GFLOPs decreased from 58.4 to 55.4 and FPS increased from 87.7 to 96.2.

[0085] The above ablation experiment results show that FGP-Stem, MLA-AIFI and BCGF contribute to the model performance in terms of shallow detail preservation, intra-scale context enhancement and cross-scale background noise suppression, respectively, and the three have synergistic gains when used together.

[0086] To further verify the performance advantages of the method of the present invention over existing detection methods, a comparative experiment was conducted in this embodiment under the same training environment and the same data partitioning conditions.

[0087] The comparison methods include YOLOv5m, YOLOv8m, YOLOv9m, YOLOv10m, YOLOv11m, YOLOv12m, M2DETR, RT-DETR-R18, and RT-DETR-R34.

[0088] The results of the comparative experiment are shown in Table 4.

[0089] Table 4. Comparative experimental results on the self-built dataset.

[0090] As shown in Table 4, GQ-DETR achieves superior results in Precision, mAP@0.5, and mAP@0.5:0.95, reaching 91.6%, 86.7%, and 65.0%, respectively; its Recall is 83.3%, which is close to the higher level of the comparative models, while having lower computational cost and higher inference speed.

[0091] Compared to YOLOv5m, GQ-DETR's mAP@0.5 increased from 80.1% to 86.7%, and its mAP@0.5:0.95 increased from 57.6% to 65.0%, representing increases of 6.6 and 7.4 percentage points, respectively.

[0092] Compared to YOLOv9m, GQ-DETR's mAP@0.5 improved from 85.7% to 86.7%, mAP@0.5:0.95 improved from 63.6% to 65.0%, and Precision improved from 87.4% to 91.6%.

[0093] Compared to YOLOv10m, GQ-DETR has a slightly higher recall, and its mAP@0.5 and mAP@0.5:0.95 are improved by 1.4 and 1.2 percentage points, respectively, indicating that it has better positioning accuracy while maintaining recall capability.

[0094] Compared to M2DETR, GQ-DETR improved mAP@0.5 from 86.3% to 86.7%, mAP@0.5:0.95 from 64.6% to 65.0%, while GFLOPs decreased from 75.2 to 55.4 and FPS increased from 68.7 to 96.2.

[0095] Compared with the RT-DETR-R18 baseline model, GQ-DETR improved the Precision, Recall, mAP@0.5, and mAP@0.5:0.95 by 2.1, 2.0, 2.2, and 2.2 percentage points, respectively.

[0096] Compared to the deeper backbone RT-DETR-R34, GQ-DETR improves mAP@0.5 and mAP@0.5:0.95 by 0.6 percentage points respectively, while GFLOPs decreases from 85.3 to 55.4 and FPS increases from 64.9 to 96.2.

[0097] The above results demonstrate that the performance improvement of this invention does not simply come from the increase in the size of the model backbone, but rather from structural improvements such as fine-grained fidelity front-end, intra-scale interaction, and bidirectional cross-gated fusion.

[0098] In terms of computational efficiency, GQ-DETR maintains high detection accuracy while still having an inference speed of 96.2 FPS, which can meet the real-time detection needs of wolfberry field inspections, edge computing devices, or agricultural management platforms.

[0099] In terms of detection stability, GQ-DETR outperforms all the comparison models in mAP@0.5:0.95, indicating that it still has better target box localization quality under strict IoU thresholds.

[0100] In addition to quantitative indicators, feature heatmaps and visualization of detection results can be used to further verify the model's focus on pest target areas.

[0101] In complex field settings, baseline models are easily affected by high-frequency background interference such as leaf vein texture, branch edges, and light reflection, resulting in scattered or shifted response regions.

[0102] Compared to the baseline model, the method of this invention can more concentratedly cover the main body of pests in high-response areas and reduce abnormal responses in non-target areas.

[0103] In challenging scenarios such as complex lighting, leaf vein texture interference, low contrast, and local occlusion, the method of this invention can more stably preserve the target subject response, which helps to reduce false detections, missed detections, and target box positioning jitter.

[0104] This invention reduces the over-compression of small and weakly textured targets by traditional fast downsampling through a fine-grained fidelity front-end module, preserving fine-grained information such as pest boundaries, insect outlines, and low-level textures. A scale-interaction module combines adaptive pooling, multi-scale pooling, local enhancement, and low-resolution token attention computation to enhance the contextual representation of deep semantic features while controlling computational load. A bidirectional cross-gated fusion module selectively fuses features at adjacent scales, reducing the propagation of low-level background noise to high-level semantic features. The shallow detail features output by the fine-grained fidelity front-end module, the enhanced contextual features output by the scale-interaction module, and the noise-suppressed multi-scale fusion features output by the bidirectional cross-gated fusion module form a continuous synergy before detection and decoding. This enables the GQ-DETR model to simultaneously achieve shallow boundary preservation, deep semantic enhancement, and cross-scale background noise suppression, thereby improving the detection stability and bounding box localization stability of wolfberry pests in complex field backgrounds.

[0105] The GQ-DETR model of this invention can be deployed in edge device or server environments. When deployed on edge devices, techniques such as model quantization and pruning can be used to reduce computational load and memory consumption; when deployed in a server environment, GPU acceleration can be used to achieve real-time detection. In practical applications, multiple cameras can be deployed in key areas of a goji berry planting base, and the collected images can be transmitted via network to computing nodes deployed with the GQ-DETR model to achieve real-time monitoring and early warning of goji berry pests.

[0106] The wolfberry pest detection system of this invention has achieved significant results in practical applications. Compared with traditional target detection methods, the detection accuracy of this invention is improved by approximately 15%, the recall rate by approximately 12%, and the mAP by approximately 0.18. Especially in complex field conditions, the detection rate of small-sized pests and weakly textured pests is significantly improved, while the false detection rate is significantly reduced, providing effective technical support for the precise control of wolfberry pests.

[0107] The embodiments described herein are preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Therefore, all equivalent changes made to the structure, shape, and principle of the present invention should be covered within the scope of protection of the present invention. Although preferred embodiments of the present invention have been described, those skilled in the art, once they understand the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the present invention. Obviously, those skilled in the art can make various modifications and variations to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention also intends to include these modifications and variations.

Claims

1. A method for detecting pests in wolfberry based on the GQ-DETR model, characterized in that, Includes the following steps: Acquire field images of wolfberries to be detected, and preprocess the wolfberry field images to obtain the model input image; The input image of the model is input into the GQ-DETR model, which is based on the RT-DETR model and includes a fine-grained fidelity front-end module, an intra-scale interaction module, a bidirectional cross-gated fusion module, and a detection and decoding module. The fine-grained high-fidelity front-end module performs shallow feature extraction and learnable downsampling on the model input image, and performs channel adaptive adjustment on the shallow features to obtain shallow features that retain the pest boundary and insect body outline information. The intra-scale interaction module is used to perform multi-scale local enhancement and intra-scale attention interaction on deep semantic features to obtain enhanced contextual features. The bidirectional cross-gated fusion module performs spatial alignment, bidirectional cross-gated fusion, coordinate constraint fusion, and residual compensation on adjacent scale features to obtain multi-scale fused features with background noise suppression. The multi-scale fused features are input into the detection and decoding module, which outputs the category information and target box location information of wolfberry pests. The fine-grained fidelity front-end module, the intra-scale interaction module, and the bidirectional cross-gated fusion module are sequentially applied to the shallow feature extraction, intra-scale context modeling, and cross-scale feature fusion stages of the GQ-DETR model, enabling the GQ-DETR model to simultaneously possess shallow detail preservation, intra-scale semantic enhancement, and cross-scale background noise suppression capabilities.

2. The method for detecting pests in wolfberry based on the GQ-DETR model as described in claim 1, characterized in that, In the fine-grained fidelity front-end module, two levels of learnable downsampling units process the input features sequentially. Each level of learnable downsampling unit includes a deep convolutional unit with a stride of two and a pointwise convolutional unit. The two levels of learnable downsampling units are connected in series to form a shallow output feature with a total stride of four.

3. The method for detecting pests in wolfberry based on the GQ-DETR model as described in claim 2, characterized in that, The fine-grained fidelity front-end module further includes a channel gating unit. The channel gating unit performs global average pooling on the shallow output features to obtain a channel description vector. The channel description vector is then subjected to channel compression mapping, nonlinear activation, channel restoration mapping, and Sigmoid normalization processing in sequence to obtain channel weights. The channel weights are then multiplied with the shallow output features channel by channel to obtain the shallow features after channel adaptive adjustment.

4. The method for detecting pests in wolfberry based on the GQ-DETR model as described in claim 1, characterized in that, In the scale-interaction module, the query branch determines the pooling scale based on the aspect ratio of the input feature: when the width of the input feature is greater than its height, a pooling scale is used where the width dimension of the output is greater than the height dimension; when the height of the input feature is greater than its width, a pooling scale is used where the height dimension of the output is greater than the width dimension; when the width and height of the input feature are equal, a pooling scale is used where the height dimension and width dimension of the output are equal; the query branch pools the input feature and maps it to obtain the query feature.

5. The method for detecting pests in wolfberry based on the GQ-DETR model as described in claim 4, characterized in that, In the scale-interaction module, the key-value branch performs multi-scale pooling and local enhancement on the input features to obtain key features and value features; The attention interaction unit performs dot product attention calculation in the low-resolution token space based on the query features, key features, and value features to obtain the attention output. After the attention output is rearranged and upsampled to restore the original spatial resolution of the input features, it is residually fused with the input features and then outputs the enhanced context features through the convolutional feedforward unit.

6. The method for detecting pests in wolfberry based on the GQ-DETR model as described in claim 1, characterized in that, In the bidirectional cross-gated fusion module, the spatial alignment unit is used to adjust the high-level features and low-level features in adjacent scales to the same spatial size. When upsampling, nearest neighbor interpolation is used in combination with convolution thinning, and when downsampling, convolution with a stride of two is used.

7. The method for detecting pests in wolfberry based on the GQ-DETR model as described in claim 6, characterized in that, In the bidirectional cross-gating fusion module, the spatial attention unit is used to generate a low-level spatial attention map and a high-level spatial attention map based on the low-level features and the spatially aligned high-level features, respectively. The cross-gating unit uses the high-level spatial attention map generated from the spatially aligned high-level features to perform element-wise weighted adjustment on the low-level features, and uses the low-level spatial attention map generated from the low-level features to perform element-wise weighted compensation on the spatially aligned high-level features.

8. The method for detecting pests in wolfberry based on the GQ-DETR model as described in claim 7, characterized in that, In the bidirectional cross-gated fusion module, the coordinate attention unit performs spatial aggregation on the low-level and high-level features after cross-gated fusion along the height and width directions, respectively, to generate height position weights and width position weights. The height position weights and width position weights are then applied to the cross-gated features to obtain fused features with directional position constraints.

9. The method for detecting pests in wolfberry based on the GQ-DETR model as described in claim 8, characterized in that, In the bidirectional cross-gated fusion module, the residual compensation unit is used to supplement the low-level structure information into the fusion output to obtain multi-scale fusion features with background noise suppression.

10. A wolfberry pest detection system based on the GQ-DETR model, used to execute the wolfberry pest detection method based on the GQ-DETR model as described in any one of claims 1-9, characterized in that, include: The image acquisition module is used to acquire field images of the goji berries to be detected. The preprocessing module is used to preprocess the wolfberry field images to obtain the model input image; the GQ-DETR detection module is used to input the model input image into the GQ-DETR model and output the category information and target box location information of wolfberry pests. The result output module is used to output the category information and the target box position information.