A grain storage pest detection method based on HPSD-DDF

By improving the HPSD-DDF model and combining it with DSTEM, MSSM and APELAN modules, the problems of insufficient accuracy and efficiency in the detection of stored grain pests are solved, and high-precision detection of small and medium-sized targets is achieved, meeting the requirements of real-time detection.

CN122157244APending Publication Date: 2026-06-05HENAN UNIVERSITY OF TECHNOLOGY

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HENAN UNIVERSITY OF TECHNOLOGY
Filing Date
2026-03-04
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

Existing technologies for detecting pests in stored grains suffer from insufficient accuracy, low computational efficiency, and are not suitable for large-scale monitoring, especially in complex environments where it is difficult to accurately identify small target pests.

Method used

The HPSD-DDF model based on the DEIM-D-Fine architecture is adopted, and the Discrete Cosine Transform Small Target Enhancement Module (DSTEM), Multi-Scale Spiral Mamba Module (MSSM), and APELAN module are introduced to construct the HPSD-DDF network model. Through frequency domain feature enhancement, multi-scale feature fusion and lightweight processing, the detection accuracy and efficiency are improved.

Benefits of technology

On the grain storage pest dataset, the AP50:95 for small targets improved from 28.8% to 32.1%, and the AP50:95 for medium targets reached 51.4%. The number of model parameters decreased from 10.1M to 9.2M, and the inference speed increased from 29.8 FPS to 37.3 FPS, achieving high-precision and high-efficiency detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122157244A_ABST
    Figure CN122157244A_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of pest detection, and particularly relates to a stored grain pest detection method based on HPSD-DDF, and specific step processes of the stored grain pest detection method are as follows: obtaining a stored grain pest image in a pest trapping trap and performing data preprocessing, data enhancement and data labeling to obtain a preprocessed image data set; in the application, DSTEM is introduced to enhance and process small target features in a frequency domain, and the detection capability of a model for small targets of stored grain pests is effectively improved. The DSTEM module adaptively processes four frequency bands of ultralow frequency, low frequency, medium frequency and high frequency through MFB, and the high-frequency boundary information of small targets is enhanced in a targeted manner; meanwhile, EEB adopts a multi-directional edge detection operator to further strengthen target boundary features. On a stored grain pest data set, compared with a baseline model, the AP 50:95 of small targets is improved from 28.8% to 32.1%, with an increase of 3.3 percentage points, which verifies the effectiveness of the DSTEM module on small target detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of pest detection technology, specifically to a method for detecting stored grain pests based on HPSD-DDF. Background Technology

[0002] Grain storage pests pose one of the most serious threats to national food security, significantly impacting the stable supply of food across the country. These destructive insects cause multifaceted damage by directly consuming stored grain products and creating microenvironments conducive to mold growth and the production of fungal toxins (especially aflatoxin), posing serious health risks to consumers. The scale of their damage is staggering: global post-harvest grain losses amount to approximately 1.3 billion tons annually, with grain storage pests accounting for 10% of these losses in developing countries alone. The sheer scale and complexity of losses caused by grain storage pests underscore the urgent need for innovative automated detection technologies to achieve early and accurate pest identification, enabling timely intervention to prevent widespread damage.

[0003] Traditional detection methods mainly rely on sampling inspections and conventional trapping techniques, which are labor-intensive and unsuitable for large-scale monitoring. Modern non-destructive testing technologies encompass acoustic systems, chemical sensing technologies, and optical methods; however, these technologies suffer from limitations such as high environmental sensitivity, weak anti-interference capabilities, and high equipment costs, necessitating a more robust detection framework. Deep learning methods have revolutionized stored grain pest detection technology by enabling automated and precise detection.

[0004] In existing research, numerous researchers have applied convolutional neural network (CNN) object detection models to detect stored grain pests, achieving significant improvements in both detection accuracy and computational efficiency. However, CNN-based object detection models have inherent limitations, such as a limited receptive field and restricted ability to capture fine features, which fundamentally restricts their effectiveness in complex environments. Recently, the DETR model and its variants have demonstrated superior performance on large-scale object detection datasets, effectively capturing global contextual relationships and long-range spatial dependencies through a self-attention mechanism. Among these advancements, the latest object detection model, DEIM-D-FINE, integrates the DEIM training framework and the D-FINE architecture. It accelerates convergence through dense one-to-one matching combined with matchability loss, and improves accuracy by employing refined distributed optimization combined with global optimal localization self-distillation technology.

[0005] Therefore, this invention is based on the DEIM-D-Fine architecture and has made a series of optimizations for the detection of stored grain pests, proposing a new DETR variant HPSD-DDF to meet the high-precision detection requirements for stored grain pest monitoring. Summary of the Invention

[0006] The purpose of this invention is to provide a method for detecting stored grain pests based on HPSD-DDF, so as to solve the problems mentioned in the background art.

[0007] To achieve the above objectives, the present invention provides the following technical solution: a method for detecting stored grain pests based on HPSD-DDF, the specific steps of which are as follows:

[0008] S1. Obtain images of stored grain pests in insect traps and perform data preprocessing, data augmentation, and data annotation to obtain a preprocessed image dataset.

[0009] S2. Based on the DEIM-D-Fine model (High Precision Stored grain pest Detection DEIM-D-Fine), the Discrete Cosine Transform Small Target Enhancement Module (DSTEM), the Multi-Scale Spiral Mamba Module (MSSM), and the APELAN Module are introduced to construct the HPSD-DDF network model.

[0010] S3. Based on the HPSD-DDF network model, the image containing stored grain pests is detected to obtain the target recognition and detection results.

[0011] Preferably, the HPSD-DDF network model specifically includes a backbone network, an encoder, and a decoder, which are connected sequentially.

[0012] Wherein: the backbone network adopts a hierarchical feature extraction mechanism, the backbone network includes a Stem module, a Stage module, and a STE-Stage module, the STE-Stage module includes a DSTEM module and a convolutional module;

