A small sample fine-grained image classification method and system

Through the combination of self-attention mechanism and inter-class and intra-class dual perception modules, the problem of large intra-class differences in small-sample fine-grained image classification is solved, and the classification accuracy is significantly improved, especially surpassing the FRN method on the Stanford Dogs data set. , which proves the effectiveness of the feature enhancement module and the bidirectional reconstruction strategy.

CN118279675BActive Publication Date: 2024-09-27JILIN UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410691981.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-31
Publication Date
2024-09-27
Estimated Expiration
2044-05-31

AI Technical Summary

Technical Problem

Existing technology is difficult to effectively reduce intra-class differences in fine-grained image classification of small samples, making it difficult for the model to accurately identify multiple sub-class objects under the same super class with a very small amount of annotated data, and is prone to overfitting due to data scarcity.

Method used

The self-attention mechanism is used for feature self-reconstruction, and the query features are reconstructed through the support features and the query features are reconstructed to support the features, combined with the inter-class and intra-class dual perception module to calculate the distance between the query sample and the support sample to evaluate the similarity and reduce intra-class differences and increase inter-class differences.

Benefits of technology

Significantly improved the accuracy of small-sample fine-grained image classification, especially on the Stanford Dogs data set, surpassing the 16.3% accuracy of the state-of-the-art FRN method, and confirmed the effectiveness of the feature enhancement module and the inter-class and intra-class perception module through ablation experiments Complementarity and the effectiveness of bidirectional restructuring strategies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118279675B
    Figure CN118279675B
Patent Text Reader

Abstract

The present invention is applicable to the field of image classification technology, and provides a small sample fine-grained image classification method and system. The classification method includes the following steps: extracting features from support images and query images; using a self-attention mechanism to perform self-reconstruction of features; using support features to reconstruct query features, and using query features to reconstruct support features; calculating the distance between the query sample and the support sample. The present invention is significantly improved over the prior art on the Stanford Dogs, Stanford Cars and CUB‑200‑2011 datasets; at the same time, the complementarity of the feature enhancement module and the inter-class and intra-class perception module and the effectiveness of the bidirectional reconstruction strategy are also confirmed through ablation experiments. The present invention has practical significance when applied to small sample fine-grained image classification tasks, and reduces the intra-class variance while increasing the inter-class variance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of image classification, and in particular relates to a small sample fine-grained image classification method and system. Background Art

[0002] The study of fine-grained image classification based on few-shot learning is a challenging research direction in the field of computer vision. It aims to achieve accurate classification and recognition of fine-grained images with limited sample data. In order to reduce the burden of manual annotation caused by traditional fine-grained image classification methods and improve the generalization ability of algorithms, researchers have begun to explore methods based on weakly supervised learning, using only image-level labels to train models. Although this method reduces the annotation cost, it is still limited by the dependence of traditional deep learning methods on a large number of training samples. In many cases, due to the cost constraints and scarcity of original samples, it is impossible to obtain sufficient training data, which makes it difficult for the model to learn more discriminative features from limited samples. In response to these challenges, fine-grained image classification based on few-shot learning has become a research hotspot. It requires the algorithm to be able to identify multiple subclass objects under the same superclass with only a very small amount of labeled data. This task requires the algorithm to not only locate key local areas and extract discriminative features, but also avoid overfitting problems caused by very little data. Because it combines the difficulties of few-shot learning and fine-grained recognition, research in this field is highly challenging and has practical application value.

[0003] The challenge of small sample fine-grained image classification is not limited to the similarity between classes, but the diversity within classes also constitutes an important problem. Figure 4 As shown in the figure, the main difference between the Crested Auklet and the Grooved Rhinoceros Cuckoo is reflected in the subtle features of the beak shape and eye color, while the difference between (e) and (f) is much smaller than the difference between (e) and (a)-(d). Since the (a)-(d) images are quite different due to different flight states and shooting angles, it is easier for the model to classify (e) and (f) as the same class, and (e) and (a)-(d) as different classes. This is the dual challenge of large intra-class variance and small inter-class variance faced by the small sample fine-grained image classification task. This shows that although the current research can increase the inter-class difference, it performs poorly in reducing the intra-class difference, and thus cannot solve the small sample fine-grained image classification task well. To this end, we propose a small sample fine-grained image classification method and system. Summary of the invention

