A small sample target detection method based on KL divergence loss and contrast loss

By introducing KL divergence loss and contrastive loss into a few-shot object detection network, and utilizing bias candidate region generation and re-detection modules for feature constraints and contrastive learning, the problems of low classifier performance and base class forgetting in few-shot object detection are solved, thereby improving detection accuracy.

CN122115835APending Publication Date: 2026-05-29SOUTHWEST JIAOTONG UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SOUTHWEST JIAOTONG UNIV
Filing Date
2026-03-11
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Few-sample object detection networks suffer from low classifier performance and the problem of forgetting base classes, leading to misclassification and decreased performance in object detection.

Method used

A few-sample object detection method based on KL divergence loss and contrastive loss is adopted. By constructing a base class and query image training set, the network classification performance is optimized by using a bias candidate region generation module and a re-detection module for feature constraint and contrastive learning.

Benefits of technology

It improves the base class target detection performance of the small sample target detection model, reduces misclassification and base class forgetting problems, and improves detection accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122115835A_ABST
    Figure CN122115835A_ABST
Patent Text Reader

Abstract

The present application relates to the field of image processing and artificial intelligence, and particularly relates to a small sample target detection method based on KL divergence loss and contrast loss, comprising the following steps: constructing a base class image training set containing a large number of samples, training a base class target detection model; constructing a query image training set; constructing a support image training set; combining the query and support image training sets into a training set, training a small sample target detection network; calculating a bias generation module binary classification regression loss and target positioning loss; calculating a re-detection module KL divergence loss, contrast learning loss, class regression loss and target regression loss; in the model training process, by adding the KL divergence loss, the base class target classifier result is constrained and optimized for the new class target classifier, the small sample target detection model base class target detection performance is improved; and through the contrast loss, the small sample target detection model classifier performance is optimized, and the small sample target detection model classification performance is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of image processing and artificial intelligence, and in particular to a small-sample target detection method based on KL divergence loss and contrast loss. Background Technology

[0002] Object detection is an important direction in computer vision perception tasks. It can provide basic information on the location and category of objects within an image, providing necessary perception information support for decision-making applications such as autonomous driving and intelligent security, and enhancing the target perception capabilities of autonomous driving and intelligent security systems.

[0003] In recent years, deep learning-based object detection algorithms have made great breakthroughs in the field of object detection. This method, which uses a large amount of data to drive the training of visual object detection models, avoids the problem of difficulty in manually designing effective features due to the influence of task, scene and target characteristics. It automatically extracts the features of the target through multi-layer deep neural networks and optimizes the model parameters by updating the weights through directional gradient propagation. It can better adapt to the scene, target and task, and has become the mainstream method for computer vision perception tasks.

[0004] In practical applications of deep learning-based object detection models, the difficulty in obtaining sample data for specific task scenarios and the often high cost of sample collection make training models with large amounts of data impractical. Few-shot object detection networks typically require only a small number of target samples to learn and achieve good performance. However, few-shot object detection networks generally face two problems: first, the network classifier's performance is low, leading to misclassification of objects; second, because few-shot object detection networks usually employ fine-tuning with relatively few samples, they exhibit base class forgetting characteristics, resulting in a decline in the detection performance of base class objects. Both of these problems limit the performance of few-shot object detection. Summary of the Invention

[0005] The purpose of this invention is to overcome the shortcomings of the prior art and provide a small sample target detection method based on KL divergence loss and contrast loss.

[0006] The objective of this invention is achieved through the following technical solution: A small-sample target detection method based on KL divergence loss and contrast loss includes the following steps: S1. Construct a base class image training set containing a large number of samples, and use the base class image training set to train the Faster-RCNN architecture object detection network to obtain the base class object detection model; The Faster-RCNN architecture for object detection includes a first basic feature extraction module, a first multi-resolution feature pyramid module (the first basic feature extraction module and the first multi-resolution feature pyramid module in this network architecture are the same as the basic feature extraction module and the multi-resolution feature pyramid module in the few-shot object detection network based on KL divergence loss and contrast loss), a binary classification regression module, a candidate region feature pooling module, a category regression module, and a bounding box regression module.