[0013] The encoder includes a bidirectional feature fusion path that is both bottom-up and top-down. The encoder integrates an MSSM module and an APELAN module. The MSSM module includes a spiral progressive state space model and a multi-scale averaging fusion module. The MSSM module includes multiple S6 blocks. The APELAN module includes adaptive partial convolution APConv and selective cross-stage partial blocks.

[0014] The decoder generates detection results through edge probability distribution modeling and a self-distillation mechanism.

[0015] Preferably, in step S1, the specific steps for acquiring and preprocessing, labeling, and annotating the image data of stored grain pests are as follows:

[0016] S11. Collect images of stored grain pests in the insect trap to obtain images of stored grain pests.

[0017] S12: The images of stored grain pests obtained in S11 are preprocessed and then divided into training set, validation set and test set in a ratio of 7:1:2.

[0018] S13: Perform data augmentation on the training set partitioned in S12 separately;

[0019] S14: Label the enhanced training, validation, and test sets using COCO format. After labeling, the final dataset is obtained.

[0020] Preferably, in step S3, the specific steps for detecting images containing stored grain pests and obtaining detection results are as follows:

[0021] S31: Input the preprocessed image dataset into the HPSD-DDF network model;

[0022] S32: Based on the HPSD-DDF network model, the backbone network extracts basic features from the preprocessed image dataset to obtain the extracted target image features;

[0023] S33: An encoder based on the HPSD-DDF network model performs multi-scale feature fusion processing on the target image features to obtain the fused target image features;

[0024] S34: A decoder based on the HPSD-DDF network model, which decodes and predicts the features of the fused target image to obtain the target recognition and detection results.

[0025] Preferably, in step S32, the specific steps for extracting basic features of stored grain pest images based on the backbone network of the HPSD-DDF model are as follows:

[0026] S321: Input the preprocessed image dataset into the backbone network;

[0027] S322: The Stem module based on the backbone network performs channel adjustment and feature extraction on the preprocessed image dataset to obtain a preliminary target feature map;

[0028] S323: The Stage module based on the backbone network performs convolution and spatial channel dimension transformation on the initial target feature map to obtain the intermediate target feature map;

[0029] S324: The complex STE-Stage module based on the backbone network performs frequency domain enhancement and edge feature enhancement processing on the intermediate target feature map to obtain the enhanced target image features.

[0030] Preferably, in step S324, the specific steps for edge feature enhancement processing of the intermediate target feature map are as follows:

[0031] S3241: Input the preliminary target feature map into the DSTEM module;

[0032] S3242: Based on the DSTEM module, a multi-frequency block performs two-dimensional discrete cosine transform (DCT) on the preliminary target feature map, converting spatial domain features into frequency domain coefficients.

[0033] S3243: Generates weights for four different frequency bands based on frequency domain coefficients, corresponding to ultra-low frequency, low frequency, mid frequency and high frequency components respectively;

[0034] S3244: Attention weights are applied to each frequency band through a frequency attention mechanism to obtain frequency-enhanced features;

[0035] S3245: Convert the frequency enhancement features back to the spatial domain using inverse DCT transform;

[0036] S3246: An edge enhancement block based on the DSTEM module, which uses Sobel-X, Sobel-Y and Laplacian operators to perform multi-directional edge detection on the feature map;

[0037] S3247: Adaptive weights are generated through an edge intensity modulation network to selectively emphasize edge features;

[0038] S3248: The frequency enhancement features and edge enhancement features are fused through residual connections to obtain the enhanced target feature map.

[0039] Preferably, in step S3248, the specific steps for fusing the frequency enhancement features and edge enhancement features through residual connections are as follows:

[0040] S3248-1: Input the enhanced target feature map into the encoder;

[0041] S3248-2: Multi-scale feature fusion based on bottom-up and top-down paths of the encoder;

[0042] S3248-3: Integrate the MSSM module and APELAN module for feature enhancement during the feature fusion process;

[0043] S3248-4: Output the fused multi-scale target image features.

[0044] Preferably, in S3248-3, the specific steps for integrating the MSSM module and the APELAN module for feature enhancement processing during feature fusion are as follows:

[0045] S3248-3-1: Spiral Progressive State Space Model (SPSSM) based on MSSM module, starting from the center coordinates of the feature map, and performing a spiral scan with increasing step size in four directions: right, down, left, and up;

[0046] S3248-3-2: Process scanned features at multiple scales through adaptive downsampling and upsampling operations;

[0047] S3248-3-3: Input the scanning results at different scales into the corresponding S6 blocks for state space modeling;

[0048] S3248-3-4: The S6 block adopts a selective scanning mechanism and performs feature processing according to the state space formula.

[0049] S3248-3-5: The output features of multiple S6 blocks are fused using the Multi-Scale Average Fusion Module (MSAFM).

[0050] S3248-3-6: The MSAFM uses a shared compressor to extract key information of features at each scale, and obtains fused features through averaging and expansion operations;

[0051] S3248-3-7: Adaptive partial convolution APConv based on APELAN module, calculating importance weights through channel attention analysis;

[0052] S3248-3-8: Select the top-k most important channels based on the learned importance scores and perform 3×3 convolution processing, while keeping the other channels unchanged;

[0053] S3248-3-9: Selective cross-stage partial block SCSPB based on APELAN module divides the input features into two branches along the channel dimension after expansion by 1×1 convolution;

[0054] S3248-3-10: One branch processes the APConv and MLP layers sequentially, while the other branch maintains the direct feature flow;

[0055] S3248-3-11: After concatenating the features of the two branches along the channel dimension, the features are fused by a final 1×1 convolution to obtain the lightweight features.

[0056] Preferably, the decoder of the HPSD-DDF model generates prediction results, which specifically include:

[0057] The fused multi-scale target image features are input into the decoder; the decoder models each edge of the bounding box as a probability distribution through a fine-grained distribution refinement mechanism; a global optimal localization self-distillation mechanism is adopted to transfer deep localization knowledge to the shallow layer; accurate bounding box prediction and category classification results are generated, and detection results of eight target grain storage pests are obtained.

