Crop pest detection method and system based on improved ConvNeXt

By constructing the EDA-ConvNeXt model, which integrates multi-scale features and insect outline information, the adaptability and accuracy of crop pest detection in complex environments are solved, achieving higher recognition accuracy and robustness, and supporting intelligent monitoring and control of crop pests.

CN121708345APending Publication Date: 2026-03-20JILIN AGRI SCI & TECH COLLEGE
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511618057.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-06
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

Existing methods for detecting crop pests are not adaptable and accurate enough in complex field environments, and are difficult to effectively integrate multi-scale features, enhance insect outline information, and adapt to morphological changes.

Method used

The EDA-ConvNeXt model is constructed, including a backbone network, an edge enhancement branch, a dynamic feature extraction branch, and a multi-branch feature fusion module. Through multi-level feature extraction, insect contour enhancement, and dynamic feature fusion, the detection accuracy and robustness are improved.

Benefits of technology

It achieves higher recognition accuracy and stronger generalization ability in complex field scenarios, providing intelligent monitoring and control support for crop pests.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121708345A_ABST
    Figure CN121708345A_ABST
Patent Text Reader

Abstract

The invention discloses a crop insect pest detection method and system based on improved ConvNeXt, and relates to the technical field of crop insect pest detection, and the method comprises the steps: constructing an EDA-ConvNeXt model, training the EDA-ConvNeXt model to obtain a crop insect pest detection model, according to the method, the detection precision is improved through the EDA-ConvNeXt model, the multi-scale features are captured by the backbone network, the boundary information is enhanced by the edge enhancement branch, the dynamic feature extraction branch adapts to the morphological change, and the key features are highlighted by the multi-branch fusion. The classification layer ensures the recognition reliability, and finally higher accuracy is achieved in a complex field scene.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of crop pest detection technology, and in particular to a crop pest detection method and system based on an improved ConvNeXt. Background Technology

[0002] Crops are not only a staple food for residents but also play a vital role in animal husbandry and the food industry. During production, pests are a major factor causing reduced crop yields and quality decline, estimated at 10%–15% annually. To achieve effective control, agricultural production generally emphasizes timely identification and appropriate measures in the early stages of pest outbreaks; therefore, accurate identification of pest species and infestation severity is crucial. However, traditional methods relying on manual observation and experience are not only time-consuming and labor-intensive but also susceptible to environmental complexity and subjective factors, leading to misjudgments or omissions. With the development of machine learning and deep neural networks, crop pest identification is gradually evolving from manual methods and traditional image processing to automated identification technologies based on deep learning, providing new technological support for green pest control and smart agriculture.

[0003] In its early stages, research on crop pest image detection mainly focused on exploring and optimizing manually designed features and traditional classification algorithms. This period of research largely relied on low-level features such as color, texture, and morphology to describe pest images. For example, Zhao Sanqin et al. used Fourier descriptors to extract the contour morphological features of rice planthoppers to enhance robustness to changes in insect posture and scale. Liu Deying et al. captured the morphological invariance of pests through image spectral features, thus maintaining good classification stability under different shooting conditions. Zou Xiuguo et al. integrated multiple invariant moments and combined them with a BP neural network to build a classifier, improving the discrimination accuracy of rice planthoppers. Meanwhile, Lü Jun et al. proposed a multi-target recognition method based on template matching, achieving rapid pest detection under field light-attracting conditions. Li Zhen et al. used K-means clustering to complete the automatic segmentation of pest images, providing prior knowledge for subsequent classification. Xiao Y et al. further introduced the bag-of-words model (BOF-SVM) to classify vegetable pest images through a feature dictionary, demonstrating the feasibility of traditional machine learning methods in agricultural pest identification. Building upon this foundation, Cheng Ke et al. proposed a hybrid algorithm combining multiple features, while Xie Chengjun et al. introduced sparse coding and a spatial pyramid model to enhance discrimination capabilities in complex backgrounds. These works signify a gradual transition from traditional methods to more complex feature representations, aiming to overcome practical challenges in field pest detection such as large variations in lighting, cluttered backgrounds, and differences in insect size.

[0004] With the rise of deep learning technology, this field entered a data-driven intelligent recognition stage after 2016, fundamentally changing the research paradigm. Liu Tingting et al. pioneered the application of convolutional neural networks to crop disease recognition, validating the effectiveness of deep learning in agriculture and breaking through the limitations of traditional feature-dependent methods. Subsequently, research focus gradually shifted to high-precision detection and network structure optimization. For example, Yao Qing et al. improved the RetinaNet model, achieving accurate detection of small-scale insect damage in the crop canopy, effectively alleviating the problem of field insects being easily obscured by plants or interfered with by background noise. In recent years, research has deepened further. Li Y et al. proposed a deep residual network for multi-scale feature extraction, effectively solving the problems of large differences in insect scale and insufficient cross-scene generalization ability. However, existing deep learning methods still have limitations when dealing with complex field environments, especially in scenarios with blurred insect outlines, varied morphologies, and severe background interference; detection accuracy and robustness still need improvement.

[0005] In summary, the adaptability and accuracy of existing crop pest detection methods in complex field environments still need further improvement. There is an urgent need for a detection scheme that can effectively integrate multi-scale features, enhance insect outline information, and adapt to morphological changes, so as to improve the accuracy and practicality of crop pest identification. Summary of the Invention

[0006] The technical problem to be solved by this invention is to address the shortcomings of existing technologies, specifically by providing a method and system for detecting crop pests based on an improved ConvNeXt, as detailed below: 1) In a first aspect, the present invention provides a method for detecting crop pests based on an improved ConvNeXt, the specific technical solution of which is as follows: An EDA-ConvNeXt model is constructed, comprising a backbone network, an edge enhancement branch, a dynamic feature extraction branch, a multi-branch feature fusion module, and a classification layer. The backbone network, built based on the ConvNeXt structure, is used to extract multi-level features from sample crop pest images. The edge enhancement branch extracts insect contour enhancement features from the sample crop pest images. The dynamic feature extraction branch processes the feature maps output from at least one downsampling stage in the backbone network using multiple expert deep convolutional kernels to obtain dynamic features. The multi-branch feature fusion module performs weighted fusion processing on the multi-level features, insect contour enhancement features, and dynamic features to obtain the final features. The classification layer generates pest category identification results corresponding to the sample crop pest images based on the final features. The EDA-ConvNeXt model was trained to obtain a crop pest detection model; The pest category identification results corresponding to the crop pest images to be detected are obtained by using a crop pest detection model.

[0007] The beneficial effects of the improved ConvNeXt-based crop pest detection method provided by this invention are as follows: By constructing the EDA-ConvNeXt model, the accuracy and robustness of crop pest detection were effectively improved. The backbone network, based on the ConvNeXt structure, extracts multi-level features, capturing rich information from low-level details to high-level semantics, enhancing its adaptability to multi-scale changes in the insect body. The edge enhancement branch extracts insect contour enhancement features, explicitly strengthening the insect boundary information and reducing the impact of texture confusion and noise interference in complex field backgrounds. The dynamic feature extraction branch utilizes multiple expert deep convolutional kernels to generate adaptive dynamic features, flexibly adjusting the feature extraction strategy according to the input content, improving adaptability to insect morphological diversity and environmental changes. The multi-branch feature fusion module integrates global structure, local details, and dynamic information by weighted fusion of multi-level features, insect contour enhancement features, and dynamic features, highlighting key features and suppressing redundant content. The classification layer generates pest category identification results based on the final features, ensuring the accuracy and reliability of the prediction. The entire method, through an end-to-end training and inference process, achieves higher recognition accuracy and stronger generalization ability in complex field scenarios, providing reliable technical support for intelligent monitoring and control of crop pests.

