A YOLOV10 lightweight optimization method for small target pest detection
By using the YOLOV10 lightweight optimization method, the problem of insufficient boundary information separation in the identification of densely distributed tiny insects is solved, improving detection accuracy and identification reliability, and making it suitable for intelligent pest monitoring equipment.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGDONG IND TECHN COLLEGE
- Filing Date
- 2026-03-23
- Publication Date
- 2026-06-19
AI Technical Summary
Existing lightweight pest detection methods lack the ability to separate the boundary information of adjacent targets in scenarios where tiny insects are densely distributed, mutually occluded, and have similar shapes, leading to serious problems of false positives, false negatives, and mixed detections.
The YOLOv10 lightweight optimization method is adopted to enhance the boundary difference information between adjacent insects in dense areas through multi-layer feature extraction, multi-scale fusion and enhanced representation of the boundary of adjacent micro-insects. The target classification and location regression are performed by decoupled detection head to reduce false detection and mixed detection.
It improves the detection accuracy and recognition reliability in dense small target scenarios, reduces false positives, false negatives and mixed detections, and is suitable for application in insect monitoring lamps, sticky insect monitoring equipment, greenhouse monitoring terminals and field fixed collection equipment.
Smart Images

Figure CN122244862A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of pest detection technology, specifically a lightweight optimization method for detecting small-target pests using YOLOv10. Background Technology
[0002] In real-world pest detection scenarios, the objects to be identified are often not single, isolated, clearly defined insects, but rather multiple insects that are close together, partially overlapping, have interlocking edges, or even interfere with each other's morphology. This is especially evident in environments with sticky insect boards, traps, or high insect population density. For these densely distributed tiny insects, existing technologies can improve the response capability to small target areas by increasing the resolution of shallow features or enhancing multi-scale feature expression. However, most of these improvements still focus on enhancing the "visibility" of the target. The stable separation of boundary information between adjacent tiny insects and the effective extraction of independent discriminative features remain insufficient. Existing research on small target detection and pest detection also points out that the difficulty in distinguishing between dense small targets, mutual occlusion, and similar targets is a technical challenge that has not yet been fully resolved in the field of visual detection.
[0003] Insect pests are typically small in size, with limited available texture, contour, and local structural information. When detection models employ lightweight structures, shallow details are more easily attenuated during feature extraction and cross-scale transfer. Furthermore, when multiple insects are close together, the already weak boundary differences between adjacent targets are further obscured, leading to the detection model misclassifying multiple adjacent insects as the same target or shifting the localization boundary of a single insect to the region of adjacent insects. Simultaneously, some insects are similar in body color, contour, and posture, which can easily lead to category confusion under dense occlusion conditions, resulting in missed detections, false positives, and mixed detections. These problems have been repeatedly mentioned in research on general small target detection and agricultural insect pest detection, indicating that they are not isolated defects in localized scenarios but rather a common bottleneck prevalent in existing technologies.
[0004] Therefore, how to improve the ability to separate and independently distinguish the boundary information of adjacent targets, and reduce false positives, false negatives, and mixed detections, within a lightweight target detection framework for densely distributed, mutually occluded, and similarly shaped micro-insects, has become an urgent technical problem to be solved in this field. Summary of the Invention
[0005] Technical problems to be solved In addressing the shortcomings of existing lightweight pest detection methods in identifying densely distributed, mutually occluded, and similarly shaped small insects, which suffer from insufficient ability to separate adjacent target boundary information and inadequate extraction of independent discriminative features, leading to false positives, false negatives, and mixed detections, this invention provides a lightweight optimization method for small target pest detection using YOLOv10. This method aims to resolve the technical deficiencies of existing detection models under lightweight conditions, such as unclear representation of densely distributed small insect boundaries, easy interference between adjacent targets, and insufficient recognition reliability in complex pest scenarios.
[0006] (II) Technical Solution To achieve the above objectives, the present invention provides the following technical solution: a lightweight optimization method for detecting small target pests using YOLOv10, comprising the following steps: S1. Obtain an image of the pest to be detected, and preprocess the image of the pest to be detected to obtain an input image; S2. Input the input image into a lightweight feature extraction network for multi-layer feature extraction to obtain a multi-layer feature map containing shallow detail features and deep semantic features. The lightweight feature extraction network retains the edge texture information and local contour information of the tiny insect body while reducing the number of model parameters and computational cost. S3. Perform multi-scale fusion on the multi-layer feature map to obtain a fused feature map, wherein the boundary difference information between adjacent micro-insects in the densely distributed area is enhanced during the multi-scale fusion process. S4. Construct an enhanced representation of the boundary between adjacent micro-insects based on the fused feature map to strengthen the edge response information and independent discrimination features of adjacent insects in dense areas; S5. Input the features after boundary enhancement into the detection head for target classification and location regression, and output insect category information and target location information. The detection head decouples the classification features and the localization features to reduce false positives, false negatives and mixed detections in dense small target scenes. S6. Perform target screening and result optimization processing on the insect category information and target location information to obtain the final pest detection result.
[0007] Preferably, the process involves acquiring an image of the pest to be detected, preprocessing the image to obtain an input image, including: Acquire images of pests to be detected by insect monitoring lamps, sticky insect monitoring devices, greenhouse monitoring cameras, fixed field collection terminals, mobile inspection terminals, and manual shooting equipment; The images of the pests to be detected are resized and pixel normalized. The image, after being resized and normalized, undergoes various processing steps including brightness adjustment, contrast adjustment, flip transformation, random cropping, and noise perturbation to obtain the input image.
[0008] Preferably, the input image is input into a lightweight feature extraction network for multi-layer feature extraction to obtain a multi-layer feature map containing shallow detail features and deep semantic features, including: The input image is fed into a lightweight feature extraction network that is improved based on the YOLOV10 backbone network; By lightweighting and replacing the basic feature extraction structure in the YOLOV10 backbone network, the number of model parameters and computational cost are reduced. In the lightweight feature extraction process, shallow feature outputs that represent the edge texture information and local contour information of tiny insect bodies are retained to obtain multi-layer feature maps.
[0009] Preferably, a lightweight replacement is performed on the basic feature extraction structure in the YOLOv10 backbone network, including: The standard convolutional structure in the original backbone network is replaced by a lightweight convolutional structure, a depthwise separable convolutional structure, a partial channel feature extraction structure, and a bottleneck compression structure. The system outputs shallow feature maps after the input image passes through 2x downsampling layers, 4x downsampling layers, and 8x downsampling layers to reduce the loss of detailed features of tiny insect bodies during the downsampling process.
[0010] Preferably, the multi-scale feature maps are fused at multiple scales to obtain a fused feature map, including: Perform size alignment and channel adjustment on feature maps at different levels; By employing bidirectional fusion, cross-layer aggregation, and weighted fusion methods, shallow detail features and deep semantic features can jointly participate in the representation of the insect target. In the multi-scale fusion process, at least one shallow feature map is introduced to enhance the boundary difference information between adjacent micro-insects in densely distributed areas, thus obtaining a fused feature map.
[0011] Preferably, enhancing the boundary difference information between adjacent micro-insects within a densely distributed region during multi-scale fusion includes: Enhance the local edge response regions in the shallow feature map; Analyze the transition region features between multiple local response peaks in the fused feature map; Furthermore, based on the characteristics of the local edge response region and the transition region between multiple local response peaks, the boundary difference information between adjacent micro-insects in the densely distributed region is enhanced.
[0012] Preferably, constructing an enhanced boundary representation of adjacent micro-insect bodies based on the fused feature map includes: Extract edge response information between adjacent insects within a dense region; By combining local texture changes, feature response differences, and spatial relationships in the target neighborhood, boundary difference description information is constructed. The boundary difference description information is used to perform weighted enhancement and feature redistribution on the fused feature map to strengthen the edge response information and independent discrimination features of adjacent insects in dense areas.
[0013] Preferably, the features after boundary enhancement are input into the detection head for target classification and location regression, and the output includes insect category information and target location information, including: The features after boundary enhancement are input into the classification branch and the regression branch respectively; The insect category discrimination features are extracted by classifying branches and the insect category information is output. Extract the target location boundary features through regression branch and output the target location information; The classification branch and the regression branch are decoupled.
[0014] Preferably, the classification branch and the regression branch are decoupled, including: The ability to identify fine-grained differences in features between morphologically similar insects is enhanced by taxonomic branching; The ability to constrain the boundary positions of densely adjacent insect bodies is enhanced by regression branching; The results of the classification branch and the regression branch are used to jointly determine the worm category information and the target location information, so as to reduce the mixed detection of similar worms and boundary drift.
[0015] Preferably, the insect category information and target location information are subjected to target screening and result optimization processing to obtain the final pest detection result, including: Confidence-based screening is performed on candidate targets corresponding to insect category information and target location information; When the center distance between candidate targets is less than a preset threshold or the degree of overlap is greater than a preset threshold, the candidate targets are retained or suppressed by combining target boundary difference information, local response intensity and independent discrimination features. The candidate targets that have been retained or suppressed will be output as the final pest detection results.
[0016] Compared with existing technologies, this invention provides a lightweight optimization method for detecting small-target pests using YOLOv10, which has the following beneficial effects: 1. This invention addresses the problem of false positives, false negatives, and mixed detections in existing lightweight pest detection methods when dealing with densely distributed, mutually occluded, and similarly shaped micro-insects due to unclear boundaries between adjacent targets and insufficient independent discrimination features. By introducing multi-scale fusion and enhanced representation of the boundaries between adjacent micro-insects on the basis of lightweight feature extraction, this invention strengthens the edge response information, local difference information, and independent representation capabilities between adjacent insects in dense areas. This allows multiple closely adjacent micro-insects to be more clearly separated at the feature level. As a result, when the detection head performs classification and location regression, it is less likely to misclassify multiple nearby insects as a single target, and it is less likely to cause the boundary of a single insect to drift into the region of adjacent insects. This can more effectively reduce false positives, false negatives, and mixed detections in dense micro-target scenarios, and improve the detection accuracy and recognition reliability under complex pest monitoring conditions.
[0017] 2. This invention, while ensuring the accuracy of small insect target detection, has optimized the YOLOV10 backbone network with lightweight design. During the lightweighting process, it retains shallow edge texture information and local contour information, which are more crucial for the identification of tiny insects. Combined with the collaborative fusion of multi-layer features and the decoupling of classification and regression branches, the model can still effectively balance target category discrimination and boundary location while controlling the number of parameters and computational load. Compared with solutions that rely solely on conventional lightweight compression or simply adding detection layers, this invention is more suitable for practical deployment in scenarios such as insect monitoring lamps, sticky insect monitoring devices, greenhouse monitoring terminals, and fixed field collection devices. It not only improves the stability of small insect target identification but also enhances the model's operational efficiency and adaptability in practical applications, thereby better meeting the comprehensive requirements of accuracy and practicality for intelligent insect monitoring. Attached Figure Description
[0018] Figure 1 This is a schematic diagram of the method steps of the present invention. Detailed Implementation
[0019] 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.
[0020] Please see Figure 1 A lightweight optimization method for detecting small-target pests using YOLOv10 includes the following steps: S1. Obtain the image of the pest to be detected, and preprocess the image of the pest to be detected to obtain the input image. The specific implementation is as follows: In this step, the first step is to acquire images of the pests to be detected. These images can be obtained from pest monitoring lamps, sticky insect monitoring devices, greenhouse pest monitoring cameras, fixed field acquisition terminals, mobile inspection terminals, warehouse monitoring equipment, or manual shooting equipment. Considering that this invention is mainly aimed at the detection of tiny insect targets, the stability and clarity of the image source have a significant impact on the subsequent recognition effect. Therefore, in actual implementation, it is preferable to use a high-definition image acquisition device with fixed focal length or autofocus function, and to ensure as much as possible that the shooting angle is stable, the imaging area is complete, and the lighting conditions are relatively uniform. In a common implementation, the image acquisition device includes a camera module, a supplementary lighting unit, a mounting bracket, and an image transmission unit. The camera module can be an industrial camera, a network camera, a USB camera, or an embedded camera module. If deployed in a fixed monitoring scenario, such as an automatic insect sticky board identification device or a greenhouse monitoring point, an industrial camera or network camera with a resolution of not less than 2 million pixels is preferred. If deployed in a mobile scenario, such as a handheld inspection or a portable monitoring terminal, a high-pixel mobile phone camera or a portable camera can also be used. The image resolution is preferably not less than 1280×720, and more preferably 1600×1200, 1920×1080, 2592×1944, or 3264×2448. When the insect body is short, the target is more dense, or the monitoring object includes very small targets such as insect eggs and nymphs, a resolution between 1920×1080 and 4096×2160 is preferred to preserve the edge information and local structural details of the insect body as much as possible. Regarding the installation method, if the target is insects on sticky insect boards, the distance between the camera and the surface of the sticky insect board can be set to 20 cm to 120 cm, preferably 35 cm to 80 cm; if the target is insects on insect-attracting lamp collection boards, the distance between the camera and the imaging area can be set to 30 cm to 150 cm, preferably 50 cm to 100 cm; if used for photographing insects on leaves in the field, the distance between the lens and the leaf can be set to 10 cm to 60 cm, preferably 15 cm to 35 cm, and the lens focal length can be set to 4 mm to 16 mm, preferably 6 mm to 12 mm; the field of view can be adjusted according to the size of the target area, preferably controlled between 35° and 90°. For fixed monitoring equipment, it is recommended that the lens optical axis be kept as perpendicular or nearly perpendicular to the target plane as possible to reduce the problem of insect size changes and boundary stretching caused by perspective distortion. Regarding lighting conditions, to reduce the impact of shadows, reflections, and color casts, it is preferable to arrange supplementary lighting units around the image acquisition device. These units can be LED ring lights, strip lights, or planar supplementary lighting panels. The color temperature of the supplementary light is preferably between 4500K and 6500K, more preferably between 5000K and 5800K, and the illuminance is preferably controlled between 300 lux and 2000 lux. If the background being measured is an insect-sticking board or a light-colored substrate, diffuse reflection supplementary lighting is preferred to avoid overexposure in localized areas caused by high-light reflection. If the monitoring environment experiences day-night variations, the supplementary light intensity can be automatically adjusted via a photosensitive sensor or a timing control module to maintain image brightness within a relatively stable range. After acquiring the image of the pest to be detected, it is preprocessed. The preprocessing is mainly used to unify the image size, suppress environmental interference, enhance the visibility of small targets, and provide a more stable input for subsequent model inference. The preprocessing module can be deployed in the front-end device or the back-end server. The preprocessing process includes at least size adjustment and pixel normalization. In most implementations, it may further include color correction, brightness correction, noise reduction, image enhancement, slicing, and format conversion steps. In some implementations, the original large image can be divided into multiple local blocks at a fixed size using a block-slicing method, and then each block can be detected separately. The block size can be set to 512×512, 640×640, 800×800 or 960×960. An overlap area of 16 to 96 pixels is retained between adjacent blocks, preferably 24 to 48 pixels, in order to avoid cutting off small insects located at the edge of the blocks as much as possible. In terms of pixel normalization, image pixel values can be mapped to between 0 and 1. Mean and variance standardization can also be performed. For red, green and blue three-channel images, channel normalization can be performed separately to reduce color drift caused by imaging differences between different devices and different lighting environments. In some implementations, color correction can also be performed by combining standard gray cards, background board colors or historical calibration samples to make the overall tone of images acquired at different times more consistent. For example, when the background board is a yellow sticky insect board, the response of the blue and green channels can be appropriately balanced to reduce the interference of the background color on the extraction of insect edges. In terms of noise reduction, if there is sensor noise, compression noise or particle noise generated in low light environment in the image, it can be suppressed by median filtering, bilateral filtering or light smoothing. The filter window is preferably 3×3 or 5×5. It is generally not recommended to use too large a filter window to avoid erasing the edges and fine textures of small insects. For images with slight blur, moderate sharpening can also be used to improve the contrast of the insect outline, but the sharpening intensity should not be too large. It is preferred to control it in the weak to medium range to avoid introducing additional false edges. During the training phase, preprocessing can also include data augmentation. Data augmentation improves the model's adaptability to complex real-world environments, enabling it to maintain good recognition capabilities even with varying brightness, backgrounds, insect poses, and slight occlusion. Augmentation methods can include one or more of the following: random flipping, brightness perturbation, contrast adjustment, color perturbation, random cropping, slight rotation, local occlusion simulation, and slight noise addition. For example, the brightness adjustment can be set to 0.75 to 1.25 times the original image, the contrast adjustment to 0.8 to 1.2 times, the rotation angle to 5° to 20°, the local occlusion area to be controlled between 2% and 15% of the image area, and the noise addition ratio to 0.1% to 1.0%. These methods enhance the model's tolerance to changes in the actual acquisition environment. In some implementations, preprocessing may also include a preliminary screening step for candidate regions. For example, large areas of blank background regions may be excluded by background separation or color thresholding, and only regions that may contain insects may be subsequently detected. The advantage of doing this is that it can reduce invalid regions from participating in inference and reduce computational overhead, which is especially suitable for large-format monitoring images or fixed background scenes. After the above processing is completed, the input image is obtained. The input image has been unified and optimized in terms of size, brightness, color, and local quality, making it more suitable as input for the subsequent lightweight feature extraction network, thus providing a more stable image foundation for subsequent small target pest detection.
[0021] S2. Input the input image into a lightweight feature extraction network for multi-layer feature extraction to obtain a multi-layer feature map containing shallow detail features and deep semantic features. The lightweight feature extraction network retains the edge texture information and local contour information of the tiny insect body while reducing the number of model parameters and computational cost. Specifically, the implementation is as follows: The input image obtained in step S1 is input into the lightweight feature extraction network to complete multi-layer feature extraction. The lightweight feature extraction network is an improvement on the original backbone network of YOLOv10. The focus of the improvement is not only to reduce the number of model parameters and computation, but more importantly, to preserve as much edge texture, local contour and fine-grained structural differences as possible that are valuable for the identification of small insects under the lightweight condition, so as to avoid the problem of small targets being "unclear, indistinguishable and inaccurate" after lightweighting. Some existing lightweight detection networks can balance speed and accuracy when processing general objects, but when used for insect pest images, they often encounter the following problem: while the overall model speed is improved, shallow features are quickly compressed when the insects are small, close together, and the background is cluttered. Even with subsequent fusion and detection, sufficient detailed information is lacking. Therefore, this invention, in designing a lightweight feature extraction network, does not simply replace all convolutional modules with lighter ones. Instead, it takes into account the actual characteristics of insect pest images and makes targeted adjustments to the feature extraction methods at different levels. In one implementation, the input image first passes through an initial feature extraction layer to extract low-level texture and basic edge information. The initial feature extraction layer can be a convolutional layer with a stride of 2, or it can be a structure composed of two convolutional layers with smaller strides. The kernel size is preferably 3×3, but 5×5 kernels can also be used in some locations to expand the local receptive range. Considering the computational overhead, 3×3 convolution is preferred. The initial number of channels can be set to 16, 24, 32 or 48, preferably 24 or 32. For scenes with high resolution and small insect bodies, the initial number of channels can be appropriately increased to enhance the ability to extract low-level edge details. Subsequently, the input features sequentially enter multiple lightweight feature extraction stages. Each stage can consist of several lightweight convolutional units, which can be depthwise separable convolutional units, partial channel convolutional units, lightweight bottleneck units, grouped convolutional units, or a combination of two or more of these. For example, in the earlier layers, more ordinary convolutions or partial channel convolutions are preferred to reduce damage to shallow textures; in the middle and later layers, depthwise separable convolutions and lightweight bottleneck structures are preferred to further reduce the parameter burden. The advantage of this approach is that the first few layers are responsible for capturing the edges and local textures of the insect body as reliably as possible, while the later layers extract category-related semantic information based on the existing information, thus balancing detail preservation and model efficiency. In a more specific implementation, the backbone network can be divided into 4 or 5 feature extraction stages. If divided into 4 stages, the feature map size of each stage can be 1 / 4, 1 / 8, 1 / 16, and 1 / 32 of the input image, respectively. If divided into 5 stages, a shallow feature layer at the first half scale can be retained to more finely preserve the local information of extremely small insects. For the task of detecting tiny insects, it is preferable to retain at least two shallow or mid-shallow feature layers at the scales of 1 / 4 and 1 / 8 for subsequent multi-scale fusion. For images of extremely small insect eggs, nymphs, or pests with short body length, even a shallower feature map can be retained as an auxiliary output to avoid compressing the target information too much during the initial downsampling. From the perspective of channel settings, the number of output channels in different stages can be gradually increased from shallow to deep. For example, the number of output channels in the first stage can be set to 32 to 64, the second stage to 64 to 128, the third stage to 128 to 256, and the fourth stage to 256 to 512. If the computing power of the model deployment end is limited, the channel scale can also be appropriately reduced, for example, set to 24, 48, 96, 192 or 32, 64, 128, 256. If the deployment end allows for higher computing power consumption and has higher accuracy requirements, the number of channels can be appropriately increased. The overall parameter quantity is preferably controlled between 4M and 14M, and more preferably between 5M and 10M. The overall computational quantity is preferably controlled between 8GFLOPs and 30GFLOPs, and more preferably between 10GFLOPs and 22GFLOPs. This setting can usually achieve a good balance between edge devices and medium computing power platforms. To reduce the loss of small target information during downsampling, this invention sets up a shallow feature preservation path in the lightweight feature extraction network. The so-called shallow feature preservation path refers to directly outputting some feature maps that still maintain high spatial resolution at the beginning or middle of the network, without immediately sending them to a deep compression layer. For example, the feature map after one or two downsamplings can be output as the first shallow feature map, and the feature map after three downsamplings can be output as the second shallow feature map. The first shallow feature map can better reflect the edge and local contour of the insect body, while the second shallow feature map can add some semantic features while retaining certain edge information. Both of these feature layers are valuable for subsequent dense small target boundary separation tasks. In one implementation, the lightweight feature extraction network may also include short connection structures or residual structures to reduce inter-layer information decay. Short connections can make shallow edge textures more smoothly transmitted to subsequent layers, avoiding complete reliance on deep semantic output. Residual connections can also improve the network training stability, so that the lightweight model is not too difficult to converge while reducing parameters. Considering that there are a lot of local details in insect pest images and that there are large differences between different batches of images, the use of short connections and residual connections can often make the training process more stable and the detection performance more stable. During feature extraction, quality control is preferably performed on feature maps at different levels. For example, for the first shallow feature map, the focus is on whether it can clearly preserve the outline of the insect body and local texture changes; for the middle feature map, the focus is on whether it has formed a relatively stable insect body region response; for the deep feature map, the focus is on whether it can highlight the insect body region and suppress background noise. In actual training and debugging, if the shallow features are found to be too blurry, the compression intensity of the first few layers can be appropriately reduced; if the deep features are found to have strong semantics but the small target response is obviously insufficient, the output weight of the middle and shallow features can be appropriately increased or the step size compression of a certain level can be reduced. For dense insect scenes, this invention emphasizes the importance of the first and second shallow feature maps. The reason is that when multiple insects are closely arranged, they are likely to form continuous response areas in deeper feature layers, while in shallow features, there is still a chance to retain some independent edges or local peaks. As long as this part of the information is preserved as much as possible in the beginning, there is still a chance to "separate" these adjacent insects in the fusion and boundary enhancement stages. If the shallow details are suppressed at the beginning, it is difficult to make up for them later. Finally, the lightweight feature extraction network outputs a multi-layer feature map containing shallow detail features and deep semantic features. The multi-layer feature map provides the foundation for multi-scale fusion, enhanced representation of the boundary of adjacent small insects, and decoupling of the detection head input in subsequent steps. Through the design of this step, the present invention not only takes into account the lightweight requirements, but also tries to take into account the problem of "preservation of small target details" which is particularly critical in pest detection.
[0022] S3. Perform multi-scale fusion on the multi-layer feature map to obtain a fused feature map. Specifically, during the multi-scale fusion process, the boundary difference information between adjacent micro-insects within a densely distributed region is enhanced. In this step, the multi-scale feature map output from step S2 is fused at multiple scales to obtain a fused feature map. The purpose of multi-scale fusion is not just to simply put the features of different layers together, but to make the detailed information in the shallow features and the semantic information in the deep features work together effectively, so that the model can both perceive the existence of the insect and distinguish the insects that are close to each other as much as possible. For pest detection, multi-scale fusion is more important than in general scenarios because many insects are small with fine outlines, and the background can be complex. If only deep semantics are considered, it is often known that "there are insects in this area," but it may not be possible to determine "whether there are actually two or three insects here." If only shallow details are considered, fragmented responses and unstable category judgments are likely to occur. Therefore, the goal of this invention in the multi-scale fusion stage is to allow shallow details to help deep semantics clarify the boundaries, and to allow deep semantics to help shallow features identify the target area, thereby forming fused features that are both visible and distinguishable. In one implementation, feature maps of different levels are first fed into a feature alignment unit. Since the size and number of channels of feature maps of different levels are usually different, size alignment and channel adjustment are required before fusion. Size alignment can be achieved by upsampling or downsampling. Upsampling can be performed using nearest neighbor interpolation, bilinear interpolation, or a learnable upsampling structure. Downsampling can be performed using strided convolution or pooling. In this invention, to minimize the destruction of edge information of small targets, upsampling is preferred in the top-down feature transfer, so that high-level semantic features move closer to shallow detail features. In the bottom-up re-aggregation process, lightweight convolution downsampling can be used to further summarize the fused shallow features. Channel adjustment can be achieved using 1×1 convolution, making it easier to align the feature maps of each layer participating in the fusion in the channel dimension. After channel adjustment, the number of fusion channels of each feature map can be set to 64, 96, 128, or 160, preferably 96 or 128. In a common implementation, multi-scale fusion employs a bidirectional fusion structure. First, the deepest feature map is upsampled and fused with the previous layer's feature map. Then, the resulting features are upsampled again and fused with shallower feature maps. After this process, the shallow fusion result can be passed down to re-aggregate with mid- and deep features, forming a bidirectional flow of information from top to bottom and bottom to top. Compared to unidirectional fusion, bidirectional fusion has a significant advantage: deep semantics can guide shallow details on "where to look," while shallow details can conversely remind deep semantics that "there is actually more than one target here." For densely packed small insects, this back-and-forth interaction is often more effective than simply passing features up or down once. In another implementation, a cross-layer aggregation method can also be used. For example, features at three scales of 1 / 4, 1 / 8 and 1 / 16 can be directly fed into the same fusion unit at the same time, and unified weighting and redistribution can be completed in the unit. The advantage of doing this is that information from multiple levels can be integrated at one time without too much repeated transmission. For scenes with relatively stable backgrounds but high insect density, this method is relatively simple to implement and easy to control the amount of computation. To make multi-scale fusion more suitable for the characteristics of insect pest images, this invention preferably introduces at least one layer of shallow feature map to participate in the fusion, and more preferably introduces two layers of shallow feature map. For example, a shallow feature map at scale 1 / 4 and a medium-shallow feature map at scale 1 / 8 of the input image can be introduced into the fusion path at the same time. These two layers of feature map usually retain more insect body outline, edge and local texture information, which is especially suitable for helping the model to process small insects, adjacent insects and slightly occluded insects. If only deeper features such as 1 / 16 or 1 / 32 are retained, multiple close small insects are often compressed into a continuous area, and it will be much more difficult to separate them later. In terms of fusion methods, in addition to simple splicing or addition, this invention also preferably assigns different fusion weights to features at different levels. The weights can be set fixedly or learned gradually during training. When set fixedly, if the task is mainly to detect small insects, the weight of shallow features is preferably slightly higher than that of deep features. For example, shallow features can account for 35% to 55%, medium features can account for 25% to 40%, and deep features can account for 15% to 30%. If the task also includes some larger insects or strong background interference, the proportion of medium and deep features can be appropriately increased. In general, the fusion weight is not better the shallower it is, but rather a more suitable balance point should be selected according to the size of the insect, the complexity of the background, and the deployment scenario. A key aspect of this invention lies in enhancing the boundary difference information between adjacent micro-insects within a densely distributed region during multi-scale fusion. Traditional multi-scale fusion typically focuses more on enhancing the overall target response, making the "insect-containing" area more prominent, but it doesn't particularly care whether "there are two adjacent insects in this area." In this invention, the fusion process not only enhances the target region but also tries to preserve the differences in the transition regions between targets. The reason for this is straightforward: if the boundaries between multiple insects are smoothed out during the fusion stage, the subsequent detection head may only be able to output a large bounding box; only by preserving these boundary differences as much as possible can subsequent boundary enhancement and the detection head distinguish them. Specifically, high-frequency response regions in shallow features can be enhanced before fusion. These regions typically correspond to the edges of insect bodies, abrupt changes in local texture, or transitional locations between adjacent targets. Enhancement methods can include increasing the response coefficient for areas with significant local changes, moderately reducing the response intensity for overly smooth areas that may belong to the background, or performing boundary difference compensation after fusion to separate and enhance regions with strong overall responses but multiple local peaks. For example, if two or three obvious local peaks are detected within a local region, and there is a certain degree of response drop between the peaks, then this region is more likely to correspond to multiple adjacent insect bodies rather than a single large target. In this case, redistribution can be used to make the boundaries around each local peak clearer, thereby increasing the likelihood of subsequent separation and detection. In some implementations, multi-scale fusion can also be combined with local attention guidance. However, the focus here is not on simply "enhancing important regions" in the traditional sense, but rather on more specifically enhancing the differences between boundary regions and independent peak regions between insects. For example, within a local area of 3×3, 5×5, or 7×7, the amplitude and direction of feature changes at adjacent locations are compared. If some locations are found to be both close to the target response center and between two peaks, these locations can be preferentially retained as "boundary transition cues." After this processing, the fused feature map will no longer simply show "where there is light, there may be an insect," but will gradually form "which region is an insect, and which region may be the boundary between two insects." In terms of parameter design, the number of fused feature maps is preferably 3 or 4 layers. If small target detection is taken into consideration, it is preferable to retain at least one high-resolution fused feature map. High-resolution fused feature maps are more suitable for subsequent processing of extremely small and dense insects. Medium-resolution fused feature maps are more suitable for taking into account both small and medium-sized targets. Lower-resolution fused feature maps can retain some deep semantics for category discrimination and context assistance. Through such layered output, the subsequent detection head can select more suitable fused features according to different target scales. After multi-scale fusion, the fused feature map is obtained.
[0023] S4. Construct an enhanced boundary representation of adjacent micro-insects based on the fused feature map to strengthen the edge response information and independent discrimination features of adjacent insects in dense areas. Specifically, this is implemented as follows: This step is one of the key parts of the whole method. The previous lightweight feature extraction and multi-scale fusion solve the problem of "preserving the details and semantics of small targets as much as possible". This step further solves the problem of "separating multiple tiny insects from features as much as possible even if they are very close to each other". This step is very critical for actual pest monitoring scenarios, because many false positives, false negatives and mixed detections often occur here. In real-world images, densely distributed insects are common, especially in sticky traps, bait traps, or certain centralized sampling devices. Multiple insects may be connected head to tail, with overlapping wings, intersecting body segments, or even locally adhered. In such scenarios, ordinary detection models often treat a continuous high-response area as a whole, ultimately only outlining a single larger target, resulting in the merging of multiple insects. Even if the model can detect multiple candidate targets, it often encounters problems such as boundary drift, overlapping localizations, or unstable classification. This invention sets up enhanced representations of the boundaries of adjacent tiny insects to enable the model to learn in advance at the feature level to "see boundaries, differentiate targets, and maintain independence." In one implementation, local edge responses are first extracted from the fused feature map. Local edge responses are not simply about finding bright areas, but rather focusing on locations that "may correspond to the boundaries or transitions between worm bodies." Specifically, a local neighborhood can be constructed around each location in the fused feature map, with neighborhood sizes of 3×3, 5×5, 7×7, or 9×9. For extremely small worm bodies and high-resolution fusion layers, a 3×3 or 5×5 neighborhood is preferred; for slightly larger worm bodies or more severe local occlusion, a 5×5 or 7×7 neighborhood can be used. By comparing the changes in response strength, direction, and local peak distribution within the neighborhood, it is possible to preliminarily determine which areas belong to the worm body edges and which areas belong to the transition regions between adjacent worm bodies. When extracting edge response information, three types of locations are preferred. The first type is the outer contour of the insect body, which usually shows a clear change in response from the background to the target. The second type is the boundary between adjacent insect bodies. Although these locations are also near high-response areas, their response trends often show multiple centers expanding to both sides. The third type is the location of local texture abrupt changes, such as the markings on the insect body surface, wing vein structures, or the connection of body segments. Distinguishing between these three types of locations can provide more detailed basis for subsequent boundary difference description. In one implementation, the edge response information is preferably extracted from the high-resolution fusion feature map and the medium-resolution fusion feature map, respectively. Specifically, the first edge response information can be extracted from the 1 / 4 scale fusion feature map first, and the second edge response information can be extracted from the 1 / 8 scale fusion feature map. Then, the first edge response information and the second edge response information are jointly processed. This approach can preserve the edge details of the tiny insect body on the one hand, and combine the local target response in the medium-layer features on the other hand, making the subsequent boundary separation results more stable. Subsequently, boundary difference description information is constructed by combining local texture changes, feature response differences, or spatial relationships in the target neighborhood. Local texture changes are mainly used to describe the continuity and abruptness of the insect surface structure; feature response differences are mainly used to describe whether there are multiple independent response peaks in a local area; and spatial relationships are used to describe the relative position, relative distance, and arrangement of multiple peaks. In one implementation, the boundary difference description information is determined based on at least one or more of the following: the number of response peaks in the local neighborhood, the spacing between adjacent response peaks, the width of the transition region between peaks, the change in local response direction, and the local texture undulation. If there are two or more response peaks that are close to each other in a certain region, and there is a clear transition zone between the peaks, then the region can be identified as a candidate boundary region of adjacent insects. If there is only a single response peak in a certain region, and the edge response is continuously distributed around the peak, then the region can be identified as the region corresponding to a single insect. If there is only one obvious response center in a local area, and the edges are basically closed or semi-closed around this center, then it is more likely to correspond to a single insect body; if there are two or more local response centers that are close to each other but in different directions in a local area, and there is a relatively weak but still continuous transition zone between them, then it is more likely to correspond to multiple insect bodies that are close to each other. The boundary difference description information is to extract these differences as much as possible for subsequent feature enhancement. In one implementation, the construction of boundary difference description information can be divided into two levels: local description and regional description. Local description mainly targets small neighborhoods, such as response differences within a 3×3 or 5×5 area, and is used to determine small boundaries and transition points. Regional description mainly targets slightly larger areas, such as peak distribution and spatial arrangement within a 7×7, 9×9, or even larger area, and is used to determine the approximate structural relationship between multiple targets. Through local and regional two-level descriptions, both edge details at extremely small scales and multi-target relationships at slightly larger scales can be taken into account. After constructing the boundary difference description information, this information is used to perform weighted enhancement or feature redistribution on the fused feature map. Weighted enhancement can be done by increasing the response weight of regions identified as target edges or target boundaries, and appropriately reducing the overall response of regions that have strong responses but may just be multiple targets overlapping. Feature redistribution can be done by redistributing features that were originally over-concentrated in a single large region to multiple local peaks, making each local peak more like the center of an independent target, rather than several insects sharing the same center. More specifically, for two insect bodies that are very close to each other, if they already show two local peaks in the fused feature map, but there is still a strong connection in the middle, then the overall response of the middle connection area can be appropriately reduced by boundary enhancement, while improving the clarity of the outer edges of the two peaks; if multiple insect bodies are completely squeezed together, forming only a few weak peaks in a very small area, the features around these local peaks can also be enhanced separately, making it easier for the subsequent detection head to determine that "this is not a large target, but multiple small targets squeezed together"; In one implementation, when weighting the fused feature map, it can be processed according to the region type. For the location determined to be the outer contour of the insect body, the edge preservation weight is increased; for the location determined to be the boundary between adjacent insect bodies, the boundary weight is increased; for the location determined to be a continuous high-response region formed by multiple overlapping targets, the overall response intensity is reduced, and the features in the region are redistributed to the vicinity of multiple local response centers. After the above processing, the originally continuous target response can be transformed into multiple relatively independent local response regions, so that the subsequent detection head can output multiple insect targets respectively. In one implementation, boundary enhancement characterization can also be performed at different levels. For high-resolution fusion feature maps, the focus is on preserving the edges of the insect outline and local transition positions; for medium-resolution fusion feature maps, the focus is on enhancing the separation between multiple response centers; for low-resolution fusion feature maps, the focus is on limiting the excessive diffusion of the target response to the surrounding area. After this processing, feature maps at different scales can participate in the separation of adjacent insects, thereby improving the detection stability in dense insect scenes. In one implementation, after the boundary enhancement characterization is formed, the number of local response peaks and the strength of boundary differences can be used as auxiliary inputs for subsequent detection heads. When there are many peaks and significant boundary differences in a certain local area, the detection head prioritizes classification and location regression in a multi-target manner. When there is only a single peak in a certain local area and the boundary distribution is continuous, the detection head outputs results in a single-target manner. In this way, the situation where multiple adjacent insects are misclassified as a single target can be further reduced. In some implementations, the enhancement of the boundary representation of adjacent micro-insects can be performed in layers. For example, for high-resolution fused feature maps, the focus is on enhancing the outline of the insect and the edge transition; for medium-resolution fused feature maps, the focus is on enhancing the ability to distinguish between multiple local peaks; and for low-resolution fused feature maps, the focus is on limiting the region response from excessive diffusion. The reason for this is that the tasks undertaken by feature maps at different levels are not entirely the same: high-resolution layers are more suitable for viewing details, intermediate layers are more suitable for viewing the distribution relationship of targets, and low-resolution layers are more suitable for performing region-level discrimination. Through layered enhancement, the boundary separation can be made more stable, and it is not only effective in a certain layer. To improve the implementation effect, the boundary enhancement representation in this step is preferably closely coordinated with the multi-scale fusion in the previous step, rather than being processed completely independently. In other words, the boundary difference clues that have been initially preserved in the multi-scale fusion are further amplified and sorted in this step. In this way, when the model enters the detection head later, it will no longer see a response map that "looks like a target everywhere", but a feature map that "has a relatively independent target center, clearer target boundaries, and more obvious transitions between adjacent targets". During training, the boundary enhancement representation generated in this step can also be used in conjunction with boundary constraint supervision. That is, instead of relying on the model to learn the boundary on its own, the model is guided to focus on the boundary region between adjacent insects in the training samples. For dense small insect samples, the training ratio of such samples can be appropriately increased so that the model can adapt to the situation of multiple targets being close together earlier and obtain the feature map after boundary enhancement representation.
[0024] S5. Input the features after boundary enhancement into the detection head for target classification and location regression, and output insect category information and target location information. The detection head decouples the classification features and localization features to reduce false positives, false negatives, and mixed detections in dense, small target scenarios. Specifically, the implementation is as follows: In this step, the features obtained in step S4 after boundary enhancement are input into the detection head to perform target classification and location regression tasks. The detection head is the part that directly outputs the recognition results in the entire detection chain. The previous steps are more like laying the foundation for it, while this step is to truly transform the boundary information, detail information and semantic information accumulated in the previous steps into usable detection results. In some traditional detection methods, classification and regression often share a set of features or have only very simple branches for differentiation. While this approach may not be problematic in general scenarios, it often leads to two issues in dense, small-target insect infestation scenarios: first, classification features tend to focus more on overall semantics to differentiate categories, resulting in insufficiently fine localization boundaries; second, localization features focus more on local textures to fit the boundaries, which can affect the stability of category discrimination, especially when multiple insects are close together and have similar shapes. Therefore, this invention preferably employs a decoupled detection head structure, that is, processing the classification and regression branches separately. In one implementation, the detection head includes a classification branch, a regression branch, and an optional target confidence branch. The classification branch is mainly responsible for outputting which category the insect belongs to, the regression branch is mainly responsible for outputting the location information of the insect target, and the target confidence branch is used to reflect whether the candidate region actually contains the target. For cases where the structural simplification is the only goal, the target confidence and classification output can be considered together. However, in most implementations, retaining the target confidence branch separately is more beneficial for subsequent result screening. In one implementation, the feature sources received by the classification branch and the regression branch can be different. The classification branch preferably receives mid-level fusion features and deep fusion features to complete the insect category determination using relatively stable category semantic information. The regression branch preferably receives high-resolution fusion features and features after boundary enhancement representation to complete the target location determination using clearer edge and boundary information. With this setting, the classification branch and the regression branch each process feature content more suitable for their respective tasks, thereby reducing the mutual influence between category discrimination and boundary localization. In one implementation, the classification branch is mainly used to enhance the ability to distinguish between insects with similar morphology. For insect categories with similar appearance, similar body color, or small differences in local texture, the classification branch preferably refers more to local contour, pattern distribution, segment morphology, and local color difference information to improve the stability of category judgment. For categories that are prone to mixed detection, the participation ratio of the corresponding samples can be appropriately increased during the training phase to enhance the classification branch's ability to identify such differences. In one implementation, the regression branch is mainly used to enhance the boundary localization capability between densely adjacent insects. For insects that are close to each other, partially overlap, or are closely arranged, the regression branch prefers to refer to more feature responses after the boundary enhancement, local peak positions, and transition region information between adjacent targets, so that each detection box fits the actual range of a single insect as closely as possible, without expanding into the region of adjacent insects. After such processing, multiple adjacent insects are more likely to output multiple independent bounding boxes. In one implementation, the outputs of the classification branch and the regression branch jointly participate in the final target result determination. If the classification branch determines different categories and the regression branch outputs multiple independently located bounding boxes, they are retained as multiple targets respectively. If the classification branch determines the same category, but the centers of the bounding boxes output by the regression branch are clearly separated and there is a clear boundary in the boundary enhancement features, they are still processed as multiple independent targets. If both the classification branch and the regression branch show that the targets are highly overlapping and lack independent boundaries, they are output as a single target result. Through this joint judgment method, the problems of mixed detection of similar insects and boundary drift can be further reduced. The input to the classification branch should preferably reference more of the fused features from the shallow and medium layers. This is because insect classification often relies not only on deep semantics but also on fine-grained information such as local contours, markings, color distribution, body segment morphology, and even wing shape. If only deep semantic features are used, some insects with similar appearances may be difficult to distinguish. For example, some small flying insects may look similar from a distance, but differences can be found in their local contours or body color details. If the classification branch can retain more shallow and medium-layer features, it has a better chance of capturing these differences. In terms of the classification branch structure, several layers of convolutional units can be used to gradually extract category discrimination features. The number of convolutional layers can be set to 2 to 5, preferably 2 or 3. The kernel of each convolutional layer is preferably 3×3 or 1×1. The number of channels can be set to 64, 96, 128 or 160. In order to prevent the branches from being too heavy and causing additional overhead, it is preferable to use a lightweight convolutional structure or a smaller channel configuration. The number of classification output categories is set according to the actual pest monitoring task. For example, in pest monitoring of a single crop, it can be set to 5 to 15 categories; in multi-crop or integrated pest monitoring, it can be set to 15 to 50 categories or even more. For each type of insect, it can be further distinguished into different growth stages such as adult, nymph or egg, provided that the training sample annotation is sufficiently detailed. The input to the regression branch preferably references more boundary-enhanced features and high-resolution fused features. The reason is simple: localization relies on boundary, center, and scale information, not just simple category semantics. For densely packed small insects, if the regression branch only considers coarser region responses, it can easily group multiple closely spaced insects into one large box, or position the box between two insects. Therefore, this invention preferably allows the regression branch to have more contact with boundary-enhanced features, so that when regressing the center point and width / height, it can refer as much as possible to those separated boundary cues and independent peak information. In the regression branch, the center position and size information of each candidate target are typically output. The position parameters of the candidate target can include the center horizontal position, center vertical position, width, and height. In some implementations, more detailed boundary offset information can also be output to improve the fit of the bounding boxes. For small target scenarios, it is preferable to increase the participation of the localization branch on the high-resolution feature map. For example, for fusion feature maps at a scale of 1 / 4 or 1 / 8, a dedicated small target detection branch can be set up so that smaller, closely spaced insect bodies are preferentially handled by these high-resolution branches to output position parameters. For feature maps at a resolution of 1 / 16 or lower, it is more suitable for handling the detection tasks of general small and medium-sized targets. To improve the detection of insects of different sizes, the detection head can be configured with multi-layer output. For example, a high-resolution detection layer can handle extremely small insects with dimensions of approximately 6 to 24 pixels in the original image; a medium-resolution detection layer can handle small insects with dimensions of 16 to 64 pixels; and a low-resolution detection layer can handle medium-sized targets with dimensions of 48 pixels or more. Specific thresholds can be adjusted based on actual statistical results from the samples. Through layered output, insects of different sizes can be detected by the most suitable feature layer, thus reducing the problem of "small insects being invisible in deeper layers and large insects being incompletely visible in shallower layers." The target confidence branch outputs the probability of each candidate target's existence. This branch is very useful for subsequent screening, especially when the background is complex or the insect density is high. A high classification probability does not necessarily mean that there is actually an independent target; sometimes it is just an incorrect response caused by multiple insects or background noise. Therefore, outputting the target existence probability separately can provide an additional layer of judgment for subsequent result optimization. During training, the classification and regression branches are preferably jointly optimized using losses adapted to their respective tasks. The classification loss is mainly used to improve the accuracy of category discrimination, especially the ability to distinguish between similar insects; the regression loss is mainly used to improve the fit between the bounding box and the real insect, especially the ability to locate and separate adjacent insects. In this invention, a boundary constraint term can also be introduced to make the regression branch more sensitive to the boundary region between adjacent targets. For example, when there are two insects close to each other in the training sample, the regression branch should not only learn their respective center points and scales, but also try to avoid extending the detection box into the intermediate transition region. The regression branch trained in this way is less likely to encounter situations where a large bounding box covers multiple insects during actual inference. In actual deployment, if it is found that the model still has mixed detections for some similar insects, it can be improved by increasing the number of such samples, refining the labeling criteria, or strengthening the dependence of the classification branch on local features; if it is found that the model is still prone to false mixed detections for dense insects, it can be improved by increasing the proportion of high-resolution features used in the regression branch or increasing the training weights of boundary constraints. Finally, the detection head outputs insect category information and target location information. The category information includes the category label and category probability of each target, and the location information is the corresponding bounding box parameters.
[0025] S6. Perform target screening and result optimization processing on the insect category information and target location information to obtain the final pest detection result. The specific implementation is as follows: In this step, the insect category information and target location information output from step S5 are processed for target filtering and result optimization to obtain the final pest detection result. This step can be understood as the "final check" of the detection chain. The preceding feature extraction, fusion, boundary enhancement, and detection head output have tried their best to distinguish, identify, and box the targets. However, there may still be duplicate boxes, overlapping boxes, false boxes, or multiple insects being incorrectly merged in the detection result. Especially in dense small target scenarios, if the last step is not processed carefully enough, it is easy to "suppress" multiple small targets that have been saved in the previous steps in the post-processing. In one implementation, the target screening and result optimization process sequentially includes initial confidence screening, overlapping candidate target discrimination, local region verification, and final result output; The initial confidence screening is used to remove obviously invalid candidate targets; overlapping candidate target discrimination is used to identify possible duplicate boxes and mismerged boxes; local region verification is used to confirm whether overlapping candidate targets correspond to multiple independent worms in the high-resolution fused feature map or boundary enhancement representation map; the final result output is used to generate worm category, location and number results; First, a basic screening is performed on the candidate targets output by the detection head. This basic screening is usually based on the target confidence and category probability. The target confidence threshold can be set according to the needs of the scenario. If the background is clean and the number of missed detections is too small, the threshold can be set to 0.15 to 0.30. If there is a lot of background interference and the cost of false detection is high, the threshold can be set to 0.25 to 0.50. The category probability threshold can also be set separately, and it can generally be controlled between 0.20 and 0.60. In practice, the common practice is to first screen out the candidate boxes with low target confidence, and then further sort the remaining results according to the category probability. For multi-category pest monitoring, thresholds can also be set separately for each category. For example, the threshold can be appropriately increased for categories that are similar in appearance and easily confused, and the threshold can be appropriately decreased for categories that are very small and originally difficult to detect, in order to reduce excessive missed detections. In some implementations, a reasonableness check can be performed based on the bounding box size after the basic screening. For example, for the detection results of a 640×640 input image, if some candidate boxes are only 1 to 2 pixels wide and high, or are more than half the size of the entire image, and are clearly inconsistent with the actual monitoring scenario, they can be regarded as abnormal results and removed. For insect pest monitoring scenarios, the width and height of normal small insect targets on the input image are generally between 4 and 80 pixels, extremely small targets can be as low as 3 to 15 pixels, and medium targets may reach 30 to 120 pixels. The specific range can be set according to the statistical results of the dataset. Through this simple size reasonableness judgment, some obviously unreliable false boxes can be removed. Next, the overlapping relationships between candidate targets are processed. Traditional post-detection processing often uses conventional overlap suppression strategies, that is, when two candidate boxes overlap significantly, only the one with higher confidence is retained. This approach is common in general object detection, but it has obvious problems when used in scenes with dense small insects: multiple real insects are naturally close together, and some overlap between boxes is normal. If all boxes are deleted based on "large overlap", it is easy to delete real targets. Therefore, in the result optimization process of this invention, the overlapping relationship processing is not simply determined by the degree of overlap, but comprehensively considers boundary difference information, local response intensity, independent discrimination features, and the spatial distribution relationship between candidate targets. Specifically, when the center-to-center distance between two or more candidate targets is less than a preset threshold, or the overlap between candidate boxes is greater than a preset threshold, the target with lower confidence is not immediately deleted, but further judgment is performed. The center-to-center distance threshold can be set according to the input size and target size, for example, it can be set to 6 to 24 pixels, preferably 8 to 18 pixels; the overlap threshold can be set to 0.40 to 0.80, preferably 0.50 to 0.70. If there are two clearly independent response centers in the corresponding areas of two boxes, or the boundary enhancement characterization shows that their boundary area is relatively clear, it means that they are more likely to correspond to two different insects and should be retained at the same time; if the two boxes are basically around the same response center, only slightly off in position, it means that they are more likely to correspond to the same insect, and only the box with better quality can be retained. When determining whether a target is independent, the following information can be considered: First, the distance between the center points of the candidate boxes; second, whether there are independent local peaks in the corresponding regions of the candidate boxes; third, whether there are clear boundary clues in the boundary enhancement features; and fourth, whether the classification results show that the two are different categories, or even if they are the same category, they still have obvious independent responses. By combining these factors, dense small insects can be handled more reliably than simple overlap suppression. To put it simply, we cannot only look at whether the two boxes overlap, but also whether they are two different insects. In some implementations, result optimization can also be combined with local region re-examination. For example, for several candidate boxes that are particularly close to each other, a local review can be performed on the high-resolution fused feature map or the boundary enhancement representation map to check how many independent peaks or obvious boundary transition regions are covered by these boxes. If the review results show that the number of targets is greater than the number of boxes currently retained, the suppression conditions can be appropriately relaxed. If the review results show that multiple boxes are indeed around the same target center, then duplicate boxes are suppressed. Although this process increases the computational cost slightly, it is usually worthwhile for high-density insect scenes. If the block input method is used in step S1, this step also includes merging cross-block results. That is, the targets detected on different blocks need to be mapped back to the original large image coordinate system. After mapping, the edges of different blocks may produce duplicate detections of the same insect body. Therefore, cross-block deduplication is also required. The deduplication principle can be similar to the aforementioned overlapping relationship processing, but the fact that there is a fixed overlapping area between blocks must be considered. Generally speaking, if two boxes come from adjacent blocks and their positions are close in height after mapping, with a center distance of less than 4 to 12 pixels and an overlap of more than 0.5 to 0.8, they are more likely to be duplicate detections of the same target in different blocks. The one with higher confidence can be retained. If deployed in video stream or continuous monitoring scenarios, this step can be extended to cross-frame result stabilization. That is, when the same type of insect is detected at the same location in several consecutive frames, the category and location results can be smoothly output to reduce the jitter caused by false detections in a single frame. For example, a newly appearing target can be required to appear at least twice in 2 to 5 consecutive frames before being included in the official statistics. The positions in consecutive frames can also be averaged or weighted to update, thereby making the monitoring results more stable. This cross-frame stabilization is particularly useful for fixed sticky insect board scenarios because the actual target position usually does not change much, while the false detection box often appears and disappears intermittently. In terms of output, the final pest detection results can include information such as the category label, category confidence, bounding box position, center coordinates, target size, and source detection level for each target. If the system needs to perform pest statistics, it can further output the number of each type of insect, the total number of targets, the insect density per unit area, and the distribution of high-density areas. For scenarios connected to the management platform, the detection results can also be saved in chronological order to form a pest change record for subsequent analysis and early warning. Finally, after target screening and result optimization, the final pest detection results were obtained.
[0026] In one embodiment, the method of the present invention further includes a model training process. The training samples are preferably obtained from insect pest images acquired under different acquisition devices, different lighting conditions, and different insect density scenarios. In order to make the model more suitable for the actual monitoring environment, the training samples preferably include single-target samples, densely distributed samples, partially occluded samples, and insect samples with similar morphology. For densely distributed samples, it is preferable to ensure that the image contains at least two insect targets that are close to each other. For occluded samples, it is preferable to ensure that there is partial edge occlusion or local overlap between the insects. For samples with similar morphology, it is preferable to ensure that there are at least two types of insects with similar shapes. For sample annotation, it is preferable to use a per-target bounding box annotation method to annotate insect targets. For multiple insects in a densely distributed area, it is preferable to annotate the location range of each insect separately, rather than merging multiple insects into a single region. For smaller insects, the annotation should be as close as possible to the actual outline of the insect to more accurately constrain the classification and location results during training. If the sample contains targets at different stages such as adults, nymphs, or eggs, they can also be annotated separately according to the category system. In terms of training strategy, the model can be initially trained using common insect pest samples to enable it to develop basic target recognition capabilities. Then, densely distributed samples, occluded samples, and samples with similar morphology can be added for reinforcement training to gradually adapt the model to the task of detecting tiny insects in complex scenarios. The initial training rounds can be set to 80 to 200 rounds, and the reinforcement training rounds can be set to 30 to 120 rounds. The learning rate can be set according to the training stage. The initial training stage can use a learning rate of 0.001 to 0.01, and the reinforcement training stage can be appropriately reduced to 0.0001 to 0.001. The batch size can be set to 8, 16, 24, or 32 depending on the available video memory. During training, at least classification loss and localization loss are used to jointly optimize the model. Classification loss is used to constrain the output of the insect category, and localization loss is used to constrain the output of the target position. In order to enhance the model's ability to identify the boundary region of densely adjacent insects, boundary constraint loss can be further introduced. The boundary constraint loss is mainly used to enhance the model's response to the boundary region of adjacent insects, so that multiple insects that are close to each other maintain a good separation state at the feature level. For dense small target samples, the participation ratio of boundary constraint loss can be appropriately increased to enhance the model's learning effect on this type of scene. During the validation phase, a separate set of validation samples can be used to evaluate the model's detection performance. The evaluation should include at least the detection accuracy, false negative rate, false positive rate, and mixed detection rate. If the validation results show that there are still many mixed detections among similar insects, the number of samples of the corresponding category can be appropriately increased or the training ratio of samples related to the classification branch can be increased. If the validation results show that multiple insects in dense areas are still prone to merging, the proportion of dense samples can be appropriately increased or the training intensity of boundary constraints can be increased. After training and validation adjustments, the target detection model for actual deployment is obtained.
[0027] 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 lightweight optimization method for detecting small-target insect pests using YOLOv10, characterized in that, Includes the following steps: S1. Obtain an image of the pest to be detected, and preprocess the image of the pest to be detected to obtain an input image; S2. Input the input image into a lightweight feature extraction network for multi-layer feature extraction to obtain a multi-layer feature map containing shallow detail features and deep semantic features. The lightweight feature extraction network retains the edge texture information and local contour information of the tiny insect body while reducing the number of model parameters and computational cost. S3. Perform multi-scale fusion on the multi-layer feature map to obtain a fused feature map, wherein the boundary difference information between adjacent micro-insects in the densely distributed area is enhanced during the multi-scale fusion process. S4. Construct an enhanced representation of the boundary between adjacent micro-insects based on the fused feature map to strengthen the edge response information and independent discrimination features of adjacent insects in dense areas; S5. Input the features after boundary enhancement into the detection head for target classification and location regression, and output insect category information and target location information. The detection head decouples the classification features and the localization features to reduce false positives, false negatives and mixed detections in dense small target scenes. S6. Perform target screening and result optimization processing on the insect category information and target location information to obtain the final pest detection result.
2. The lightweight optimization method for detecting small target pests using YOLOv10 according to claim 1, characterized in that: Acquire an image of the pest to be detected, preprocess the image to obtain an input image, including: Acquire images of pests to be detected by insect monitoring lamps, sticky insect monitoring devices, greenhouse monitoring cameras, fixed field collection terminals, mobile inspection terminals, and manual shooting equipment; The images of the pests to be detected are resized and pixel normalized. The image, after being resized and normalized, undergoes brightness adjustment, contrast adjustment, flip transformation, random cropping, and noise perturbation to obtain the input image.
3. The lightweight optimization method for detecting small target pests using YOLOv10 according to claim 1, characterized in that: The input image is fed into a lightweight feature extraction network for multi-layer feature extraction, resulting in a multi-layer feature map containing shallow detail features and deep semantic features, including: The input image is fed into a lightweight feature extraction network that is improved based on the YOLOV10 backbone network; By lightweighting and replacing the basic feature extraction structure in the YOLOV10 backbone network, the number of model parameters and computational cost are reduced. In the lightweight feature extraction process, shallow feature outputs that represent the edge texture information and local contour information of tiny insect bodies are retained to obtain multi-layer feature maps.
4. The lightweight optimization method for detecting small target pests using YOLOv10 according to claim 3, characterized in that: The basic feature extraction structure in the YOLOv10 backbone network is replaced with a lightweight version, including: The standard convolutional structure in the original backbone network is replaced by a lightweight convolutional structure, a depthwise separable convolutional structure, a partial channel feature extraction structure, and a bottleneck compression structure. The system outputs shallow feature maps after the input image passes through 2x downsampling layers, 4x downsampling layers, and 8x downsampling layers to reduce the loss of detailed features of tiny insect bodies during the downsampling process.
5. The lightweight optimization method for detecting small target pests using YOLOv10 according to claim 1, characterized in that: Multi-scale fusion of the multi-layer feature maps is performed to obtain a fused feature map, including: Perform size alignment and channel adjustment on feature maps at different levels; By employing bidirectional fusion, cross-layer aggregation, and weighted fusion methods, shallow detail features and deep semantic features can jointly participate in the representation of the insect target. In the multi-scale fusion process, at least one shallow feature map is introduced to enhance the boundary difference information between adjacent micro-insects in densely distributed areas, thus obtaining a fused feature map.
6. The lightweight optimization method for detecting small target pests using YOLOv10 according to claim 5, characterized in that: Enhancing boundary difference information between adjacent micro-insects within densely distributed regions during multi-scale fusion includes: Enhance the local edge response regions in the shallow feature map; Analyze the transition region features between multiple local response peaks in the fused feature map; Furthermore, based on the characteristics of the local edge response region and the transition region between multiple local response peaks, the boundary difference information between adjacent micro-insects in the densely distributed region is enhanced.
7. The lightweight optimization method for detecting small target pests using YOLOv10 according to claim 1, characterized in that: Based on the fused feature map, an enhanced representation of the boundary between adjacent micro-insects is constructed, including: Extract edge response information between adjacent insects within a dense region; By combining local texture changes, feature response differences, and spatial relationships in the target neighborhood, boundary difference description information is constructed. The boundary difference description information is used to perform weighted enhancement and feature redistribution on the fused feature map to strengthen the edge response information and independent discrimination features of adjacent insects in dense areas.
8. The lightweight optimization method for detecting small target pests using YOLOv10 according to claim 1, characterized in that: The features, after boundary enhancement, are input into the detection head for target classification and location regression, outputting insect category information and target location information, including: The features after boundary enhancement are input into the classification branch and the regression branch respectively; The insect category discrimination features are extracted by classifying branches and the insect category information is output. Extract the target location boundary features through regression branch and output the target location information; The classification branch and the regression branch are decoupled.
9. The lightweight optimization method for detecting small target pests using YOLOv10 according to claim 8, characterized in that: The classification and regression branches are decoupled, including: The ability to identify fine-grained differences in features between morphologically similar insects is enhanced by taxonomic branching; The ability to constrain the boundary positions of densely adjacent insect bodies is enhanced by regression branching; The results of the classification branch and the regression branch are used to jointly determine the worm category information and the target location information, so as to reduce the mixed detection of similar worms and boundary drift.
10. The lightweight optimization method for detecting small target pests using YOLOv10 according to claim 1, characterized in that: The insect category information and target location information are used for target screening and result optimization to obtain the final pest detection results, including: Confidence-based screening is performed on candidate targets corresponding to insect category information and target location information; When the center distance between candidate targets is less than a preset threshold or the degree of overlap is greater than a preset threshold, the candidate targets are retained or suppressed by combining target boundary difference information, local response intensity and independent discrimination features. The candidate targets that have been retained or suppressed will be output as the final pest detection results.