[0007] S2. Construct a query image training set, wherein the number of samples in each class of the query image training set is less than or equal to 30 and the number of samples in each class is equal; S3. Construct a support image training set, wherein the support image training set samples are from the base class image training set, and the number of samples of each class in the support image training set is equal to the number of samples of each class in the query image training set. S4. Combine the query image training set and the support image training set into a training set, and feed it into a few-shot object detection network based on KL divergence loss and contrastive loss for forward propagation. This few-shot object detection network includes a basic feature extraction module, a multi-resolution feature pyramid module, a bias candidate region generation module, and a re-detection module. The basic feature extraction module extracts high-dimensional features of the target, and the multi-resolution feature pyramid module outputs multi-scale resolution of the target. The bias candidate region generation module constrains the base class binary classification result for the new class binary classification result. The re-detection module implements comparative learning between the new class features and the base class features, and constrains the base class regression branch for the new class regression branch, avoiding the forgetting problem in few-shot base class learning.

[0008] In step S4, the bias candidate region generation module consists of a candidate region feature pooling module, a target localization branch, a base class binary classification regression branch, and a new class binary classification regression branch. The base class binary classification regression branch and the new class binary classification regression branch are fused by taking the result with the maximum score in the output results.

[0009] In step S4, the re-detection module consists of a base class target category regression branch, a base class target localization branch, a new class target regression branch, a new class target localization branch, and a contrastive learning branch. The base class target localization branch and the new class target regression branch are optimized using KL divergence to improve the network classification performance.

[0010] The contrastive learning branch uses supervised contrastive loss to optimize the object detection network classifier. This branch consists of a multilayer perceptual product encoding module and a supervised contrastive loss calculation module, which maps candidate region features onto a projected hypersphere to calculate the similarity between features.

[0011] S5. Calculate the binary regression loss and target localization loss of the bias candidate region generation module; The binary regression loss of the biased candidate region generation module in step S5 The calculation formula is:

[0012] in, For tags, Predict the probability that a candidate box is foreground. Valid sample size; Target location loss The calculation formula is:

[0013] in This is the predicted border offset. Actual offset; The number of positive samples To smooth the L1 norm loss, The formula is as follows:

[0014] in, .

[0015] S6. Calculate the KL divergence loss, contrastive learning loss, class regression loss, and target localization loss of the re-detection module; Step S6 includes the following sub-steps: S61. Calculate the KL divergence loss using the regression vectors of the base class and the new class. .

[0016] KL divergence loss of re-detection module The formula is:

[0017] in, The number of categories in the base class. , , To predict the confidence level for the new class of bounding boxes, To predict the confidence level of the base class bounding box, To predict the confidence level for a new class of bounding box, To predict the confidence level of a bounding box for a certain base class.

[0018] S62. Obtain the similarity matrix using contrastive learning of the encoded vectors. The formula for the similarity matrix is ​​as follows:

[0019] Where Z is the contrastive learning encoding vector matrix. For devices with a value of Z, the similarity matrix size is 512×512.

[0020] S63. Calculate the contrastive learning loss using the similarity matrix. .

[0021] Comparative learning loss of the re-detection module The formula is:

[0022]

[0023] in These are features output by the multilayer perceptron product coding module. Indicates the degree of overlap between the candidate bounding box and the label bounding box. This represents the category label of the bounding box, where N is the number of samples in the training batch. , This indicates the cosine similarity between the output features of the candidate region feature pooling module. This is the temperature coefficient. This indicates the actual category label of the annotation box, and exp(·) is an exponential function with base e.

[0024] S64. Obtain the classification loss using the regression vector of the new target category and the label category information. .

[0025] Class regression loss of the re-detection module The formula is:

[0026] Where B is the total number of candidate boxes involved in the calculation. Let be the probability that the j-th candidate box is predicted as the true class. For the first i The true category of each candidate box.

[0027] S65. Obtain the target localization loss using the new type of target localization vector and the label target bounding box information. .

[0028] Target localization loss of re-detection module The formula is:

[0029] in, This is the predicted border offset. The true offset, where M is the number of positive samples.

[0030] S7. Multiply the losses in S5 and S6 by the coefficients, sum them up and calculate the average, and then perform backpropagation to update the weights of the small sample target detection network based on KL divergence loss and contrast loss. In step S7, the total loss formula for small sample target detection based on KL divergence loss and contrast loss is as follows:

[0031] Among them, the bias candidate region generation module loss , The bias candidate region binary classification loss is used. The bias candidate region localization loss. For the re-detection module category regression loss, The loss was located by the re-detection module. To compare learning loss, This represents the KL divergence loss. , It is a decimal between (0,1).

[0032] S8. Input the test image containing the base class or the new class into the trained few-sample object detection network based on KL divergence loss and contrast loss to perform object detection, and output the detection box, class and confidence score.

[0033] The beneficial effects of this invention are: 1) In the model training process, this invention incorporates KL divergence loss to optimize the base class target classifier results for the new class target classifier, thereby improving the base class target detection performance of the small sample target detection model.

[0034] 2) This invention optimizes the classifier performance of the small sample target detection model by comparing loss, thereby improving the classification performance of the small sample target detection model. Attached Figure Description

[0035] Figure 1 This is a flowchart illustrating a specific implementation of the detection method described in this invention; Figure 2 This is a flowchart illustrating a specific implementation of the detection model described in this invention. Detailed Implementation

[0036] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0037] See Figures 1-2The present invention provides a technical solution: Example

[0038] A small-sample target detection method based on KL divergence loss and contrast loss includes the following steps: S1. Construct a base class image training set with a large number of samples using the PASCAL VOC dataset. There are 15 base class object categories, namely aeroplane, bicycle, bird, boat, bottle, bus, car, cat, chair, cow, dining table, dog, horse, motorbike, and person. Use this base class image training set to train the Faster-RCNN architecture object detection network to obtain the base class object detection model. The Faster-RCNN object detection network includes a first basic feature extraction module, a first multi-resolution feature pyramid module, a binary classification regression module, a candidate region feature pooling module, a category regression module, and a bounding box regression module.

[0039] S2. Construct a training set of query images with 10 samples per class. The target classes are pottedplant, sheep, sofa, train, and tvmonitor.

[0040] S3. Construct a support image training set. The support image training set samples are from the base class image training set. There are 15 target categories, namely aeroplane, bicycle, bird, boat, bottle, bus, car, cat, chair, cow, dining table, dog, horse, motorbike, and person. The number of samples in each category is 10.

[0041] S4. Combine the query image training set and the support image training set into a training set, and feed it into a few-shot object detection network based on KL divergence loss and contrast loss for forward propagation; wherein, the few-shot object detection network based on KL divergence loss and contrast loss includes a basic feature extraction module, a multi-resolution feature pyramid module, a bias candidate region generation module, and a re-detection module.

[0042] The basic feature extraction module extracts high-dimensional features of the target, while the multi-resolution feature pyramid module outputs multi-scale resolution features of the target. The bias candidate region generation module constrains the base class binary classification results for the new class binary classification results. The re-detection module implements comparative learning between the new class features and the base class features, as well as constrains the base class regression branch for the new class regression branch, avoiding the forgetting problem in small-sample base class learning.

[0043] Step S4 includes the following sub-steps: S41. Randomly select training batches of images from the training set consisting of the query image training set and the supporting image training set. The batch of images consists of 8 images. First, convert the batch images into a four-dimensional tensor (8×3×W×H), where W and H are the image width and height. Then, feed the four-dimensional tensor into the basic feature extraction module to obtain multi-scale features. Next, feed the multi-scale features into the biased candidate region generation network to generate candidate regions and candidate region binary classification results.

[0044] The specific functions implemented by the bias candidate region generation module are as follows: The bias candidate region generation module consists of a candidate region feature pooling module, a target localization branch, a base class binary classification regression branch, and a new class binary classification regression branch. The base class binary classification regression branch and the new class binary classification regression branch are fused by taking the result with the maximum score to improve the accuracy of bias candidate region generation.

[0045] S4. The candidate regions and the binary classification results of the candidate regions are fed into the base class target category regression branch, base class target localization branch, new class target regression branch, new class target localization branch, and contrastive learning branch of the re-detection module to obtain the base class target category regression vector, base class target localization vector, new class target category regression vector, new class target localization vector, and contrastive learning encoding matrix.

[0046] The specific functions implemented by the newly added re-detection module in this invention are as follows: The re-detection module consists of a base class target category regression branch, a base class target localization branch, a new class target regression branch, a new class target localization branch, and a contrastive learning branch. The base class target localization branch and the new class target regression branch are optimized using KL divergence to improve the network's classification performance. The contrastive learning branch uses supervised contrastive loss to optimize the object detection network classifier.