[0008] 2) Secondly, the present invention also provides a crop pest detection system based on an improved ConvNeXt, the specific technical solution of which is as follows: It includes: a model building module, a model training module, and a model application module; The model building module is used to construct the EDA-ConvNeXt model, which includes a backbone network, an edge enhancement branch, a dynamic feature extraction branch, a multi-branch feature fusion module, and a classification layer. The backbone network is built based on the ConvNeXt structure and is used to extract multi-level features from sample crop pest images. The edge enhancement branch is used to extract insect contour enhancement features from sample crop pest images. The dynamic feature extraction branch is used to process the feature maps output from at least one downsampling stage in the backbone network using multiple expert deep convolutional kernels to obtain dynamic features. The multi-branch feature fusion module is used to perform weighted fusion processing on multi-level features, insect contour enhancement features, and dynamic features to obtain the final features. The classification layer is used to generate pest category identification results corresponding to the sample crop pest images based on the final features. The model training module is used to train the EDA-ConvNeXt model to obtain a crop pest detection model. The model application module is used to: use the crop pest detection model to identify the pest category corresponding to the image of the crop pest to be detected.

[0009] 3) In a third aspect, the present invention also provides an electronic device, the electronic device including a processor coupled to a memory, the memory storing at least one computer program, the at least one computer program being loaded and executed by the processor to enable the electronic device to implement any of the above-mentioned crop pest detection methods based on the improved ConvNeXt.

[0010] 4) In a fourth aspect, the present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements any of the above-mentioned crop pest detection methods based on the improved ConvNeXt.

[0011] It should be noted that the beneficial effects of the technical solutions of the second to fourth aspects of the present invention and their corresponding possible implementations can be found in the above description of the technical effects of the first aspect and its corresponding possible implementations, and will not be repeated here. Attached Figure Description

[0012] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments of the present invention will be briefly introduced below: Figure 1 This is a schematic flowchart of a crop pest detection method based on an improved ConvNeXt according to an embodiment of the present invention. Figure 2 This is a schematic diagram of the EDA-ConvNeXt model. Figure 3 This is a schematic diagram of an edge-enhanced branch structure; Figure 4 This is a schematic diagram of the branch structure for dynamic feature extraction; Figure 5 This is a schematic diagram of the multi-branch feature fusion module structure; Figure 6 A schematic diagram illustrating the example distribution of the dataset; Figure 7 This is a schematic diagram of the model training loss curve; Figure 8 A schematic diagram of the ROC curve for the model's classification performance; Figure 9 A schematic diagram of the confusion matrix of the model classification results; Figure 10 This is a schematic diagram of the results of the parameter sensitivity analysis; Figure 11 This is a schematic diagram of the structure of a crop pest detection system based on an improved ConvNeXt according to an embodiment of the present invention. Detailed Implementation

[0013] like Figure 1 As shown in the figure, an embodiment of the present invention provides a method for detecting crop pests based on an improved ConvNeXt, comprising the following steps: S1. Construct the EDA-ConvNeXt model. The EDA-ConvNeXt model includes a backbone network, an edge enhancement branch, a dynamic feature extraction branch, a multi-branch feature fusion module, and a classification layer. Specifically: 1) The backbone network is constructed based on the ConvNeXt structure and is used to extract multi-level features from sample crop pest images; The backbone network consists of an initial Stem layer and multiple successive feature extraction stages. Each feature extraction stage comprises stacked EConvNeXt blocks, connected by downsampling operations to progressively reduce spatial resolution and increase the number of channels, thus forming a hierarchical feature representation. The Stem layer is responsible for initial feature mapping and downsampling of the input image, reducing computational complexity while preserving key information. Each feature extraction stage further extracts and refines features through multiple EConvNeXt blocks, which are based on depthwise and pointwise convolution operations, combined with layer normalization and residual connections to enhance feature representation and training stability. The downsampling operation is implemented through convolution stride, progressively reducing the feature map size and expanding the channel dimension, thereby capturing multi-level features from low-level details to high-level semantics.

[0014] The process of extracting multi-level features from sample crop pest images is as follows: ① Input sample crop pest images are represented as follows ,in Indicates batch size, Indicates the number of RGB channels. Indicates the image height. This represents the image width. First, the image is processed by the Stem layer, which consists of a 4×4 convolutional layer with a stride of 4, performing initial downsampling and feature mapping. The specific operation formula is as follows: ,in, This represents a two-dimensional convolution operation. This represents the convolutional weight parameters of the Stem layer. Output feature map. ,in, This indicates the initial number of channels, with the spatial resolution reduced to one-quarter of the original height and one-quarter of the original width.

[0015] ② The feature map undergoes hierarchical processing through multiple feature extraction stages. Each stage contains multiple stacked EConvNeXt blocks, connected by a downsampling module. The downsampling module uses convolutional layers with a kernel size of 2×2 and a stride of 2 to halve the spatial size of the feature map while doubling the number of channels. For example, the first... The input feature map for each stage is represented as follows: The size of the output feature map after downsampling is ,in Indicates the first The number of channels in a stage, usually Through this design, the network gradually captures features at different scales: the lower-level stages retain high spatial resolution and detailed information, while the higher-level stages provide low-resolution but semantically rich abstract features.

[0016] In each stage of the EConvNeXt block, feature extraction is achieved through the following steps: for input features First, apply layer normalization: ,in, The representation layer is normalized to stabilize the training process. Then, a depthwise convolution operation is performed, using a kernel size typically of 7×7, to capture local spatial features. ,in, This represents a depthwise convolution operation. The weight parameters of the depthwise convolution are used to output features. Maintain the same dimensions as the input. Then, apply the GELU activation function to introduce nonlinearity: .

[0017] ③ Use point convolution operations, i.e., 1×1 convolution, to fuse channel information and adjust feature dimensions: ,in, This represents a point convolution operation. The weight parameters of the point convolution are represented, and the output features are... Finally, the input features are added to the point convolution output via residual connections to enhance gradient flow and feature reuse. By stacking multiple EConvNeXt blocks, each stage can progressively extract and refine features, thus forming a rich, multi-level feature representation. The entire backbone network outputs feature maps from multiple stages, which have different spatial resolutions and channel numbers, collectively constituting multi-level features for subsequent multi-branch feature fusion modules. This design effectively solves the problem of fine-grained feature loss caused by differences in insect morphology in complex field environments, improving the accuracy and robustness of pest detection.

[0018] Here, multi-level features refer to the output feature maps at the end of each feature extraction stage in the backbone network. Each stage's output feature map is the final result of processing multiple stacked EConvNeXt blocks within that stage, i.e., the output feature map of the last EConvNeXt block, denoted as... These feature maps, with varying spatial resolutions and channel numbers, form a hierarchical feature representation, capturing multi-scale information from low-level details (such as texture and edges) to high-level semantics (such as insect morphology). Specifically, the backbone network comprises multiple consecutive feature extraction stages, each consisting of a downsampling operation and multiple EConvNeXt blocks. The downsampling operation is implemented through convolutional strides, progressively reducing the spatial resolution of the feature maps and increasing the number of channels. Each EConvNeXt block performs operations such as depthwise convolution, pointwise convolution, and residual connections on the input features, outputting a feature map. The output feature map of each stage is the last EConvNeXt block of that stage. These output feature maps collectively constitute multi-level features, which are used in subsequent multi-branch feature fusion modules. For example, suppose the backbone network has multiple stages (such as stage 1, stage 2, stage 3, etc.): the input of stage 1 is the output feature map of the Stem layer, which is processed by multiple EConvNeXt blocks, and the output feature map of the last block is... As the output of Phase 1, the dimension is... The input to stage 2 is the output feature map of stage 1. After downsampling and processing by multiple EConvNeXt blocks, the output feature map of the last block is... As the output of stage 2, the dimension is... And so on, the output feature map of stage N. As the output of stage N. Indicates batch size, Indicates the first The number of channels in a stage Indicates the first The height of the stage feature map, Indicates the first The width of the stage feature map. Through this design, the multi-level features output by the backbone network can effectively characterize the features of the insect at different scales, solving the problem of fine-grained feature loss caused by morphological differences of insects in complex field backgrounds, and improving detection accuracy.

[0019] 2) The edge enhancement branch is used to extract insect contour enhancement features from sample crop pest images. Specifically, the Sobel operator is used to calculate the horizontal and vertical gradients of each channel of the sample rice pest image, and the gradient magnitude is calculated based on the horizontal and vertical gradients. The edge response features are generated based on the gradient magnitudes, and then mapped through a convolutional layer to obtain the insect contour enhancement features.