[0058] Compared with the prior art, the beneficial effects of the present invention are:

[0059] 1) In this invention, by introducing DSTEM, the features of small targets are enhanced in the frequency domain, effectively improving the model's detection capability for small targets such as stored grain pests. The DSTEM module uses MFB to adaptively process four frequency bands: ultra-low frequency, low frequency, mid frequency, and high frequency, specifically enhancing the high-frequency boundary information of small targets; simultaneously, EEB employs a multi-directional edge detection operator to further strengthen the target boundary features. On the stored grain pest dataset, compared to the baseline model, the AP of small targets is significantly improved. 50:95 The accuracy rate increased from 28.8% to 32.1%, a rise of 3.3 percentage points, validating the effectiveness of the DSTEM module in detecting small targets.

[0060] 2) In this invention, by introducing MSSM (Multi-Scale Average Fusion Model) and employing a spiral scanning strategy from the center outwards, features in the central region of the image are prioritized, which aligns with the distribution characteristics of stored grain pests in insect traps. The MSSM module achieves long-range dependency modeling with linear computational complexity based on a state-space model, significantly reducing computational overhead compared to the self-attention mechanism of the traditional Transformer. Simultaneously, the multi-scale average fusion module MSAFM (Multi-Scale Average Fusion Model) enables efficient feature fusion with parameter sharing, significantly improving inference speed while maintaining detection accuracy. Experimental results show that the MSSM module allows the model to accurately capture target features even under complex background interference, achieving high AP (Average Precision) for medium-sized targets. 50:95 It reached 51.4%, outperforming all the comparison models;

[0061] 3) In this invention, the computational complexity and number of parameters of the model are effectively reduced by introducing APELAN. The APELAN module uses APConv, which intelligently selects the top-k important channels for convolution processing through a channel attention mechanism, while keeping the remaining channels unchanged, thus avoiding the information loss risk caused by a fixed channel partitioning strategy. The selective cross-stage partial block SCSPB achieves selective processing and direct transmission of features through a dual-branch architecture, and introduces nonlinear transformations in the MLP layer to enhance feature representation capabilities. Compared with the baseline model, APELAN reduces the number of parameters from 10.1M to 9.2M, GFLOPs from 24.8 to 19.6, and inference speed from 29.8 FPS to 37.3 FPS, while maintaining high detection accuracy, achieving the optimal balance between accuracy and efficiency.

[0062] 4) In this invention, a complete HPSD-DDF storage pest detection framework is constructed through the collaborative work of three modules: DSTEM, MSSM, and APELAN, achieving high-precision detection while maintaining lightweight characteristics. On a self-built storage pest dataset, HPSD-DDF achieves an accuracy of 94.5%. 50 and 49.8% AP 50:95 The detection accuracy was improved by 4.7% and 2.1% respectively compared to the baseline model, and the best AP was achieved at the three scales of small, medium and large targets. 50:95 Performance. The model has only 9.2M parameters, a computational complexity of 19.6 GFLOPs, and an inference speed of 37.3 FPS, meeting the requirements for real-time detection. This invention has good generalization ability and robustness, and is suitable for small target detection tasks in different scenarios. It provides practical technical support for intelligent grain depot management systems, helping to reduce grain storage losses and ensure food security. Attached Figure Description

[0063] Figure 1 This is a network structure diagram of the present invention;

[0064] Figure 2 This is a network structure diagram of DSTEM provided in a specific embodiment of the present invention;

[0065] Figure 3 This is a network structure diagram of MSSM provided in a specific embodiment of the present invention;

[0066] Figure 4 This is a network structure diagram of APELAN provided in a specific embodiment of the present invention;

[0067] Figure 5 This is a schematic diagram of the detection results of stored grain pests provided in a specific embodiment of the present invention. Detailed Implementation

[0068] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0069] Example:

[0070] Please see Figure 1-5 The present invention provides a technical solution:

[0071] A method for detecting stored grain pests based on HPSD-DDF, the specific steps of which are as follows:

[0072] S1. Acquire images of stored grain pests in insect traps and perform data preprocessing, data augmentation, and data annotation to obtain a preprocessed image dataset. The image species in the dataset include grain beetles, red flour beetles, Indian meal borers, maize weevils, wheat moths, sawtooth grain beetles, bean weevils, and tobacco beetles. Images of stored grain pests in insect traps are collected using a camera to obtain a stored grain pest image dataset. Then, the dataset is divided, and data augmentation is performed on the training set. The stored grain pest dataset is annotated according to the COCO dataset format.

[0073] S2. Based on the DEIM-D-Fine model (High Precision Stored grain pest Detection DEIM-D-Fine), the Discrete Cosine Transform Small Target Enhancement Module (DSTEM), the Multi-Scale Spiral Mamba Module (MSSM), and the APELAN Module are introduced to construct the HPSD-DDF network model.

[0074] S3. Based on the HPSD-DDF network model, the image containing stored grain pests is detected to obtain the target recognition and detection results.

[0075] The HPSD-DDF network model specifically includes a backbone network, an encoder, and a decoder, which are connected sequentially.

[0076] Wherein: the backbone network adopts a hierarchical feature extraction mechanism, the backbone network includes a Stem module, a Stage module, and a STE-Stage module, the STE-Stage module includes a DSTEM module and a convolutional module;

[0077] The backbone network integrates a Discrete Cosine Transform Small Target Enhancement Module (DSTEM) in the STE-Stage stage. The DSTEM module includes a Multi-Frequency Block (MFB) and an Edge Enhancement Block (EEB). The MFB converts spatial domain features into frequency domain coefficients through two-dimensional discrete cosine transform (DCT), generating weights for four different frequency bands, corresponding to ultra-low frequency, low frequency, mid frequency, and high frequency components, respectively. Attention weights are applied to each frequency band through a frequency attention mechanism to enhance the high-frequency features of the small target. The EEB uses Sobel-X, Sobel-Y, and Laplacian operators for multi-directional edge detection and generates adaptive weights through an edge intensity modulation network.