[0047] S5. Calculate the binary regression loss and target localization loss of the bias candidate region generation module; Step S5 includes the following sub-steps: S51. Calculate the binary classification regression loss of the bias candidate region generation module using the binary classification results of the candidate regions and the binary classification information of the labels. The calculation formula is:

[0048] in, For tags, Predict the probability that a candidate box is foreground. Valid sample size; S52. Calculate the target localization loss using the bounding boxes of the candidate regions and the bounding boxes of the labels. The calculation formula is:

[0049] in This is the predicted border offset. Actual offset; The number of positive samples To smooth the L1 norm loss, The formula is as follows:

[0050] in, .

[0051] S6. Calculate the KL divergence loss, contrastive learning loss, class regression loss, and target localization loss of the re-detection module; Step S6 includes the following sub-steps: S61. Calculate the KL divergence loss using the regression vectors of the base class and the new class. .

[0052] KL divergence loss of re-detection module The formula is:

[0053] in, The number of categories in the base class. , , To predict the confidence level for the new class of bounding boxes, To predict the confidence level of the base class bounding box, To predict the confidence level for a new class of bounding box, To predict the confidence level of a bounding box for a certain base class.

[0054] S62. Obtain the similarity matrix using contrastive learning of the encoded vectors. The formula for the similarity matrix is ​​as follows:

[0055] Where Z is the contrastive learning encoding vector matrix. For devices with a value of Z, the similarity matrix size is 512×512.

[0056] S63. Calculate the contrastive learning loss using the similarity matrix. .

[0057] Comparative learning loss of the re-detection module The formula is:

[0058]

[0059] in These are features output by the multilayer perceptron product coding module. Indicates the degree of overlap between the candidate bounding box and the label bounding box. This represents the category label of the bounding box, where N is the number of samples in the training batch. , This indicates the cosine similarity between the output features of the candidate region feature pooling module. This is the temperature coefficient. This represents the actual category label of the annotation box, and exp(·) is an exponential function with base e.

[0060] S64. Obtain the classification loss using the regression vector of the new target category and the label category information. .

[0061] Class regression loss of the re-detection module The formula is:

[0062] Where B is the total number of candidate boxes involved in the calculation. Let be the probability that the j-th candidate box is predicted as the true class. For the first i The true category of each candidate box.

[0063] S65. Obtain the target localization loss using the new type of target localization vector and the label target bounding box information. .

[0064] Target localization loss of re-detection module The formula is:

[0065] in, This is the predicted border offset. The true offset, where M is the number of positive samples.

[0066] S7. Multiply the losses in S5 and S6 by the coefficients, sum them up and calculate the average, and then perform backpropagation to update the weights of the small sample target detection network based on KL divergence loss and contrast loss. In step S7, the total loss formula for small sample target detection based on KL divergence loss and contrast loss is as follows:

[0067] Among them, the bias candidate region generation module loss , The bias candidate region binary classification loss is used. The bias candidate region localization loss. For the re-detection module category regression loss, The loss was located by the re-detection module. To compare learning loss, This represents the KL divergence loss. , It is a decimal between (0,1).

[0068] S8. Input the test images containing base classes or new classes from the PASCAL VOC dataset into the trained few-sample object detection network based on KL divergence loss and contrast loss to perform object detection, and output the detection box, class and confidence score.

[0069] The method was tested on the PASCAL VOC dataset, which contains only 5 new categories and 15 base categories. The test results are shown in Table 1 below: method New class map (average accuracy across all classes) Old class map (average accuracy across all classes) Method 1 56.1 74.6 Method 2 58.4 72.0 Method 3 61.1 76.2 Table 1 In Table 1: Method 1 represents the case using KL divergence loss, Method 2 represents the case using only contrast loss, and Method 3 represents the case using both KL divergence loss and contrast loss. It can be seen that the map has been significantly improved, which demonstrates the effectiveness of this method.

[0070] The above description is merely a preferred embodiment of the present invention. It should be understood that the present invention is not limited to the forms disclosed herein and should not be construed as excluding other embodiments. It can be used in various other combinations, modifications, and environments, and can be altered within the scope of the concept described herein through the above teachings or related technologies or knowledge. Modifications and variations made by those skilled in the art that do not depart from the spirit and scope of the present invention should be within the protection scope of the appended claims.