[0004] The purpose of the present invention is to provide a small sample fine-grained image classification method and system, aiming to solve the problems raised in the above background technology.

[0005] To achieve the above object, the present invention provides the following technical solutions:

[0006] A small sample fine-grained image classification method includes the following steps:

[0007] Step 1: Extract features from support images and query images;

[0008] Step 2: Use the self-attention mechanism to reconstruct features.

[0009] Step 3: Reconstruct the query feature using the support feature, and reconstruct the support feature using the query feature;

[0010] Step 4: Calculate the distance between the query sample and the support sample to evaluate the similarity between the query sample and the support sample.

[0011] A small sample fine-grained image classification system, comprising:

[0012] A feature extractor, used to extract features from support images and query images;

[0013] Feature enhancement module, which is used to reconstruct features using the self-attention mechanism;

[0014] The inter-class and intra-class dual perception module is used to reconstruct the query features using the support features and to reconstruct the support features using the query features;

[0015] The metric module is used to calculate the distance between the query sample and the support sample to evaluate the similarity between the query sample and the support sample.

[0016] Furthermore, the specific operation of the step of extracting features from the support image and the query image is:

[0017] For the c-way k-shot classification task with small samples, a feature extractor is used to classify C×K+M samples. x i Perform feature extraction and obtain The feature representation of h , w , d Represent the height, width and number of channels of the feature respectively; Reorganize into r Local feature sequences at spatial locations ,in r = h × w ; The local feature sequence and the corresponding spatial position embedded Combined, that is , z i As the input of the feature enhancement module.

[0018] Furthermore, the output of the feature enhancement module is calculated through a self-attention mechanism, and the specific calculation process is as follows:

[0019] ;

[0020] ;

[0021] ;

[0022] in, Q , K , V Represents query, key, and value respectively; represents the transpose of a key; d k Represents the dimension of the key; Represents a set of dimensions d × d The learnable weight parameters of LN and MLP Continuous operation calculation ,in , As the output of the feature enhancement module.

[0023] Furthermore, after being processed by the feature enhancement module, the enhanced support features of the cth category are obtained, which is expressed as ,in, , ; At the same time, the enhanced query features are obtained, expressed as ,in, ; Using weight parameters Reconstruct the enhanced support features and query features of each category; the specific operations include:

[0024] Will S c Respectively with the weight matrix Multiply them together and you get ,Will Q i Respectively with the weight matrix Multiply them together and you get ,in, The dimension is d × d ; Using the obtained Calculate the support features from the cth class The i-th query feature reconstructed in , and the query features from the i-th category The supporting features of the cth category reconstructed in ; The calculation formula is as follows:

[0025] ;

[0026] .

[0027] Furthermore, the specific operation of the step of calculating the distance between the query sample and the support sample to evaluate the similarity between the query sample and the support sample is:

[0028] Use Euclidean metric to calculate query samples Q i With supporting samples in category c S c The distance between , and supporting samples in category c S c With query sample Q i The distance between ; Perform weighted summation of the two distances to obtain the total distance , the calculation formula is as follows:

[0029] ;

[0030] ;

[0031] ;

[0032] in, is a learnable weight parameter, initialized to 0.5[49, 50]; is the learnable temperature factor; Normalize it and get ;based on , calculate the loss function of the classification task, the specific formula is as follows:

[0033] ;

[0034] ;

[0035] in, l ( y i == c ) is an indicator function, when y i and c The indicator function evaluates to 1 when they are equal, and 0 otherwise.

[0036] Compared with the prior art, the present invention has the following beneficial effects:

[0037] The present invention has significantly improved the existing technology on the Stanford Dogs, Stanford Cars and CUB-200-2011 datasets, and surpassed the most advanced FRN method by 16.3% accuracy on the Stanford Dogs dataset. The ablation experiment also confirmed the complementarity of the feature enhancement module and the inter-class and intra-class perception modules and the effectiveness of the bidirectional reconstruction strategy. The present invention has practical significance when applied to small sample fine-grained image classification tasks, and reduces the intra-class variance while increasing the inter-class variance. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 The present invention is a process of the method.

[0039] Figure 2 It is a framework diagram of the system of the present invention.

[0040] Figure 3 It is a structural diagram of the feature enhancement module in the present invention.