[0078] The encoder includes a bidirectional feature fusion path that is both bottom-up and top-down. The encoder integrates an MSSM module and an APELAN module. The MSSM module includes a spiral progressive state space model and a multi-scale averaging fusion module. The MSSM module includes multiple S6 blocks. The APELAN module includes adaptive partial convolution APConv and selective cross-stage partial blocks.

[0079] The encoder integrates a multi-scale spiral Mamba module (MSSM) and an adaptive partially augmented lightweight aggregation network (APELAN). The MSSM module includes a spiral progressive state space model (SPSSM) and a multi-scale average fusion module (MSAFM). The SPSSM starts from the center coordinates of the feature map and performs spiral scanning in four directions (right, down, left, and up) with increasing step sizes. It processes the scanned features at multiple scales through adaptive downsampling and upsampling operations, and inputs the scanning results at different scales into the corresponding S6 blocks for state space modeling. The adaptive partially augmented lightweight aggregation network (APELAN) module includes an adaptive partial convolution (APConv) and a selective cross-stage partial block (SCSPB). The APConv intelligently selects the top-k important channels for convolution processing through a channel attention mechanism, and the SSCSPB achieves selective processing and direct transfer of features through a dual-branch architecture.

[0080] The decoder generates detection results through edge probability distribution modeling and a self-distillation mechanism.

[0081] The HPSD-DDF model was trained based on the training data to obtain a detection model for stored grain pests. The trained detection model for stored grain pests was then tested, and the test results were evaluated after the test was completed.

[0082] The detection model for stored grain pests is evaluated based on the test results. If the evaluation is qualified, the stored grain pest detection model is used to identify and detect stored grain pests. The evaluation indicators include average accuracy (AP), number of parameters, computational cost, and frame rate (FPS).

[0083] The evaluation metrics include AP value, number of parameters, computational cost, and FPS.

[0084] The first Average precision of each category The calculation formula is:

[0085]

[0086]

[0087] In the above formula, TP represents the number of true positives, and FP represents the number of false positives; TP represents the number of true positives, and FN represents the number of false negatives. P represents precision, and R represents recall.

[0088] Average accuracy across all categories The calculation formula is:

[0089]

[0090] In the above formula, Indicates the total number of categories. Indicates the first Average precision for each category.

[0091] The AP 50 This represents the average accuracy calculated when the IoU threshold is 0.5, and the AP 50:95 This represents the average accuracy calculated with IoU thresholds ranging from 0.5 to 0.95 in steps of 0.05. 50:95 APs are divided into small, medium, and large goals. 50:95 .

[0092] The parameter count quantifies the total number of trainable parameters in a neural network, reflecting the model's complexity and memory requirements. Computational complexity is measured in GFLOPs, representing the number of floating-point operations required to process a single input image, thus reflecting computational efficiency.

[0093] Frame rate (FPS) measures a model's real-time processing capability, representing the number of images that can be processed per second. Its calculation formula is:

[0094] In the above formula, This represents the average processing time for each image;

[0095] The specific steps for acquiring image data of stored grain pests and performing data preprocessing, data annotation, and data labeling are as follows:

[0096] S11. Collect images of stored grain pests in the insect trap to obtain images of stored grain pests.

[0097] S12: The images of stored grain pests obtained in S11 are preprocessed and then divided into training set, validation set and test set in a ratio of 7:1:2.

[0098] S13: Perform data augmentation on the training set partitioned in S12 separately;

[0099] S14: Label the enhanced training, validation, and test sets using COCO format. After labeling, the final dataset is obtained.

[0100] In step S3, the specific steps for detecting images containing stored grain pests and obtaining detection results are as follows:

[0101] S31: Input the preprocessed image dataset into the HPSD-DDF network model;

[0102] S32: Based on the HPSD-DDF network model, the backbone network extracts basic features from the preprocessed image dataset to obtain the extracted target image features;

[0103] S33: An encoder based on the HPSD-DDF network model performs multi-scale feature fusion processing on the target image features to obtain the fused target image features;

[0104] S34: A decoder based on the HPSD-DDF network model, which decodes and predicts the features of the fused target image to obtain the target recognition and detection results.

[0105] In step S32, the specific steps for extracting basic features of stored grain pest images based on the backbone network of the HPSD-DDF model are as follows:

[0106] S321: Input the preprocessed image dataset into the backbone network;

[0107] S322: The Stem module based on the backbone network performs channel adjustment and feature extraction on the preprocessed image dataset to obtain a preliminary target feature map;

[0108] S323: The Stage module based on the backbone network performs convolution and spatial channel dimension transformation on the initial target feature map to obtain the intermediate target feature map;

[0109] S324: The complex STE-Stage module based on the backbone network performs frequency domain enhancement and edge feature enhancement processing on the intermediate target feature map to obtain the enhanced target image features.

[0110] In step S324, the specific steps for edge feature enhancement processing of the intermediate target feature map are as follows:

[0111] S3241: Input the preliminary target feature map into the DSTEM module;

[0112] S3242: Based on the DSTEM module, a multi-frequency block performs two-dimensional discrete cosine transform (DCT) on the preliminary target feature map, converting spatial domain features into frequency domain coefficients.

[0113] S3243: Generates weights for four different frequency bands based on frequency domain coefficients, corresponding to ultra-low frequency, low frequency, mid frequency and high frequency components respectively;

[0114] S3244: Attention weights are applied to each frequency band through a frequency attention mechanism to obtain frequency-enhanced features;

[0115] S3245: Convert the frequency enhancement features back to the spatial domain using inverse DCT transform;

[0116] S3246: An edge enhancement block based on the DSTEM module, which uses Sobel-X, Sobel-Y and Laplacian operators to perform multi-directional edge detection on the feature map;

[0117] S3247: Adaptive weights are generated through an edge intensity modulation network to selectively emphasize edge features;

[0118] S3248: The frequency enhancement features and edge enhancement features are fused through residual connections to obtain the enhanced target feature map.