[0020] The edge enhancement branch is an independent component in the EDA-ConvNeXt model, mainly consisting of three sequential parts: a Sobel operator convolutional layer, a gradient magnitude calculation module, and a convolutional mapping layer. The Sobel operator convolutional layer is responsible for calculating the gradient responses of the input image in the horizontal and vertical directions, respectively; the gradient magnitude calculation module generates edge response features based on these gradient responses; and the convolutional mapping layer further refines the features through learnable convolutional operations, outputting the worm contour enhancement features. This entire branch runs in parallel with the backbone network, ensuring that edge information can be processed independently and that fine-grained structure is preserved. The specific implementation process for obtaining the worm contour enhancement features is as follows: ① Represent the input sample crop pest images as follows: ,in It is a four-dimensional tensor with dimension . . This indicates the batch size, which is the number of images processed at one time. This indicates the number of channels; for an RGB image, the number of channels is 3. Indicates the image height; Let represent the image width. The Sobel operator is used to calculate the horizontal and vertical gradients of each channel of the input image. The Sobel kernel in the horizontal direction is defined as... The specific form is as follows: The Sobel operator's convolution kernel in the vertical direction is defined as follows: The specific form is For the input image Each channel is independently convolutional to obtain the horizontal gradient response. and vertical gradient response The formula for convolution is: , ,in, This represents a two-dimensional convolution operation using a fixed Sobel convolution kernel. and It does not contain learnable parameters. Output and Dimensions and input They are the same, both are .

[0021] ②Based on horizontal gradient and vertical gradient Calculate the gradient magnitude. Calculated using the Euclidean distance formula, with the addition of a numerical stability constant. To prevent division by zero errors. The calculation formula is: ,in, Represents the gradient magnitude, with dimension . ; This represents the numerical stability constant, which is usually set to a minimum value, for example... Gradient magnitude As a direct edge response feature, it highlights edge and contour information in the image.

[0022] ③ Edge response characteristics The process is further processed by a convolutional mapping layer to generate enhanced features for the worm's outline. The convolutional mapping layer consists of a learnable two-dimensional convolutional operation, including convolutional weights. and bias This is followed by an activation function. The convolution operation formula is: ,in, This represents the weight parameters of the convolutional layer; This represents the bias parameters of the convolutional layer; This represents a 2D convolution operation using learnable parameters. Output The dimension is ,in This refers to the number of output channels, which can be adjusted according to the network design. Finally, an activation function such as GELU or ReLU is applied to introduce nonlinearity; the complete expression is: , This represents the activation function, such as the GELU function. Output This is the insect body contour enhancement feature, which is used in the subsequent multi-branch feature fusion module.

[0023] This implementation process enhances the ability to express insect outlines against complex field backgrounds by explicitly extracting gradient information, effectively solving the problem of confusion between insect details and rice leaf texture, and improving the accuracy of fine-grained pest identification.

[0024] 3) The dynamic feature extraction branch is used to process the feature maps output from at least one downsampling stage in the backbone network using multiple expert depth convolution kernels to obtain dynamic features. Specifically: Multiple expert deep convolutional kernels are used to convolve the feature maps output from at least one downsampling stage in the backbone network to obtain multiple expert features; after global average pooling of each received feature map, routing weights are generated through a routing function; and all expert features are weighted and fused using the routing weights to obtain dynamic features.

[0025] The dynamic feature extraction branch comprises four sequential parts: a multi-expert deep convolutional kernel module, a global average pooling layer, a routing function module, and a weighted fusion module. The multi-expert deep convolutional kernel module consists of a set of parallel deep convolutional layers, each using different kernel parameters to independently process the input feature map and generate diverse expert features. The global average pooling layer compresses the spatial dimension of the input feature map, generating channel-level statistical descriptions. The routing function module generates routing weight vectors based on the pooled features using learnable parameters, quantifying the importance of each expert feature. The weighted fusion module linearly combines all expert features according to the routing weights, outputting dynamic features. This entire branch runs in parallel with the backbone network, ensuring that feature extraction adapts to changes in the input. The specific implementation process of dynamic features includes: ① The input feature map comes from the output of at least one downsampling stage in the backbone network, denoted as: . This indicates the batch size, which is the number of feature maps processed at one time. Indicates the number of channels; Indicates the feature map height; This represents the width of the feature map. Multiple expert depthwise convolutional kernels are used to process the input feature map separately. Perform convolution operations. Define the set of expert depthwise convolution kernels as follows: ,in This represents the number of experts, and the depthwise convolution kernel for each expert. It is a two-dimensional convolution kernel with a size of , This indicates the kernel size. For each expert depthwise convolution kernel, a depthwise convolution operation is performed to obtain the expert features. The formula for depthwise convolution is: ,in, This represents a depthwise convolution operation. Indicates the first The weight parameters of each expert deep convolution kernel. Output expert features. It maintains the same spatial dimensions and number of channels as the input feature map. Each expert feature captures different local patterns in the input feature map, such as edge, texture, or shape information.

[0026] ② Input feature map Perform global average pooling. Global average pooling operation is performed along the spatial dimension height. and width Perform the process of generating channel description vectors. , Each channel corresponds to a scalar value, which sums the average activation of that channel across the entire spatial range.

[0027] ③ Generate route weights using the routing function. The routing function is a learnable mapping, typically implemented by a fully connected layer, which averages the vectors globally. Convert to weight vector The routing function formula is: ,in, The weight matrix of the routing function has dimensions of . ; The bias vector representing the routing function has dimensions of . ; This represents the softmax activation function, ensuring the output weight vector... The sum of the elements is 1. Output ,in, Indicates the first The nth sample pair The weights of each expert feature.

[0028] ④ Utilize route weights For all expert characteristics Weighted fusion is performed to obtain dynamic features. The weighted fusion formula is: ,in, This represents channel-level multiplication, specifically, for each sample Weight It is a scalar, and is related to expert characteristics. Each channel is multiplied, and this is achieved through a broadcast mechanism. The output dynamic characteristics are then processed. It integrates an adaptive combination of multiple expert features.

[0029] This implementation process, through multi-expert deep convolutional kernels and input-adaptive routing weights, enables the model to dynamically adjust the feature extraction strategy according to changes in insect morphology and background, effectively solving the problem of feature adaptation in complex environments with large differences in insect morphology, and improving the robustness and accuracy of detection.

[0030] 4) The multi-branch feature fusion module is used to perform weighted fusion processing on multi-level features, worm contour enhancement features and dynamic features to obtain the final features. Specifically, the multi-level features, worm contour enhancement features and dynamic features are concatenated in the channel dimension and the number of channels is compressed by pointwise convolution to generate fused features. A lightweight channel attention mechanism is introduced and channel weights are generated based on global average pooling and one-dimensional convolution. The fused features are then weighted channel by channel using the generated channel weights to obtain the final features.

[0031] The multi-branch feature fusion module consists of four sequential parts: a feature concatenation layer, a pointwise convolutional layer, a lightweight channel attention mechanism, and a weighted output layer. The feature concatenation layer merges multi-level features, insect contour enhancement features, and dynamic features along the channel dimension to form a high-dimensional feature tensor. The pointwise convolutional layer compresses the number of channels through 1×1 convolution operations, reducing computational complexity and generating fused features. The lightweight channel attention mechanism generates channel weight vectors based on global average pooling and one-dimensional convolution operations, used to quantify the importance of each channel. The weighted output layer uses the generated channel weights to weight the fused features channel by channel, highlighting key information and suppressing redundancy, outputting the final features. The entire module effectively enhances feature representation capabilities through multi-branch fusion and attention guidance. The specific process for obtaining the final features is as follows: ① Input features include multi-level features, insect body contour enhancement features, and dynamic features. Multi-level features are represented as follows: ,in This indicates the batch size, which is the number of samples processed at one time. The number of channels representing multi-level features; Indicates the feature map height; This represents the width of the feature map. The insect body contour enhancement feature is represented as... ,in The number of channels represents the enhancement features of the worm's outline. Dynamic features are represented as... ,in The number of channels representing dynamic features. These feature maps have the same spatial dimension height. and width However, the number of channels may differ. Multi-level features, insect contour enhancement features, and dynamic features are concatenated along the channel dimension. The concatenation operation is performed along the channel axis, generating a merged feature tensor. The specific formula is: ,in, This indicates a channel-level concatenation operation. Output features. The number of channels is the sum of the original three feature channel numbers.