[0041] Figure 4 The following are examples from the background art. (a)-(e) are all from the Crested Auklet in the CUB-200-2011 dataset; (f) belongs to another category, the Grooved Rhinoceros Cuckoo. DETAILED DESCRIPTION

[0042] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0043] The specific implementation of the present invention is described in detail below in conjunction with specific embodiments.

[0044] like Figure 1 As shown, a small sample fine-grained image classification method provided by an embodiment of the present invention includes the following steps:

[0045] Step 1: Extract features from support images and query images;

[0046] Step 2: Use the self-attention mechanism to reconstruct features.

[0047] Step 3: Reconstruct the query feature using the support feature, and reconstruct the support feature using the query feature;

[0048] Step 4: Calculate the distance between the query sample and the support sample to evaluate the similarity between the query sample and the support sample.

[0049] like Figure 2As shown, an inter-class and intra-class dual perception model provided by an embodiment of the present invention includes:

[0050] A feature extractor, used to extract features from support images and query images;

[0051] Feature Enhancement (FEM) module, which is used to self-reconstruct features using the self-attention mechanism;

[0052] The inter-class and intra-class dual perception module is used to reconstruct the query features using the support features and to reconstruct the support features using the query features;

[0053] The metric module is used to calculate the distance between the query sample and the support sample to evaluate the similarity between the query sample and the support sample.

[0054] In an embodiment of the present invention, in the first stage of the model, a powerful feature extractor is used to extract features from the support image and the query image. The feature extractor can be selected in a variety of forms, such as the traditional convolutional neural network Conv4 or the more advanced residual network Resnet12, to ensure that high-quality feature information is extracted. Then, the extracted features are sent to the feature enhancement module. This module uses the self-attention mechanism to self-reconstruct the features, aiming to highlight the subtle and unique features in each image category and effectively reduce the interference of irrelevant features. This process is crucial for more accurately capturing and expressing the subtle differences between images, thereby significantly improving the classification performance of the model. Further, the enhanced features are input into the dual perception module between classes and within classes. The design concept of this module is to use the support features to reconstruct the query features, and also use the query features to reconstruct the support features. Through this two-way reconstruction strategy, not only the differences between the features between classes are improved, but also the differences within the classes are reduced, effectively coping with the challenges faced in the fine-grained image classification task.

[0055] As a preferred embodiment of the present invention, the architecture of the constructed feature enhancement module is as follows: Figure 3 As shown in the figure, for the c-way k-shot classification task with small samples, a feature extractor is used to classify C×K+M samples. x i Perform feature extraction and obtain The feature representation of h , w , d Represent the height, width and number of channels of the feature respectively; these features Reorganize into r Local feature sequences at spatial locations ,in r = h × w; In the next step, the local feature sequence and the corresponding spatial position embedded Combined, that is , z i As the input of the feature enhancement module, Epos adopts the sinusoidal position encoding method.

[0056] like Figure 1 As shown, as a preferred embodiment of the present invention, the output of the FEM module is calculated by a self-attention mechanism, and the specific calculation process is as follows:

[0057] ;

[0058] ;

[0059] ;

[0060] in, Q , K , V Represents query, key, and value respectively; represents the transpose of a key; d k Represents the dimension of the key; Represents a set of dimensions d × d The learnable weight parameters of ; Next, through layer normalization ( LN ) and Multilayer Perceptron ( MLP ) continuous operation calculation ,in , As the output of the feature enhancement module.

[0061] As a preferred embodiment of the present invention, the inter-class and intra-class dual perception module includes two key steps. First, the query features are reconstructed based on the supporting features to address the inter-class similarity challenge in the small sample classification task of histology images. Second, the supporting features of a class are reconstructed based on the query features to address the intra-class diversity challenge in the small sample classification task of histology images.

[0062] After being processed by the feature enhancement module, the enhanced support features of the cth category are obtained, which is expressed as ,in, , ; At the same time, the enhanced query features are obtained, expressed as ,in, Next, use the weight parameter Reconstruct the enhanced support features and query features of each category; the specific operations include:

[0063] Will S c Respectively with the weight matrix Multiply them together and you get ,Will Q i Respectively with the weight matrix Multiply them together and you get ,in, The dimension is d × d ; Finally, using the obtained Calculate the support features from the cth class The i-th query feature reconstructed in , and the query features from the i-th category The supporting features of the cth category reconstructed in ; The calculation formula is as follows:

[0064] ;

[0065] .

[0066] As a preferred embodiment of the present invention, after being processed by the inter-class and intra-class dual perception modules, the Euclidean metric is used to calculate the query sample Q i With supporting samples in category c S c The distance between , and supporting samples in category c S c With query sample Q i The distance between ; Take the weighted sum of these two distances to get the total distance , the calculation formula is as follows:

[0067] ;

[0068] ;

[0069] ;

[0070] in, is a learnable weight parameter, initialized to 0.5[49, 50]; is the learnable temperature factor; Normalize it and get ;based on , calculate the loss function of the classification task, the specific formula is as follows:

[0071] ;

[0072] ;

[0073] in, l ( y i == c ) is an indicator function, when y i and c The indicator function evaluates to 1 when they are equal, and 0 otherwise.

[0074] Example 1, comparative experimental analysis;

[0075] The small sample classification accuracy of the model established by the present invention is compared with other classic network structures to verify the effectiveness of the model. Tables 1 and 2 show the average accuracy of the inter-class and intra-class dual perception algorithm model and other classic network structures in 5-way 1-shot and 5-way 5-shot experiments under the 95% confidence interval with different feature extractors on the Stanford Dogs, Stanford Cars and CUB-200-2011 datasets. In this experiment, the MAML method based on optimization, the ProtoNet method and the MatchingNet method based on global feature metrics, the DN4 method and the DeepEMD method based on local feature metrics, and the FRN method based on unidirectional feature reconstruction were used as comparisons, and the results of these models were obtained through publicly available codes.

[0076] Table 1 Comparison of the accuracy of different models using Conv4 on three datasets

[0077]

[0078] Table 1 shows the experimental results of the inter-class and intra-class dual perception model and other classic models using Conv4 as feature extractor on three datasets. The experimental results on the CUB-200-2011 dataset show that the proposed model achieves accuracies of 76.77% and 91.68% respectively in the 5-way 1-shot and 5-way 5-shot experimental settings, which are 6.54% and 3.46% higher than the best performance of other classic models, and 4.6% and 2.78% higher than the category-aware feature alignment network. The experimental results on the Stanford Cars dataset show that the proposed model achieves accuracies of 74.42% and 92.50% respectively in the 5-way 1-shot and 5-way 5-shot experimental settings, which are 12.79% and 13.96% higher than the best performance of other classic models, and 9.82% and 5.21% higher than the category-aware feature alignment network. Experimental results on the Stanford Dogs dataset show that the accuracy of the inter-class and intra-class dual perception model reaches 63.93% and 82.02% respectively in the 5-way 1-shot and 5-way 5-shot experimental settings. The proposed model is 16.3% and 4.35% higher than the best performance of other models, and 4.19% and 2.45% higher than the category-aware feature alignment network. The inter-class and intra-class dual perception model with Conv4 as the feature extractor has been greatly improved in all three datasets, and even improved by more than 10% in some experimental settings. It has also been greatly improved compared to the category-aware feature alignment network, which indirectly confirms the effectiveness of the design of the inter-class and intra-class dual perception model.

[0079] Table 2 Comparison of the accuracy of different models using Resnet12 on three datasets

[0080]

[0081] Table 2 shows the experimental results of the inter-class and intra-class dual perception model and other classic network models using Resnet12 as feature extractor on three datasets. The experimental results on the CUB-200-2011 dataset show that the proposed model achieves 85.38% and 94.68% accuracy respectively in the 5-way 1-shot and 5-way 5-shot experimental settings, which are 1.43% and 1.22% higher than the best performance of other classic models, and 0.16% and 0.31% higher than the category-aware feature alignment network. The experimental results on the Stanford Cars dataset show that the proposed model achieves 90.36% and 97.78% accuracy respectively in the 5-way 1-shot and 5-way 5-shot experimental settings, which are 4.66% and 1.09% higher than the best performance of other classic models, and 2.3% and 0.02% higher than the category-aware feature alignment network. Experimental results on the Stanford Dogs dataset show that the accuracy of the inter-class and intra-class dual perception model reaches 77.13% and 90.44% in the 5-way 1-shot and 5-way 5-shot experimental settings, respectively, but does not reach the highest accuracy in the 5-way 1-shot experimental setting.