[0119] In step S3248, the specific steps for fusing frequency enhancement features and edge enhancement features through residual connection are as follows:

[0120] S3248-1: Input the enhanced target feature map into the encoder;

[0121] S3248-2: Multi-scale feature fusion based on bottom-up and top-down paths of the encoder;

[0122] S3248-3: Integrate the MSSM module and APELAN module for feature enhancement during the feature fusion process;

[0123] S3248-4: Output the fused multi-scale target image features.

[0124] In S3248-3, the specific steps for integrating the MSSM module and APELAN module to perform feature enhancement processing during feature fusion are as follows:

[0125] S3248-3-1: Spiral Progressive State Space Model (SPSSM) based on MSSM module, starting from the center coordinates of the feature map, and performing a spiral scan with increasing step size in four directions: right, down, left, and up;

[0126] S3248-3-2: Process scanned features at multiple scales through adaptive downsampling and upsampling operations;

[0127] S3248-3-3: Input the scanning results at different scales into the corresponding S6 blocks for state space modeling;

[0128] S3248-3-4: The S6 block adopts a selective scanning mechanism and performs feature processing according to the state space formula.

[0129] S3248-3-5: The output features of multiple S6 blocks are fused using the Multi-Scale Average Fusion Module (MSAFM).

[0130] S3248-3-6: The MSAFM uses a shared compressor to extract key information of features at each scale, and obtains fused features through averaging and expansion operations;

[0131] S3248-3-7: Adaptive partial convolution APConv based on APELAN module, calculating importance weights through channel attention analysis;

[0132] S3248-3-8: Select the top-k most important channels based on the learned importance scores and perform 3×3 convolution processing, while keeping the other channels unchanged;

[0133] S3248-3-9: Selective cross-stage partial block SCSPB based on APELAN module divides the input features into two branches along the channel dimension after expansion by 1×1 convolution;

[0134] S3248-3-10: One branch processes the APConv and MLP layers sequentially, while the other branch maintains the direct feature flow;

[0135] S3248-3-11: After concatenating the features of the two branches along the channel dimension, the features are fused by a final 1×1 convolution to obtain the lightweight features.

[0136] The decoder of the HPSD-DDF model generates prediction results, which specifically include:

[0137] The fused multi-scale target image features are input into the decoder; the decoder models each edge of the bounding box as a probability distribution through a fine-grained distribution refinement mechanism; a global optimal localization self-distillation mechanism is adopted to transfer deep localization knowledge to the shallow layer; accurate bounding box prediction and category classification results are generated, and detection results of eight target grain storage pests are obtained.

[0138] In this embodiment, to construct a high-quality dataset for detecting stored grain pests, researchers used a camera to capture images of stored grain pests in insect traps. The specific acquisition process is as follows:

[0139] Live grain borers, red flour beetles, Indian meal borers, maize weevils, wheat moths, sawtooth flour beetles, bean weevils, and tobacco beetles were captured using insect traps placed in grain warehouses. Images of the stored grain pests in the traps were then captured using a 24mm focal length camera, resulting in 3800 images, each containing 1-8 individuals. These images were then divided into training, validation, and test sets in a 7:1:2 ratio.

[0140] Since the number of images in the dataset was insufficient to meet the requirements for training and testing the detection model, data augmentation techniques were used to expand the training set. For each training image, two random methods were applied: horizontal transformation, vertical transformation, brightness reduction, Gaussian noise, image scaling, and image rotation. Each image was augmented three times, generating three augmented variants. Ultimately, the grain storage pest dataset contained 7980 training images with 37110 labeled instances; 380 validation images with 1640 labeled instances; and 760 test images with 3557 labeled instances.

[0141] Because this embodiment of the invention uses the Detection Transformer series of neural networks, it is necessary to label the final version of the dataset after amplification, and the labeling format is COCO.

[0142] The experiments of this invention were conducted in the following environment:

[0143] In terms of hardware, the computing platform uses a server with the Ubuntu 22.04 operating system; the central processing unit is an Intel Xeon Gold 5318Y processor with a main frequency of 2.10GHz and 62GB of memory; the graphics processing unit is equipped with four NVIDIA RTX A4000 graphics cards, each with 16GB of video memory, for a total of 64GB of video memory, which is used to accelerate model training and inference; the storage device is a solid-state drive, which is used to store the training dataset and model weight files.

[0144] In terms of software environment, the deep learning framework used is PyTorch version 2.4.1, with CUDA 12.4 acceleration library; the programming language used is Python version 3.10.15.

[0145] In terms of training parameter configuration, all input images were uniformly adjusted to 640×640 pixels; 4 images were processed in each batch; the model was trained for a total of 132 epochs; the backbone network used a learning rate of 0.0001 and the overall network used a learning rate of 0.0004; the AdamW optimizer was used for parameter updates, which added weight decay regularization to the Adam optimizer.

[0146] The step of performing frequency domain enhancement and edge feature enhancement processing on the target feature map output by the Stage module using the complex STE-Stage module based on the backbone network specifically includes:

[0147] The target feature map output by the Stage module is input into the STE-Stage module, and the target features are extracted by multiple convolutional layers in the STE-Stage module. Then, the output feature maps of the multiple convolutional layers are concatenated.

[0148] The target feature map after feature extraction from the convolutional layer is input into the DSTEM module in the STE-Stage module;

[0149] Based on the DSTEM module, multi-frequency blocks are used to perform frequency domain transformation and frequency band processing on the target feature map;

[0150] Based on the edge enhancement block of the DSTEM module, multi-directional edge detection and edge intensity modulation are performed on the target feature map;

[0151] The frequency domain enhancement features and edge enhancement features are fused through residual connections to obtain the enhanced target image features.

[0152] Reference Figure 2 The step of performing frequency domain transformation and frequency band processing on the feature map based on the multi-frequency block of the DSTEM module specifically includes:

[0153] Perform a two-dimensional discrete cosine transform on the input feature map to convert the spatial domain representation into a frequency domain representation;