[0032] ② Use pointwise convolutional layers to process the stitched features Channel compression is performed. Pointwise convolutional layers use 1×1 kernels and reduce the number of channels through learnable weight parameters to generate fused features. The formula for pointwise convolution is: ,in This represents a 1×1 two-dimensional convolution operation; This represents the weight parameters of the pointwise convolutional layer, with dimension 1. ,in Indicates the number of channels after compression. Output fusion features. The number of channels is reduced to The spatial dimensions remain unchanged.

[0033] ③ Introduce a lightweight channel attention mechanism for feature fusion The process involves processing to generate channel weights. The lightweight channel attention mechanism includes a global average pooling layer and a one-dimensional convolutional layer. First, the fused features... Perform global average pooling operation along the spatial dimension height and width Calculate the average value for each channel to generate a channel description vector. . Each channel corresponds to a scalar value, which summarizes the spatial information of that channel.

[0034] ④ Use one-dimensional convolutional layers to describe the channel description vectors The process is performed to generate an initial weight vector. The formula for one-dimensional convolution is: ,in, This represents a one-dimensional convolution operation; This represents the weight parameters of a one-dimensional convolutional layer, with dimension 1. ,in, This indicates the size of the one-dimensional convolution kernel, typically set to 3 or 5 to capture local channel interactions. Output This represents the initial weight vector. Then, the Sigmoid activation function is applied to normalize the initial weight vector, generating the channel weight vector. The formula is: , This represents the Sigmoid activation function, ensuring that the output weight vector... Each element is between 0 and 1, representing the importance score of each channel.

[0035] ⑤ Through the generated channel weight vector Fusion features Perform a channel-by-channel weighted operation to obtain the final features. The weighted operation formula is: ,in, This represents channel-wise multiplication, specifically, for each sample and each channel, the weight scalar. With fusion features The corresponding channels are multiplied, and this is achieved through a broadcast mechanism. The final feature is output. This method preserves the spatial structure and highlights the relevant channel information of the insect. Through multi-branch feature fusion and lightweight channel attention, this process effectively integrates the global structure, contour details, and dynamic adaptive features of the insect, solving the problem that insect features are easily submerged by background noise in complex field backgrounds, and improving detection accuracy and robustness.

[0036] 5) The classification layer is used to: generate pest category identification results corresponding to the sample crop pest images based on the final features; The classifier consists of two sequential parts: a global average pooling layer and a fully connected layer. The global average pooling layer is responsible for compressing the spatial dimension of the final input features, aggregating the spatial information of each channel into a scalar value to form a feature vector. The fully connected layer then maps the feature vector to the dimension of the number of pest categories through learnable weight parameters, outputting the raw score for each category. The entire classifier structure is simple and efficient, capable of converting high-level features into category predictions. The specific implementation process for generating pest category identification results corresponding to sample crop pest images is as follows: ①The final input feature is represented as . This indicates the batch size, which is the number of samples processed at one time. The number of channels representing the final feature; Indicates the height of the final feature; Indicates the width of the final feature. For the final feature... Apply global average pooling. Global average pooling is performed along the spatial dimension height. and width The process involves calculating the average value across all spatial locations for each channel to generate a feature vector. . eigenvectors This represents the feature vector after global average pooling, with each channel corresponding to a scalar value that summarizes the information of that channel across the entire spatial range.

[0037] ②Eigenvectors The raw category score vector is generated by processing through a fully connected layer. Fully connected layers use learnable weight matrices and bias vectors to map the input feature vectors to the dimension of the number of pest categories. The formula for the fully connected operation is: ,in, This represents the weight matrix of the fully connected layer; This represents the bias vector of the fully connected layer; Indicates the number of pest categories; This represents the matrix transpose operation. Output This represents the raw score for each sample for each pest category.

[0038] ③ For the original score vector Apply the softmax function to generate a probability distribution vector. The softmax function converts the raw scores into probability values, ensuring that the probability of each category is between 0 and 1, and that the sum of the probabilities of all categories is 1. The softmax formula is: ,in, This represents a probability distribution vector, where each element... Indicates the first The sample belongs to the first The probability of each pest category.

[0039] Finally, based on the probability distribution vector Generate pest category identification results. For each sample, select the category index with the highest probability as the prediction result. Specifically, this is achieved through the argmax operation: ,in, This represents the predicted pest category index vector, with each element corresponding to the identification result of a sample. This implementation process transforms the final features into category predictions through global average pooling and fully connected layers, solving the problem of accurate pest identification in complex field environments and providing reliable output for intelligent agricultural monitoring.

[0040] The pest category identification result refers to the pest species label predicted by the model for the input sample crop pest image. It is based on the probability distribution output by the model, and is obtained by selecting the category index with the highest probability, representing the specific pest type present in the image, such as weevils or rice planthoppers. This result is used for decision support in actual pest monitoring, helping users identify pests and take corresponding control measures.

[0041] S2. Train the EDA-ConvNeXt model to obtain a crop pest detection model. The specific implementation process includes: ① Configure the training environment using the PyTorch deep learning framework in a Python programming environment, and utilize CUDA acceleration on a workstation equipped with an NVIDIA GPU. When preparing training data, the collected crop pest image dataset is divided into training, validation, and test sets according to a preset ratio. The training set is used for model parameter learning, the validation set for hyperparameter tuning and early stopping detection, and the test set for final performance evaluation. Standardization preprocessing is performed on the training images, normalizing pixel values ​​to zero mean and unit variance. Data augmentation techniques such as random horizontal flipping and color dithering are used to improve the model's generalization ability.

[0042] ② Initialize the parameters of the EDA-ConvNeXt model. Use the Kaiming initialization method for the weights of all convolutional and fully connected layers, and initialize the bias terms to zero. Define the class-weighted cross-entropy loss function, whose mathematical expression is: in, Indicates batch size, This indicates the total number of pest categories. Indicates the first The true label of the sample in the th... The values ​​(0 or 1) for each category. The model predicts the first The sample belongs to the first The probability of each category, Indicates the first The weights of each category are inversely proportional to the number of samples in each category, which is used to alleviate the class imbalance problem.

[0043] ③ Select the Adam optimizer to update parameters and set the initial learning rate to [value missing]. Momentum parameters and Weight decay coefficient To prevent overfitting, a learning rate scheduling strategy is used during training. When the validation set loss no longer decreases for several consecutive epochs, the learning rate is halved to promote convergence.

[0044] ④ The specific execution of the training cycle is as follows: within each training cycle, the training data is divided according to the batch size. The data is divided into multiple mini-batches. For each mini-batch, forward propagation is performed. The image is input into the EDA-ConvNeXt model, passing sequentially through the backbone network, edge enhancement branch, dynamic feature extraction branch, multi-branch feature fusion module, and classification layer, ultimately outputting the predicted probability of the pest category. The loss function value is calculated based on the prediction results and the true labels. Then, the backpropagation algorithm is executed to calculate the gradient of the loss function with respect to the model parameters. The optimizer updates the model parameters based on the gradient, using the following formula: ,in, Indicates the first Model parameters at the next iteration and These are the bias correction estimates for the first and second moments of the gradient, respectively. is the numerical stability constant.

[0045] ⑤ After each training cycle, evaluate the model performance on the validation set and record the accuracy and loss values. When the validation set loss no longer decreases for 20 consecutive training cycles, trigger the early stopping mechanism to terminate training and prevent overfitting. Finally, save the model parameters with the best performance on the validation set to obtain the trained EDA-ConvNeXt model, i.e., the crop pest detection model. Throughout the training process, both training loss and validation loss are recorded and visualized in real time to ensure stable convergence of the training process without drastic fluctuations or divergence.