[0082] From the results in Table 1 and Table 2, it is found that the proposed model has a significant improvement on the Conv4 feature extractor, but has limited improvement on Resnet12. This may be because Conv4, as an extractor with limited feature extraction capabilities, leads to poor results for all models, but the inter-class and intra-class dual perception model makes up for the defects of the feature extractor through excellent network design. Resnet12, as an extractor with relatively excellent feature extraction capabilities, can achieve good results on the three data sets with excellent network design, and can achieve an accuracy of about 90%, so there is limited room for improvement. Although the improvement on Resnet12 is limited, the proposed model is still the best model, so the proposed network structure is more suitable for small sample classification tasks of fine-grained images, and can improve the accuracy of this task. It further illustrates the importance of increasing the variance between classes while reducing the intra-class differences. Bidirectional reconstruction through feature enhancement and reconstruction of query feature maps based on support feature maps and reconstruction of support feature maps based on query feature maps is a very effective method.

[0083] In order to more comprehensively demonstrate the effect of the proposed model, Tables 3 and 4 show the accuracy, precision, recall, F1-Score and Kappa Coefficient of the inter-class and intra-class dual perception models using Conv4 and Resnet12 in 5-way 1-shot, 5-way 5-shot, 5-way 10-shot and 5-way 20-shot, respectively.

[0084] Table 3 Results of the inter-class and intra-class dual perception model using Conv4 on three datasets

[0085]

[0086] Table 3 shows all the metric results of the inter-class and intra-class dual perception model using Conv4 as the feature extractor on the three datasets. It can be seen from Table 3 that as the number of supporting images of each class in the test set increases, the metric effects are getting better and better. In the 5-way 5-shot experimental setting of the CUB-200-2011 dataset, the Kappa coefficient and F1 score can reach more than 90%, and in the 5-way 5-shot experimental setting of the Stanford Cars dataset, the Kappa coefficient and F1 score also reach more than 90%. In the 5-way 20-shot experimental setting, all metric indicators reach the highest among the three datasets. However, in the 5-way 20-shot experimental setting, the Kappa coefficient and F1 score of the Stanford Dogs dataset do not reach 90%. Compared with the category-aware feature alignment network, the proposed model is greatly improved under the Conv4 feature extractor, and all metric indicators reach more than 90% in the 5-way 5-shot experimental setting. Although the Stanford Dogs dataset cannot achieve this effect, it has also been greatly improved.

[0087] Table 4 Results of the inter-class and intra-class dual perception model using Resnet on three datasets

[0088]

[0089] Table 4 shows all the metric results of the inter-class and intra-class dual perception model using Resnet12 as the feature extractor on the three datasets. It can be seen from Table 4 that after using Resnet12 as the feature extractor, the proposed network model has achieved good results in the 5-way 1-shot experimental setting of the three datasets. In the 5-way 1-shot experimental setting of the CUB-200-2011 dataset, the Kappa coefficient and F1 score reached 81.7% and 84.7%, and in the 5-way 1-shot experimental setting of the Stanford Cars dataset, the Kappa coefficient and F1 score reached 88.0% and 89.9%. In the 5-way 1-shot experimental setting of the Stanford Dogs dataset, the Kappa coefficient and F1 score reached 71.4% and 76.2%. The proposed model shows unexpected performance under the very difficult experimental conditions of 5-way 1-shot.

[0090] Example 2, ablation experiment analysis;

[0091] The inter-class and intra-class dual perception algorithm model proposed in the present invention is mainly composed of a feature enhancement module (FEM) and an inter-class and intra-class dual perception module (CDWM), wherein the model proposes a bidirectional reconstruction method to increase the difference between classes while reducing the difference within classes. In order to further verify the efficiency and accuracy of the method and module design, an ablation study was conducted using the CUB-200-2011 dataset, the Stanford Cars dataset, and the Stanford Dogs dataset.

