A small sample pest image classification method based on cross-domain generalization
By introducing an adaptive multi-scale cross-domain few-shot classification framework based on EMA, I-BN, and RG-Gconv, the performance degradation caused by domain offset in cross-domain few-shot learning is solved, improving the accuracy and generalization ability of pest image classification, especially showing excellent performance in the classification of different developmental stages of fall armyworm.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHANGZHOU UNIV
- Filing Date
- 2026-02-03
- Publication Date
- 2026-06-02
Smart Images

Figure CN122135075A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and in particular to a small-sample pest image classification method based on cross-domain generalization. Background Technology
[0002] The fall armyworm is a holometabolous pest. Its larvae feed extensively on crop leaves and stems. Strengthening monitoring throughout the entire crop growth period is beneficial to preventing large-scale outbreaks of fall armyworm infestations and is crucial for protecting crop growth and the ecological environment.
[0003] Few-shot learning (FSL) extracts transferable knowledge at the task distribution level, enabling effective learning with very few samples. However, FSL models are limited by the strong assumption of consistent style distribution between the training and test sets. When generalized to a significant domain shift between the training and test sets, model performance will be greatly reduced. Cross-domain few-shot learning aims to overcome the differences in data distribution between the training and test sets. However, instance-guided strategies are highly dependent on the quality of the selection of a small number of support samples and auxiliary instances. When there is noise in the support set or the inter-class differences are minimal, the model may have poor generalization ability when facing unknown domains.
[0004] Traditional cross-domain few-shot learning methods typically employ fixed feature extraction networks (such as ResNet-10) and standard GNN classifiers. Their structural design makes it difficult to fully capture subtle morphological changes in the target, and they also have limited robustness in feature transfer and inter-class semantic discrimination in cross-domain relationship modeling. Summary of the Invention
[0005] To address the shortcomings of existing methods, this invention proposes an adaptive multi-scale cross-domain small sample classification framework to reduce annotation costs and improve model discrimination and generalization capabilities. The framework optimizes cross-domain representation consistency from feature encoding to graph relation reasoning. The classification uses the fall armyworm as the object, which exhibits significant morphological differences at different developmental stages and subtle morphological variations at different larval instars, posing a major challenge to image classification.
[0006] The technical solution adopted in this invention is: a small sample pest image classification method based on cross-domain generalization, comprising the following steps: Step 1: Collect pest image data; As a preferred embodiment of the present invention, a hybrid query set is constructed based on the support set and query set of the source domain image and the support set and query set of the target domain image.
[0007] In a preferred embodiment of the present invention, the formula for the hybrid query set is: in, For random parameters, For the source domain query set, For the target domain query set.
[0008] Step 2: Extract preliminary features, shallow features, and deep features from the image step by step; In a preferred embodiment of the present invention, the initial feature network consists of 7×7Conv, BatchNorm, ReLU, and Maxpool.
[0009] In a preferred embodiment of the present invention, the shallow feature network includes a main branch and a residual branch. The main branch consists of a 3×3 Conv, an IBN layer, a ReLU, a 3×3 Conv, an IBN layer, and an EMA module. The residual branch consists of a 1×1 Conv. The outputs of the residual branch and the main branch are added together and then connected to a ReLU.
[0010] In a preferred embodiment of the present invention, the IBN layer includes: the feature map is output through a 3x3 Conv layer with 64 output channels; the first 16 channels are processed using the IN layer; the last 48 channels are processed using the BN layer, and the sum is followed by ReLU.
[0011] In a preferred embodiment of the present invention, the deep feature network includes a main branch and a residual branch. The main branch consists of a 3×3 Conv, a BN layer, a ReLU, a 3×3 Conv, a BN layer, and an EMA module. The residual branch consists of a 1×1 Conv. The outputs of the residual branch and the main branch are added together and then connected to a ReLU.
[0012] Step 3: Input the extracted deep features into the decoupling module, which outputs domain-specific feature branches and domain-independent feature branches, and uses a classifier to output the classification results; In a preferred embodiment of the present invention, the improved GNN classifier only processes domain-independent features, while the domain classifier processes both domain-specific features and domain-independent features.
[0013] As a preferred embodiment of the present invention, the improved GNN classifier introduces a residual gating mechanism into the GNN graph convolution module to obtain the RG-Gconv module.
[0014] In a preferred embodiment of the present invention, the formula for the RG-Gconv module is: ; ; ; ; in, Indicates the first Layered graph convolution; Indicates batch normalization; indicates linear projection of the main branch; This indicates an information aggregation operation; Represents learnable edge features; Indicates batch size; Indicates the number of nodes; Indicates the number of relational channels; Indicates the dimension of the input features; This represents the Sigmoid activation function; Indicates a learnable scalar parameter; This represents the main branch of the standard graph convolution; This represents the node features input to the current layer; Indicates the learnable gating coefficient; This indicates a residual branch.
[0015] The beneficial effects of this invention are: 1. Introduce an efficient multi-scale attention (EMA) mechanism to dynamically model long-term stable attention regions in the backbone feature flow, guiding the model to focus on insect body structural features (such as somatic outlines and wing patterns), thereby enhancing intra-class aggregation and inter-class separation capabilities; 2. Introduce Instance-Batch Normalization (I-BN) to decouple style and discriminative features through channel split normalization in the shallow feature encoding stage, so as to reduce the feature distribution shift caused by differences in morphology, body color and quantity distribution; 3. A residual-gated graph neural network (RG-Gconv) is proposed, which introduces residual branches and adaptive gating in the node update stage to dynamically balance the transmission and retention of node features, thereby effectively improving the model classification performance; 4. This study aims to provide methodological support and experimental foundation for constructing an efficient and scalable pest classification system. By improving the image classification method for holometabolous pests, it achieves effective classification of datasets with different categories and styles without relying on a large amount of labeled data. Attached Figure Description
[0016] Figure 1 This is a diagram showing the overall structure of the small-sample pest image classification model based on cross-domain generalization of the present invention. Figure 2 These are characteristic diagrams of the various growth stages of the polymorphic pest (spodumene) of this invention; Figure 3 This is a data model diagram for few-shot learning and cross-domain few-shot learning; Figure 4 This is a structural diagram of the EMA of the present invention; Figure 5 This is a structural diagram of the I-BN of the present invention; Figure 6 It is a residual gated graph convolutional architecture diagram; Figure 7 This is an ablation experiment diagram based on the 5-way-5-shot setup; Figure 8 This compares other model diagrams under a 5-way 5-shot setup; Figure 9 It is a visualization result based on Grad-CAM; Figure 10 This is the model convergence curve under the 5-way 5-shot / 1-shot settings. Detailed Implementation
[0017] The present invention will be further described below with reference to the accompanying drawings and embodiments. The drawings are simplified schematic diagrams, which only illustrate the basic structure of the present invention in a schematic manner, and therefore only show the components related to the present invention.
[0018] like Figure 1 As shown, a small-sample pest image classification method based on cross-domain generalization includes the following steps: like Figure 2 The dataset consists of a training set (the public dataset miniImageNet) and a test set (self-built datasets SF-1450 and BM-1050, and the public datasets CUB and CropDisease). The SF-1450 and BM-1050 datasets contain complete life stages of the fall armyworm (9 morphologies, 1450 images) and silkworm (8 morphologies, 1050 images), respectively. CUB and CropDisease datasets contain publicly available datasets of birds (200 morphologies, 11788 images) and plant diseases (38 morphologies, 54306 images), respectively. Image acquisition for the self-built datasets was conducted in two phases, from September 2024 to June 2025, at the Xinkang Village Modern Agricultural Industrial Park, Changzhou City, Jiangsu Province, China (geographic coordinates: 31°48′44.1″N). Field data was collected at 119°58′9.0″E, covering complex backgrounds (such as multi-angle leaf occlusion and non-uniform lighting); images were also collected under controlled laboratory conditions (constant light source 700~900 Lux), highlighting the insect's fine textures (such as surface gloss and segment structure). The data collection devices included a vivo x100 PRO mobile phone (equipped with a 1 / 0.98-inch Sony IMX989 sensor, 50 megapixels) and a DJI Mini 3 Pro drone (1 / 1.3-inch sensor with f / 1.7 aperture, 48 megapixels); the training set (composed of natural images from the Internet) and the test set (based on field and laboratory data collection) showed significant inter-domain differences in imaging mechanisms, background structure, and feature distribution (meeting the cross-domain small sample learning setting).
[0019] Few-Shot Learning (FSL) aims to learn a prediction function suitable for a classification target, based on prior knowledge from the training set and a very small number of labeled samples from the test set, when the class spaces and data distributions of the training and test sets are similar. This enables the model to quickly adapt to and generalize to classification targets (such as...). Figure 3 (a).
[0020] Specifically, given a dataset The dataset is divided into base classes based on categories. ), Validation datasets ( ) and new class datasets ( ), The base class is used for model training (training set); the validation class is used for model hyperparameter tuning (validation set); and the new class is used to evaluate the model's generalization ability on unseen classes (test set).
[0021] In experimental setups, an N-way K-shot task is typically used (where N and K represent the number of task categories and the number of samples per category, respectively). N categories are randomly selected from the training, validation, or test sets, and K labeled samples are selected from each category to form the support set (K is very small, typically 1, 5, or 10). Then, a number of unlabeled samples are sampled from the corresponding category to form the query set. Figure 3 In step c), the pre-trained model attempts an episode in each task, using the support set of the base class to learn prior knowledge of the category, helping the model understand category features. By validating the support set of the class, the model's adaptability to different category features is enhanced. Finally, by combining the support set of the new class, the model classifies the query set of the new class to evaluate the model's classification performance on unseen categories.
[0022] Cross-Domain Few-Shot Learning (CDFSL) aims to learn prior knowledge on a training set with sufficient labeled samples and effectively generalize it to the test set when there are significant differences in the data distribution or image imaging mechanism between the training and test sets. Figure 3 (b) Generally, a dataset with sufficient labeled samples and containing multiple categories is called the source domain dataset, while a dataset with fewer labeled samples and a data distribution significantly different from the source domain is called the target domain dataset; specifically, given two datasets... , Represents the source domain. The target domain is represented, and the dataset partitioning and task format follow the few-shot learning setting. The pre-trained model combines the knowledge learned from the source domain (base classes and validation classes) with the target domain knowledge (new class support set) to classify the query set of new classes in the target domain in order to evaluate the model's cross-domain generalization ability.
[0023] like Figure 1 The orange section represents the improved module, and the gray section represents the original module; the dashed arrows indicate the transition from the output of one module to the input of the next module. Indicates the support set / query set of the source domain. This represents the support set and query set of the target domain. "a" represents the hybrid query module, "b" represents the feature extraction module, and "c" represents the classifier module.
[0024] During training, five classes are randomly selected from the target domain (base class) to construct an auxiliary training set. At the same time, the query sets of the source domain base class and the auxiliary training set are mixed proportionally to form a new query set (mixed query set) to help the model adapt to the image style of the target domain in advance. In particular, the categories of the auxiliary training set do not overlap with the new categories of the target domain, which is in line with the basic assumption of Cross Domain Few-Shot Learning.
[0025] Figure 1 Specifically, based on the N-way K-shot task format, the source domain... Base class divided into support sets and query set ; The auxiliary training set is divided into support sets. and query set In each episode, through a random parameter Two-domain query samples , Perform linear interpolation to obtain a mixed query set .
[0026] In the feature extraction stage, ResNet-10 is used as the backbone network for improvement. The overall structure consists of a Stem module and two feature extraction layers (shallow and deep). Figure 1 (b) The Stem module consists of 7×7 convolution, BatchNorm, ReLU and max pooling, used to perform preliminary feature extraction on the input image; then, the features are sent to the shallow feature extraction layer, where local spatial features are further extracted through 3×3 convolution, and Instance-Batch Normalization (I-BN) is introduced to normalize the feature distribution from the perspectives of sample-specific features and batch global features.
[0027] Next, the ReLU activation function is applied to the normalized features, and the features are further processed through a second 3×3 convolution.
[0028] Next, the I-BN and Efficient Multi-Scale Attention (EMA) modules are applied in sequence. EMA enhances the response to key regions of the insect body (such as texture and body length) through a multi-scale attention mechanism.
[0029] Finally, the main branch outputs... F(x) With residual branch F(r) The sum is used as input for the deep feature extraction stage.
[0030] The processing flow of the deep feature extraction stage is similar to that of the shallow feature extraction stage, but the normalization process uses the traditional BN layer.
[0031] In the classification stage ( Figure 1 (c) The model first decomposes the features extracted in the above stages into two parallel feature branches through the decoupling module. These branches are domain-specific feature branches (features related to imaging device, shooting style, and ambient lighting) and domain-independent feature branches (features related to the object itself and unaffected by style and lighting). Among them, the improved GNN classifier only processes domain-independent features, while the domain classifier processes both domain-specific and domain-independent features.
[0032] Specifically, to effectively extract and utilize domain-independent discriminative information, a residual gating mechanism, GR-Gconv, is proposed based on the GNN graph convolution module. This mechanism adds the original input features to the processed output features through residual connections, while using gating coefficients (initially zero) to control the model's dependence on the residuals. The model can adaptively adjust these coefficients during training, ensuring effective extraction and utilization of domain-independent discriminative information even when training data in the target domain is scarce, and avoiding feature information loss due to over-smoothing. LFSL (Few-shot learning loss) guides the improvement of GNN classifiers to learn more effectively by utilizing the shared information between source and target data, thereby enhancing the model's classification ability between the source and target datasets; Domain classifiers perform standard domain discrimination tasks on domain-specific features, enabling the model to accurately identify the domain from which the data originates. For domain-independent features, the classifier eliminates domain-specific discriminative properties, ensuring that the feature contains only content relevant to the object itself, thereby enhancing cross-domain learning capabilities. Simultaneously... LDom (Domain classification loss) helps the model further decouple the feature differences between the source and target domains, reducing the impact of domain shift on model performance.
[0033] The classification of fall armyworm mainly relies on fine-grained texture and gloss. However, under cross-domain conditions, the target insect's information representation is inconsistent with the source domain feature distribution, making the model susceptible to domain shift during feature extraction and reducing its cross-domain robustness. To address this, this invention designs a multi-scale style consistency feature extractor, incorporating two key ideas: 1. Embedding an Efficient Multi-scale Attention (EMA) module in each residual unit to improve the effective response to extracting key regions (texture, body length) of the insect through a cross-spatial attention mechanism; 2. Designing a style consistency module in the shallow feature extraction stage, dividing the feature channels into two groups according to the number of channels, normalizing them using Instance Norm (IN) and Batch Norm (BN) respectively, and then concatenating them to alleviate cross-domain drift and enhance the stability of shallow texture information extraction.
[0034] The fall armyworm exhibits relatively small morphological differences during its larval stage. Furthermore, under the cross-domain hybrid training strategy, the model needs to process mixed features from both the source and target domains simultaneously, leading to a decline in the model's feature discrimination ability.
[0035] like Figure 4 The EMA module is introduced to enhance the expressive power of main branch features; Specifically, EMA adopts a multi-branch parallel topology, taking a C×H×W feature map as input. The features are divided into G groups according to the number of channels, and the size of each group of feature maps is C / / G×H×W. To capture multi-scale spatial information, two parallel branches (1×1 and 3×3 branches) are used to extract attention weights from each group of feature maps respectively. Among them, the 1×1 branch first performs one-dimensional global average pooling along the horizontal and vertical directions respectively to obtain two one-dimensional features, which are then concatenated to obtain a feature map of size C / / G×1×(W+H). Then, it is re-divided into two paths through 1×1 convolution, and the horizontal and vertical attention weight maps are generated by sigmoid. These are then re-weighted with the original feature map to obtain a feature map of size C / / G×H×W. Subsequently, spatial features are compressed into channel-level global statistical vectors using two-dimensional global average pooling. Then, softmax is used to obtain channel weights, which are then multiplied by matrix multiplication with the feature map processed by the 3×3 convolution kernel in the 3×3 branch to generate the first spatial attention weight map with dimensions 1×H×W. The 3×3 branch performs operations similarly to the 1×1 branch, except that it first obtains multi-scale feature representations through a single 3×3 convolution. Similarly, after the softmax operation, it is multiplied by matrix multiplication with the feature map obtained by reweighting the 1×1 branch to obtain the second spatial attention map. The two spatial attention maps are added together and normalized by sigmoid to obtain the final attention weight map. Finally, the original feature map is reweighted by the final attention weight map to output a feature map that emphasizes the region of interest, thereby strengthening the model's attention to the insect's outline, texture structure, and morphological differences at different developmental stages.
[0036] Traditional cross-domain few-sample model feature extractors rely solely on a single BN layer to normalize the feature statistics of the source / target domain support set, which is insufficient to address style interference and class feature differentiation challenges caused by domain differences and inter-class similarity. To solve these problems, inspired by the hierarchical normalization concept, this invention designs an Instance-Batch Normalization (IBN) strategy (applying IN+BN in the shallow stage and BN in the deep stage), combining IN and BN to suppress style interference while preserving discriminative features.
[0037] like Figure 5 I-BN combines IN and BN by dividing channels. Specifically, the input image is convolved to output a feature map with 64 channels. The channels are divided into two parts in a 1:3 ratio: the first 16 channels use the IN layer, which calculates the mean and variance of a single image sample in the spatial dimensions (height and width) to standardize the features of that sample, aiming to remove style perturbations caused by differences in lighting, color, and other imaging between the source and target domains; the last 48 channels use the BN layer, which calculates the mean and variance of the same batch of samples to obtain statistics and standardize the channel features, aiming to focus on the boundaries, textures, and shapes of the image, enabling the feature extraction network to learn stable semantic features and improve the model's ability to distinguish between different categories. This strategy more stably supports shallow cross-domain feature representation than BN alone, while achieving a balance between "style consistency" and "category distinctiveness," maintaining stable classification performance under different backgrounds and imaging conditions, and avoiding interference from leaf textures.
[0038] Under the cross-domain hybrid training strategy, the feature distribution of the hybrid query set tends to have blurred inter-class boundaries, making it difficult for the model classifier to establish a clear class correspondence between the support set and the query set. In particular, GNNs that only process domain-independent features mainly rely on node features (image features) to model the similarity between the support set and the query samples. Hybrid training weakens the ability of GNNs to distinguish morphological differences of pests at different developmental stages.
[0039] like Figure 6 To alleviate the above problems, this invention introduces a residual gating mechanism into the graph convolution module of the GNN classifier, proposing RG-Gconv. Specifically, in the standard graph convolution main branch... In addition, residual gating connections are introduced to incorporate the node features input from the current layer. Through residual linear projection ( Residual branches are formed in the output dimension. The output is obtained by adding it to the main branch. The calculation formula is shown in Formulas 1-4; at the same time, a learnable gating coefficient constrained to (0,1) is set. The residual strength is adaptively controlled to suppress oversmoothing when there is a lot of noise in the cross-domain relationship, thus preserving stronger discriminative information and improving generalization ability; at the same time, the improved GNN structure retains the traditional hierarchical design, and the input and output of each layer are linked through multi-layer processing, thereby gradually enhancing the classification ability of the model. in, Indicates the first Layered graph convolution, Indicates batch normalization, Indicates the linear projection of the main trunk. This indicates an information aggregation operation. This represents learnable edge features. Indicates batch size, Indicates the number of nodes. Indicates the number of relational channels. Indicates the input feature dimension. This represents the Sigmoid activation function. This represents a learnable scalar parameter.
[0040] Experimental procedure: To evaluate the model's generalization ability, ablation experiments were conducted in a 5-way 5-shot setting using self-built datasets (SF-1450, BM-1050) and public datasets (CUB, CropDisease). The model was compared with five mainstream cross-domain few-shot learning methods (Meta-FDMixup, AFA, Wave-San, LDP-net, StyleAdv). The performance improvement and effectiveness of the improved model were comprehensively demonstrated by combining accuracy and loss convergence curves, as well as Grad-CAM visualization results (as shown in Table 1).
[0041] The specifications of the hardware platform used in the experiment are as follows: The system features a 14th generation Intel® Core™ i7-14650HX CPU @ 2.2GHz, an NVIDIA GeForce RTX4060 GPU (8 GB VRAM), and 16GB of RAM. Algorithm development was based on Python 3.6.13 programming and the PyTorch 1.10.2 deep learning framework; model training parameters were set to a learning rate of 0.001 and 200 iterations to optimize model fitting ability.
[0042] Table 1 Experimental setup for performance evaluation of the EIR-CDFS model Ablation experiment: The model's classification accuracy showed a stepwise increase in single / multi-factor ablation experiments. Figure 7The S1+S2+S3 (EIR-CDFS) model improved performance by 4.01%, 1.14%, 4.45%, and 3.17% on the SF-1450, BM-1050, CUB, and CropDisease datasets, respectively, compared to the original model. The average accuracy reached its highest level and broke 90% for the first time (90.10%). To avoid the impact of excessively high or low accuracy on data analysis from any single dataset, the harmonic mean (averaging the reciprocals of dataset accuracies and then taking the reciprocal) and geometric mean (the fourth root of the product of dataset accuracies) for each strategy were calculated. Specifically, after introducing the S1 strategy, both the harmonic mean accuracy and the geometric mean accuracy significantly improved compared to S0 (>2%). The classification accuracy showed the most significant improvement on the CUB dataset (3.23%). This may be because the EMA attention mechanism effectively enhanced the model's ability to focus on key regions (such as insects, birds, and leaf textures), thereby improving the model's ability to distinguish between highly similar classes. After the S1+S2 strategy was combined, the classification accuracy improved by more than 3% on all four datasets compared to S0, with the most significant improvement (2.26%) on CropDisease compared to S1 alone. This may be attributed to the I-BN module weakening the influence of style and other domain-specific features on the model in the shallow stage, allowing the deep discriminative features to focus more on category-related information, thereby mitigating cross-domain bias. After the improved strategy was combined, the model achieved the best classification performance on SF-1450, CUB, and CropDisease (up to 4.45% improvement over S0). At the same time, the model showed good adaptability to different datasets, with the harmonic mean and geometric mean improving by 3.35% and 3.21% respectively compared to S0. This may be because the introduction of residual connections and gating mechanisms allows features to retain their original information when propagating in the graph structure. Combined with gating, the contribution of each feature is adaptively adjusted, thereby enhancing the class discrimination ability and significantly improving the robustness of cross-domain discrimination under small sample conditions.
[0043] like Figure 7 Note: S0 represents the original model; S1 represents the introduction of an efficient multi-scale attention (EMA) mechanism; S2 represents the introduction of an I-BN module; S3 represents the introduction of a residual gated graph neural network (GR-GNN). The classification ablation experiment results of the model on different developmental stages of fall armyworm (Table 2) show that the quarter-digit (Q1) of the average classification accuracy of the S1, S1+S2 and S1+S2+S3 models were 4.70%, 5.08% and 5.61% higher than that of S0, respectively. The improvement strategy significantly improved the classification performance of the model on complex tasks.
[0044] Specifically, after introducing the S1 strategy, the model's classification accuracy in the early larval stages (1st and 2nd instars) significantly improved by 3.61% and 8.99% compared to the S0 model, respectively. With the synergistic effect of S1 and S2, the model's average classification accuracy and harmonic mean improved by 2.04% and 0.64% compared to S0, respectively. It also achieved the highest accuracy (98.44%) in the 2nd instar larvae, and in the stages of similar larval size (4th and 5th instars), the classification accuracy also improved by 1.87% and 0.78% compared to S1, respectively. Finally, S3 was introduced. The average classification accuracy, harmonic mean, and geometric mean of the model improved most significantly compared to S0, by 2.89%, 1.81%, and 1.84%, respectively. In particular, the model achieved the highest accuracy in the six developmental stages, with the greatest improvement in the egg stage, which improved by 3.39%, 3.35%, and 2.86% compared to S0, S1, and S1+S2, respectively. The classification accuracy reached a maximum of 99.69% in the 4th, 5th, and 6th instars, three growth stages where the morphology of the insect is easily confused.
[0045] Table 2. Classification performance of the model for fall armyworm at different developmental stages under the 5-way 5-shot setting. Comparison with other classification models: The experimental results of the comparative analysis of classification performance of different mainstream models show that the average accuracy of the EIR-CDFS model is 90.10%, which is 3.19%, 9.62%, 6.32%, 7.11% and 4.54% higher than that of Meta-FDMixup, AFA
[38] , Wave-San
[22] , LDP-net and StyleAdv, respectively (e.g. Figure 8 It exhibits stronger adaptability in cross-domain tasks with significant domain shifts and subtle differences between categories.
[0046] Specifically, EIR-CDFS achieved the highest classification accuracy on the SF-1450 and CUB datasets, at 93.15% and 80.73%, respectively. On the SF-1450 dataset, its classification accuracy improved by 4.01% and 7.27% compared to the second-best model, Meta-FDMixup, and the worst model, AFA, respectively. On the CUB dataset, its classification accuracy improved by 4.45% and 20.11%, respectively. On the BM-1050 and CropDisease datasets, EIR-CDFS achieved classification accuracies of 95.86% and 90.67%, respectively. The performance of EIR-CDFS is comparable to that of the optimal model, StyleAdv. To analyze the model's adaptability to different datasets, the standard deviation of the model's classification accuracy on the four datasets was compared. The standard deviation of EIR-CDFS was only 5.71%, which was 0.98%, 6.32%, 5.46%, 6.05%, and 6.88% lower than that of Meta-FDMixup, AFA, Wave-San, LDP-net, and StyleAdv, respectively. This indicates that EIR-CDFS has less performance fluctuation across different datasets and more stable cross-domain generalization performance.
[0047] Grad-CAM method: This study uses the Grad-CAM visualization method to conduct a comparative visualization analysis of the class activation maps (CAMs) generated by the baseline and EIR-CDFS (e.g., ...). Figure 9 Experimental results show that the area ratio between high-response regions and target ground truth regions in the class activation map of EIR-CDFSD is significantly improved (>20%) compared to the baseline, effectively focusing on the core regions of class discrimination and avoiding dependence on non-specific background information in the image.
[0048] Specifically, in the SF-1450 and BM-1020 datasets, EIR-CDFS exhibits a more focused attention distribution and more complete coverage, accurately locking high-response regions onto the main target and its key structural features (such as the insect's outline and fine texture), and significantly reducing the response to high-frequency background noise. In contrast, Baseline's attention is mostly distributed in the background region around the egg (leaf veins or non-main areas), the gap between the pupa and the measuring ruler, and the edge region of the adult insect, failing to effectively cover the key discriminative parts of the target object. This attention shift easily introduces background interference, weakening the model's discriminative ability. In the CUB dataset, EIR-CDFS... Focusing on key classification features of birds, such as head morphology and body structure, it demonstrates excellent fine-grained feature capture capabilities. In the CropDisease dataset, the high-response regions of EIR-CDFS are concentrated in lesions and key infected tissues, and it can accurately capture disease edges and texture changes. This feature focusing ability is particularly crucial in agricultural disease identification tasks because lesions are usually small in spatial extent and have only subtle differences from healthy tissues. The Baseline, on the other hand, focuses on non-disease areas of leaves or a large area of irrelevant background, which may lead to insufficient expression of disease features and affect the model's accurate classification of disease categories.
[0049] Accuracy and loss convergence curves: Accuracy and loss convergence curves show that EIR-CDFS improves the average accuracy by 1.93% compared to the baseline in the early training phase (first 20 epochs) and converges 21 epochs earlier. In the later training phase, the accuracy variance decreases by 27% compared to the baseline, demonstrating more stable classification performance (e.g., Figure 10 Specifically, after the 19th epoch, the accuracy rapidly increased to 74-76%, while the baseline accuracy only remained at 67-75%. EIR-CDFS showed higher training efficiency in the early stages of convergence. In terms of peak performance, EIR-CDFS reached its highest accuracy of 81.35% at 116 epochs, a slight improvement over the baseline's 80.67%. Notably, its high-precision range (>78%) lasted longer, reflecting its more robust generalization ability. Regarding the loss curve, EIR-CDFS rapidly decreased from 1.60 in the early stages to about 0.6 in the middle stages, with an overall loss value lower than the baseline.
[0050] Furthermore, in the 5-way 1-shot setting, the model's validation accuracy improved by an average of 1.01% compared to the baseline in the early stages of training, and after 100 epochs, the training accuracy was superior to the baseline (94 epochs). Specifically, at the 100th and 150th epochs, EIR-CDFS reached 60.23% and 60.10%, respectively, which were 5.56% and 3.66% higher than the baseline. The peak performance was 62.23%, which was 2.63% higher than the highest accuracy of the baseline (59.60%). In terms of the loss curve, the EIR-CDFS loss dropped to a minimum of 0.98 in the later stages of training, which was better than the baseline's 1.05, and after obtaining the minimum loss, the EIR-CDFS loss was always better than the baseline.
[0051] To verify the model performance under different settings, an experimental analysis under the 5-way 1-shot setting was added, including ablation experiments (different datasets and different developmental stages of fall armyworm), and comparison of classification performance of different models. S1~S3 in the experiment followed the 5-way 5-shot experimental setting.
[0052] The ablation experiment results (Table 3) show that the average accuracy of EIR-CDFS is significantly improved (>70%), which is 4.55% higher than that of S0, and the model has higher classification stability.
[0053] Specifically, after introducing strategy S1, the classification accuracy on the BM-1050 and CUB datasets improved by 6.59% and 2.83% respectively compared to the baseline model. After the synergistic effect of strategies S1 and S2, the model improved the classification accuracy on the SF-1450, BM-1050, CUB, and CropDisease datasets by 6.06%, 0.52%, 2.14%, and 0.30% respectively compared to the original model. In particular, the improvement was the greatest on SF-1450, and the classification accuracy was the highest (69.40%). After the combined effect of S1, S2, and S3, the model achieved a significant advantage over other strategies on all four datasets (0.47%~8.23%), and the classification accuracy was the highest on BM-1050 (83.46%).
[0054] Table 3 Ablation experiments based on 5-way 1-shot setup Note: S1-S3 represent three different improvement strategies, M0 is the baseline model, and M1-M5 represent five different model configurations. Configurations (where M1-M3 are single-factor experimental model configurations, and M4 and M5 are multi-factor experimental model configurations). M1 is based on M0 applying S1. The strategy can be further improved and configured in this way. M5 represents a model that integrates the three strategies.
[0055] The classification experiment of the model on different developmental stages of fall armyworm under the 5-way 1-shot setting showed that the average classification accuracy of S1, S1+S2 and S1+S2+S3 for each developmental stage was improved by 2.58%, 9.13% and 6.86% respectively compared with the baseline. After the three strategies worked together, the model achieved the highest quarter-digit average classification accuracy (67.19%), indicating that the model is better able to handle complex classification tasks. At the same time, the model achieved the best classification results in the egg, 4th instar and pupa stages, which were improved by 1.50%, 7.20% and 3.25% respectively compared with the second best model. Compared to the baseline, the accuracy improved by 8.35%, 24.95%, and 17.81%, respectively. The synergistic effect of S1 and S2 was the best in the early stages of fall armyworm, with classification accuracy improved by 7.44%, 9.79%, and 11.03% compared to the second-best model in the 1st, 2nd, and 3rd instars, respectively. This may be because the combination of the two modules effectively improved the model's ability to capture key geometric structures and fine-grained textures, achieving significant optimization in intra-class aggregation and inter-class separation. The S1+S2+S3 model ranked second in overall average accuracy. This may be attributed to the fact that in the 1-shot setting, each class contains only one support sample, which easily introduces noise during graph message passing, leading to over-smoothing of part-level features and thus reducing the model's feature discrimination ability.
[0056] Table 4. Classification performance of the model for fall armyworm at different developmental stages under the 5-way 1-shot setting. Comparative analysis of classification results with other models in a 5-way 1-shot setting (Table 5) shows that the EIR-CDFS model achieved an average accuracy of 71.03%, which is an improvement of 4.67%, 12.29%, 9.17%, 10.23%, and 5.20% compared to Meta-FDMixup, AFA, Wave-San, LDP-NET, and StyleAdv, respectively. Specifically, it achieved 68.26% and 62.65% accuracy on the SF-1450 and CUB datasets, respectively, both significantly outperforming other comparative methods. On the SF-1450 dataset, it improved by 16.37% compared to the worst model, LDP-NET, and on the CUB dataset, it improved by 21.35% compared to the worst model, AFA. This indicates that the model still possesses strong feature extraction and cross-domain discrimination capabilities even with very few samples.
[0057] Table 5 compares the classification performance of different models in a 5-way 1-shot setting. This invention addresses the problems of data scarcity and significant domain differences in cross-domain small sample image classification tasks by integrating Efficient Multi-Scale Attention (EMA), Instance-Batch Normalization (I-BN), and Residual Gated Graph Convolution (RG-Gconv).
[0058] The I-BN module aims to divide channels at a fixed ratio (1:3) to mix instance normalization and batch normalization, effectively mitigating the inter-domain statistical distribution shift caused by imaging style, illumination variations, and background complexity, and enhancing the consistency of shallow texture and geometric features in cross-domain scenarios. The EMA module employs a multi-scale parallel attention structure, which can adaptively allocate attention weights between local details and global semantics, guiding the network to focus on key areas of the insect body (such as eggshell gloss, segment texture, and wing vein structure), thereby strengthening the discriminativeness and robustness of high-level semantics. Residual gated graph convolution is introduced in the classification stage, allowing the residual connection strength to be adaptively adjusted, promoting the more effective propagation of discriminative semantic relationships in the graph structure, thus stabilizing feature distribution and improving classification performance. The synergistic effect of these three modules enables the model to maintain stable cross-domain generalization performance even under conditions of significant differences in the source and target domain distributions.
[0059] Evaluation results on self-built datasets (SF-1450, BM-1050) and public benchmark datasets (CUB, CropDisease) demonstrate that the proposed method exhibits significant advantages in cross-domain small-shot scenarios: in the 5-way 5-shot setting, the classification accuracy is improved by 4.01%, 1.14%, 4.41%, and 3.17% respectively compared to the baseline model; in the more challenging 5-way 1-shot setting, the average classification accuracy is improved by 4.67% compared to the baseline model. This verifies the stability of I-BN in inter-domain style alignment, the efficiency of EMA in multi-scale semantic modeling, and the role of GR-Gconv in preserving key discriminative information.
[0060] In summary, the improved model provides an efficient and reliable solution for cross-domain small-sample polymorphic pest classification tasks. It not only improves the accuracy of fine-grained recognition but also enhances the model's generalization performance under domain differences, providing strong technical support for the practical application of computer vision in monitoring the entire growth cycle of holometabolous pests and classifying agricultural pests.
[0061] Based on the above-described preferred embodiments of the present invention, and through the foregoing description, those skilled in the art can make various changes and modifications without departing from the inventive concept. The technical scope of this invention is not limited to the contents of the specification, but must be determined according to the scope of the claims.
Claims
1. A small-sample pest image classification method based on cross-domain generalization, characterized in that, Includes the following steps: Step 1: Collect pest image data; Step 2: Extract preliminary features, shallow features, and deep features from the image step by step; Step 3: Input the extracted deep features into the decoupling module, output domain-specific feature branches and domain-independent feature branches, and use the classifier to output the classification results.
2. The small-sample pest image classification method based on cross-domain generalization according to claim 1, characterized in that, The initial feature network consists of 7×7 Conv, BatchNorm, ReLU, and Maxpool.
3. The small-sample pest image classification method based on cross-domain generalization according to claim 2, characterized in that, The shallow feature network consists of a main branch and a residual branch. The main branch consists of a 3×3 Conv, an IBN layer, a ReLU, a 3×3 Conv, an IBN layer, and an EMA module. The residual branch consists of a 1×1 Conv. The outputs of the residual branch and the main branch are added together and then connected to a ReLU.
4. The small-sample pest image classification method based on cross-domain generalization according to claim 3, characterized in that, The deep feature network consists of a main branch and a residual branch. The main branch consists of a 3×3 Conv, a BN layer, a ReLU, a 3×3 Conv, a BN layer, and an EMA module. The residual branch consists of a 1×1 Conv. The outputs of the residual branch and the main branch are added together and then connected to a ReLU.
5. The small-sample pest image classification method based on cross-domain generalization according to claim 3, characterized in that, The IBN layer consists of: the feature map is output through a 3x3 Conv layer with 64 channels; the first 16 channels are processed using an IN layer; the last 48 channels are processed using a BN layer, and then summed and followed by ReLU.
6. The small-sample pest image classification method based on cross-domain generalization according to claim 1, characterized in that, An improved GNN classifier only processes domain-independent features, while a domain classifier processes both domain-specific and domain-independent features.
7. The small-sample pest image classification method based on cross-domain generalization according to claim 6, characterized in that, The improved GNN classifier is achieved by introducing a residual gating mechanism into the GNN graph convolution module, resulting in the RG-Gconv module.
8. The small-sample pest image classification method based on cross-domain generalization according to claim 7, characterized in that, The formula for the RG-Gconv module is: ; ; ; ; in, Indicates the first Layered graph convolution; Indicates batch normalization; indicates linear projection of the main branch; This indicates an information aggregation operation; Represents learnable edge features; Indicates batch size; Indicates the number of nodes; Indicates the number of relational channels; Indicates the dimension of the input features; This represents the Sigmoid activation function; Indicates a learnable scalar parameter; This represents the main branch of the standard graph convolution; This represents the node features input to the current layer; Indicates the learnable gating coefficient; This indicates a residual branch.
9. The small-sample pest image classification method based on cross-domain generalization according to claim 1, characterized in that, A hybrid query set is constructed based on the support set and query set of the source domain image and the support set and query set of the target domain image.
10. The small-sample pest image classification method based on cross-domain generalization according to claim 9, characterized in that, The formula for a mixed query set is: ; in, For random parameters, For the source domain query set, For the target domain query set.