[0046] S3. Using a crop pest detection model, the pest category identification result corresponding to the crop pest image to be detected is obtained. The specific implementation process is as follows: ① Acquire images of the crop pests to be detected. These images are RGB format color digital images, possibly from field photography equipment or storage systems. Preprocess the input images by resizing them to the fixed size required by the model, for example, 224 pixels × 224 pixels. Then perform standardization, normalizing the image pixel values ​​using the same mean and standard deviation as during training. The preprocessed image is represented as follows: ,in, This represents the preprocessed input tensor. In the dimension, 1 indicates batch processing of a single image, 3 indicates the three RGB channels, and 224 indicates the image height and width.

[0047] ②Preprocessed image Input a pre-trained crop pest detection model. The model performs forward computation sequentially: extracting multi-level features through the backbone network, extracting insect contour enhancement features through the edge enhancement branch, obtaining dynamic features through the dynamic feature extraction branch, integrating these features through the multi-branch feature fusion module to generate the final features, and finally outputting the prediction result through the classification layer. The entire forward computation process does not require gradient calculation, significantly improving inference speed.

[0048] ③ The original prediction result output by the classification layer is a vector. ,in, Represents the original prediction vector. This represents the total number of pest categories supported by the model. Each element in the vector... This represents the original score for the corresponding pest category. The softmax function is applied to this original prediction vector to transform it into a probability distribution: ,in Indicates the first The predicted probability of each pest category is given, with the sum of the probabilities of all categories being 1. The probability value reflects the confidence that the input image belongs to each pest category.

[0049] ④ Determine the final pest category identification result based on the probability distribution. Select the category with the highest probability value as the prediction result: ,in, This represents the predicted pest category index, corresponding to a specific pest type defined in the dataset, such as weevils or rice planthoppers. This pest category identification result is the model's final judgment on the input image of crop pests to be detected, and can be directly used for decision support in pest monitoring systems. The entire inference process is executed on a GPU-equipped computing device, fully utilizing parallel computing capabilities to improve processing speed. For a single image, the complete inference process can be completed in milliseconds, meeting real-time detection requirements. Simultaneously, the system records the confidence score for each identification, providing a reference for subsequent result verification and analysis.

[0050] The technical solution of the present invention will be further described through the following embodiments.

[0051] The overall architecture of EDA-ConvNeXt is as follows: Figure 2As shown, firstly, the input RGB image of rice pests against a complex field background undergoes preliminary downsampling and feature mapping through the Stem layer. Simultaneously, Sobel edge detection and convolution operations are combined to highlight the structural details of the insects and reduce background interference. Subsequently, the network enters a multi-stage feature extraction process, achieving hierarchical feature representation through progressive downsampling and stacked EConvNeXtBlocks. A multi-expert deep convolution kernel mechanism is introduced in the dynamic branches, combined with global pooling and routing functions to achieve adaptive input selection, thereby enhancing adaptability to differences in insect morphology and complex environments. In feature fusion and classification, backbone features, edge enhancement features, and dynamic branch features are uniformly integrated, and channel attention-guided multi-branch fusion and result recognition are completed in pointwise convolutions with an attention mechanism. Specifically, the initial feature processing module receives RGB images of rice pests against a complex field background as input. First, it performs preliminary downsampling and feature mapping through a Stem layer. This layer uses a 4x4 convolution kernel with a stride of 4, combined with batch normalization, to convert the image into an initial feature representation. Simultaneously, it performs Sobel edge detection in parallel to highlight insect structural details and effectively reduce field background interference, generating edge-enhanced features. Next, the module proceeds to a multi-stage feature extraction module. In the first stage, a downsampling layer expands the number of channels from 96 to 192 while reducing spatial resolution, followed by stacking three EConvNeXtBlocks for multi-branch feature extraction. In the second stage, a downsampling layer expands the number of channels from 192 to 384 while reducing resolution, and then stacks three EConvNeXtBlocks for further feature extraction. In the third stage, a downsampling layer expands the number of channels from 384 to 768 while reducing resolution, followed by stacking nine EConvNeXtBlocks for deep feature extraction. In the fourth stage, a downsampling layer maintains 768 channels and unchanged resolution, and finally, three EConvNeXtBlocks are stacked to complete high-level semantic feature extraction. The system then enters the dynamic branch processing module, which uses four multi-expert deep convolutional kernels with different kernels to process features separately. Combined with a routing function, it achieves adaptive input selection through global pooling, convolution, and softmax operations, outputting dynamic features to improve adaptability to insect morphological differences and complex environments. Next, it enters the multi-branch feature fusion stage, where features extracted from the backbone network, edge enhancement features, and dynamic features are uniformly fused. This is processed through a lightweight channel attention mechanism, including pointwise convolution, GELU activation, ECA module, and pointwise convolution operations. After further processing by global average pooling, batch normalization, and fully connected layers, the final pest identification result is output. The entire architecture, through the collaborative work of sequential and parallel components, ensures a complete data flow from image input to pest category identification, effectively solving the problem of pest detection in complex field environments.

[0052] In images of rice pests, the insect body often contains fine-grained structures such as antennae, wing veins, and mouthparts. However, this information is easily lost due to interference from rice leaf texture and complex backgrounds, making it difficult for conventional convolutional features to capture key contours. Therefore, such as... Figure 3 As shown, an edge enhancement modeling branch is introduced in EConvNeXtBlock. Stable edge features are obtained through a Sobel operator-gradient magnitude calculation-convolution mapping approach. Specifically, the RGB image is used as the raw data input to the edge enhancement branch. First, the Sobel operator is applied to calculate the gradient response of each channel of the image in the horizontal and vertical directions to obtain directional gradient information. Then, the gradient magnitude is calculated, and the overall gradient magnitude is synthesized based on the horizontal and vertical gradients using the Euclidean distance formula. A numerical stability constant is added to ensure computational stability, forming edge response features. Then, a learnable convolution mapping is performed on the edge response features through 3x3 convolution processing. A 3x3 convolution kernel combined with weight parameters and bias terms is used to perform a two-dimensional convolution operation, and then an activation function is applied to introduce a nonlinear transformation. Finally, the edge enhancement feature is output, which enhances the details of the worm outline and suppresses background interference, providing fine-grained structural information for subsequent multi-branch feature fusion. The entire process, from image input to feature output, has a clear and coherent data flow. The explicit gradient extraction and convolution optimization effectively improve the ability to express the worm boundary.

[0053] Let the input features be represented as ,in For batch size, For the number of channels, These represent the spatial resolution. The convolution kernels of the Sobel operator in the horizontal and vertical directions are defined as follows: For input features Each channel is convolved independently to obtain the gradient response in the horizontal and vertical directions: and .in, This represents a two-dimensional convolution operation. Based on this, the gradient magnitude can be expressed as: ,in, For edge response features, is the numerical stability constant.

[0054] To enhance edge feature representation and adapt to subsequent network processing, further mapping is performed in the convolutional layers: ,in, These are the convolution weights and biases, respectively. This represents a nonlinear activation function (such as ReLU or GELU). The resulting... This serves as the input for the insect body contour enhancement feature in the subsequent multi-branch fusion module. The above modeling, by explicitly introducing gradient information, effectively highlights the boundaries of the insect body structure, alleviates the impact of background interference on fine-grained recognition, and thus improves the ability to distinguish small targets from similar insect species in rice pest detection.

[0055] In images of rice pests, the significant differences in insect posture, morphology, and background conditions make it difficult for a single convolutional kernel to meet the diverse representational needs. For example... Figure 4 As shown, to improve the adaptability of feature extraction, a dynamic feature extraction mechanism with multiple expert deep convolutional kernels is introduced. The core idea is to utilize multiple candidate convolutional kernels and combine them with adaptive routing weights to achieve weighted fusion of expert features, thereby obtaining a dynamic feature representation. Specifically, the backbone network outputs Feature Input during the downsampling stage. This Feature Input is then fed in parallel into four independent expert convolutional kernel processing units: Expert 1, Expert 2, Expert 3, and Expert 4. Each expert convolutional kernel uses a depthwise convolutional kernel with different parameters to perform convolution operations on the input features, generating four different expert features. Simultaneously, the feature input is fed into the Routing Function, which obtains channel statistics through global average pooling and then generates adaptive weights corresponding to the four expert convolutional kernels through convolution and Softmax operations. Finally, a Weighted Fusion operation linearly combines the four expert features according to the weights generated by the Routing Function, forming Dynamic Features output. This structure effectively improves the model's adaptability to insect morphological differences and complex field environments through input adaptation.

