A dense micro-agricultural pest detection method and system based on multi-scale perception and dynamic reconstruction
By constructing a full-scale feature pyramid detection architecture and combining multi-scale perception and dynamic reconstruction technology, the problems of feature information loss, boundary confusion and localization convergence in pest detection under complex field environments have been solved, and the accurate monitoring and automatic counting of pest targets have been achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HUAIHUA UNIV
- Filing Date
- 2026-02-12
- Publication Date
- 2026-06-02
AI Technical Summary
Existing target detection technologies struggle to effectively handle situations where pest targets have extremely low pixel ratios, high individual density, and strong background camouflage in complex field environments. This leads to issues such as loss of feature information, confusion of dense boundaries, and difficulty in convergence of localization and regression.
A detection method based on multi-scale perception and dynamic reconstruction is adopted. By constructing a full-scale feature pyramid detection architecture, embedding a context enhancement module, a dynamic reconstruction upsampler, and a dual-branch hole perception module, and combining an adaptive auxiliary scaling bounding box regression loss optimization strategy, the accurate detection of pest targets is achieved.
It significantly improves the accuracy of pest monitoring in complex natural scenarios, solves the problems of "not being able to see, distinguish, or accurately locate" pests, and improves the detection rate and positioning accuracy of tiny targets.
Smart Images