[0154] For an input feature map X∈R^(H×W×C), where H, W, and C represent the height, width, and number of channels of the feature map, the two-dimensional discrete cosine transform is calculated as follows:

[0155]

[0156] In the above formula, Represents spatial domain coordinates, Represents frequency domain coordinates, and These are the normalization coefficients;

[0157] Calculate the normalized distance from each location in the frequency domain to the DC component. The formula for calculating the normalized distance is as follows:

[0158]

[0159] The frequency domain coefficients are divided into four frequency bands based on a learnable threshold parameter;

[0160] The four frequency bands are ultra-low frequency band, low frequency band, mid frequency band, and high frequency band, which are divided by three threshold parameters τ1, τ2, and τ3. The mask for each frequency band is defined as follows:

[0161]

[0162]

[0163]

[0164]

[0165] in, Indicates an indicator function;

[0166] Adaptive weights are generated for each frequency band using a frequency attention mechanism;

[0167] The frequency attention mechanism first extracts global information of frequency domain features through global average pooling and a two-layer fully connected network, and then generates four frequency segment weights w1, w2, w3, and w4 through an activation function, with each weight being a positive value.

[0168] The frequency domain coefficients are weighted, and the calculation formula for the weighting is as follows:

[0169]

[0170] in, The symbol represents the weight of the i-th frequency band. This represents element-wise multiplication. This represents the mask for the i-th frequency band;

[0171] The frequency enhancement features are obtained by converting the weighted frequency domain coefficients back to the spatial domain through the two-dimensional discrete cosine inverse transform.

[0172] Reference Figure 3 The step of performing multi-directional edge detection and edge intensity modulation on the feature map based on the edge enhancement block of the DSTEM module specifically includes:

[0173] Three separable convolutional kernels are used to perform edge detection on the feature map;

[0174] The three separable convolution kernels are the horizontal Sobel operator, the vertical Sobel operator, and the Laplacian operator, respectively. They extract edge responses from different directions through convolution operations. The formula for fusing multi-directional edge responses is as follows:

[0175]

[0176] In the above formula, the symbol * represents the convolution operation, and the symbol... This indicates taking the absolute value. , , These represent three edge detection operators. Indicates the edge response after fusion;

[0177] Adaptive weights are generated using an edge intensity modulation network;

[0178] The edge intensity modulation network includes a convolutional layer and an activation function. The convolutional layer performs feature transformation on the edge response, and the activation function uses the sigmoid function to limit the output between 0 and 1. The generated weights are used to modulate the intensity of the edge features.

[0179] The frequency enhancement features and the modulated edge features are fused together using residual connections.

[0180] The step of the encoder based on the HPSD-DDF network model performing multi-scale feature fusion processing on the target image features specifically includes:

[0181] The enhanced target image features are input into the encoder; the MSSM module is integrated into the encoder path for feature enhancement; multi-scale features are fused through top-down and bottom-up paths; the APELAN module is integrated for lightweight processing during the process; and the fused multi-scale target image features are output.

[0182] Reference Figure 3 The step of integrating the MSSM module into the encoder for feature enhancement specifically includes:

[0183] The center coordinates of the feature map are determined as the starting point for scanning. For a feature map with height H and width W, the center coordinates are calculated as (H / 2, W / 2), obtained by integer division. A spiral scan is performed sequentially in four directions: right, bottom, left, and top. The spiral scan uses an increasing step size strategy. The first scan step size is 1, moving 1 step each in the right and bottom directions; the second scan step size is 2, moving 2 steps each in the left and top directions; the step size increases sequentially in subsequent scans until the entire feature map is covered.

[0184] The feature sequence obtained by scanning is subjected to multi-scale processing, which includes three scale branches. The first branch maintains the original scale, the second branch reduces the width and height of the feature map to 2 / 3 of the original through downsampling, and the third branch reduces the width and height of the feature map to 1 / 2 of the original through downsampling.

[0185] The feature sequences at each scale are input into the corresponding S6 blocks for state space modeling. The S6 blocks implement selective sequence modeling, capturing long-range dependencies by maintaining hidden states. The state update equation is:

[0186] The output calculation equation is:

[0187] In the above formula, This represents the hidden state at time t. and Let these represent the input and output at time t, respectively. Let A be the time step parameter and A be the state transition matrix. For the input mapping matrix, To output the mapping matrix, To directly connect the matrices, all the above parameters were obtained through network learning.

[0188] The step of feature fusion of the outputs of each scale S6 block by the multi-scale spiral Mamba module specifically includes:

[0189] The shared compressor compresses the dimensions of features at each scale using a single convolutional layer. The compressed features have the same dimension, denoted as y'1, y'2, and y'3. The compressed features are then averaged and fused. The formula for calculating the average fusion is as follows:

[0190]

[0191] In the above formula, n represents the number of scales; in this embodiment, n=3. This represents the transpose of the shared compressor weights, used to map the fused features back to the original dimensions;

[0192] The fused features are enhanced using learnable scale weights; these scale weights are normalized using a Softmax function to ensure that the sum of all scale weights is 1. The formula for calculating the enhanced features is as follows:

[0193]

[0194] In the above formula, Indicates the first Original features at each scale For feature fusion weight parameters, The scale weights are used as parameters, and the Softmax function is used for normalization. This represents the multi-scale fusion feature of the final output.

[0195] Reference Figure 4 The step of integrating the APELAN module for lightweight processing during upsampling specifically includes:

[0196] The features to be processed are input into the APELAN module; the input features are sequentially passed through multiple selective cross-stage partial layers; in this embodiment, two selective cross-stage partial layers are cascaded, with the output of the first block serving as the input of the second block; 1×1 convolutions are inserted between each selective cross-stage partial block to adjust the feature dimensions; the 1×1 convolutions are used to flexibly adjust the number of feature channels to adapt to the feature expression needs of different levels; the output features of each selective cross-stage partial block are collected and concatenated along the channel dimension; the concatenated multi-level features are fused through the final 1×1 convolution to obtain the final output of the APELAN module.