[0056] Let the input features be ,in For batch size, For the number of channels, Spatial resolution. Defined by Each expert convolutional kernel (this invention takes) (See the ablation experiment for details) Each convolution kernel Convolving the input features separately yields the... The expert output is: , This represents a two-dimensional convolution operation, outputting... Routing function Based on input features The global average pooling result generates a weight vector: ,in, Indicates the first The adaptive weights of each expert are used. The final dynamic features are obtained through weighted fusion: , This represents the output features of the dynamic convolution branch.

[0057] In pest detection tasks, a single feature branch often struggles to capture the insect's overall structure, detailed texture, and dynamic adaptability. For example... Figure 5 As shown, the core features, edge enhancement features, and dynamic convolution features are fused in a unified manner, and a channel attention mechanism is introduced to achieve adaptive modeling of cross-channel dependencies. Specifically, the multi-branch feature fusion structure guided by channel attention starts with three parallel input feature sources: Edge Features (from the worm outline enhancement features of the edge enhancement branch), Main Features (from the multi-level features of the backbone network), and Dynamic Features (from the output of the dynamic feature extraction branch). These features are merged into a comprehensive feature tensor in the channel dimension through the Feature Concatenation operation. Then, 1×1 Conv Fusion 1×1 convolution fusion is applied to achieve channel compression and preliminary feature integration through pointwise convolution. Next, Pointwise Conv pointwise convolution is used to further process the features and reduce computational complexity. Then, GELU Activation is introduced to enhance non-linear expressive power. After that, lightweight channel attention calculation is performed through the ECA Attention module, which generates channel weights based on global average pooling and one-dimensional convolution to highlight important features and suppress redundant information. Finally, another Pointwise Conv is used. Conv performs pointwise convolutions to adjust feature dimensions and optimize representation; the final output is Fused Features, which effectively integrates multi-branch information and strengthens insect-related features, providing robust input for subsequent classification layers. The entire process, from multi-feature input to fused output, features a coherent and orderly data flow, progressively optimizing feature representation through concatenation, convolution, activation, and attention mechanisms. Let the main branch output be... The edge enhancement branch output is The output of the dynamic convolution branch is The three are spliced ​​together in the channel dimension to obtain: The spliced ​​features are Convolution achieves dimensionality compression: A unified channel number fusion representation is obtained. Building upon this, a channel attention mechanism (ECA) is introduced, firstly extracting channel descriptions through global average pooling: Then, one-dimensional convolution is used to model the local interaction relationships between channels: ,in, A one-dimensional convolution kernel, This represents the Sigmoid activation function. Finally, the fused features are weighted channel-by-channel: ,in, This represents Hadamard element-wise multiplication. The result is... It can highlight the insect-related feature channels and suppress background interference, significantly improving the overall detection robustness while maintaining low computational complexity.

[0058] The technical effects of the present invention will be illustrated through the following experiments.

[0059] 1. Experimental setup: (1) Experimental environment: This invention was carried out in the Python 3.8 environment, and the model training and inference were implemented based on the PyTorch 1.12.1 deep learning framework. The experiments were run on a workstation equipped with an NVIDIA Quadro P5000 GPU (16GB of video memory) and hardware acceleration was provided by CUDA 12.1. All experiments were independently repeated 30 times, and the final results were averaged to reduce the impact of randomness.

[0060] (2) Dataset: The experiment used a self-built rice pest image dataset, totaling 4,559 samples, covering 11 types of pests. The specific distribution is as follows: Weevils (824 images), Planthoppers (729 images), Leafhoppers (636 images), Tube Thrips (290 images), Gall midges (370 images), Skimmers (393 images), Pyralidae (461 images), Rice Flies (153 images), Swamp Flies (167 images), Noctuidae (206 images), and Thrips (330 images). This dataset includes both complete insect morphology and local samples against complex backgrounds, reflecting the challenges of actual detection scenarios, such as... Figure 6 As shown.

[0061] (3) Basis for selecting benchmark models: To evaluate the performance of EDA-ConvNeXt, this invention selects nine typical visual models as comparison methods, including CNN, ConvNeXt, DenseNet121, GhostNet, MobileNetV2, ResNet34, ShuffleNetV2, SqueezeNet, and VGG16. CNN uses a three-layer convolutional structure to extract local texture and edge information. ConvNeXt optimizes feature extraction and balances speed through modern convolutional modules. DenseNet121 relies on dense connections to enhance feature reuse and gradient propagation. GhostNet generates redundant features through inexpensive linear operations to reduce computation. MobileNetV2 uses depthwise separable convolutions and inverse residual structures to maintain accuracy under small model conditions. ResNet34 alleviates gradient vanishing and enhances multi-level features through residual connections. ShuffleNetV2 uses grouped convolutions and channel-wise convolutions to improve efficiency. SqueezeNet relies on the Fire module to compress parameter scale while maintaining reasonable accuracy. VGG16, as a classic network, can stably extract texture features and is still of reference value under small sample conditions.