Figure CN122135401A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the interdisciplinary field of computer vision and smart agriculture. In particular, it relates to a method and system for detecting dense micro-agricultural pests based on multi-scale perception and dynamic reconstruction, which is used for accurate monitoring and automatic counting of highly dense and extremely small agricultural pests in complex field natural environments. It is especially suitable for embedded monitoring lamp terminals or agricultural Internet of Things cloud analysis platforms. Background Technology
[0002] Precise monitoring and early warning of agricultural pests are crucial for reducing pesticide use and increasing efficiency, and for ensuring national food security. With the rapid development of smart agriculture and the Internet of Things (IoT), the use of automatic field monitoring lights combined with computer vision technology for pest image acquisition and intelligent identification has gradually replaced traditional manual surveys, becoming the mainstream technology for modern plant protection monitoring. This non-contact, automated monitoring method can acquire field pest data around the clock, providing a scientific basis for early warning and precise control of pests and diseases.
[0003] However, image detection for pests trapped by monitoring lights faces numerous severe challenges in complex field environments, significantly limiting the practical accuracy of monitoring systems. First, the targets are extremely small and lack features. Important agricultural pests such as rice planthoppers and leafhoppers often occupy only a very small pixel area (typically less than 32×32 pixels) in large-field-of-view monitoring images with tens of millions of pixels, making their visual features extremely weak. Existing target detection algorithms based on deep convolutional neural networks (CNNs) typically employ multiple downsampling operations to expand the receptive field. This easily leads to over-compression or even complete loss of the texture and edge features of tiny targets in the deep network, resulting in serious missed detections.
[0004] Secondly, the targets are densely distributed and severely obscured. During peak pest outbreaks, pests in the traps of monitoring lights often exhibit high-density stacking and sticking together, with blurred boundaries between individuals. Traditional general detection models often use simple upsampling methods such as nearest neighbor or bilinear interpolation in the feature fusion stage, which struggles to effectively reconstruct dense spatial details while restoring resolution. This leads to feature confusion between adjacent targets, resulting in erroneous merged detection boxes during post-processing. Furthermore, strong background noise interference is a significant issue. Field imaging environments are complex and variable, and traps often contain plant debris, raindrop stains, reflective spots, and non-target insects. These background noises often have a high degree of similarity in morphology and color to tiny pests, easily inducing false detections.
[0005] In existing technologies, most mainstream one-stage object detection algorithms (such as the YOLO series) are designed for general objects of medium to large scale (such as vehicles and pedestrians), lacking explicit mechanisms for preserving minute textures and dynamic feature reconstruction capabilities. Meanwhile, during the training phase, while commonly used IoU series and their improved versions (such as CIoU and SIoU) bounding box regression loss functions have solved some convergence problems, they often employ fixed geometric calculation methods or static auxiliary scaling ratios (such as Inner-IoU), failing to adaptively adjust based on the real-time overlap between predicted and ground truth bounding boxes during training. When facing extremely small targets, these traditional strategies are prone to imbalances in sample difficulty, leading to insufficient gradients on difficult samples or over-optimization on simple samples. This makes it difficult to balance accelerated convergence with accurate localization in the localization regression of small targets, further affecting the detection accuracy. Therefore, there is an urgent need to develop a dedicated pest detection method that can jointly perceive local texture and environmental context, possess dynamic feature refinement and reconstruction capabilities, and effectively solve the convergence problem of small target localization. Summary of the Invention
[0006] To address the above technical problems, this invention provides a method and system for detecting dense micro-agricultural pests based on multi-scale perception and dynamic reconstruction. It is mainly used to solve the bottleneck problems faced by existing target detection technologies when dealing with pest target pixels with extremely low pixel ratios, high individual density, and strong background camouflage in complex field natural environments, such as loss of feature information, confusion of dense boundaries, and difficulty in convergence of localization regression.
[0007] The technical solution adopted by this invention to solve its technical problem is: A method for detecting dense micro-agricultural pests based on multi-scale sensing and dynamic reconstruction, the method comprising the following steps: S100: Collect and preprocess high-density stacked pest images to construct a multi-scale micro-target dataset, and construct a full-scale feature pyramid detection architecture containing a high-resolution feature layer, wherein the architecture includes a backbone network, a neck network and a detection head connected in sequence. S200: Input the dataset into the backbone network for feature extraction. The backbone network contains a context enhancement module for global and local recalibration of the extracted multi-scale features to suppress background noise and enhance the pest target features. S300: The recalibrated multi-scale features are input into the neck network for multi-scale fusion. The neck network is equipped with a dynamic reconstruction upsampler, which is used to perform content-aware dynamic feature reconstruction on low-resolution feature maps to decouple densely clustered pest targets. S400: The fused feature map is input into the detection head for prediction. The detection head is equipped with a dual-branch hole perception module, which is used to extract and fuse local texture features and environmental semantic features in parallel, and output the target's category and location prediction information. S500: The full-scale feature pyramid detection architecture is trained using an adaptive auxiliary scaling bounding box regression loss optimization strategy based on real-time IoU feedback. The trained full-scale feature pyramid detection architecture is then used to detect pests in the input image, and the final pest detection result is output.
[0008] Preferably, the full-scale feature pyramid detection architecture is constructed in S100, including: S110: Based on the CSPDarknet backbone architecture, the original image is input into the network and then features are extracted step by step. S120: Extract the feature layer from the backbone network that is 4 times lower in resolution than the input image as the P2 layer, which is used to characterize the texture details of extremely small targets; S130: Extract the feature layers in the backbone network that are reduced by 8 times, 16 times and 32 times respectively relative to the resolution of the input image as layers P3, P4 and P5, which correspond to the feature representation of small targets, medium targets and large targets respectively. S140: Construct a neck structure that includes a Feature Pyramid Network (FPN) and a Path Aggregation Network (PAN), and perform bidirectional fusion of features from layers P5 to P2, so that deep semantic information is transmitted to the lower layers and lower-level localization information is transmitted to the higher layers, forming a multi-scale feature map that complements semantics and details.
[0009] Preferably, S200 includes: S210: Divide the input feature tensor into g subgroups along the channel dimension, and perform the following feature extraction operation in parallel for each subgroup; S220: Construct a parallel dual-branch structure with different receptive fields. The first branch uses 3×3 standard convolution to extract local features, and the second branch uses 3×3 dilated convolution to extract environmental context features. S230: The features output from the two branches are aggregated element by element, and spatial information is compressed through a global average pooling layer; S240: The channel weights are learned using a 1×1 convolution, and after Sigmoid activation, the aggregated features are reweighted to output an enhanced feature map.
[0010] Preferably, S300 includes: S310: Receives a low-resolution feature map and uses a linear projection layer to adaptively generate the initial sampling point offset based on the input feature content; S320: The offset tensor is reshaped into a high-resolution dynamic sampling grid using a pixel recombination operation. Based on this grid, position-sensitive content-aware resampling is performed on the input feature map to generate a dynamic upsampled feature map. S330: The dynamically sampled feature map is added element-wise to the output of the detail enhancement branch, and the dynamically reconstructed features and high-frequency texture details are fused to obtain the final reconstructed upsampled feature map.
[0011] Preferably, S400 includes: S410: The input feature stream is divided into two parts along the channel dimension using the Split operation; S420: The first part extracts local texture through standard 3×3 depthwise separable convolution; the second part extracts environmental semantics through 3×3 hole-deep separable convolution with a dilation rate of 2. S430: Perform a concatenation operation on the output features of the two branches along the channel dimension; S440: The concatenated features are fused and reduced in dimensionality using a 1×1 convolutional layer and mapped to the predicted output.
[0012] Preferably, S500 introduces auxiliary scaling to optimize loss calculation, specifically including: S510: Calculate the adaptive scaling ratio: Calculate the intersection-union ratio (IU) of the original predicted bounding box and the ground truth bounding box. And calculate the dynamic auxiliary scaling ratio based on the principle of negative feedback. The formula is: , where α is the sensitivity coefficient; S520: Obtain the original bounding box geometry parameters: Obtain the coordinates of the center point of the predicted bounding box respectively. ,width With height and the center point coordinates of the actual bounding box ,width With height This provides the basic geometric data for the subsequent generation of auxiliary bounding boxes; S530: Generating Adaptive Auxiliary Bounding Boxes: To construct a virtual overlap region for gradient backpropagation, the formula is used... , , and Generate adaptively scaled auxiliary bounding boxes while preserving the center point. constant; S540: Calculate and apply adaptive regression loss: Calculate the CIoU loss value based on the adaptively scaled auxiliary bounding box, which serves as the final regression loss function. Instead of calculating the loss at the original scale, this method drives the network parameters to converge rapidly to the true bounding box. The formula is as follows: in, v is the intersection-union ratio between the adaptively scaled auxiliary bounding box and the true bounding box. Aspect ratio consistency parameter These are the weighting coefficients. It predicts the center point coordinates of the auxiliary bounding box. , The coordinates of the center point of the true bounding box , Let Euclidean distance be the square of the distance between the two center points. The diagonal length of the minimum bounding rectangle covering the adaptively scaled auxiliary bounding box and the true bounding box is the square of the length of the rectangle.
[0013] Preferably, in S500, the trained full-scale feature pyramid detection architecture is used to detect pests in the input image, and the final pest detection result is output, including: S550: Summarize the prediction results of the four scales P2, P3, P4 and P5 to obtain a set of candidate boxes containing all potential targets; S560: Perform non-maximum suppression on the candidate box set, set an IoU threshold to remove redundant detection boxes with excessive overlap, and retain the optimal bounding box corresponding to the local maxima; S570: For the candidate bounding boxes of tiny targets output by the P2 layer, set an independent confidence filtering threshold that is different from other scales, and prioritize retaining extremely tiny targets with confidence scores higher than the threshold to prevent tiny targets from being suppressed by low-confidence bounding boxes of large-scale targets. S580: Map the filtered bounding box coordinates back to the original image coordinate system, and output the final bounding box coordinates and their corresponding pest category labels.
[0014] A dense detection system for small agricultural pests based on multi-scale sensing and dynamic reconstruction includes: The detection architecture building module is used to collect and preprocess high-density stacked pest images to construct a multi-scale micro-target dataset and build a full-scale feature pyramid detection architecture containing a high-resolution feature layer. The architecture includes a backbone network, a neck network and a detection head connected in sequence. The feature extraction module is used to input the dataset into the backbone network for feature extraction. The backbone network contains a context enhancement module, which is used to perform global and local recalibration on the extracted multi-scale features to suppress background noise and enhance the pest target features. The multi-scale fusion module is used to input the recalibrated multi-scale features into the neck network for multi-scale fusion. The neck network is equipped with a dynamic reconstruction upsampler, which is used to perform content-aware dynamic feature reconstruction on low-resolution feature maps to decouple densely clustered pest targets. The prediction module is used to input the fused feature map into the detection head for prediction. The detection head is equipped with a dual-branch hole perception module, which is used to extract and fuse local texture features and environmental semantic features in parallel, and output the target's category and location prediction information. The pest detection module is used to train the full-scale feature pyramid detection architecture using an adaptive auxiliary scaling bounding box regression loss optimization strategy based on real-time IoU feedback. The trained full-scale feature pyramid detection architecture is then used to detect pests in the input image and output the final pest detection results.
[0015] A computer device includes a memory and a processor, the memory storing a computer program, characterized in that the processor executes the computer program to implement the steps of a method for detecting dense micro-agricultural pests based on multi-scale sensing and dynamic reconstruction.
[0016] A computer-readable storage medium having a computer program stored thereon, characterized in that, when the computer program is executed by a processor, it implements the steps of a method for detecting dense micro-agricultural pests based on multi-scale sensing and dynamic reconstruction.
[0017] The aforementioned method and system for detecting dense, small agricultural pests based on multi-scale perception and dynamic reconstruction employs a comprehensive system-level improvement scheme for dense, small targets. This scheme addresses the challenges of "invisibility, indistinguishability, and inaccuracy" in agricultural pest monitoring by dynamically focusing computational resources on the joint perception of micro-textures and environmental semantics. This significantly improves monitoring efficiency in complex natural scenarios. Attached Figure Description
[0018] Figure 1 This is a flowchart of a dense micro-agricultural pest detection method based on multi-scale sensing and dynamic reconstruction in an embodiment of the present invention. Figure 2 This is a schematic diagram of the overall network architecture of the dense micro-agricultural pest detection system in this embodiment of the invention; Figure 3 This is a detailed structural diagram of the context enhancement module in an embodiment of the present invention; Figure 4 This is a schematic diagram of the structure of the dynamic reconfiguration upsampler in an embodiment of the present invention. Detailed Implementation
[0019] To enable those skilled in the art to better understand the technical solution of the present invention, the present invention will be further described in detail below with reference to the accompanying drawings.
[0020] It is particularly important to emphasize that the core of the following embodiments is to demonstrate how to apply the "multi-scale perception and dynamic reconstruction" method proposed in this invention to solve the problem of accurate detection of agricultural pests (such as rice planthoppers, aphids, thrips, etc.) that are densely distributed, extremely small in size, and have strong background camouflage in complex field environments.
[0021] Example: Precise monitoring of dense microscopic pests in complex field environments.
[0022] This embodiment assumes an application scenario of monitoring high-density brown planthoppers in rice paddies. The goal is to significantly improve the detection rate and positioning accuracy of pest targets with extremely low pixel ratios (<32×32 pixels) and overlapping structures by applying the method of this invention to embedded agricultural IoT devices or edge computing nodes.
[0023] In one embodiment, such as Figure 1 and Figure 2 As shown, a method for detecting dense micro-agricultural pests based on multi-scale perception and dynamic reconstruction is described, the method comprising the following steps.
[0024] S100: Collect and preprocess high-density stacked pest images to construct a multi-scale micro-target dataset, and construct a full-scale feature pyramid detection architecture containing high-resolution feature layers, wherein the architecture includes a backbone network, a neck network and a detection head connected in sequence.
[0025] Specifically, multimodal image data from the field was collected and preprocessed. Based on the extremely small size of pests in the images, a backbone network architecture based on CSPDarknet was constructed, and a full-scale feature pyramid detection architecture covering four feature levels from P2 to P5 was built. To address the extremely low pixel proportion and uneven distribution of pest targets in the images, a P2 detection layer that preserves high-resolution texture features was explicitly added to the conventional detection architecture, and a context enhancement module (DCE-Block) was embedded in the backbone network.
[0026] In one embodiment, S100 constructs a full-scale feature pyramid detection architecture, including: S110: Based on the CSPDarknet backbone architecture, the original image is input into the network and then features are extracted step by step. S120: Extract the feature layer from the backbone network that is 4 times lower in resolution than the input image as the P2 layer, which is used to characterize the texture details of extremely small targets; S130: Extract the feature layers in the backbone network that are reduced by 8 times, 16 times and 32 times respectively relative to the resolution of the input image as layers P3, P4 and P5, which correspond to the feature representation of small targets, medium targets and large targets respectively. S140: Construct a neck structure that includes a Feature Pyramid Network (FPN) and a Path Aggregation Network (PAN), and perform bidirectional fusion of features from layers P5 to P2, so that deep semantic information is transmitted to the lower layers and lower-level localization information is transmitted to the higher layers, forming a multi-scale feature map that complements semantics and details.
[0027] Specifically, the detailed descriptions of the four levels are shown in Table 1: Table 1 To overcome the limitation of conventional detection models (such as YOLOv8 / v10) that only start detection from the P3 layer (8x downsampling), this embodiment explicitly constructs a P2 feature layer (4x downsampling). By preserving this high-resolution layer, the network can retain detailed texture information of tiny pest edges before deep semantic abstraction, enabling the network to capture weak target signals before deep semantic abstraction, laying the foundation for solving the "invisible" problem later. Simultaneously, context enhancement modules (DCE-Block) are embedded in various stages of the backbone network to replace traditional bottleneck layers, introducing background suppression mechanisms from the early stages of feature extraction.
[0028] S200: Input the dataset into the backbone network for feature extraction. The backbone network contains a context enhancement module for global and local recalibration of the extracted multi-scale features to suppress background noise and enhance the pest target features.
[0029] Specifically, when image data flows through the backbone network, DCE-Block is used to perform differential feature extraction and recalibration. DCE-Block divides the input features along the channel dimension into local feature subgroups and context feature subgroups. Differential features are extracted using standard convolution and dilated convolution with a dilation rate of 2, respectively. A cross-dimensional attention mechanism is used to establish global dependency encoding between channels and space. The aggregated feature channels are then recalibrated and filtered, thereby decoupling the pest target from the complex background during the feature extraction stage.
[0030] In one embodiment, such as Figure 3 As shown, S200 includes three key components: S210: Divide the input feature tensor into g subgroups along the channel dimension, and perform the following feature extraction operation in parallel for each subgroup; S220: Construct a parallel dual-branch structure with different receptive fields. The first branch uses 3×3 standard convolution to extract local features of the pest body, and the second branch uses 3×3 dilated convolution (Dilation=2) to extract broader environmental context features (such as leaf vein direction and light changes), expanding the receptive field without reducing resolution. S230: The features output from the two branches are aggregated element by element, and spatial information is compressed through a global average pooling layer; S240: The channel weights are learned using a 1×1 convolution, and after Sigmoid activation, the aggregated features are reweighted to output an enhanced feature map.
[0031] Specifically, the two sets of features are fused and then processed using a cross-dimensional attention mechanism. This mechanism utilizes global average pooling and... The convolution learns the dependencies between channels and generates weight vectors to recalibrate the feature channels, thereby automatically suppressing complex background noise and highlighting the feature responses of pests.
[0032] S300: The recalibrated multi-scale features are input into the neck network for multi-scale fusion. The neck network is equipped with a dynamic reconstruction upsampler, which is used to perform content-aware dynamic feature reconstruction on low-resolution feature maps to decouple densely clustered pest targets.
[0033] In one embodiment, such as Figure 4 As shown, S300 includes: S310: Receives a low-resolution feature map and uses a linear projection layer to adaptively generate the initial sampling point offset based on the input feature content; S320: The offset tensor is reshaped into a high-resolution dynamic sampling grid using a pixel recombination operation. Based on this grid, position-sensitive content-aware resampling is performed on the input feature map to generate a dynamic upsampled feature map. S330: The dynamically sampled feature map is added element-wise to the output of the detail enhancement branch, and the dynamically reconstructed features and high-frequency texture details are fused to obtain the final reconstructed upsampled feature map.
[0034] Specifically, in the feature fusion stage of the neck network, to address the "adhesion" and "blurring" problems easily caused by dense pests, a dynamic reconstruction upsampler (DR-Upsampler) is used instead of traditional interpolation upsampling to perform dynamic feature reconstruction. In this process, the network no longer performs simple pixel duplication or linear interpolation, but instead learns content-aware offsets and combines them with pixel recombination techniques. This allows for the intelligent recovery of high-frequency texture details from the upsampling process without introducing excessive computational overhead, thereby effectively separating the boundaries of adhered targets within high-density regions at the feature map level. The specific dynamic reconstruction operations include: Dynamic Offset Prediction: Utilizing a spatial weight mask generated by large-kernel convolution, the sampling offset of each pixel is predicted. Pixel Shuffle: Based on the predicted offset, pixel shuffle is used to map low-resolution features to a high-resolution mesh. This non-linear resampling method allows the network to adaptively adjust the sampling point positions, effectively "separating" the boundaries of clustered pests at the feature map level. Texture Compensation: Detail information extracted from high-frequency residual branches is simultaneously overlaid to repair texture loss during the upsampling process.
[0035] S400: The fused feature map is input into the detection head for prediction. The detection head is equipped with a dual-branch hole perception module, which is used to extract and fuse local texture features and environmental semantic features in parallel, and output the target's category and location prediction information.
[0036] Specifically, in the detection head section, PestConv prediction is performed on the feature maps at the four scales from P2 to P5.
[0037] In one embodiment, S400 includes: S410: The input feature stream is divided into two parts along the channel dimension using the Split operation; S420: The first part extracts local texture through standard 3×3 depthwise separable convolution; the second part extracts environmental semantics through 3×3 hole-deep separable convolution with a dilation rate of 2. S430: Perform a concatenation operation on the output features of the two branches along the channel dimension; S440: The concatenated features are fused and reduced in dimensionality using a 1×1 convolutional layer and mapped to the predicted output.
[0038] Specifically, a dual-branch hole perception module is applied in the detection head to perform differential feature extraction and fusion. Parallel local branches and environmental context branches are constructed to split the feature stream. The local branch uses standard depthwise separable convolution to extract the texture of the pest body, while the context branch uses hole depthwise separable convolution to extract environmental semantics. The two feature streams are concatenated and then fused. Finally, the class confidence and bounding box coordinates of the target are regressed to ensure accurate differentiation of adjacent targets even in dense scenes.
[0039] S500: The full-scale feature pyramid detection architecture is trained using an adaptive auxiliary scaling bounding box regression loss optimization strategy based on real-time IoU feedback. The trained full-scale feature pyramid detection architecture is then used to detect pests in the input image, and the final pest detection result is output.
[0040] Specifically, in the backpropagation stage of model training, to address the gradient vanishing or optimization stagnation problem caused by the large spatial distance or lack of overlap (IoU=0) between the predicted bounding box and the ground truth (for small pest targets) in the early stage of training, this invention introduces a dynamic adaptive ratio based on real-time IoU feedback to optimize the loss calculation.
[0041] In one embodiment, the dynamic adaptive scaling mechanism based on real-time IoU feedback in S500 optimizes the loss calculation, specifically including: S510: Calculate the adaptive scaling ratio: Calculate the intersection-union ratio (IU) of the original predicted bounding box and the ground truth bounding box. And calculate the dynamic auxiliary scaling ratio based on the principle of negative feedback. This dynamic scaling mechanism establishes an inverse mapping relationship with the original overlap using a negative feedback mechanism. In the early stages of training when the overlap is low, it automatically increases the scale of the auxiliary bounding box, thereby generating a strong and effective gradient signal by constructing virtual overlap, guiding the model to converge quickly. The formula is: , where α is the sensitivity coefficient; S520: Obtain the original bounding box geometry parameters: Obtain the coordinates of the center point of the predicted bounding box respectively. ,width With height and the center point coordinates of the actual bounding box ,width With height This provides the basic geometric data for the subsequent generation of auxiliary bounding boxes; S530: Generating Adaptive Auxiliary Bounding Boxes: To construct a virtual overlap region for gradient backpropagation, the formula is used... , , and Generate adaptively scaled auxiliary bounding boxes while preserving the center point. constant; S540: Calculate and apply adaptive regression loss: Calculate the CIoU loss value based on the adaptively scaled auxiliary bounding box described above, and use it as the final regression loss function. Instead of calculating the loss at the original scale, this method drives the network parameters to converge rapidly to the true bounding box. The formula is as follows: in, v is the intersection-union ratio between the adaptively scaled auxiliary bounding box and the true bounding box. Aspect ratio consistency parameter These are the weighting coefficients. It predicts the center point coordinates of the auxiliary bounding box. , The coordinates of the center point of the true bounding box , Let Euclidean distance be the square of the distance between the two center points. The diagonal length of the minimum bounding rectangle covering the adaptively scaled auxiliary bounding box and the true bounding box is the square of the length of the rectangle.
[0042] Specifically, unlike existing technologies that directly calculate CIoU loss based on predicted and ground truth bounding boxes, this invention proposes an adaptive scaling mechanism, AI-CIOU, based on real-time IoU feedback. This mechanism first calculates the original IoU as a feedback signal and then dynamically generates a scaling factor. An auxiliary bounding box with higher gradient sensitivity is constructed, and the loss is calculated within this auxiliary bounding box space. This allows the model to obtain greater gradient guidance in the early stages of training or when facing difficult samples, while automatically regressing to a refined regression state in the later stages of training, thus balancing convergence speed and localization accuracy.
[0043] In one embodiment, S500 uses a trained full-scale feature pyramid detection architecture to detect pests in the input image and outputs the final pest detection result, including: S550: Summarize the prediction results of the four scales P2, P3, P4 and P5 to obtain a set of candidate boxes containing all potential targets; S560: Perform non-maximum suppression on the candidate box set, set an IoU threshold to remove redundant detection boxes with excessive overlap, and retain the optimal bounding box corresponding to the local maxima; S570: For the candidate bounding boxes of tiny targets output by the P2 layer, set an independent confidence filtering threshold that is different from other scales, and prioritize retaining extremely tiny targets with confidence scores higher than the threshold to prevent tiny targets from being suppressed by low-confidence bounding boxes of large-scale targets. S580: Map the filtered bounding box coordinates back to the original image coordinate system, and output the final bounding box coordinates and their corresponding pest category labels.
[0044] Specifically, full-scale target capture and result output are implemented during the inference stage. The image to be tested is input into the model, and the high-resolution features of the P2 layer are used to retain information on tiny pests with extremely low pixel ratios. That is, it specifically captures those extremely small larval targets that are easily lost by downsampling in conventional models. Combined with the multi-scale detection results from the P2 to P5 layers, the model covers the entire growth cycle from larva to adult. Non-maximum suppression is performed on the output candidate box set to eliminate redundant detections. Finally, the accurate pest count categories and bounding box coordinates are calculated, providing a basis for agricultural plant protection decisions.
[0045] The aforementioned method for detecting dense, small agricultural pests based on multi-scale perception and dynamic reconstruction addresses the challenges of detection in complex field environments due to the extremely low pixel ratio, highly dense distribution, and strong background camouflage of pest targets. It proposes a full-scale feature pyramid detection architecture covering four feature levels, from P2 to P5. First, a context enhancement module is embedded in the backbone network, utilizing dilated convolution and cross-dimensional attention mechanisms to perform feature recalibration, dynamically suppressing background noise while preserving resolution. Second, in the feature fusion stage, a dynamic reconstruction upsampler is employed to perform dynamic feature reconstruction, using spatially aware masks to guide point resampling and fusing high-frequency texture residuals to decouple the feature boundaries of densely clustered targets. Third, a dual-branch dilated perception module is applied in the detection head to perform differential feature extraction and fusion, thereby jointly perceiving local texture and environmental semantics. Finally, during the training phase, an auxiliary scaling factor is introduced to optimize the bounding box regression loss, and the convergence problem of small target localization is solved by constructing virtual overlapping regions. This method effectively solves the problems of missed and false detections of densely clustered small pests, improving monitoring accuracy in complex natural scenes.
[0046] In one embodiment, a dense detection system for micro-agricultural pests based on multi-scale sensing and dynamic reconstruction is also provided, comprising: The detection architecture building module is used to collect and preprocess high-density stacked pest images to construct a multi-scale micro-target dataset and build a full-scale feature pyramid detection architecture containing a high-resolution feature layer. The architecture includes a backbone network, a neck network and a detection head connected in sequence. The feature extraction module is used to input the dataset into the backbone network for feature extraction. The backbone network contains a context enhancement module, which is used to perform global and local recalibration on the extracted multi-scale features to suppress background noise and enhance the pest target features. The multi-scale fusion module is used to input the recalibrated multi-scale features into the neck network for multi-scale fusion. The neck network is equipped with a dynamic reconstruction upsampler, which is used to perform content-aware dynamic feature reconstruction on low-resolution feature maps to decouple densely clustered pest targets. The prediction module is used to input the fused feature map into the detection head for prediction. The detection head is equipped with a dual-branch hole perception module, which is used to extract and fuse local texture features and environmental semantic features in parallel, and output the target's category and location prediction information. The pest detection module is used to train the full-scale feature pyramid detection architecture using an adaptive auxiliary scaling bounding box regression loss optimization strategy based on real-time IoU feedback. The trained full-scale feature pyramid detection architecture is then used to detect pests in the input image and output the final pest detection results.
[0047] Specific limitations regarding the dense micro-agricultural pest detection system based on multi-scale sensing and dynamic reconstruction can be found in the limitations of the dense micro-agricultural pest detection method based on multi-scale sensing and dynamic reconstruction described above, and will not be repeated here. Each module in the aforementioned dense micro-agricultural pest detection system based on multi-scale sensing and dynamic reconstruction can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.
[0048] In one embodiment, a computer device is also provided, including a memory and a processor, the memory storing a computer program, characterized in that the processor executes the computer program to implement the steps of a method for detecting dense micro-agricultural pests based on multi-scale sensing and dynamic reconstruction.
[0049] In one embodiment, a computer-readable storage medium is also provided, on which a computer program is stored, characterized in that, when the computer program is executed by a processor, it implements the steps of a method for detecting dense micro-agricultural pests based on multi-scale perception and dynamic reconstruction.
[0050] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0051] The foregoing has provided a detailed description of the method and system for detecting dense micro-agricultural pests based on multi-scale sensing and dynamic reconstruction provided by this invention. Specific examples have been used to illustrate the principles and implementation methods of this invention, and the descriptions of the embodiments above are merely for the purpose of helping to understand the core ideas of this invention. It should be noted that those skilled in the art can make various improvements and modifications to this invention without departing from the principles of this invention, and these improvements and modifications also fall within the protection scope of the claims of this invention.
Claims
1. A method for detecting dense micro-agricultural pests based on multi-scale sensing and dynamic reconstruction, characterized in that, The method includes the following steps: S100: Collect and preprocess high-density stacked pest images to construct a multi-scale micro-target dataset, and construct a full-scale feature pyramid detection architecture containing a high-resolution feature layer, wherein the architecture includes a backbone network, a neck network and a detection head connected in sequence. S200: Input the dataset into the backbone network for feature extraction. The backbone network contains a context enhancement module for global and local recalibration of the extracted multi-scale features to suppress background noise and enhance the pest target features. S300: The recalibrated multi-scale features are input into the neck network for multi-scale fusion. The neck network is equipped with a dynamic reconstruction upsampler, which is used to perform content-aware dynamic feature reconstruction on low-resolution feature maps to decouple densely clustered pest targets. S400: The fused feature map is input into the detection head for prediction. The detection head is equipped with a dual-branch hole perception module, which is used to extract and fuse local texture features and environmental semantic features in parallel, and output the target's category and location prediction information. S500: The full-scale feature pyramid detection architecture is trained using an adaptive auxiliary scaling bounding box regression loss optimization strategy based on real-time IoU feedback. The trained full-scale feature pyramid detection architecture is then used to detect pests in the input image, and the final pest detection result is output.
2. The method according to claim 1, characterized in that, The S100 architecture constructs a full-scale feature pyramid detection system, including: S110: Based on the CSPDarknet backbone architecture, the original image is input into the network and then features are extracted step by step. S120: Extract the feature layer from the backbone network that is 4 times lower in resolution than the input image as the P2 layer, which is used to characterize the texture details of extremely small targets; S130: Extract the feature layers in the backbone network that are reduced by 8 times, 16 times and 32 times respectively relative to the resolution of the input image as layers P3, P4 and P5, which correspond to the feature representation of small targets, medium targets and large targets respectively. S140: Construct a neck structure that includes a Feature Pyramid Network (FPN) and a Path Aggregation Network (PAN), and perform bidirectional fusion of features from layers P5 to P2, so that deep semantic information is transmitted to the lower layers and lower-level localization information is transmitted to the higher layers, forming a multi-scale feature map that complements semantics and details.
3. The method according to claim 2, characterized in that, S200 includes: S210: Divide the input feature tensor into g subgroups along the channel dimension, and perform the following feature extraction operation in parallel for each subgroup; S220: Construct a parallel dual-branch structure with different receptive fields. The first branch uses 3×3 standard convolution to extract local features, and the second branch uses 3×3 dilated convolution to extract environmental context features. S230: The features output from the two branches are aggregated element by element, and spatial information is compressed through a global average pooling layer; S240: The channel weights are learned using a 1×1 convolution, and after Sigmoid activation, the aggregated features are reweighted to output an enhanced feature map.
4. The method according to claim 3, characterized in that, The S300 includes: S310: Receives a low-resolution feature map and uses a linear projection layer to adaptively generate the initial sampling point offset based on the input feature content; S320: The offset tensor is reshaped into a high-resolution dynamic sampling grid using a pixel recombination operation. Based on this grid, position-sensitive content-aware resampling is performed on the input feature map to generate a dynamic upsampled feature map. S330: The dynamically sampled feature map is added element-wise to the output of the detail enhancement branch, and the dynamically reconstructed features and high-frequency texture details are fused to obtain the final reconstructed upsampled feature map.
5. The method according to claim 4, characterized in that, The S400 includes: S410: The input feature stream is divided into two parts along the channel dimension using the Split operation; S420: The first part extracts local texture through standard 3×3 depthwise separable convolution; the second part extracts environmental semantics through 3×3 hole-deep separable convolution with a dilation rate of 2. S430: Perform a concatenation operation on the output features of the two branches along the channel dimension; S440: The concatenated features are fused and reduced in dimensionality using a 1×1 convolutional layer and mapped to the predicted output.
6. The method according to claim 5, characterized in that, The S500 optimizes loss calculation based on a dynamic adaptive scaling mechanism using real-time IoU feedback, specifically including: S510: Calculate the adaptive scaling ratio: Calculate the intersection-union ratio (IU) of the original predicted bounding box and the ground truth bounding box. And calculate the dynamic auxiliary scaling ratio based on the principle of negative feedback. The formula is: , where α is the sensitivity coefficient; S520: Obtain the original bounding box geometry parameters: Obtain the coordinates of the center point of the predicted bounding box respectively. ,width With height and the center point coordinates of the actual bounding box ,width With height This provides the basic geometric data for the subsequent generation of auxiliary bounding boxes; S530: Generating Adaptive Auxiliary Bounding Boxes: To construct a virtual overlap region for gradient backpropagation, the formula is used... , , and Generate adaptively scaled auxiliary bounding boxes while preserving the center point. constant; S540: Calculate and apply adaptive regression loss: Calculate the CIoU loss value based on the adaptively scaled auxiliary bounding box, which serves as the final regression loss function. Instead of calculating the loss at the original scale, this method drives the network parameters to converge rapidly to the true bounding box. The formula is as follows: in, v is the intersection-union ratio between the adaptively scaled auxiliary bounding box and the true bounding box. Aspect ratio consistency parameter These are the weighting coefficients. It predicts the center point coordinates of the auxiliary bounding box. , The coordinates of the center point of the true bounding box , Let Euclidean distance be the square of the distance between the two center points. The diagonal length of the minimum bounding rectangle covering the adaptively scaled auxiliary bounding box and the true bounding box is the square of the length of the rectangle.
7. The method according to claim 6, characterized in that, The S500 uses a trained full-scale feature pyramid detection architecture to detect pests in the input image and outputs the final pest detection results, including: S550: Summarize the prediction results of the four scales P2, P3, P4 and P5 to obtain a set of candidate boxes containing all potential targets; S560: Perform non-maximum suppression on the candidate box set, set an IoU threshold to remove redundant detection boxes with excessive overlap, and retain the optimal bounding box corresponding to the local maxima; S570: For the candidate bounding boxes of tiny targets output by the P2 layer, set an independent confidence filtering threshold that is different from other scales, and prioritize retaining extremely tiny targets with confidence scores higher than the threshold to prevent tiny targets from being suppressed by low-confidence bounding boxes of large-scale targets. S580: Map the filtered bounding box coordinates back to the original image coordinate system, and output the final bounding box coordinates and their corresponding pest category labels.
8. A dense detection system for micro-agricultural pests based on multi-scale sensing and dynamic reconstruction, characterized in that, include: The detection architecture building module is used to collect and preprocess high-density stacked pest images to construct a multi-scale micro-target dataset and build a full-scale feature pyramid detection architecture containing a high-resolution feature layer. The architecture includes a backbone network, a neck network and a detection head connected in sequence. The feature extraction module is used to input the dataset into the backbone network for feature extraction. The backbone network contains a context enhancement module, which is used to perform global and local recalibration on the extracted multi-scale features to suppress background noise and enhance the pest target features. The multi-scale fusion module is used to input the recalibrated multi-scale features into the neck network for multi-scale fusion. The neck network is equipped with a dynamic reconstruction upsampler, which is used to perform content-aware dynamic feature reconstruction on low-resolution feature maps to decouple densely clustered pest targets. The prediction module is used to input the fused feature map into the detection head for prediction. The detection head is equipped with a dual-branch hole perception module, which is used to extract and fuse local texture features and environmental semantic features in parallel, and output the target's category and location prediction information. The pest detection module is used to train the full-scale feature pyramid detection architecture using an adaptive auxiliary scaling bounding box regression loss optimization strategy based on real-time IoU feedback. The trained full-scale feature pyramid detection architecture is then used to detect pests in the input image and output the final pest detection results.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.