A multi-label classification method for crop diseases and insect pests
By acquiring field pest image data, performing multi-scale feature extraction and graph structure modeling, and using an improved graph convolutional network to explicitly infer the association between pest categories and life cycles, the problem of insufficient pest identification accuracy in existing technologies is solved, and more efficient multi-label classification is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUANGDONG POLYTECHNIC NORMAL UNIV
- Filing Date
- 2026-04-28
- Publication Date
- 2026-07-10
AI Technical Summary
Existing technologies struggle to achieve multi-label classification of pest images in complex contexts when identifying crop pests and diseases. Furthermore, existing technologies often fail to effectively integrate local visual features, global spatial relationships, and the correlation between pest categories and life cycles, leading to insufficient accuracy and robustness in identification.
By acquiring insect pest image data in the field crop environment, preprocessing and extracting multi-scale features, using a multi-head attention mechanism to enhance key areas, constructing a graph structure and introducing an improved graph convolutional network for modeling, and explicitly inferring the association information between insect pest categories and life cycles, multi-label classification is achieved.
It improves the accuracy and robustness of pest identification, effectively identifies multiple pests in complex backgrounds, provides richer agricultural control information support, and enhances the targeting of pest monitoring and precision application.
Smart Images

Figure CN122368631A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the technical field of agricultural intelligent sensing and computer vision, and in particular to a multi-label classification method for crop diseases and pests. Background Technology
[0002] In modern agricultural production, pests and diseases often present a complex situation characterized by the coexistence of multiple pests and the concurrent occurrence of multiple life cycles of the same type of pest. Especially in open field environments, pests are often accompanied by complex backgrounds, changing lighting, occlusion interference, and high morphological similarity, transforming pest identification from a single-class discrimination problem into a complex identification problem with significant multi-label characteristics and strong correlations. Existing pest identification technologies are mainly based on deep learning image classification or object detection models, which typically assume that the same image sample corresponds to only one pest category, or that the categories are independent of each other. However, in real agricultural scenarios, these assumptions often do not hold. On the one hand, the same image may contain multiple pest individuals simultaneously; on the other hand, the same pest exhibits significantly different morphological characteristics at different life cycle stages, while different pests may exhibit highly similar visual features at specific stages. To address the multi-label identification problem, some studies have introduced multi-output classification structures or attention mechanisms to enhance the model's ability to focus on different discrimination regions. However, these methods primarily focus on independent modeling at the feature level, failing to explicitly characterize the inherent semantic and temporal relationships between pest categories and their life cycles. When categories are highly similar or sample distributions are extremely imbalanced, these methods are prone to inconsistent label predictions and insufficient ability to identify rare categories. In recent years, graph structure modeling methods have demonstrated advantages in handling complex, interconnected data, providing new technical approaches for multi-label pest identification. However, existing schemes introducing graph structures into image classification mostly focus on single-label spaces or simple relationship modeling, and have not yet formed a unified technical framework that can simultaneously integrate visual feature enhancement, label relationship modeling, and multi-task joint inference. Therefore, how to construct a multi-label pest classification method that can effectively integrate local visual features, global spatial relationships, and the correlation information between pest categories and their life cycles, while ensuring model feasibility, remains a pressing technical problem to be solved in this field. Summary of the Invention
[0003] The purpose of this invention is to overcome the shortcomings and deficiencies of the existing technology and propose a multi-label classification method for crop diseases and pests. This method can effectively integrate the local visual features, global spatial relationships, and the correlation information between pest categories and life cycles of pest images. It introduces graph structure explicit modeling of the inherent dependency constraints between multiple labels, which greatly improves the accuracy and robustness of pest identification in scenarios with complex backgrounds, highly similar categories, and unbalanced sample distribution. It has excellent engineering feasibility and prospects for widespread application.
[0004] To achieve the above objectives, the technical solution provided by this invention is: a multi-label classification method for crop diseases and pests, comprising the following steps:
[0005] S1: Acquire pest image data collected in the field crop environment and preprocess it to obtain pest images of uniform size with pest species labels and life cycle labels;
[0006] S2: Perform feature extraction and global relationship modeling on preprocessed pest image data to obtain discriminative multi-scale feature representations;
[0007] S3: Utilize the multi-head attention mechanism to enhance key regions of the multi-scale feature representation obtained above, mapping the features of different discrimination regions into multiple feature nodes, providing structured input for subsequent relationship modeling;
[0008] S4: The obtained feature nodes are used as nodes in the graph structure. The edge relationships between nodes are determined based on the feature similarity between nodes. By constructing a graph structure between feature nodes, a pre-trained improved graph convolutional network is introduced to model the relationships between nodes, realizing explicit reasoning about the association information between pest categories and life cycle attributes, and obtaining feature nodes that provide the association information between pest categories and life cycle attributes; wherein, the improvement of the graph convolutional network includes: Construct an adjacency matrix based on the co-occurrence frequency of pest species labels; The adjacency matrix is normalized to avoid high-frequency categories dominating propagation;
[0009] S5: Based on the feature nodes of the association information between the obtained pest category and life cycle attribute, the classifier performs joint prediction on the pest type label and life cycle label to obtain the multi-label classification result, and outputs the pest type label and life cycle label at the same time.
[0010] Furthermore, in step S1, the collected pest image data is labeled, that is, each pest image in the pest image data is labeled with two tags: pest species and its life cycle.
[0011] Furthermore, the specific steps of step S2 are as follows:
[0012] S21: For the input pest image By performing layer-by-layer feature extraction using a convolutional neural network, feature values at each location in the pest image are obtained. These feature values are then neatly arranged together to form a feature map. The operation formula is as follows:
[0013] ;
[0014] In the formula, Let represent the feature value output by the k-th convolutional kernel at position (i,j) in the output feature map. This represents the pixel value at position (i+m, j+m) in the input pest image. This represents the weight parameters of the k-th convolutional kernel at position (m,n) on the c-th channel. The term represents the bias term corresponding to the k-th convolutional kernel. i and j represent the row and column indices of the output feature map, respectively, which are the output coordinates corresponding to the current spatial position of the convolutional kernel. m and n represent the row and column indices of the elements inside the convolutional kernel, which are used to describe the weight parameters at each position within the convolutional window. c represents the channel index of the input pest image, which is used to perform weighted summation of the information on the input channels.
[0015] Next, the ReLU activation function is used to... Activation values are obtained by performing nonlinear transformations. This enhances the response of salient features, suppresses invalid information, and performs pooling operations to reduce dimensionality features while retaining the main response information. The operation formula is as follows:
[0016] ;
[0017] In the formula, Let represent the activation value of the r-th channel at position (u, v), where r represents the channel number of the feature map. and These represent the row and column indices in the output feature map after pooling, respectively, which are the spatial output positions corresponding to the pooling window. (u, v) are the spatial coordinates of each element within the pooling window, where u represents the x-coordinate of the element and v represents the y-coordinate of the element. Indicates the pooled window region. This represents the final feature value obtained after pooling;
[0018] After pooling, a sliding convolution kernel is used to perform convolution within a local region of the input pest image. Through layer-by-layer convolution, activation, and feature mapping transformation, edge, texture, shape, and semantic structure information in the pest image are gradually extracted, ultimately obtaining discriminative multi-scale features. The calculation formula is as follows:
[0019] ;
[0020] In the formula, This represents the output feature map after activation of the h-th convolutional layer. This represents the output feature map of layer h-1, which serves as the input to layer h. Represents the parameters of the h-th convolutional kernel. This represents the bias term at level h. This represents the convolution operation. denoted as a non-linear activation function, h represents the convolutional layer number, and the h-th layer is the convolutional layer currently performing the convolution operation;
[0021] After multiple convolutional processes, the output is a discriminative multi-scale feature representation, i.e., the output feature map, expressed by the following formula:
[0022] ;
[0023] In the formula, and Indicates the height and width of the feature map. Let R be the number of feature channels, and R be the set of real numbers. This indicates that all elements in this feature map are real numbers. The output feature map of the h-th layer The final output represents the multi-scale feature representation obtained after multi-layer convolution processing;
[0024] S22: Using an attention modeling network, global dependency modeling is performed on the multi-scale feature representation, enabling the model to capture the correlation between distant regions in the image.
[0025] Furthermore, the specific steps of step S3 are as follows:
[0026] S31: For input multi-scale feature representation Expand into a series , represented as:
[0027] ;
[0028] In the formula, This represents the overall representation of the token sequence formed after expanding the input multi-scale feature representation, where each token represents a feature unit. This represents the feature vector of the Nth token, where N represents the number of tokens. R represents the dimension of each token, and R represents the set of real numbers.
[0029] S32: After unfolding in step S31 Based on this, positional information is preserved, and positional encoding is added to obtain the input sequence for the multi-head attention mechanism:
[0030] ;
[0031] In the formula, Indicates position code, The input sequence for the multi-head attention mechanism;
[0032] S33: The input sequence In the input multi-head attention mechanism, the input vector is treated as a multi-head parallel self-attention computation.<Key,Value> In key-value pair format, the similarity coefficient between the Key and Query is calculated based on the Query value in the given task objective. This yields the weight coefficient corresponding to the Value. Here, Q, K, and V represent Query, Key, and Value, respectively. Query, Key, and Value are the query matrix, key matrix, and value matrix obtained through linear mapping of the input sequence, respectively. The calculation formula is as follows:
[0033] ;
[0034] ;
[0035] In the formula, , , These are the learnable weight matrices corresponding to the query, key, and value, respectively. In multi-head attention mechanisms, "head" refers to a subspace branch that performs parallel mapping and independent attention computation of input features. This represents the output of the h-th attention head. Indicates multi-head output. This is the final weight matrix corresponding to the multi-head concatenation result. The feature sequence is the output after multi-head attention mechanism operation, and then the feature sequence is encoded through multiple layers to obtain a global feature representation: ;
[0036] S34: Represent the multi-scale features and the global feature representation The desired feature nodes are obtained through weighted calculation, and the calculation formula is as follows:
[0037] ;
[0038] In the formula, and is the weighting coefficient, and F is the feature node obtained by mapping after the multi-scale features are enhanced through the key region.
[0039] Furthermore, the specific steps of step S4 are as follows:
[0040] S41: For the input feature nodes F, construct the graph structure and initialize the node feature matrix, as follows:
[0041] ;
[0042] In the formula, The initialized node feature matrix, For feature representation, For natural numbers, Indicates the first The feature representation vector corresponding to each feature node;
[0043] S42: To determine the feature similarity between nodes and the edge relationships between nodes, cosine similarity is used, expressed by the formula:
[0044] ;
[0045] In the formula, This represents the similarity between node p and node q; and They are respectively represented as For two distinct feature nodes, ||·|| represents the L2 norm;
[0046] S43: After obtaining the similarity between nodes, based on the set threshold Determine the edge relationships between nodes, and then construct the adjacency matrix. The adjacency matrix can be written in block matrix form:
[0047] ;
[0048] In the formula, Indicates the relationship between nodes representing pest categories; This represents the relationships between lifecycle attribute nodes; This indicates the reverse association weight between the lifecycle attribute node and the pest category node. This indicates the bidirectional association weight between the pest category node and the life cycle attribute node;
[0049] Then, by introducing the identity matrix I, we obtain the extended adjacency matrix. The extended adjacency matrix is then normalized using the degree matrix D to obtain the normalized adjacency matrix: ;
[0050] In the formula, the identity matrix I is the adjacency matrix. A square matrix of the same dimension has 1s on its main diagonal and 0s on all other elements. The degree matrix D is a diagonal matrix, and its diagonal elements represent the sum of the connection weights between the node element and its neighboring nodes. The off-diagonal elements are all 0s.
[0051] S44: Combine the node feature matrix A and the normalized adjacency matrix. Input the pre-trained improved graph convolutional network and model it according to the following formula:
[0052] ;
[0053] In the formula, This represents the node feature matrix of the input layer l. This represents the node feature matrix output by the (l+1)th layer. Let represent the weight matrix of the l-th layer, which is generated during the training of the graph convolutional network. This represents the bias term of the l-th layer. Represents a non-linear activation function;
[0054] S45: During the multi-layer iterative update process of the graph convolutional network, each feature node continuously aggregates feature information from adjacent connected nodes. Simultaneously, guided by constraints from the adjacency matrix (based on label co-occurrence frequency statistics and normalized), it gradually encodes pest category discrimination information, life cycle stage attribute information, and the inherent association rules between pest categories and life cycle stage attributes into the node features. After graph convolutional inference, the original feature nodes are updated to enhanced feature nodes that simultaneously contain pest category semantics, life cycle attribute semantics, and their association information. This results in the aggregation of feature nodes containing complete association information between pest categories and life cycle attributes. .
[0055] Furthermore, the specific steps of step S5 are as follows:
[0056] S51: In order to use the graph structure reasoning results for the final classification, the feature nodes containing complete association information between pest categories and life cycle attributes are... Fusion with feature node F:
[0057] ;
[0058] In the formula, This represents the final feature obtained after fusion;
[0059] S52: The final feature The data is fed into a classifier for final prediction. The prediction formula is as follows:
[0060] ;
[0061] In the formula, This represents the joint prediction result of pest category and life cycle attribute, including both pest species label and life cycle label. Represents the activation function mapping, , These are the classifier parameters.
[0062] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0063] 1. This invention does not simply classify pests by species, but simultaneously predicts pest species tags and life cycle tags, enabling a more complete identification result in one go. Compared to existing methods that only focus on pest category identification, this invention provides richer information support for agricultural pest control decisions, thereby improving the targeting and practical value of pest monitoring and precision application.
[0064] 2. This invention first extracts multi-scale features from insect damage images, and then enhances key regions through global dependency modeling and multi-head attention mechanisms. This enables more effective extraction of edge, texture, shape, and semantic information from insect damage images, highlighting key discrimination regions. Therefore, even in complex field environments with varying backgrounds, large target scales, and subtle differences in insect life stages, it can still enhance the model's ability to express key features and improve the accuracy and robustness of multi-label classification.
[0065] 3. This invention constructs feature nodes as a graph structure and utilizes an improved graph convolutional network to explicitly infer the association information between pest categories and life cycle attributes. Simultaneously, through improvements such as "constructing an adjacency matrix based on label co-occurrence frequency" and "normalizing the adjacency matrix," it avoids high-frequency categories dominating information propagation. Compared to existing technologies that lack label-based association modeling, this invention can more fully utilize the inherent connection between categories and life cycles, improving the rationality, stability, and overall performance of multi-label prediction. Attached Figure Description
[0066] Figure 1 This is a schematic diagram of the logical flow of the method of the present invention.
[0067] Figure 2 This is an architectural diagram of the method of the present invention. Detailed Implementation
[0068] The present invention will be further described in detail below with reference to the embodiments and accompanying drawings, but the embodiments of the present invention are not limited thereto.
[0069] like Figure 1 and Figure 2 As shown in the figure, this embodiment discloses a multi-label classification method for crop diseases and pests, the specific details of which are as follows:
[0070] S1: Acquire pest image data collected in the field crop environment and preprocess it (including labeling, that is, label each pest image in the pest image data with two types of labels: pest type and life cycle), to obtain pest images of uniform size with pest type and life cycle labels.
[0071] S2: Feature extraction and global relationship modeling are performed on the preprocessed insect pest image data to obtain discriminative multi-scale feature representations. The specific steps are as follows:
[0072] S21: For the input pest image By performing layer-by-layer feature extraction using a convolutional neural network, feature values at each location in the pest image are obtained. These feature values are then neatly arranged together to form a feature map. The operation formula is as follows:
[0073] ;
[0074] In the formula, Let represent the feature value output by the k-th convolutional kernel at position (i,j) in the output feature map. This represents the pixel value at position (i+m, j+m) in the input pest image. This represents the weight parameters of the k-th convolutional kernel at position (m,n) on the c-th channel. The term represents the bias term corresponding to the k-th convolutional kernel. i and j represent the row and column indices of the output feature map, respectively, which are the output coordinates corresponding to the current spatial position of the convolutional kernel. m and n represent the row and column indices of the elements inside the convolutional kernel, which are used to describe the weight parameters at each position within the convolutional window. c represents the channel index of the input pest image, which is used to perform weighted summation of the information on the input channels.
[0075] Next, the ReLU activation function is used to... Activation values are obtained by performing nonlinear transformations. This enhances the response of salient features, suppresses invalid information, and performs pooling operations to reduce dimensionality features while retaining the main response information. The operation formula is as follows:
[0076] ;
[0077] In the formula, Let represent the activation value of the r-th channel at position (u, v), where r represents the channel number of the feature map. and These represent the row and column indices in the output feature map after pooling, respectively, which are the spatial output positions corresponding to the pooling window. (u, v) are the spatial coordinates of each element within the pooling window, where u represents the x-coordinate of the element and v represents the y-coordinate of the element. Indicates the pooled window region. This represents the final feature value obtained after pooling;
[0078] After pooling, a sliding convolution kernel is used to perform convolution within a local region of the input pest image. Through layer-by-layer convolution, activation, and feature mapping transformation, edge, texture, shape, and semantic structure information in the pest image are gradually extracted, ultimately obtaining discriminative multi-scale features. The calculation formula is as follows:
[0079] ;
[0080] In the formula, This represents the output feature map after activation of the h-th convolutional layer. This represents the output feature map of layer h-1, which serves as the input to layer h. Represents the parameters of the h-th convolutional kernel. This represents the bias term at level h. This represents the convolution operation. denoted as a non-linear activation function, h represents the convolutional layer number, and the h-th layer is the convolutional layer currently performing the convolution operation;
[0081] After multiple convolutional processes, the output is a discriminative multi-scale feature representation, i.e., the output feature map, expressed by the following formula:
[0082] ;
[0083] In the formula, and Indicates the height and width of the feature map. Let R be the number of feature channels, and R be the set of real numbers. This indicates that all elements in this feature map are real numbers. The output feature map of the h-th layer The final output represents the multi-scale feature representation obtained after multi-layer convolution processing;
[0084] S22: Using an attention modeling network, global dependency modeling is performed on the multi-scale feature representation, enabling the model to capture the correlation between distant regions in the image.
[0085] S3: Utilizing a multi-head attention mechanism, key region enhancement is performed on the multi-scale feature representation obtained above. Features from different discrimination regions are mapped to multiple feature nodes, providing structured input for subsequent relationship modeling. The specific operation steps are as follows:
[0086] S31: For input multi-scale feature representation Expand into a series , represented as:
[0087] ;
[0088] In the formula, This represents the overall representation of the token sequence formed after expanding the input multi-scale feature representation, where each token represents a feature unit. This represents the feature vector of the Nth token, where N represents the number of tokens. R represents the dimension of each token, and R represents the set of real numbers.
[0089] S32: After unfolding in step S31 Based on this, positional information is preserved, and positional encoding is added to obtain the input sequence for the multi-head attention mechanism:
[0090] ;
[0091] In the formula, Indicates position code, The input sequence for the multi-head attention mechanism;
[0092] S33: The input sequence In the input multi-head attention mechanism, the input vector is treated as a multi-head parallel self-attention computation.<Key,Value> In key-value pair format, the similarity coefficient between the Key and Query is calculated based on the Query value in the given task objective. This yields the weight coefficient corresponding to the Value. Here, Q, K, and V represent Query, Key, and Value, respectively. Query, Key, and Value are the query matrix, key matrix, and value matrix obtained through linear mapping of the input sequence, respectively. The calculation formula is as follows:
[0093] ;
[0094] ;
[0095] In the formula, , , These are the learnable weight matrices corresponding to the query, key, and value, respectively. In multi-head attention mechanisms, "head" refers to a subspace branch that performs parallel mapping and independent attention computation of input features. This represents the output of the h-th attention head. Indicates multi-head output. This is the final weight matrix corresponding to the multi-head concatenation result. The feature sequence is the output after multi-head attention mechanism operation, and then the feature sequence is encoded through multiple layers to obtain a global feature representation: ;
[0096] S34: Represent the multi-scale features and the global feature representation The desired feature nodes are obtained through weighted calculation, and the calculation formula is as follows:
[0097] ;
[0098] In the formula, and is the weighting coefficient, and F is the feature node obtained by mapping after the multi-scale features are enhanced through the key region.
[0099] S4: The obtained feature nodes are used as nodes in the graph structure. The edge relationships between nodes are determined based on the feature similarity between nodes. By constructing a graph structure between feature nodes, a pre-trained improved graph convolutional network is introduced to model the relationships between nodes, realizing explicit reasoning on the association information between pest categories and life cycle attributes, and obtaining feature nodes that provide association information between pest categories and life cycle attributes. The specific operation steps are as follows:
[0100] S41: For the input feature nodes F, construct the graph structure and initialize the node feature matrix, as follows:
[0101] ;
[0102] In the formula, The initialized node feature matrix, For feature representation, For natural numbers, Indicates the first The feature representation vector corresponding to each feature node;
[0103] S42: To determine the feature similarity between nodes and the edge relationships between nodes, cosine similarity is used, expressed by the formula:
[0104] ;
[0105] In the formula, This represents the similarity between node p and node q; and They are respectively represented as For two distinct feature nodes, ||·|| represents the L2 norm;
[0106] S43: After obtaining the similarity between nodes, based on the set threshold Determine the edge relationships between nodes, and then construct the adjacency matrix. The adjacency matrix can be written in block matrix form:
[0107] ;
[0108] In the formula, Indicates the relationship between nodes representing pest categories; This represents the relationships between lifecycle attribute nodes; This indicates the reverse association weight between the lifecycle attribute node and the pest category node. This indicates the bidirectional association weight between the pest category node and the life cycle attribute node;
[0109] Then, by introducing the identity matrix I, we obtain the extended adjacency matrix. The extended adjacency matrix is then normalized using the degree matrix D to obtain the normalized adjacency matrix: ;
[0110] In the formula, the identity matrix I is the adjacency matrix. A square matrix of the same dimension has 1s on its main diagonal and 0s on all other elements. The degree matrix D is a diagonal matrix, and its diagonal elements represent the sum of the connection weights between the node element and its neighboring nodes. The off-diagonal elements are all 0s.
[0111] S44: Combine the node feature matrix A and the normalized adjacency matrix. Input the pre-trained improved graph convolutional network and model it according to the following formula:
[0112] ;
[0113] In the formula, This represents the node feature matrix of the input layer l. This represents the node feature matrix output by the (l+1)th layer. Let represent the weight matrix of the l-th layer, which is generated during the training of the graph convolutional network. This represents the bias term of the l-th layer. Represents a non-linear activation function;
[0114] The improvements to the graph convolutional network include: Construct an adjacency matrix based on the co-occurrence frequency of pest species labels; The adjacency matrix is normalized to avoid high-frequency categories dominating propagation;
[0115] S45: During the multi-layer iterative update process of the graph convolutional network, each feature node continuously aggregates feature information from adjacent connected nodes. Simultaneously, guided by constraints from the adjacency matrix (based on label co-occurrence frequency statistics and normalized), it gradually encodes pest category discrimination information, life cycle stage attribute information, and the inherent association rules between pest categories and life cycle stage attributes into the node features. After graph convolutional inference, the original feature nodes are updated to enhanced feature nodes that simultaneously contain pest category semantics, life cycle attribute semantics, and their association information. This results in the aggregation of feature nodes containing complete association information between pest categories and life cycle attributes. .
[0116] S5: Based on the feature nodes obtained from the correlation information between pest categories and life cycle attributes, the classifier jointly predicts the pest type label and life cycle label to obtain a multi-label classification result. Simultaneously, the pest type label and life cycle label are output. The specific operation steps are as follows:
[0117] S51: In order to use the graph structure reasoning results for the final classification, the feature nodes containing complete association information between pest categories and life cycle attributes are... Fusion with feature node F:
[0118] ;
[0119] In the formula, This represents the final feature obtained after fusion;
[0120] S52: The final feature The data is fed into a classifier for final prediction. The prediction formula is as follows:
[0121] ;
[0122] In the formula, This represents the joint prediction result of pest category and life cycle attribute, including both pest species label and life cycle label. Represents the activation function mapping, , These are the classifier parameters.
[0123] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any changes, modifications, substitutions, combinations, or simplifications made without departing from the spirit and principle of the present invention shall be considered equivalent substitutions and shall be included within the protection scope of the present invention.
Claims
1. A multi-label classification method for crop diseases and pests, characterized in that, Includes the following steps: S1: Acquire pest image data collected in the field crop environment and preprocess it to obtain pest images of uniform size with pest species labels and life cycle labels; S2: Perform feature extraction and global relationship modeling on preprocessed pest image data to obtain discriminative multi-scale feature representations; S3: Utilize the multi-head attention mechanism to enhance key regions of the multi-scale feature representation obtained above, mapping the features of different discrimination regions into multiple feature nodes, providing structured input for subsequent relationship modeling; S4: The obtained feature nodes are used as nodes in the graph structure. The edge relationships between nodes are determined based on the feature similarity between nodes. By constructing a graph structure between feature nodes, a pre-trained improved graph convolutional network is introduced to model the relationships between nodes, realizing explicit reasoning about the association information between pest categories and life cycle attributes, and obtaining feature nodes that provide the association information between pest categories and life cycle attributes; wherein, the improvement of the graph convolutional network includes: Construct an adjacency matrix based on the co-occurrence frequency of pest species labels; The adjacency matrix is normalized to avoid high-frequency categories dominating propagation; S5: Based on the feature nodes of the association information between the pest category and the life cycle attribute, the classifier performs joint prediction on the pest type label and life cycle label to obtain the multi-label classification result, and outputs the pest type label and life cycle label at the same time.
2. The multi-label classification method for crop diseases and pests according to claim 1, characterized in that, In step S1, the collected pest image data is labeled, that is, each pest image in the pest image data is labeled with two tags: pest species and life cycle stage.
3. The multi-label classification method for crop diseases and pests according to claim 1, characterized in that, The specific steps for step S2 are as follows: S21: For the input pest image By performing layer-by-layer feature extraction using a convolutional neural network, feature values at each location in the pest image are obtained. These feature values are then neatly arranged together to form a feature map. The operation formula is as follows: ; In the formula, Let represent the feature value output by the k-th convolutional kernel at position (i,j) in the output feature map. This represents the pixel value at position (i+m, j+m) in the input pest image. This represents the weight parameters of the k-th convolutional kernel at position (m,n) on the c-th channel. The term represents the bias term corresponding to the k-th convolutional kernel. i and j represent the row and column indices of the output feature map, respectively, which are the output coordinates corresponding to the current spatial position of the convolutional kernel. m and n represent the row and column indices of the elements inside the convolutional kernel, which are used to describe the weight parameters at each position within the convolutional window. c represents the channel index of the input pest image, which is used to perform weighted summation of the information on the input channels. Next, the ReLU activation function is used to... Activation values are obtained by performing nonlinear transformations. This enhances the response of salient features, suppresses invalid information, and performs pooling operations to reduce dimensionality features while retaining the main response information. The operation formula is as follows: ; In the formula, Let represent the activation value of the r-th channel at position (u, v), where r represents the channel number of the feature map. and These represent the row and column indices in the output feature map after pooling, respectively, which are the spatial output positions corresponding to the pooling window. (u, v) are the spatial coordinates of each element within the pooling window, where u represents the x-coordinate of the element and v represents the y-coordinate of the element. Indicates the pooled window region. This represents the final feature value obtained after pooling; After pooling, a sliding convolution kernel is used to perform convolution within a local region of the input pest image. Through layer-by-layer convolution, activation, and feature mapping transformation, edge, texture, shape, and semantic structure information in the pest image are gradually extracted, ultimately obtaining discriminative multi-scale features. The calculation formula is as follows: ; In the formula, This represents the output feature map after activation of the h-th convolutional layer. This represents the output feature map of layer h-1, which serves as the input to layer h. Represents the parameters of the h-th convolutional kernel. This represents the bias term at level h. This represents the convolution operation. denoted as a non-linear activation function, h represents the convolutional layer number, and the h-th layer is the convolutional layer currently performing the convolution operation; After multiple convolutional processes, the output is a discriminative multi-scale feature representation, i.e., the output feature map, expressed by the following formula: ; In the formula, and Indicates the height and width of the feature map. Let R be the number of feature channels, and R be the set of real numbers. This indicates that all elements in this feature map are real numbers. The output feature map of the h-th layer The final output represents the multi-scale feature representation obtained after multi-layer convolution processing; S22: Using an attention modeling network, global dependency modeling is performed on the multi-scale feature representation, enabling the model to capture the correlation between distant regions in the image.
4. The multi-label classification method for crop diseases and pests according to claim 3, characterized in that, The specific steps for step S3 are as follows: S31: For input multi-scale feature representation Expand into a series , represented as: ; In the formula, This represents the overall representation of the token sequence formed after expanding the input multi-scale feature representation, where each token represents a feature unit. This represents the feature vector of the Nth token, where N represents the number of tokens. R represents the dimension of each token, and R represents the set of real numbers. S32: After unfolding in step S31 Based on this, positional information is preserved, and positional encoding is added to obtain the input sequence for the multi-head attention mechanism: ; In the formula, Indicates position code, The input sequence for the multi-head attention mechanism; S33: The input sequence In the input multi-head attention mechanism, the input vector is treated as a multi-head parallel self-attention computation.<Key,Value> In key-value pair format, the similarity coefficient between the Key and Query is calculated based on the Query value in the given task objective. This yields the weight coefficient corresponding to the Value. Here, Q, K, and V represent Query, Key, and Value, respectively. Query, Key, and Value are the query matrix, key matrix, and value matrix obtained through linear mapping of the input sequence, respectively. The calculation formula is as follows: ; ; In the formula, , , These are the learnable weight matrices corresponding to the query, key, and value, respectively. In multi-head attention mechanisms, "head" refers to a subspace branch that performs parallel mapping and independent attention computation of input features. This represents the output of the h-th attention head. Indicates multi-head output. This is the final weight matrix corresponding to the multi-head concatenation result. The feature sequence is the output after multi-head attention mechanism operation, and then the feature sequence is encoded through multiple layers to obtain a global feature representation: ; S34: Represent the multi-scale features and the global feature representation The desired feature nodes are obtained through weighted calculation, and the calculation formula is as follows: ; In the formula, and is the weighting coefficient, and F is the feature node obtained by mapping after the multi-scale features are enhanced through the key region.
5. The multi-label classification method for crop diseases and pests according to claim 4, characterized in that, The specific steps for step S4 are as follows: S41: For the input feature nodes F, construct the graph structure and initialize the node feature matrix, as follows: ; In the formula, The initialized node feature matrix, For feature representation, For natural numbers, Indicates the first The feature representation vector corresponding to each feature node; S42: To determine the feature similarity between nodes and the edge relationships between nodes, cosine similarity is used, expressed by the formula: ; In the formula, This represents the similarity between node p and node q; and They are respectively represented as For two distinct feature nodes, ||·|| represents the L2 norm; S43: After obtaining the similarity between nodes, based on the set threshold Determine the edge relationships between nodes, and then construct the adjacency matrix. The adjacency matrix can be written in block matrix form: ; In the formula, Indicates the relationship between nodes representing pest categories; This represents the relationships between lifecycle attribute nodes; This indicates the reverse association weight between the lifecycle attribute node and the pest category node. This indicates the bidirectional association weight between the pest category node and the life cycle attribute node; Then, by introducing the identity matrix I, we obtain the extended adjacency matrix. The extended adjacency matrix is then normalized using the degree matrix D to obtain the normalized adjacency matrix: ; In the formula, the identity matrix I is the adjacency matrix. A square matrix of the same dimension has 1s on its main diagonal and 0s on all other elements. The degree matrix D is a diagonal matrix, and its diagonal elements represent the sum of the connection weights between the node element and its neighboring nodes. The off-diagonal elements are all 0s. S44: Combine the node feature matrix A and the normalized adjacency matrix. Input the pre-trained improved graph convolutional network and model it according to the following formula: ; In the formula, This represents the node feature matrix of the input layer l. This represents the node feature matrix output by the (l+1)th layer. Let represent the weight matrix of the l-th layer, which is generated during the training of the graph convolutional network. This represents the bias term of the l-th layer. Represents a non-linear activation function; S45: During the multi-layer iterative update process of the graph convolutional network, each feature node continuously aggregates feature information from adjacent connected nodes. Simultaneously, guided by constraints from the adjacency matrix (based on label co-occurrence frequency statistics and normalized), it gradually encodes pest category discrimination information, life cycle stage attribute information, and the inherent association rules between pest categories and life cycle stage attributes into the node features. After graph convolutional inference, the original feature nodes are updated to enhanced feature nodes that simultaneously contain pest category semantics, life cycle attribute semantics, and their association information. This results in the aggregation of feature nodes containing complete association information between pest categories and life cycle attributes. .
6. The multi-label classification method for crop diseases and pests according to claim 5, characterized in that, The specific steps for step S5 are as follows: S51: In order to use the graph structure reasoning results for the final classification, the feature nodes containing complete association information between pest categories and life cycle attributes are... Fusion with feature node F: ; In the formula, This represents the final feature obtained after fusion; S52: The final feature The data is fed into a classifier for final prediction. The prediction formula is as follows: ; In the formula, This represents the joint prediction result of pest category and life cycle attribute, including both pest species label and life cycle label. Represents the activation function mapping, , These are the classifier parameters.