[0197] Selective cross-stage partial blocks process features through a dual-branch approach. One part of the features is left unprocessed, while the other part is first extracted using APConv lightweight extraction, and then further extracted using a multilayer perceptron. Ideally, the two parts of features are concatenated and adjusted through convolution to obtain the output. By stacking multiple selective cross-stage partial blocks, selective cross-stage partial layers can be obtained.

[0198] The step of selectively processing important channels based on adaptive partial convolution in the APELAN module specifically includes:

[0199] Global average pooling is used to extract global statistical information for each channel. For the input feature X∈R^(H×W×C), global average pooling compresses the spatial dimension of each channel into a single value, resulting in a feature vector of length C. Channel importance weights are calculated using a two-layer fully connected network. The first fully connected network compresses the number of channels from C to C / r, where r is the compression ratio. The second fully connected network restores the dimension to C. Finally, the Sigmoid activation function is used to restrict the output to between 0 and 1, yielding the importance score for each channel.

[0200] The top-k channels are selected for convolution processing based on their importance scores. The top-k selection process is as follows: C channels are sorted in descending order of importance scores, and the top k channels are selected; 3×3 convolution is performed on the selected k channels, while the unselected Ck channels are kept in their original values; the processed k channels are concatenated with the Ck channels that have kept their original values ​​along the channel dimension; the concatenated features are fused using 1×1 convolution to obtain the output of the adaptive partial convolution.

[0201] This invention employs a collaborative design of three core modules, effectively solving key technical challenges in the detection of stored grain pests. The DSTEM module adaptively processes four frequency bands (ultra-low, low, mid, and high) using multi-frequency blocks (MFB) to specifically enhance the high-frequency boundary information of small targets; simultaneously, the edge enhancement block (EEB) uses multi-directional edge detection operators to further strengthen target boundary features. On the stored grain pest dataset, compared to the baseline model, the AP of small targets...50:95 The accuracy improved from 28.8% to 32.1%, a 3.3 percentage point increase, validating the effectiveness of the DSTEM module for small target detection. Furthermore, the MSSM module was integrated into the encoder, employing a spiral scanning strategy from the center outwards, prioritizing features in the central image region, consistent with the distribution characteristics of stored grain pests in insect traps. The MSSM module, based on a state-space model, achieves long-range dependency modeling with linear computational complexity, significantly reducing computational overhead compared to the self-attention mechanism of traditional Transformers. Simultaneously, the Multi-Scale Average Fusion (MSAFM) module enables efficient feature fusion with parameter sharing, significantly improving inference speed while maintaining detection accuracy. Experimental results show that the MSSM module allows the model to accurately capture target features even under complex background interference, with a high AP for medium-sized targets. 50:95 Achieving a 51.4% accuracy rate, outperforming all comparison models. Furthermore, the introduction of the APELAN module effectively reduced the model's computational complexity and parameter count. The APELAN module employs adaptive partial convolution (APConv), intelligently selecting the top-k important channels for convolution processing through a channel attention mechanism, while keeping the remaining channels unchanged, thus avoiding the information loss risk associated with fixed channel partitioning strategies. APELAN reduced the parameter count from 10.1M to 9.2M, GFLOPs from 24.8 to 19.6, and inference speed from 29.8 FPS to 37.3 FPS, while maintaining high detection accuracy, achieving an optimal balance between accuracy and efficiency.

[0202] Through the collaborative work of the three core modules mentioned above, this invention constructs a complete HPSD-DDF framework for detecting stored grain pests, achieving high-precision detection while maintaining lightweight characteristics. On a self-built stored grain pest dataset, HPSD-DDF achieves an accuracy of 94.5%. 50 and 49.8% AP 50:95 The detection accuracy was improved by 4.7% and 2.1% respectively compared to the baseline model, and the best AP was achieved at the three scales of small, medium and large targets. 50:95 The performance figures were 32.1%, 51.4%, and 47.1%, respectively. The model has only 9.2M parameters, a computational complexity of 19.6 GFLOPs, and an inference speed of 37.3 FPS, meeting the requirements for real-time detection. (Reference) Figure 5 In the comparison of detection results, HPSD-DDF showed significantly lower false positive rate, false negative rate, and duplicate detection rate than the benchmark model DEIM-D-Fine. This invention possesses good generalization ability and robustness, making it suitable for small target detection tasks in complex scenarios. It provides practical technical support for intelligent grain depot management systems, helping to reduce grain storage losses and ensure food security.

[0203] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the invention can be implemented in other specific forms without departing from its spirit or basic characteristics. Therefore, the embodiments should be considered exemplary and non-limiting in all respects. The scope of the invention is defined by the appended claims rather than the foregoing description. Therefore, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within the present invention, and no reference numerals in the claims should be construed as limiting the scope of the claims.

[0204] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A method for detecting stored grain pests based on HPSD-DDF, characterized in that, The specific steps of this method for detecting pests in stored grain are as follows: S1. Obtain images of stored grain pests in insect traps and perform data preprocessing, data augmentation, and data annotation to obtain a preprocessed image dataset. S2. Based on the DEIM-D-Fine model (High Precision Stored grain pest Detection DEIM-D-Fine), the Discrete Cosine Transform Small Target Enhancement Module (DSTEM), the Multi-Scale Spiral Mamba Module (MSSM), and the APELAN Module are introduced to construct the HPSD-DDF network model. S3. Based on the HPSD-DDF network model, the image containing stored grain pests is detected to obtain the target recognition and detection results.

2. The method for detecting stored grain pests based on HPSD-DDF according to claim 1, characterized in that: The HPSD-DDF network model specifically includes a backbone network, an encoder, and a decoder, which are connected sequentially. Wherein: the backbone network adopts a hierarchical feature extraction mechanism, the backbone network includes a Stem module, a Stage module, and a STE-Stage module, the STE-Stage module includes a DSTEM module and a convolutional module; The encoder includes a bidirectional feature fusion path that is both bottom-up and top-down. The encoder integrates an MSSM module and an APELAN module. The MSSM module includes a spiral progressive state space model and a multi-scale averaging fusion module. The MSSM module includes multiple S6 blocks. The APELAN module includes adaptive partial convolution APConv and selective cross-stage partial blocks. The decoder generates detection results through edge probability distribution modeling and a self-distillation mechanism.