[0092] First, in order to verify the effectiveness of the feature enhancement module and the inter-class and intra-class dual perception module, the feature enhancement module and the inter-class and intra-class dual perception module are removed by stripping for experimental comparison. This method removes the feature enhancement module and the inter-class and intra-class dual perception module in three datasets and conducts experimental comparisons in four scenarios: 5-way 1-shot, 5-way5-shot with Conv4 as the feature extractor and 5-way 1-shot, 5-way 5-shot with Resnet12 as the feature extractor. Among them, ProtoNet is selected as the baseline model. FEM represents only the feature enhancement module, excluding the inter-class and intra-class dual perception module. CDWM represents only the inter-class and intra-class dual perception module, excluding the feature enhancement module. Ours represents the inter-class and intra-class dual perception network model, which includes the feature enhancement module and the inter-class and intra-class dual perception module. Table 5 shows the ablation experiment results with Conv4 as the feature extractor, and Table 6 shows the ablation experiment results with Resnet12 as the feature extractor.

[0093] Table 5 Module ablation experiments on three datasets using Conv4’s inter-class and intra-class dual perception network

[0094]

[0095] Table 6 Module ablation experiments on three datasets using Resnet12 inter-class and intra-class dual perception network

[0096]

[0097] The corresponding results are presented in Tables 5 and 6, from which it can be clearly seen that each module has a positive impact on the performance compared with the baseline model. In the 5-way 1-shot experimental setting with Conv4 as the feature extractor on the Stanford Cars dataset, the independent use of the feature enhancement module and the inter-class and intra-class dual perception module improves the performance by 21.1% and 17.75% respectively compared with the baseline model. Both modules have significant improvements over the baseline model on other datasets. The main goal of the feature enhancement module is to discover the discriminative fine-grained features of each sample, which helps the inter-class and intra-class dual perception modules to better reconstruct the query features and support features to achieve the goal of increasing the inter-class variance and reducing the intra-class variance. This shows that the two modules play a positive role in both the microscopic features and the discriminative features of the fine-grained images. It proves the importance of each module. It is worth noting that when the feature enhancement module and the inter-class and intra-class dual perception modules are used simultaneously, the performance of the proposed method is further improved. Therefore, it can be concluded that these two modules are indispensable and complementary to each other in performing the small sample fine-grained image classification task.

[0098] Secondly, in order to verify the effectiveness of the bidirectional reconstruction method, an experimental comparison is conducted by unidirectional reconstruction of the query set with only the support set and unidirectional reconstruction of the support set with only the query set. The baseline model is ProtoNet. In the inter-class and intra-class dual perception module, the reconstruction based on the query sample to the support sample is removed, marked as Q->S, and the reconstruction based on the support sample to the query sample is removed, marked as S->Q. Ours represents bidirectional reconstruction, including reconstruction based on the support sample to the query sample and reconstruction based on the query sample to the support sample. Table 7 shows the ablation experiment results using Conv4 as the feature extractor, and Table 8 shows the ablation experiment results using Resnet12 as the feature extractor.

[0099] Table 7 Reconstruction ablation experiments of inter-class and intra-class dual perception networks using Conv4 on three datasets

[0100]

[0101] Table 8 Reconstruction ablation experiments on three datasets using Resnet12 inter-class and intra-class dual perception network

[0102]

[0103] As shown in Tables 7 and 8, both the unidirectional and bidirectional reconstruction methods significantly outperform the baseline model, which demonstrates the effectiveness of the reconstruction. However, outside the 5-way 1-shot task with Conv4 as the feature extractor, it is observed that the performance of both unidirectional reconstruction methods is lower than that of the bidirectional reconstruction method. Reconstructing the query features by the support features can increase the inter-class variance and solve the problem of inter-class similarity. In the 5-way 1-shot experiment, the reason why the Q->S method performs better is that each class contains only one sample, so there is no challenge of intra-class diversity. Therefore, solving only the challenge of inter-class similarity is the most efficient for this situation. When the impact of intra-class diversity is not considered (under the 1-shot experimental setting), it can be found that removing the operation of query sample reconstruction on support sample, that is, Q->S performs best. This finding further confirms that reconstructing the query features by the support features can increase the inter-class variance and solve the problem of inter-class similarity. This conclusion is also supported by multiple studies. On the other hand, the problem of large intra-class variance is solved by reconstructing the support samples by the query samples. The results of ablation experiments show that the reconstruction of support samples by query samples only, i.e. S->Q, has a significant improvement over the baseline model, especially when the number of samples in each category increases. The performance improvement is more obvious compared to Q->S, and even exceeds Q->S in the 5-shot experimental setting. This result further confirms that the reconstruction of query features by support features can reduce intra-class variance and solve the problem of intra-class diversity. Although the two unidirectional reconstruction methods S->Q and Q->S have significant improvements over the baseline model and show excellent performance in different experimental settings, almost all experimental results show that the performance of bidirectional reconstruction is better than that of unidirectional reconstruction. Therefore, the proposed design choice of using the bidirectional reconstruction method is reasonable and effective.