[0062] (4) Training strategy optimization: The model training uses the Adam optimizer, and the initial learning rate is determined by grid search within {10 -2 10 -3 10 -4 Within a specified range, the batch size is 16. The maximum number of training epochs is 200, and the early stopping mechanism is set to 20 epochs to prevent overfitting. To address the class imbalance problem, a class-weighted cross-entropy loss function is used, with weights inversely proportional to sample frequencies, to improve minority class detection capabilities.

[0063] like Figure 7 As shown, EDA-ConvNeXt exhibits a stable convergence trend during both training and testing. The training loss decreases rapidly in the initial stage, levels off after about 30 epochs, and gradually converges to close to 0.05 within 200 epochs. The test loss also decreases rapidly in the early stages, then maintains a stable decrease, eventually converging to the same level as the training set without significant oscillations or overfitting. This indicates that the proposed model has good optimization stability and generalization ability in the rice pest detection task.

[0064] (5) Evaluation index system: The overall recognition accuracy (Accuracy, Acc), precision (Precision, Prec), recall (Recall, Rec) and comprehensive balance index F1-Score (F1) are used to measure the overall recognition ability, prediction accuracy, detection ability and balance of the model, respectively, so as to comprehensively reflect the detection performance.

[0065] 2. Comparative experiment: As shown in Table 1, different methods exhibit significant differences in performance across the four metrics: Accuracy, Precision, Recall, and F1. EDA-ConvNeXt demonstrates the most outstanding overall performance, achieving an Accuracy of 93.65, Precision of 94.12, and Recall of 93.01, with a corresponding F1 score of 93.33, ranking first among all methods. DenseNet121 and GhostNet show similar performance, with Accuracy scores of 89.70 and 89.44, respectively. DenseNet121 has a higher Precision score (92.49), while GhostNet is slightly better in Recall (87.20). ConvNeXt maintains stable performance across all four metrics (Accuracy of 84.04 and F1 score of 84.38), demonstrating its advantages as a modern convolutional network. MobileNetV2, ResNet34, and ShuffleNetV2 exhibit moderate overall performance, with Accuracy ranging from 79.31 to 80.66 and relatively balanced Precision and Recall. VGG16 and TinyYOLO performed slightly worse overall, with accuracy scores of 73.56 and 75.68 respectively. CNN and SqueezeNet lagged significantly behind in all four metrics, with accuracy scores of 79.65 and 68.07 respectively, indicating their limited ability to identify infrared overheating in the task.

[0066] Table 1: The performance differences among various models stem from the impact of structural design on the ability to model insect features. Lightweight networks such as SqueezeNet and ShuffleNetV2 suffer from insufficient feature representation, resulting in decreased recognition capabilities in complex backgrounds. While traditional deep models like VGG16 possess strong representational capabilities, their fixed kernels and large parameters make them difficult to adapt to insect diversity and lead to low efficiency. ResNet34 and MobileNetV2 achieve a balance between accuracy and efficiency through residual connections and depthwise separable convolutions, but they still fall short in characterizing fine-grained edge features. DenseNet121 and ConvNeXt enhance global modeling and feature reuse capabilities through dense connections and modern convolutional modules, resulting in superior accuracy. GhostNet utilizes a redundant feature generation mechanism, maintaining high accuracy with extremely low computational cost, demonstrating the efficiency of its structural design. EDA-ConvNeXt integrates edge enhancement, dynamic convolution, and channel attention mechanisms, simultaneously highlighting insect contours, adapting to morphological differences, and suppressing background interference.

[0067] from Figure 8 As can be seen, the ROC curve of EDA-ConvNeXt remains in the upper left region, indicating that the model has extremely high discrimination ability in rice pest detection, effectively balancing the risks of missed detection and false detection, and achieving stable and reliable recognition performance in actual field pest monitoring scenarios. Figure 9 The confusion matrix of EDA-ConvNeXt shows that the model achieved near-ideal classification accuracy for various rice pests, with most categories achieving an accuracy of over 0.99. Slight confusion was only observed in a few categories, such as Cicadidae and Thripsidae. This indicates that the model can effectively distinguish between insect details and leaf texture interference in complex field conditions, demonstrating stable multi-pest identification capabilities and providing reliable support for the automatic monitoring and intelligent control of rice pests.

[0068] 3. Ablation experiment: As shown in Table 2, to verify the design effectiveness of the proposed EDA-ConvNeXt, two types of ablation experiments were conducted. The first type was core module ablation (A1–A3), which progressively removed different structural modules, including removing the worm contour edge enhancement branch (A1, EDA-w / o Edge), removing the multi-expert dynamic convolution branch (A2, EDA-w / o Dynamic), and removing the lightweight channel attention mechanism (A3, EDA-w / o ECA), to analyze the contribution of each core module to the overall performance.

[0069] Table 2: Experiment A1: After removing the edge enhancement branch for insect outlines, the accuracy and F1 score dropped to 97.92% and 97.97%, respectively. In rice paddy scenes, insect outlines are easily confused with leaf textures. Without edge enhancement, the model struggles to highlight fine-grained boundaries, resulting in a weakened ability to identify small and blurred-edge pests. Experiment A2: Removing the multi-expert dynamic convolution branch resulted in the most significant performance drop, with accuracy and F1 scores of 97.46% and 97.58%, respectively. Dynamic convolution can adaptively select the convolution kernel based on the input to adapt to differences in insect morphology and background. Without it, the model degenerates into a fixed convolution, making it difficult to cover the diversity of insects and increasing the misclassification rate. Experiment A3: After removing the lightweight channel attention, the accuracy was 98.13%, and the F1 score was 98.20%. Channel attention can highlight key insect features and suppress redundant channels during the feature fusion stage. Without this module, the fusion effect is weakened, and the overall representation ability is slightly reduced.

[0070] The second category consists of parameter sensitivity experiments (B1–B2). In B1, the number of expert convolutions is varied (set to 2, 4, 8) to examine the impact of dynamic convolution size on detection performance and computational cost. In B2, the kernel size is varied (set to 3, 5, 7) to explore the role of the receptive field in modeling insect features. For example... Figure 10 As shown, adjusting the number of expert convolutions (2, 4, 8) in B1 results in an F1 score that first increases and then decreases with increasing number of convolutions, with Expert=4 being the optimal value. Adjusting the kernel size (3, 5, 7) in B2 indicates that Kernel=7 provides the best performance. Overall, EDA-ConvNeXt achieves the best balance between feature representation and parameter efficiency at Expert=4 and Kernel=7, demonstrating the rationality and effectiveness of its architecture design.

[0071] Ablation experiments show that core module and parameter design are crucial to improving the performance of EDA-ConvNeXt. Among A1–A3, removing the dynamic convolution branch (A2) results in the most significant performance degradation, indicating its greatest role in adapting to differences in insect morphology and complex backgrounds. Removing the edge enhancement branch (A1) weakens the contour modeling ability, which is detrimental to small pests. Removing channel attention (A3) has a smaller impact, but it can still suppress redundant information during feature fusion. Parameter sensitivity analysis shows that there are optimal ranges for the number of experts in B1 and the kernel size in B2, with the best performance achieved when Expert=4 and Kernel=7. Overall, the complete EDA-ConvNeXt combines the advantages of all three components, exhibiting the best performance in terms of accuracy and robustness, validating the rationality of the architecture design.

[0072] The proposed EDA-ConvNeXt effectively improves the accuracy and robustness of rice pest detection through a collaborative design of edge enhancement, dynamic convolution, and channel attention. In comparative experiments, this model significantly outperforms mainstream methods in Acc, Pre, Rec, and F1 scores. ROC curves and confusion matrices further validate its stability in identifying multiple pest classes. Ablation experiments show that the dynamic convolution branch contributes the most, while edge enhancement and channel attention also contribute to performance improvement; the complete model exhibits the best performance. Although slight confusion exists in categories such as Cicadidae and Thripsidae, future research could combine multimodal information and explore lightweight optimization to further enhance the model's practicality and generalization value.

[0073] This invention proposes an improved ConvNeXt-based crop pest detection network, named Edge Enhancement Dynamic Attention ConvNeXt, or EDA-ConvNeXt network. This network innovatively improves upon several aspects to address the practical needs of crop pest detection in complex field environments. First, an edge enhancement branch for insect body contours is designed specifically to address the problem of insect details in crop pest images being easily confused with crop textures and background noise. This branch, based on the Sobel edge detection operator, calculates the horizontal and vertical gradients of each channel of the input image, obtains edge response features through gradient magnitude calculation, and then processes them through convolutional layers to finally generate enhanced insect body contour features. This design explicitly extracts the insect body contour information, effectively enhancing the ability to express the fine-grained external structure of pests. A dynamic feature extraction branch based on multi-expert deep convolutional kernels is constructed. Building upon contour enhancement, this branch uses multiple expert deep convolutional kernels to process the feature maps output by the backbone network in parallel. Each expert deep convolutional kernel uses different convolutional parameters, enabling the extraction of diverse feature representations. This approach uses global average pooling to obtain statistical information from input features and a routing function to generate adaptive weight coefficients, achieving weighted fusion of multiple expert features and outputting dynamic features. This design enables the model to automatically select the most suitable convolution mode based on the content of the input image, improving the model's adaptability to different insect morphologies and complex scenes, and realizing a multi-branch feature fusion module guided by channel attention. This module integrates the multi-level features extracted by the backbone network, the insect contour enhancement features generated by the edge enhancement branch, and the dynamic features output by the dynamic feature extraction branch. First, features are concatenated along the channel dimension, and then the number of channels is compressed through pointwise convolution to generate preliminary fused features. Subsequently, a lightweight channel attention mechanism is introduced, generating channel weights based on global average pooling and one-dimensional convolution operations, and performing channel-wise weighted processing on the fused features to highlight key insect features and suppress background interference. This fusion method efficiently models cross-channel dependencies, improving overall detection accuracy and robustness while ensuring computational efficiency. The EDA-ConvNeXt model uses ConvNeXt as its backbone network and enhances the fine-grained feature modeling capability of insects in complex field environments by introducing edge enhancement branches, dynamic feature extraction branches, and lightweight channel attention-guided multi-branch feature fusion modules. The model was validated on multiple crop pest datasets. Experimental results show that EDA-ConvNeXt outperforms comparative methods in terms of accuracy, precision, recall, and F1 score, verifying the effectiveness and robustness of the proposed architecture in complex field scenarios. These improvements enable crop pest detection systems to more accurately identify and distinguish different types of pests, providing reliable technical support for pest monitoring and control in agricultural production.

[0074] In the above embodiments, although the steps are numbered S1, S2, etc., they are only specific embodiments given by the present invention. Those skilled in the art can adjust the execution order of S1, S2, etc. according to the actual situation. The scheme after adjusting the order is also within the protection scope of the present invention. It can be understood that in some embodiments, some or all of the above embodiments may be included.

[0075] like Figure 11 As shown, an embodiment of the present invention provides a crop pest detection system 200 based on an improved ConvNeXt, comprising: a model building module 201, a model training module 202, and a model application module 203. The model building module 201 is used to: construct an EDA-ConvNeXt model, which includes a backbone network, an edge enhancement branch, a dynamic feature extraction branch, a multi-branch feature fusion module, and a classification layer. The backbone network is constructed based on the ConvNeXt structure and is used to extract multi-level features from sample crop pest images. The edge enhancement branch is used to: extract insect contour enhancement features from sample crop pest images. The dynamic feature extraction branch is used to: process the feature maps output from at least one downsampling stage in the backbone network using multiple expert deep convolutional kernels to obtain dynamic features. The multi-branch feature fusion module is used to: perform weighted fusion processing on the multi-level features, insect contour enhancement features, and dynamic features to obtain the final features. The classification layer is used to: generate pest category identification results corresponding to the sample crop pest images based on the final features. Model training module 202 is used to: train the EDA-ConvNeXt model to obtain a crop pest detection model; The model application module 203 is used to: use the crop pest detection model to identify the pest category corresponding to the crop pest image to be detected.

[0076] Optionally, in the above technical solution, the edge enhancement branch is specifically used to: calculate the horizontal and vertical gradients of each channel of the sample rice pest image using the Sobel operator, calculate the gradient magnitude based on the horizontal and vertical gradients, generate edge response features based on the gradient magnitudes, and then obtain the insect outline enhancement features through a convolutional layer.

[0077] Optionally, in the above technical solution, the dynamic feature extraction branch is specifically used to: perform convolution operations on the feature maps output from at least one downsampling stage in the backbone network using multiple expert deep convolution kernels to obtain multiple expert features; after performing global average pooling on each received feature map, generate routing weights through a routing function; and use the routing weights to perform weighted fusion of all expert features to obtain dynamic features.

[0078] Optionally, in the above technical solution, the multi-branch feature fusion module is specifically used to: splice multi-level features, insect body contour enhancement features and dynamic features in the channel dimension and compress the number of channels through pointwise convolution to generate fused features, and introduce a lightweight channel attention mechanism and generate channel weights based on global average pooling and one-dimensional convolution, and then weight the fused features channel by channel through the generated channel weights to obtain the final features.

[0079] It should be noted that the beneficial effects of the improved ConvNeXt crop pest detection system 200 provided in the above embodiments are the same as those of the improved ConvNeXt crop pest detection method described above, and will not be repeated here. Furthermore, the system and method embodiments provided in the above embodiments belong to the same concept, and their specific implementation processes are detailed in the method embodiments, and will not be repeated here.

[0080] An electronic device according to an embodiment of the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements any of the above-described improved ConvNeXt crop pest detection methods.

[0081] An embodiment of the present invention provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements any of the above-described improved ConvNeXt methods for detecting crop pests.

[0082] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.

Claims

1. A method for detecting crop pests based on an improved ConvNeXt, characterized in that, include: An EDA-ConvNeXt model is constructed, which includes a backbone network, an edge enhancement branch, a dynamic feature extraction branch, a multi-branch feature fusion module, and a classification layer. The backbone network is constructed based on the ConvNeXt structure and is used to extract multi-level features from sample crop pest images. The edge enhancement branch is used to: extract insect body contour enhancement features from the sample crop pest images; the dynamic feature extraction branch is used to: process the feature maps output from at least one downsampling stage in the backbone network using multiple expert deep convolution kernels to obtain dynamic features; the multi-branch feature fusion module is used to: perform weighted fusion processing on the multi-level features, the insect body contour enhancement features, and the dynamic features to obtain the final features; The classification layer is used to: generate pest category identification results corresponding to the sample crop pest images based on the final features; The EDA-ConvNeXt model was trained to obtain a crop pest detection model; The pest category identification results corresponding to the crop pest images to be detected are obtained by using a crop pest detection model.

2. The crop pest detection method based on the improved ConvNeXt according to claim 1, characterized in that, The edge enhancement branch is specifically used to: calculate the horizontal and vertical gradients of each channel of the sample rice pest image using the Sobel operator, calculate the gradient magnitude based on the horizontal and vertical gradients, generate edge response features based on the gradient magnitudes, and then map the insect contour enhancement features through a convolutional layer.

3. The crop pest detection method based on the improved ConvNeXt according to claim 2, characterized in that, The dynamic feature extraction branch is specifically used to: perform convolution operations on the feature maps output by at least one of the downsampling stages in the backbone network using multiple expert deep convolution kernels to obtain multiple expert features; generate routing weights by performing global average pooling on each received feature map and then using a routing function; and perform weighted fusion of all expert features using the routing weights to obtain the dynamic features.

4. The crop pest detection method based on the improved ConvNeXt according to claim 3, characterized in that, The multi-branch feature fusion module is specifically used to: concatenate the multi-level features, the insect body contour enhancement features, and the dynamic features in the channel dimension and compress the number of channels through pointwise convolution to generate fused features; introduce a lightweight channel attention mechanism and generate channel weights based on global average pooling and one-dimensional convolution; and perform channel-wise weighting on the fused features through the generated channel weights to obtain the final features.

5. A crop pest detection system based on an improved ConvNeXt, characterized in that, include: Model building module, model training module, and model application module; The model building module is used to: construct an EDA-ConvNeXt model, which includes a backbone network, an edge enhancement branch, a dynamic feature extraction branch, a multi-branch feature fusion module, and a classification layer; the backbone network is constructed based on the ConvNeXt structure and is used to extract multi-level features from sample crop pest images. The edge enhancement branch is used to extract insect contour enhancement features from the sample crop pest images; the dynamic feature extraction branch is used to process the feature maps output from at least one downsampling stage in the backbone network using multiple expert deep convolution kernels to obtain dynamic features; the multi-branch feature fusion module is used to perform weighted fusion processing on the multi-level features, the insect contour enhancement features, and the dynamic features to obtain the final features; the classification layer is used to generate pest category identification results corresponding to the sample crop pest images based on the final features. The model training module is used to: train the EDA-ConvNeXt model to obtain a crop pest detection model; The model application module is used to: use the crop pest detection model to identify the pest category corresponding to the crop pest image to be detected.

6. The crop pest detection system based on the improved ConvNeXt according to claim 5, characterized in that, The edge enhancement branch is specifically used to: calculate the horizontal and vertical gradients of each channel of the sample rice pest image using the Sobel operator, calculate the gradient magnitude based on the horizontal and vertical gradients, generate edge response features based on the gradient magnitudes, and then map the insect contour enhancement features through a convolutional layer.

7. A crop pest detection system based on an improved ConvNeXt according to claim 6, characterized in that, The dynamic feature extraction branch is specifically used to: perform convolution operations on the feature maps output by at least one of the downsampling stages in the backbone network using multiple expert deep convolution kernels to obtain multiple expert features; generate routing weights by performing global average pooling on each received feature map and then using a routing function; and perform weighted fusion of all expert features using the routing weights to obtain the dynamic features.

8. The crop pest detection system based on the improved ConvNeXt according to claim 7, characterized in that, The multi-branch feature fusion module is specifically used to: concatenate the multi-level features, the insect body contour enhancement features, and the dynamic features in the channel dimension and compress the number of channels through pointwise convolution to generate fused features; introduce a lightweight channel attention mechanism and generate channel weights based on global average pooling and one-dimensional convolution; and perform channel-wise weighting on the fused features through the generated channel weights to obtain the final features.

9. An electronic device, characterized in that, The method includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the crop pest detection method based on any one of claims 1 to 4.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the crop pest detection method based on an improved ConvNeXt as described in any one of claims 1 to 4.

Citation Information

Cited By

  • Carya cathayensis kernel defect identification method based on improved ConvNeXtV2

    CN121884014A