A small sample target detection method and system
By improving the Faster-R-CNN model through hierarchical sampling, ternary classification, contrastive learning, and simplex isometric frame techniques, the problem of model overfitting in small sample target detection is solved, the robustness and new category recognition ability of the model are improved, and target detection that can quickly adapt to new tasks is achieved.
Patent Information
- Application Number
- CN202411347821.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2044-09-26
AI Technical Summary
Existing small-sample target detection technologies suffer from poor generalization ability due to model overfitting, which in turn reduces the model's prediction accuracy.
A hierarchical sampling method is adopted to enhance the model's ability to perceive targets at different scales. The recognition ability of new categories is enhanced through ternary classification and contrastive learning. The discriminative ability of the classifier is enhanced by using a simplex isogonal frame. The model is optimized by combining adaptive boundary distillation technology.
It improves the robustness of the model under class imbalance and uneven sample distribution, enhances detection accuracy, especially the ability to identify new classes in the case of small samples, reduces the risk of overfitting, and can quickly adapt to new tasks.
Smart Images

Figure CN119478339B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of target detection technology, and in particular to a method and system for small-sample target detection. Background Technology
[0002] Object detection, a core task in computer vision, aims to identify and locate objects of interest from images or videos. With the development of deep learning technology, especially the widespread application of convolutional neural networks, object detection technology has made significant progress. However, traditional object detection models typically require large amounts of labeled data for training, which is often costly and time-consuming in practical applications. This is especially true in industrial or medical environments, where such labeled data is even more difficult to collect.
[0003] To address this problem, researchers began exploring few-shot object detection techniques. The few-shot problem refers to the insufficient number of labeled samples for some classes in a dataset, making it impossible to build a large training set for supervised machine learning. Few-shot object detection techniques aim to train models using a small number of labeled samples, enabling them to detect and recognize objects of new categories. Research in this area mainly focuses on how to transfer knowledge learned from basic categories to new categories using techniques such as transfer learning and meta-learning.
[0004] Currently, few-shot learning techniques mainly focus on methods based on model fine-tuning, data augmentation, and transfer learning. Model fine-tuning involves pre-training a model on a large amount of data and then fine-tuning it on a small number of samples, but it may encounter overfitting problems. Data augmentation methods use auxiliary data or information to expand the target dataset, helping the model to extract features better. Transfer learning methods transfer learned knowledge to a new domain without requiring a strong correlation between the source and target domains; it can be further subdivided into metric learning, meta-learning, and graph neural network methods.
[0005] Domain transfer techniques in few-shot learning enhance the model's cross-domain capabilities by reducing the domain gap between visible and invisible classes. Meta-learning, particularly in few-shot object detection, trains the model by simulating a series of few-shot tasks, enabling it to quickly adapt to new tasks. Metric learning methods, through the idea of learning comparisons, map the target region features of the query image and the features of the support set images to the same embedding space, achieving detection. Data augmentation techniques improve sample diversity and feature robustness by enhancing both the sample space and feature space. Recently, the Transformer model has also begun to be applied to few-shot object detection, utilizing multi-head attention mechanisms to associate features of support and query images.
[0006] In addition to traditional transfer learning and meta-learning techniques, some emerging methods are also gaining attention. These methods attempt to address the challenges of few-shot learning from different perspectives. For example, they increase sample diversity by generating synthetic data through generative adversarial networks, or improve the model's ability to capture key information by utilizing attention mechanisms and feature fusion techniques. Furthermore, some studies focus on exploring the intrinsic relationships between categories, revealing connections between different categories by constructing category graphs, thereby helping the model better understand and generalize the features of new categories.
[0007] Furthermore, researchers are exploring how to leverage natural language processing techniques to enhance few-shot object detection. For example, by combining image descriptions and visual features, the model can gain a more comprehensive understanding of image content, enabling it to generalize more flexibly when faced with new categories. This approach not only improves the model's generalization ability but also reduces its reliance on large amounts of labeled data to some extent.
[0008] Furthermore, as research into the interpretability of deep learning models deepens, researchers are also attempting to improve the reliability and transparency of few-shot object detection by visualizing and explaining the model's decision-making process. This not only helps users better understand the model's behavior but also provides guidance for further model optimization.
[0009] These methods, by utilizing existing large amounts of data or unlabeled data, can alleviate the overfitting and data scarcity problems in few-shot learning to some extent. However, existing algorithms often suffer from overfitting when dealing with class imbalance and uneven sample distribution, leading to decreased generalization ability and severely reduced accuracy. Therefore, these methods do not fundamentally solve the core challenges of few-shot learning. Summary of the Invention
[0010] Therefore, the technical problem to be solved by the present invention is to overcome the problem that in the prior art, small sample learning still suffers from model overfitting, resulting in poor model generalization ability and thus reduced model prediction accuracy.
[0011] To address the aforementioned technical problems, this invention provides a small-sample target detection method, comprising:
[0012] Step S1: Obtain small sample images with multiple categories;
[0013] Step S2: Input the acquired small sample images into the improved Faster-R-CNN model, where,
[0014] The improved Faster-R-CNN model is obtained by improving the Faster-R-CNN model, and the improvement method includes:
[0015] The ability of the Faster-R-cnn model to perceive targets at different scales is enhanced by using a hierarchical sampling method;
[0016] Enhance the Faster-R-CNN model's ability to identify new categories in small sample images by using ternary classification and contrastive learning;
[0017] Enhance the Faster-R-CNN model's classifier's ability to distinguish between different classes in small sample images by using a simple isogonal frame;
[0018] Step S3: Detect different categories of targets in the image using the improved Faster-Rcnn model.
[0019] In one embodiment of the present invention, step S2 enhances the Faster-R-CNN model's ability to perceive targets at different scales through a hierarchical sampling method, the method comprising:
[0020] For the feature map extracted by the Faster-R-CNN model, an adaptive sampling method is used to dynamically adjust the number and position of sampling points according to the importance and distribution of the features. The formula is as follows:
[0021]
[0022] Where f is a function that dynamically adjusts the sampling points based on feature importance, I feature This is the original feature map, and ε is a scaling factor used to control the total number of sampling points; This is a coefficient that controls the influence of the gradient, used to adjust the effect of the gradient on the sampling density; grad(I feature ) is feature map I feature The gradient is used to represent the rate of change of features in the feature map;
[0023] The result of function f is normalized to ensure that the total number of sampling points does not exceed the preset maximum value N. max The normalization formula is:
[0024]
[0025] The `round` function is used to round to the nearest integer, and `max(f(I` is used to round to the nearest integer.) feature )) indicates that f is present in the entire feature map I feature The maximum value on the sampling point is used to normalize the output of f, ensuring that the sampling points do not exceed the preset maximum value N. max ;
[0026] A hierarchical sampling method is introduced into the Faster-R-CNN model: for targets smaller than a preset size, the model performs dense sampling on feature maps exceeding a preset resolution to capture detailed information; for targets larger than a preset size, the model performs sparse sampling on feature maps below a preset resolution to obtain overall structural information. This hierarchical sampling method is described by the resolution adjustment function R, with the following formula:
[0027]
[0028] Among them, S size The size of the target in the feature map is represented by c and d, which are the first and second adjustment parameters. c controls the cardinality, d controls the rate of exponential growth, and e is the base of the natural logarithm.
[0029] A multi-scale fusion mechanism is introduced into the Faster-R-CNN model to fuse feature maps of different resolutions to generate a comprehensive feature representation:
[0030] I combined =F fusion (I low-res ,I high-res =Upsample(I high-res )+Conv(I low-res )
[0031] Among them, F fusion It is a fusion function, where Upsample represents upsampling, Conv represents a single convolution operation, and I... low-res and I high-res I represents feature maps with resolutions below and above a preset resolution, respectively. combined It is a comprehensive feature representation after fusion.
[0032] In one embodiment of the present invention, step S2 enhances the Faster-R-CNN model's ability to identify new categories in small sample images through ternary classification and contrastive learning. The method includes:
[0033] When training the Faster-R-CNN model, a triplet classification loss and a contrastive loss are constructed, where,
[0034] The formula for the ternary classification loss is:
[0035]
[0036] Among them, L ternary It is a ternary classification loss, where N represents the total number of anchor points considered. It is the objectivity score of the i-th anchor point predicted by the model; It is the real object-oriented label of the i-th anchor point, when A value of 1 indicates that the foreground object is known. A value of 0 indicates the background; when... A value of 2 indicates a potential new category object; Represents the foreground loss function. Represents the background loss function. The loss function used to represent novel classes is usually the cross-entropy loss function;
[0037] The formula for the contrast loss is:
[0038]
[0039] Among them, L contrastive It is a comparative loss, N obj N is the number of proposals with the same object label. prop Represents the total number of all proposals; I is an indicator function, where I = 1 if the condition is true, and I = 0 otherwise; i It is the representation of the i-th feature proposal, obj gt,t It is the true object-oriented label of the i-th proposal; It is a standardized feature representation used to calculate the cosine distance;
[0040] The ternary classification loss and the contrastive loss are combined to obtain:
[0041] L total1 =L ternary +μL conirastive
[0042] Among them, L total1 It is a combination of the ternary classification loss and the contrastive learning loss, where μ is the weight parameter used to balance the two loss terms.
[0043] In one embodiment of the present invention, step S2, which enhances the classifier of the Faster-R-CNN model's ability to distinguish between different categories in small sample images using a simplex isoangular frame, includes the following method:
[0044] Before model training, a set of maximized and equivalently separable weight vectors is calculated. These weight vectors are used as fixed centers for all classes in small sample images.
[0045] The weight vector is calculated as follows: First, initialize the vector w1 as a unit vector e1; then continue constructing vectors for i = 2, ..., N. c Choose vector w i respectively with w1,…,w i-1 Orthogonal, and as far away as possible from existing vectors; then adjust the vectors, for each vector wi and w j If the included angle between them is not the largest Then by rotating w i To increase vector w i and w j The angle between them, while maintaining vector w i It is a unit vector; repeat the adjustment until the angles between all vectors are as close as possible.
[0046] To enhance intra-class compactness, an adaptive class-specific boundary is introduced, which is used to push feature vectors toward the corresponding class center w. i near;
[0047] The formula for calculating class-specific boundary offsets is:
[0048]
[0049] Where, m c It is the class-specific boundary offset of category c, p c p represents the instance frequency of category c, indicating the proportion of instances of category c in the total number of instances in the training data; bg This is the estimated probability of the background class, representing the proportion of the background or non-target class among all classes; c b It is a known set of foreground object categories, c n It is a new category set; background is the background.
[0050] Based on class-specific boundary offset m c The loss function for the simplex isometric frame is constructed as follows:
[0051]
[0052] Among them, L intra It is a simplex isogonal frame loss, y c It is an indicator function of the true label that sample x belongs to category c; v c This is the original predicted value of sample x belonging to category c; m c c is the class-specific boundary offset of class c; c' is any other class that is not class c; C is the total set of classes.
[0053] In one embodiment of the present invention, after adjusting vector w i and w j After the angle between them, it also includes further optimization of vector w. i and w j The simplex isoangular frame weight matrix W is obtained. * The optimized simplex isogonal frame weight matrix W* The weight parameters applied to the Faster-R-CNN model, where the simplex isoangular frame weight matrix W * The formula is:
[0054]
[0055] Among them, W * It is the simplex isogonal frame weight matrix, argmax is the maximum index function, W is the set of weights for the classifier, and N is the weight matrix. c It is the number of categories, w i and w j These represent the feature vectors of class i and class j, respectively, d(w i -w j ) 2 Represents vector w i and w j The square of the distance between them.
[0056] In one embodiment of the present invention, after enhancing the classifier of the Faster-R-CNN model with a simplex isoangular frame in step S2, the method further includes:
[0057] The class-specific boundary is further adjusted through a self-distillation mechanism to encourage feature points to be more closely distributed around the class center. In the self-distillation process, a teacher model is first used to generate soft labels, which reflect the model's prediction confidence for the input features. Then, a student model with the same architecture as the teacher model but different parameters is used to learn the soft labels. The goal of the student model is to adjust its own parameters by imitating the predictions of the teacher model, thereby achieving adaptive adjustment of the class-specific boundary.
[0058] Construct the adaptive boundary distillation objective loss function, the formula is as follows:
[0059]
[0060] Among them, L adapt It is an adaptive boundary distillation target loss. y is the predicted probability of teacher model category c. c Let y be a binary variable indicating whether the true label of sample x belongs to category c. If x truly belongs to category c, then y c =1, otherwise y c =0; This is the student model's predicted value for category c. It is the adaptive boundary offset of the student model learning in category c.
[0061] In one embodiment of the invention, a combined loss L based on ternary classification loss and contrastive learning loss is also included. total1Simplex equiangular frame loss L intra Adaptive boundary distillation target loss L adapt To construct the total loss function, the formula is:
[0062] L tota2 =α(L total1 )+β(L intra )+λ(L adapt )
[0063] Among them, L total1 It is a combination of ternary classification loss and contrastive learning loss; L intra It is a simple isoangular frame loss; L adapt It is the adaptive boundary distillation target loss; α, β, and λ are the weighting parameters used to balance the three losses;
[0064] Through the total loss function L total2 To train the Faster-Rcnn model.
[0065] To address the aforementioned technical problems, this invention provides a small-sample target detection system, comprising:
[0066] Acquisition module: used to acquire small sample images with multiple categories;
[0067] Input module: Used to input the acquired small sample images into the improved Faster-R-CNN model, where,
[0068] The improved Faster-R-CNN model is obtained by improving the Faster-R-CNN model, and the improvement method includes:
[0069] The ability of the Faster-R-cnn model to perceive targets at different scales is enhanced by using a hierarchical sampling method;
[0070] Enhance the Faster-R-CNN model's ability to identify new categories in small sample images by using ternary classification and contrastive learning;
[0071] Enhance the Faster-R-CNN model's classifier's ability to distinguish between different classes in small sample images by using a simple isogonal frame;
[0072] Detection module: used to detect different categories of targets in an image using the improved Faster-R-cnn model.
[0073] To address the aforementioned technical problems, the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the aforementioned small sample target detection method.
[0074] To address the aforementioned technical problems, the present invention provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the aforementioned small sample target detection method.
[0075] The technical solution of the present invention has the following advantages compared with the prior art:
[0076] This invention employs a hierarchical sampling method to enhance the model's ability to perceive targets of different sizes; it uses contrastive learning techniques, combined with ternary classification, to further improve the model's ability to identify new categories; and it utilizes a simplex isometric frame for geometric perception and designs a model classifier to make the model's discrimination effect between different categories more significant.
[0077] The improved Faster-R-CNN model of this invention exhibits stronger robustness in the face of class imbalance or uneven sample distribution, reducing the risk of overfitting; it not only improves detection accuracy, but also enhances the ability to identify new classes in the case of small samples.
[0078] This invention also enables the model to quickly adjust and adapt to new tasks after receiving a small number of samples of a new category through transfer learning technology, significantly reducing the time and resources required to retrain the model. Attached Figure Description
[0079] To make the content of this invention easier to understand, the invention will be further described in detail below with reference to specific embodiments and accompanying drawings.
[0080] Figure 1 This is a flowchart of the method of the present invention. Detailed Implementation
[0081] The present invention will be further described below with reference to the accompanying drawings and specific embodiments, so that those skilled in the art can better understand and implement the present invention. However, the embodiments described are not intended to limit the present invention.
[0082] Example 1
[0083] Reference Figure 1 As shown, this invention relates to a small-sample target detection method, comprising:
[0084] Step S1: Obtain small sample images with multiple categories;
[0085] Step S2: Input the acquired small sample images into the improved Faster-R-CNN model, where,
[0086] The improved Faster-R-CNN model is obtained by improving the Faster-R-CNN model, and the improvement method includes:
[0087] The ability of the Faster-R-cnn model to perceive targets at different scales is enhanced by using a hierarchical sampling method;
[0088] Enhance the Faster-R-CNN model's ability to identify new categories in small sample images by using ternary classification and contrastive learning;
[0089] Enhance the Faster-R-CNN model's classifier's ability to distinguish between different classes in small sample images by using a simple isogonal frame;
[0090] Step S3: Detect different categories of targets in the image using the improved Faster-Rcnn model.
[0091] The following is a detailed description of this embodiment:
[0092] Step 1: Read small sample data of multiple categories, including category information and the position information of geometric boxes; clean the image data with missing or incomplete information; then divide the cleaned image data into training and test sets; perform preprocessing operations on the divided training set images as input for the next stage of the network model.
[0093] Step 2: Employ a hierarchical sampling method to enhance the model's ability to perceive targets of different sizes;
[0094] Feature maps of the image are extracted using the feature extraction network (Conv layers) in the Faster-R-CNN model. Since this feature extraction network is existing technology, it will not be described in detail in this embodiment. For each feature map generated for an image, this embodiment employs an adaptive sampling method, dynamically adjusting the number and position of sampling points based on the importance and distribution of the features. The calculation formula is as follows:
[0095]
[0096] Where f is a function that dynamically adjusts the sampling points based on feature importance, I feature This is the original feature map, and ε is a scaling factor used to control the total number of sampling points; This is a coefficient that controls the influence of the gradient, used to adjust the effect of the gradient on the sampling density; grad(I feature ) is feature map I featureThe gradient of ε represents the rate of change of a feature in the feature map. The purpose of this formula is to increase the number of sampling points in regions with large gradients (i.e., significant feature changes) and decrease the number of sampling points in regions with small gradients (i.e., gradual feature changes). This is achieved by adjusting ε and ε... The value of can be used to control the sampling density and distribution in this embodiment.
[0097] Furthermore, to ensure that the number of sampling points is within an acceptable range, the result of f in this embodiment can be normalized to ensure that the total number of sampling points does not exceed a preset maximum value N. max Normalization can be achieved in the following ways:
[0098]
[0099] The `round` function is used to round to the nearest integer, and `max(f(I` is used to round to the nearest integer.) feature () represents the maximum value of f across the entire feature map, used to normalize the output of f, ensuring that the number of sampling points does not exceed the preset maximum value N. max .
[0100] To enable the model to focus more intently on regions crucial for target recognition while ignoring regions with lower information content, this embodiment employs a hierarchical sampling method. For small targets, the model performs dense sampling on higher-resolution feature maps to capture detailed information; while for large targets, it performs sparse sampling on lower-resolution feature maps to obtain overall structural information. This strategy not only improves the model's generalization ability but also reduces computational resource consumption. This strategy can be described by the resolution adjustment function R:
[0101]
[0102] Among them, S size The size of the target in the feature map is represented by c and d, which are adjustment parameters. c controls the cardinality, d controls the rate of exponential growth, and e is the base of the natural logarithm.
[0103] Finally, a multi-scale fusion mechanism is introduced to effectively integrate feature maps of different resolutions to generate a comprehensive feature representation. This fusion can be achieved through a fusion function F. fusion To achieve:
[0104] I combined =F fusion (I low-res ,I high-res =Upsample(I high-res )+Conv(I low-res )
[0105] Among them, F fusion It is a fusion function, where Upsample represents upsampling, Conv represents a single convolution operation, and I... low-res and I high-res Representing low-resolution and high-resolution feature maps respectively, I combined This is the fused, comprehensive feature representation. This fusion not only enhances the model's ability to perceive targets of different sizes but also improves its robustness in complex scenes. In this way, the model can more effectively handle targets of different sizes and complexities while optimizing the use of computational resources. It should be noted that I... combined This is equivalent to the feature maps extracted by the feature extraction network (Conv layers).
[0106] Hierarchical sampling replaces the original Feature Pyramid Pooling (FPN) in Faster R-CNN. The purpose of FPN is to enhance the model's ability to detect objects of different sizes with large amounts of image data, as its multi-scale feature representations are used to address this issue. In few-shot learning, the hierarchical sampling method can better dynamically adjust sampling points based on feature importance in limited data, thereby improving the model's ability to learn key features.
[0107] Step 3: Employ contrastive learning techniques and a ternary classification approach to further enhance the model's ability to identify new categories;
[0108] An innovative ternary classification mechanism is introduced to improve the Region Proposal Network (RPN) in Faster R-CNN for object detection. Building upon the traditional binary classification (foreground and background), this embodiment adds a third category during the fine-tuning phase to distinguish potential new categories of objects. This ternary classification mechanism enables the model in this embodiment not only to recognize known foreground and background but also to identify and utilize new categories of objects that are unlabeled or rare in the training data.
[0109] In the method of this embodiment, each proposal in the RPN layer is classified into one of the following three categories:
[0110] 1. The foreground object is known;
[0111] 2. Background;
[0112] 3. Potential new category objects (Novel);
[0113] For each proposal, this embodiment defines a ternary class partitioning loss, calculated as follows:
[0114]
[0115] Among them, L ternary It is a ternary classification loss, where N represents the total number of anchor points considered. It is the objectivity score of the i-th anchor point predicted by the model; It is the true object-like label of the i-th anchor point, which can be 1 (known foreground object), 0 (background object), or 2 (potential new category object); Represents the foreground loss function. Represents the background loss function. The loss function used to represent novel classes is usually the cross-entropy loss function;
[0116] Building upon the ternary classification, this embodiment employs contrastive learning to enhance the model's ability to distinguish features of new categories. Specifically, this embodiment designs a contrastive loss to encourage the model to narrow the distance with positive samples in the feature space while simultaneously widening the distance with negative samples. The inclusion of contrastive learning in the ternary classification not only helps the model distinguish between known foreground and background but also enhances the identification of potential new category objects.
[0117] The comparison loss function is calculated using the following formula:
[0118]
[0119] Among them, L contrastive It is a comparative loss, N obj N is the number of proposals with the same object label. prop Represents the total number of all proposals; I is an indicator function, where I = 1 if the condition is true, and I = 0 otherwise; i It is the representation of the i-th feature proposal, obj gt,t It is the true object label of the i-th proposal. It is a standardized feature representation used to calculate cosine distance.
[0120] This loss function encourages the model to bring together proposals with the same object label while pushing away proposals with different object labels. By minimizing this loss function, the feature representations learned by the model will be able to better distinguish between different object categories.
[0121] The comparison loss and the ternary classification loss are combined and calculated using the following formula:
[0122] L total1 =L ternary +μL contrastive
[0123] Among them, L total1 It is the total loss with two losses, L ternary It is a ternary classification loss, L contrastive It is the contrast loss, and μ is the weighting parameter used to balance the two loss terms.
[0124] Step 4: Use the simplex isoangular frame (ETF) for geometric perception and design a classifier for the Faster-R-CNN model to make the model more effective in distinguishing between different categories.
[0125] By initializing the weight vectors using a simplex isogonal frame, the minimum distance between class centers is maximized, thereby creating a clear boundary for each class in the feature space to enhance the classifier's ability to distinguish features from different classes.
[0126] Specifically, the simplex isoangular frame is a special set of vectors where all vectors are of equal length and the angles between each pair of vectors are also equal. Mathematically, this structure guarantees maximum equidistant separation between vectors. This embodiment utilizes the property of the simplex isoangular frame to provide a fixed and equidistant initialization method for the classifier's weight vectors. The core advantage of this method is that it ensures initial separation between class centers in the feature space, thus providing the model with a strong starting point, enabling it to learn and distinguish different classes more effectively.
[0127] Initial separation of class centers is crucial for improving classification performance. If class centers are too close together in the feature space, the model may face difficulties in differentiation during the early stages of training, leading to low learning efficiency. By utilizing the properties of the simplex isoangular frame, this embodiment can establish a clear and balanced geometry for the class centers before training begins, which helps the model converge faster and improves its final classification accuracy.
[0128] The initialization process can be directly calculated using mathematical formulas to obtain a set of maximized and equivalently separated weight vectors, which serve as fixed centers for all categories in small sample images.
[0129] The construction method for mathematical formula calculation is as follows: First, initialize vector w1 as a unit vector e1; then construct subsequent vectors for i = 2, ..., N. c Choose vector w i respectively with w1,...,w i-1 Orthogonal, and as far away as possible from existing vectors; then adjust the vectors, for each vector w i and w j If the included angle between them is not the largest Then by rotating w iTo increase this angle while maintaining vector w i It is a unit vector. This adjustment is repeated until all vectors satisfy the condition that the angles between them are as close as possible.
[0130] To enhance intra-class compactness, this embodiment introduces adaptive class-specific boundaries that push feature vectors toward their corresponding class centers w. i near.
[0131] The adaptive boundary offset is calculated using the following formula:
[0132]
[0133] Where, m c It is the class-specific boundary offset of category c, p c p represents the instance frequency of category c, indicating the proportion of instances of category c in the total number of instances in the training data; bg This is the estimated probability of the background class, representing the proportion of the background or non-target class among all classes; c b It is the set of basic classes (known foreground objects), c n It is a new category set, and background is the background.
[0134] Next, based on the adaptive boundary offset calculation, the loss function calculation for the simplex isometric frame is improved. The calculation formula is as follows:
[0135]
[0136] Among them, L intra It is a simplex isogonal frame loss, y c It is an indicator function of the true label that sample x belongs to category c; v c This is the original prediction that sample x belongs to category c; m c c is the class-specific boundary offset of class c, c' is any other class that is not class c; C is the total set of classes.
[0137] It is worth mentioning that after adjusting vector w i and w j After the angle between them, it also includes further optimization of vector w. i and w j The simplex isoangular frame weight matrix W is obtained. * The optimized simplex isogonal frame weight matrix W * The weight parameters applied to the Faster-R-CNN model, where the simplex isoangular frame weight matrix W * The formula is:
[0138]
[0139] Among them, W * It is the simplex isogonal frame weight matrix, argmax is the maximum index function, W is the set of weights for the classifier, and N is the weight matrix. c It is the number of categories, w i and w j These are the feature vectors representing the i-th and j-th classes, respectively, d(w i -w j ) 2 It represents the squared distance between two vectors.
[0140] After enhancing the Faster-R-CNN classifier using a simplex isoangular frame, the following steps are included: To further improve model performance, this embodiment further adjusts the class-specific boundaries using a self-distillation mechanism to encourage feature points to be more closely distributed around the class center. In the self-distillation process, this embodiment first uses a teacher model to generate soft labels that reflect the model's prediction confidence for the input features. Then, this embodiment uses a student model with the same architecture but different parameters to learn these soft labels. The goal of the student model is to adjust its parameters by mimicking the predictions of the teacher model, thereby achieving adaptive adjustment of the class-specific boundaries.
[0141] The adaptive boundary distillation objective loss function is calculated using the following formula:
[0142]
[0143] Among them, L adapt It is an adaptive boundary distillation target loss. It is the predicted probability of teacher model category c; y c y is a binary variable indicating whether the true label of sample x belongs to category c (if x truly belongs to category c, then y c =1; otherwise y c =0), It is the student model's predicted value for category c; It is the adaptive boundary offset for the student model learning for class c.
[0144] The total loss function L is constructed by combining the above three loss functions. total2 Through the total loss function L total2 To train the Faster-R-CNN model, the total loss function L total2 The calculation formula is:
[0145] L tota2 =α(L total1 )+β(L intra )+λ(Ladapt )
[0146] Among them, L total1 It is a combination of ternary classification loss and contrastive learning loss; L intra It is a simple isoangular frame loss; L adapt It is an adaptive boundary loss; where α, β, and λ are the weight parameters used to balance the three losses.
[0147] Step 5: Use transfer learning techniques to transfer the knowledge learned on the basic category to the new category, enabling the model to quickly adapt to new tasks and achieve effective object detection even with only a small amount of sample data.
[0148] The model in this embodiment is pre-trained on a large amount of basic data. Through the pre-training process, the model can learn rich feature representations and general pattern recognition capabilities.
[0149] Fine-tuning is performed on small sample data of the new category to adjust the parameters of the pre-trained model and adapt it to the new task. Feature alignment techniques are used to map the feature spaces of the base category to the feature spaces of the new category, reducing distributional differences between categories. This ensures the model maintains high performance on both old and new categories, especially on small sample data of the new category. Finally, the model outputs the category probability and bounding box coordinates for each candidate region, completing the small sample object detection task.
[0150] Example 2
[0151] This embodiment provides a small sample target detection system, including:
[0152] Acquisition module: used to acquire small sample images with multiple categories;
[0153] Input module: Used to input the acquired small sample images into the improved Faster-R-CNN model, where,
[0154] The improved Faster-R-CNN model is obtained by improving the Faster-R-CNN model, and the improvement method includes:
[0155] The ability of the Faster-R-cnn model to perceive targets at different scales is enhanced by using a hierarchical sampling method;
[0156] Enhance the Faster-R-CNN model's ability to identify new categories in small sample images by using ternary classification and contrastive learning;
[0157] Enhance the Faster-R-CNN model's classifier's ability to distinguish between different classes in small sample images by using a simple isogonal frame;
[0158] Detection module: used to detect different categories of targets in an image using the improved Faster-R-cnn model.
[0159] Example 3
[0160] This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the small sample target detection method described in Embodiment 1.
[0161] Example 4
[0162] This embodiment provides a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it implements the steps of the small sample target detection method described in Embodiment 1.
[0163] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code. The solutions in the embodiments of this application can be implemented in various computer languages, such as the object-oriented programming language Java and the interpreted scripting language JavaScript.
[0164] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0165] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1The function specified in one or more boxes.
[0166] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0167] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0168] Obviously, the above embodiments are merely illustrative examples for clear explanation and are not intended to limit the implementation. Those skilled in the art will recognize that other variations or modifications can be made based on the above description. It is neither necessary nor possible to exhaustively list all possible implementations here. However, obvious variations or modifications derived therefrom are still within the scope of protection of this invention.
Claims
1. A small sample target detection method, characterized in that: The application relates to a method for detecting different categories of targets in small sample images. Step S1: acquiring small sample images with multiple categories; Step S2: inputting the acquired small sample images into an improved Faster-Rcnn model, wherein, The improved Faster-Rcnn model is improved from a Faster-Rcnn model, and the improvement method comprises the following steps: The perception ability of the Faster-Rcnn model to targets of different scales is enhanced through a hierarchical sampling method, and the method comprises the following steps: For the feature map extracted by the Faster-Rcnn model, an adaptive sampling method is adopted, the number and position of the sampling points are dynamically adjusted according to the importance and distribution of the features, and the formula is as follows: where f is a function of dynamically adjusting sampling points according to feature importance, I feature is the original feature map, and ε is a scaling factor for controlling the total number of sampling points; is a coefficient for controlling the gradient influence, used to adjust the influence of the gradient on the sampling density; grad(I feature ) is the gradient of the feature map I feature , used to represent the rate of change of features in the feature map; The result of the function f is normalized to ensure that the total number of sampling points does not exceed a preset maximum value N max The normalization formula is: where the round function is used to round to the nearest integer, max(f(I feature )) denotes the maximum value of f over the entire feature map I feature , which is used to normalize the output of f, ensuring that the sampling points do not exceed a pre-set maximum value N max ; In the Faster-Rcnn model, a hierarchical sampling method is introduced: for a target lower than a preset size, the model performs dense sampling on a feature map higher than a preset resolution to capture detailed information; for a target higher than the preset size, the model performs sparse sampling on a feature map lower than the preset resolution to obtain overall structural information, and the hierarchical sampling method is described by a resolution adjustment function R, and the formula is as follows: where S size denotes the size of the object in the feature map, c and d are the first and second adjustment parameters, c controls the base, d is used to control the speed of the exponential growth, and e is the base of the natural logarithm; In the Faster-Rcnn model, a multi-scale fusion mechanism is introduced to fuse feature maps of different resolutions to generate comprehensive feature representation. I combined = F fusion (I low-res , I high-res ) = Upsample(I high-res ) + Conv(I low-res ) wherein F fusion is a fusion function, Upsample represents up-sampling, Conv represents a convolution operation, I low-res and I high-res represent feature maps lower than and higher than a preset resolution, respectively, and I combined is a comprehensive feature representation after fusion. The recognition ability of the Faster-Rcnn model to new categories in small sample images is enhanced through ternary category division and contrast learning; The discrimination ability of the classifier of the Faster-Rcnn model to different categories in small sample images is enhanced through a simplex isogonal frame. Step S3: detecting different categories of targets in images through the improved Faster-Rcnn model.
2. The small sample target detection method of claim 1, wherein: The recognition ability of the Faster-Rcnn model to new categories in small sample images is enhanced through ternary category division and contrast learning in the step S2, and the method comprises the following steps: When the Faster-Rcnn model is trained, ternary category division loss and contrast loss are constructed, wherein, The formula of the ternary category division loss is as follows: where L ternary is the ternary class division loss, N represents the total number of anchor points considered, is the objectness score of the i-th anchor point predicted by the model; is the true objectness label of the i-th anchor point, when is 1, it indicates a known foreground object, when is 0, it indicates background, when is 2, it indicates a potential new class object; represents the foreground loss function, represents the background loss function, represents the loss function of the new class, and cross-entropy loss function is usually used; The formula of the contrast loss is as follows: where L contrastive is the contrastive loss, N obj is the number of proposals with the same objectness label, N prop represents the total number of all proposals, I is an indicator function, I = 1 if the condition is true, otherwise I = 0; z i is the representation of the i-th feature proposal, obj gt,t is the true objectness label of the i-th proposal; is the normalized feature representation for computing cosine distance; The ternary category division loss and the contrast loss are combined to obtain: L total1 = L terntary + μL contrastive where L total1 is the combined loss of the ternary class division loss and the contrastive learning loss, and μ is a weight parameter used to balance the two loss terms.
3. The small sample target detection method of claim 2, wherein: The discrimination ability of the classifier of the Faster-Rcnn model to different categories in small sample images is enhanced through a simplex isogonal frame in the step S2, and the method comprises the following steps: Before the model is trained, a group of maximum and equivalent separation weight vectors are calculated, and the weight vectors are used as fixed centers of all categories in small sample images, wherein, The method for calculating the weight vector is: first set the initialization vector w1 as the unit vector e1; continue to construct the vector, for i = 2,...,N c , select the vector w i orthogonal to w1,...,w i-1 , and as far away from the existing vector as possible; then adjust the vector, for each vector w i and w j , if the included angle between them is not the maximum , increase the included angle between the vectors w i and w i by rotating w j , while keeping the vector w i a unit vector; repeat the adjustment until the included angles between all vectors are as close as possible In order to enhance the intra-class compactness, an adaptive class-specific boundary is introduced, which is used to push the feature vector close to the corresponding class center w i . A category-specific boundary offset is calculated, and the formula is as follows: wherein m c is a class-specific boundary offset of class c, p c is an instance frequency of class c, representing the proportion of the number of instances of class c to the total number of instances in the training data; p bg is an estimated probability of the background class, representing the proportion of the background class or non-target class in all classes; c b is a set of known foreground object classes, c n is a set of new classes; background is background; According to the class-specific boundary offset m c A simple type equiangular frame loss function is constructed, and the formula is: where L intra is the simple isometric frame loss, y c is an indicator function that the sample x belongs to class c; v c is the original prediction value that the sample x belongs to class c; m c is the class-specific boundary offset for class c; c' is other classes that are not class c; and C is the total set of classes.
4. The small sample target detection method of claim 3, wherein: Adjusting the included angle between the vectors w i and w j , the method further comprises continuing to optimize the vector w i and w j to obtain a simplex isometric frame weight matrix W * , and applying the optimized simplex isometric frame weight matrix W * to the weight parameters of the Faster-Rcnn model, wherein the formula of the simplex isometric frame weight matrix W * is: where W * is a simplex equiangular frame weight matrix, argmax is a maximum index function, W is a weight set of the classifier, N c is a class number, w i and w j are feature vectors representing the ith class and the jth class, respectively, and d(w i -w j ) 2 represents a squared distance between the vectors w i and w j .
5. The small sample target detection method of claim 3, wherein: After the classifier of the Faster-Rcnn model is enhanced through the simplex isogonal frame in the step S2, the following steps are further included. The class-specific boundary is adjusted again through a self-distillation mechanism to make the feature points more closely surround the class center; in the self-distillation process, first, a teacher model is used to generate a soft label, and the soft label is used to reflect the prediction confidence of the model for the input feature; then a student model is used, which has the same architecture as the teacher model but different parameters, to learn the soft label; the goal of the student model is to adjust its own parameters by imitating the prediction of the teacher model, so as to realize the self-adaptive adjustment of the class-specific boundary; An adaptive boundary distillation target loss function is constructed, and the formula is: where L adapt is the adaptive margin distillation target loss, is the predicted probability of the teacher model class c, y c is a binary variable that the sample x true label belongs to class c, if x true belongs to class c, then y c = 1, otherwise y c = 0; is the predicted value of the student model on class c, is the adaptive margin offset learned by the student model on class c.
6. The small sample target detection method of claim 5, wherein: The combined loss L according to the ternary category division loss and the contrast learning loss is also included total1 , the simple isometric frame loss L intra , the adaptive boundary distillation target loss L adapt , to construct a total loss function, and the formula is: L tota2 = a(L total1 ) + b(L intra ) + c(L adapt ) wherein, L total1 is the combined loss of the ternary class division loss and the contrastive learning loss; L intra is the simplex equiangular tight frame loss; L adapt is the adaptive boundary distillation target loss; and α, β, λ are weight parameters for balancing the three losses, respectively. The Faster-Rcnn model is trained by a total loss function L total2 7. A small sample target detection system for implementing the small sample target detection method according to any one of claims 1 to 6, characterized in that: It includes: An acquisition module is configured to acquire small sample images with multiple categories; An input module is configured to input the acquired small sample images into an improved Faster-Rcnn model, wherein The improved Faster-Rcnn model is improved from the Faster-Rcnn model, and the improvement method includes: Enhance the perception ability of the Faster-Rcnn model to targets of different scales through hierarchical sampling method; Enhance the recognition ability of the Faster-Rcnn model to new categories in small sample images through ternary category division and contrast learning; Enhance the discrimination ability of the classifier of the Faster-Rcnn model to different categories in small sample images through simplex isogonal frame; A detection module is configured to detect different categories of targets in images through the improved Faster-Rcnn model.
8. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that: The processor executes the computer program to realize the steps of the small sample target detection method in any one of claims 1 to 6.
9. A computer readable storage medium having stored thereon a computer program, characterized in that: The computer program is executed by the processor to realize the steps of the small sample target detection method in any one of claims 1 to 6.
Citation Information
Patent Citations
Small sample remote sensing image target detection method based on meta-learning and collaborative attention
CN112818903A
Multi-mode small target detection method based on knowledge distillation
CN113449680A