[0104] The above are only preferred embodiments of the present invention. It should be pointed out that, for those skilled in the art, several modifications and improvements can be made without departing from the concept of the present invention. These should also be regarded as the protection scope of the present invention. These will not affect the effect of the implementation of the present invention and the practicality of the patent.

Claims

1. A small sample fine-grained image classification system, characterized in that: include: A feature extractor, used to extract features from support images and query images; Feature enhancement module, which is used to reconstruct features using the self-attention mechanism; The inter-class and intra-class dual perception module is used to reconstruct the query features using the support features and to reconstruct the support features using the query features; The measurement module is used to calculate the distance between the query sample and the support sample to evaluate the similarity between the query sample and the support sample; The output of the feature enhancement module is calculated through the self-attention mechanism. The specific calculation process is as follows: Where Q, E, and V represent query, key, and value respectively; E T represents the transposition of the key; d E Represents the dimension of the key; Represents a set of learnable weight parameters of dimension d×d; calculated through the continuous operation of LN and MLP in As the output of the feature enhancement module; z i Represents the input of the feature enhancement module; After being processed by the feature enhancement module, the enhanced support features of the cth category are obtained, which is expressed as Among them, k∈[1,…,K], c∈[1,…,C]; at the same time, the enhanced query features are obtained, expressed as Among them, i∈[1,…,M]; using the weight parameter W γ Q ,W γ E ,W γ V Reconstruct the enhanced support features and query features of each category; the specific operations include: S c Respectively with the weight matrix W γ Q ,W γ E ,W V γ Multiply them and get S c Q ,S c E ,S c V , Q i Respectively with the weight matrix W γ Q ,W γ E ,W γ V Multiply them and we get Q i Q ,Q i E ,Q i V , where W γ Q ,W γ E ,W γ V The dimension is d×d; using the obtained S c Q ,S c E ,S c V ,Q i Q ,Q i E ,Q i V Calculate the support feature S from the cth class c V The i-th query feature reconstructed in And the query feature Q from the i-th category i V The supporting features of the cth category reconstructed in The calculation formula is as follows: The specific operation of the step of calculating the distance between the query sample and the support sample to evaluate the similarity between the query sample and the support sample is: Use Euclidean metric to calculate the query sample Q i and the supporting sample S in class c c The distance between And the supporting sample S in class c c With query sample Q i The distance between The weighted sum of the two distances is obtained to get the total distance d i c , the calculation formula is as follows: Among them, λ is the learnable weight parameter, which is initialized to 0.5[49,50]; τ is the learnable temperature factor; i c Normalize it and get based on Calculate the loss function of the classification task. The specific formula is as follows: Among them, l(y i ==c) is an indicator function, when y i The indicator function has the value 1 when it is equal to c, and 0 otherwise.

2. The small sample fine-grained image classification system according to claim 1, characterized in that: The specific operation of the step of extracting features from the support image and the query image is as follows: For the c-way k-shot classification task with small samples, a feature extractor is used to classify C×K+M samples x i Perform feature extraction and obtain The feature representation is: h, w, d represent the height, width and number of channels of the feature respectively; Reorganize into a local feature sequence with r spatial positions Where r = h × w; the local feature sequence and the E embedded in the corresponding spatial position pos ∈R r×d Combined, that is z i As the input of the feature enhancement module.

3. A method for using the small sample fine-grained image classification system as claimed in claim 1 or 2, characterized in that: The following steps are involved: Step 1: Extract features from support images and query images; Step 2: Use the self-attention mechanism to reconstruct features. Step 3: Reconstruct the query feature using the support feature, and reconstruct the support feature using the query feature; Step 4: Calculate the distance between the query sample and the support sample to evaluate the similarity between the query sample and the support sample.