Claims

1. A small-sample target detection method based on KL divergence loss and contrast loss, characterized in that: Includes the following steps: S1. Construct a base class image training set containing a large number of samples, and use the base class image training set to train the Faster-RCNN architecture object detection network to obtain the base class object detection model; S2. Construct a query image training set, wherein the number of samples in each class of the query image training set is less than or equal to 30 and the number of samples in each class is equal; S3. Construct a support image training set, wherein the support image training set samples are from the base class image training set, and the number of samples of each class in the support image training set is equal to the number of samples of each class in the query image training set. S4. Combine the query image training set and the support image training set into a training set, and feed it into a few-shot object detection network based on KL divergence loss and contrast loss for forward propagation; wherein, the few-shot object detection network based on KL divergence loss and contrast loss includes a basic feature extraction module, a multi-resolution feature pyramid module, a bias candidate region generation module, and a re-detection module. S5. Calculate the binary regression loss and target localization loss of the bias candidate region generation module; S6. Calculate the KL divergence loss, contrastive learning loss, class regression loss, and target localization loss of the re-detection module; S7. Multiply the losses in S5 and S6 by the coefficients, sum them up and calculate the average, and then perform backpropagation to update the weights of the small sample target detection network based on KL divergence loss and contrast loss. S8. Input the test image containing the base class or the new class into the trained few-sample object detection network based on KL divergence loss and contrast loss to perform object detection, and output the detection box, class and confidence score.

2. The small-sample target detection method based on KL divergence loss and contrast loss according to claim 1, characterized in that: In step S4, the bias candidate region generation module consists of a candidate region feature pooling module, a target localization branch, a base class binary classification regression branch, and a new class binary classification regression branch.

3. The small-sample target detection method based on KL divergence loss and contrast loss according to claim 1, characterized in that: In step S4, the re-detection module consists of a base class target category regression branch, a base class target localization branch, a new class target regression branch, a new class target localization branch, and a contrastive learning branch.

4. The small-sample target detection method based on KL divergence loss and contrast loss according to claim 1, characterized in that: The binary regression loss of the biased candidate region generation module in step S5 The calculation formula is: ; in, For tags, Predict the probability that a candidate box is foreground. The number of valid samples; Target location loss The calculation formula is: ; in This is the predicted border offset. This is the actual border offset; The number of positive samples To smooth the L1 norm loss, The formula is as follows: ; in, .

5. The small-sample target detection method based on KL divergence loss and contrast loss according to claim 4, characterized in that: In step S6, the KL divergence loss of the re-detection module The formula is: ; in, The number of categories in the base class. , , To predict the confidence level for the new class of bounding boxes, To predict the confidence level of the base class bounding box, To predict the confidence level for a new class of bounding box, To predict the confidence level of a bounding box for a certain base class.

6. The small-sample target detection method based on KL divergence loss and contrast loss according to claim 5, characterized in that: In step S6, the contrastive learning loss of the re-detection module The formula is: ; ; in These are features output by the multilayer perceptron product coding module. Indicates the degree of overlap between the candidate bounding box and the label bounding box. This represents the category label of the bounding box, where N is the number of samples in the training batch. , This indicates the cosine similarity between the output features of the candidate region feature pooling module. Temperature coefficient; This represents the actual category label of the annotation box, and exp(·) is an exponential function with base e.

7. The small-sample target detection method based on KL divergence loss and contrast loss according to claim 6, characterized in that: In step S6, the class regression loss of the re-detection module The formula is: ; Where B is the total number of candidate boxes involved in the calculation. Let be the probability that the j-th candidate box is predicted as the true class. For the first i The true category of each candidate box.

8. As described in claim 7, characterized in that A small-sample target detection method based on KL divergence loss and contrast loss: In step S6, the target localization loss of the re-detection module. The formula is: ; in, This is the predicted border offset. The true offset, where M is the number of positive samples.

9. As described in claim 8, characterized in that A small-sample target detection method based on KL divergence loss and contrastive loss: In step S7, the total loss formula for small-sample target detection based on KL divergence loss and contrastive loss is as follows: ; Among them, the bias candidate region generation module loss , , It is a decimal between (0,1).