3. The method for detecting stored grain pests based on HPSD-DDF according to claim 1, characterized in that: In step S1, the specific steps for acquiring image data of stored grain pests and performing data preprocessing, data annotation, and data labeling are as follows: S11. Collect images of stored grain pests in the insect trap to obtain images of stored grain pests. S12: The images of stored grain pests obtained in S11 are preprocessed and then divided into training set, validation set and test set in a ratio of 7:1:

2. S13: Perform data augmentation on the training set partitioned in S12 separately; S14: Label the enhanced training, validation, and test sets using COCO format. After labeling, the final dataset is obtained.

4. The method for detecting stored grain pests based on HPSD-DDF according to claim 1, characterized in that: In step S3, the specific steps for detecting images containing stored grain pests and obtaining detection results are as follows: S31: Input the preprocessed image dataset into the HPSD-DDF network model; S32: Based on the HPSD-DDF network model, the backbone network extracts basic features from the preprocessed image dataset to obtain the extracted target image features; S33: An encoder based on the HPSD-DDF network model performs multi-scale feature fusion processing on the target image features to obtain the fused target image features; S34: A decoder based on the HPSD-DDF network model, which decodes and predicts the features of the fused target image to obtain the target recognition and detection results.

5. The method for detecting stored grain pests based on HPSD-DDF according to claim 4, characterized in that: In step S32, the specific steps for extracting basic features of stored grain pest images based on the backbone network of the HPSD-DDF model are as follows: S321: Input the preprocessed image dataset into the backbone network; S322: The Stem module based on the backbone network performs channel adjustment and feature extraction on the preprocessed image dataset to obtain a preliminary target feature map; S323: The Stage module based on the backbone network performs convolution and spatial channel dimension transformation on the initial target feature map to obtain the intermediate target feature map; S324: The complex STE-Stage module based on the backbone network performs frequency domain enhancement and edge feature enhancement processing on the intermediate target feature map to obtain the enhanced target image features.

6. The method for detecting stored grain pests based on HPSD-DDF according to claim 5, characterized in that: In step S324, the specific steps for edge feature enhancement processing of the intermediate target feature map are as follows: S3241: Input the preliminary target feature map into the DSTEM module; S3242: Based on the DSTEM module, a multi-frequency block performs two-dimensional discrete cosine transform (DCT) on the preliminary target feature map, converting spatial domain features into frequency domain coefficients. S3243: Generates weights for four different frequency bands based on frequency domain coefficients, corresponding to ultra-low frequency, low frequency, mid frequency and high frequency components respectively; S3244: Attention weights are applied to each frequency band through a frequency attention mechanism to obtain frequency-enhanced features; S3245: Convert the frequency enhancement features back to the spatial domain using inverse DCT transform; S3246: An edge enhancement block based on the DSTEM module, which uses Sobel-X, Sobel-Y and Laplacian operators to perform multi-directional edge detection on the feature map; S3247: Adaptive weights are generated through an edge intensity modulation network to selectively emphasize edge features; S3248: The frequency enhancement features and edge enhancement features are fused through residual connections to obtain the enhanced target feature map.

7. The method for detecting stored grain pests based on HPSD-DDF according to claim 6, characterized in that: In step S3248, the specific steps for fusing frequency enhancement features and edge enhancement features through residual connection are as follows: S3248-1: Input the enhanced target feature map into the encoder; S3248-2: Multi-scale feature fusion based on bottom-up and top-down paths of the encoder; S3248-3: Integrate the MSSM module and APELAN module for feature enhancement during the feature fusion process; S3248-4: Output the fused multi-scale target image features.

8. The method for detecting stored grain pests based on HPSD-DDF according to claim 7, characterized in that: In S3248-3, the specific steps for integrating the MSSM module and APELAN module to perform feature enhancement processing during feature fusion are as follows: S3248-3-1: Spiral Progressive State Space Model (SPSSM) based on MSSM module, starting from the center coordinates of the feature map, and performing a spiral scan with increasing step size in four directions: right, down, left, and up; S3248-3-2: Process scanned features at multiple scales through adaptive downsampling and upsampling operations; S3248-3-3: Input the scanning results at different scales into the corresponding S6 blocks for state space modeling; S3248-3-4: The S6 block adopts a selective scanning mechanism and performs feature processing according to the state space formula. S3248-3-5: The output features of multiple S6 blocks are fused using the Multi-Scale Average Fusion Module (MSAFM). S3248-3-6: The MSAFM uses a shared compressor to extract key information of features at each scale, and obtains fused features through averaging and expansion operations; S3248-3-7: Adaptive partial convolution APConv based on APELAN module, calculating importance weights through channel attention analysis; S3248-3-8: Select the top-k most important channels based on the learned importance scores and perform 3×3 convolution processing, while keeping the other channels unchanged; S3248-3-9: Selective cross-stage partial block SCSPB based on APELAN module divides the input features into two branches along the channel dimension after expansion by 1×1 convolution; S3248-3-10: One branch processes the APConv and MLP layers sequentially, while the other branch maintains the direct feature flow; S3248-3-11: After concatenating the features of the two branches along the channel dimension, the features are fused by a final 1×1 convolution to obtain the lightweight features.

9. The method for detecting stored grain pests based on HPSD-DDF according to claim 2, characterized in that: The decoder of the HPSD-DDF model generates prediction results, which specifically include: The fused multi-scale target image features are input into the decoder; the decoder models each edge of the bounding box as a probability distribution through a fine-grained distribution refinement mechanism; a global optimal localization self-distillation mechanism is adopted to transfer deep localization knowledge to the shallow layer; accurate bounding box prediction and category classification results are generated, and detection results of eight target grain storage pests are obtained.