Dynamic feature selection and distribution method based on mass fraction distribution
By adopting a dynamic feature selection and allocation method based on quality score distribution, the problem of inaccurate sample allocation during the training of convolutional object detectors is solved, which improves the model training efficiency and reduces the error of loss value, thus achieving a more efficient detection effect.
Patent Information
- Application Number
- CN202510963368.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-14
- Publication Date
- 2025-11-18
AI Technical Summary
Existing convolutional object detectors suffer from large loss errors during training due to mismatch between preset anchor boxes and model parameters. The sample set cannot be optimized with model iteration, leading to increased detection difficulty and poor detection results.
A dynamic feature selection and allocation method based on quality score distribution is adopted. By constructing a matching matrix between samples and labels through intersection-union ratio, high-quality positive samples are dynamically screened, the sample set is optimized to reduce loss value error, and the training efficiency of the detection model is improved.
By dynamically selecting positive samples and optimizing sample allocation during training, the error in loss values is reduced, and the training efficiency of the detection model is improved without affecting the detection speed.
Smart Images

Figure CN120976519A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a dynamic feature selection and allocation method based on quality score distribution, belonging to the field of label allocation technology. Background Technology
[0002] Most convolutional object detectors are built upon pre-defined anchor boxes or anchor points, which initialize the region of interest, significantly reducing the difficulty of the detection task. However, the mismatch between the pre-defined anchor boxes and model parameters introduces loss errors during training. Furthermore, due to the fixed nature of the predicted anchor boxes, the sample set cannot be optimized with model iterations, further exacerbating the loss errors caused by inaccurate sample matching. This invention is the first patent to address this problem. It establishes a matching relationship between the sample set and model parameters using predicted boxes as samples. Based on this, it proposes the SDGFS method, which dynamically selects a suitable number of high-quality positive samples by analyzing the matching score distribution of the sample set corresponding to each ground truth (gt). This continuously optimizes the sample set to reduce loss errors and improve the training efficiency of the detection model. Summary of the Invention
[0003] To address the problem of poor training performance caused by inaccurate sample allocation in target detection models during training, this invention proposes a dynamic feature selection and allocation method based on quality score distribution.
[0004] The technical solution adopted by the present invention to solve the above problems is as follows: The present invention includes the following steps: Step 1: In each training epoch of the object detection model, construct a matching matrix between samples and labels using the intersection-union ratio (IU) as the metric. Step 2: For each label, obtain its sample matching score through the matching matrix, and normalize the obtained sample matching score to get the matching score; Step 3: Sort the matched samples of each label in descending order according to the matching score, and calculate the difference in matching scores between adjacent samples in the sort; Step 4: Set the preset value for positive sample selection topk and loop termination value score_gap The matching score difference matrix is obtained based on the matching score difference between adjacent samples in the permutation, and then combined with the preset value of the positive sample selection. topk and loop termination value score_gap Positive samples are selected one by one from the matching score difference matrix, and the unselected samples are treated as negative samples. Step 5: Calculate the classification loss and localization regression loss of the target detection model based on the selected positive samples. Classification loss and localization regression loss Add to obtain the final loss .
[0005] Furthermore, the expression for the matching matrix established in step 1 is: (1); In formula (1), gt For annotation, m The number of annotations. n The number of samples. IoU For intersection, union, and comparison, sample As a sample, i Refers to the first i Candidate box samples sample , j Refers to the first j A label box gt , Refers to the 0th annotation box gt Cross-union score with the 0th sample IoU , Refers to the first j A label box gt Cross-union score with the 0th sample IoU , Refers to the first m A label box gt Cross-union score with the 0th sample IoU , Refers to the 0th annotation box gt With the i Crossover ratio score between samples IoU , Refers to the first j A label box gt With the i Crossover ratio score between samples IoU , Refers to the first m A label box gt With the i Crossover ratio score between samples IoU , Refers to the 0th annotation box gt With the n Crossover ratio score between samples IoU , Refers to the first m A label box gt With the n Crossover ratio score between samples IoU .
[0006] Furthermore, the formula for calculating the matching score in step 2 is as follows: (2); In formula (2), The sample matching score for each sample. The matching score for each sample. This is the normalization function.
[0007] Furthermore, step 4 specifically includes: Select the first from the matching score difference matrix topk A set of 10 samples constitutes a candidate positive sample set. Two candidate positive samples are selected from the candidate positive sample set in a top-to-bottom order. and Perform calculations and select The selected samples are considered positive samples, and the unselected samples are considered negative samples. For the first i +1 mark matching score and the first i The difference in matching scores of each label For the first i +2 matching scores and the first i The difference in matching scores for +1 label.
[0008] Furthermore, step 5 specifically includes: The classification loss is calculated based on the predicted sample class labels, predicted class values, and IoU scores between positive samples and their corresponding bounding boxes in the positive and negative sample sets. ; The localization regression loss is calculated based on the predicted bounding box coordinates and labeled bounding box coordinates of positive samples and the predicted bounding box coordinates of negative samples. ; Classification loss and localization regression loss Add to obtain the final loss ; Classification loss The calculation formula is: (3); In formula (3), For the first i Each predicted sample and its corresponding bounding box IoU Fraction, For the first i Predicted values for each category, For the first i The class label of each predicted sample, To determine the final number of positive samples, The number of all samples. For the classification task loss function; Positioning Regression Loss The calculation formula is: (4); In formula (4), For the first i The coordinates of each prediction box. For the coordinates of the corresponding annotation box, For the location task loss function; Final loss The calculation formula is: (5).
[0009] The beneficial effects of this invention are: This invention constructs a training sample set based on predicted samples and controls the number of positive samples by analyzing the matching score distribution between samples and ground-truth and setting preset parameters topk and score_diff. This achieves the goal of dynamically selecting suitable positive samples for each ground-truth in each training round. Since this invention only optimizes the sample allocation process during model training and does not introduce any inference parameters, it will not affect the detection speed. Attached Figure Description
[0010] Figure 1 This is a flowchart illustrating the dynamic feature selection and allocation method based on quality fraction distribution provided by the present invention. Detailed Implementation
[0011] In this embodiment, ground-truth is a label, and its abbreviation gt is used to represent the label. Intersection-of-Union is the intersection-of-union ratio, and its abbreviation IoU is used to represent the intersection-of-union ratio.
[0012] like Figure 1 As shown, the steps of the dynamic feature selection and allocation method based on quality score distribution described in this embodiment include: S1: In each training round of the object detection model, the crossover ratio is used as a metric to construct a matching matrix between samples and labels and calculate the matching score; S101: In each epoch of model training, calculate the matching matrix between the samples and the ground truth (gt). Taking m gts and n samples as an example, using the most commonly used intersection-over-union ratio (IoU) as the metric, the IoU matrix is: (1); In formula (1), gt For annotation, m The number of annotations. n The number of samples. IoU For intersection, union, and comparison, sample As a sample, i Refers to the first i Candidate box samples sample, j Refers to the first j A label box gt , Refers to the 0th annotation box gt Cross-union score with the 0th sample IoU , Refers to the first j A label box gt Cross-union score with the 0th sample IoU , Refers to the first m A label box gt Cross-union score with the 0th sample IoU , Refers to the 0th annotation box gt With the i Crossover ratio score between samples IoU , Refers to the first j A label box gt With the i Crossover ratio score between samples IoU , Refers to the first m A label box gt With the i Crossover ratio score between samples IoU , Refers to the 0th annotation box gt With the n Crossover ratio score between samples IoU , Refers to the first m A label box gt With the n Crossover ratio score between samples IoU .
[0013] S102: Sample matching score for each ground truth (gt) Normalization is performed to obtain the matching score: (2); In formula (2), The sample matching score for each sample. The matching score for each sample. This is the normalization function.
[0014] S2: Sort the matching samples of each label in descending order according to the matching score, and calculate the difference in matching scores between adjacent samples in the sort; The formula for calculating the matching score difference is: (3); In formula (3), For the first i +1 matching score for each annotation For the first i The matching score of each label.
[0015] S3: Select positive samples for each ground truth sample; In this implementation, this step is named SDGFS, based on the set of matching score differences. In this implementation, the first step is to select the previous step for each gt. topk A set of 100 samples is formed as a candidate positive sample set. Positive samples are then selected sequentially from this set in a top-to-bottom order. The loop terminates when: (4); In formula (4), For the first i +1 mark matching score and the first i The difference in matching scores of each label For the first i +2 matching scores and the first i The difference in matching scores for +1 label, topk , score_gap These are preset values, among which topk Used to limit the maximum number of positive samples, while score_gap Used to evaluate the difference in matching scores between two adjacent samples. score_gap When the value is small, the loop termination condition is easier to satisfy. However, this leads to fewer positive samples being selected for each ground truth (gt), which is detrimental to model training because fewer positive samples hinder model convergence. Conversely, when the value is large... score_gap When the size is large, the loop termination condition becomes stricter. At this point, higher-quality samples will be selected for each ground truth (gt), correspondingly filtering out more low-quality samples. This improves the training quality of the model and allows for better parameter optimization. Once the termination condition is met, the remaining unselected samples will be classified as negative samples, i.e., background samples.
[0016] The pseudocode for sample selection is shown in Table 1: Table 1
[0017] S4: Calculate the classification loss and localization regression loss of the target detection model based on the selected positive samples, and add the classification loss and localization regression loss to obtain the final loss; Based on the predicted sample class labels, predicted class values, and IoU scores between positive and negative sample sets, the classification loss is calculated using the Quality-Focal-Loss method. : (5); In formula (5), For the first i Each predicted sample and its corresponding bounding box IoU Fraction, For the first i Predicted values for each category, For the first i The class label of each predicted sample, To determine the final number of positive samples, The number of all samples. For the classification task loss function; Based on the predicted bounding box coordinates and labeled bounding box coordinates of positive samples and the predicted bounding box coordinates of negative samples, the localization regression loss is calculated according to GIoU. : (6); In formula (4), For the first i The coordinates of each prediction box. For the coordinates of the corresponding annotation box, For the location task loss function; Classification loss and localization regression loss Add to obtain the final loss : (7).
[0018] Ultimately based on the final loss Optimize the parameter samples during the training process of the object detection model.
[0019] In summary, this invention constructs a training sample set based on predicted samples and controls the number of positive samples by analyzing the matching score distribution between samples and ground-truth and setting preset parameters topk and score_diff. This achieves the goal of dynamically selecting suitable positive samples for each ground-truth in each training round. Since this invention only optimizes the sample allocation process during model training and does not introduce any inference parameters, it will not affect the detection speed.
[0020] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the present invention. Any simple modifications, equivalent substitutions, and improvements made to the above embodiments without departing from the scope of the present invention, based on the technical essence of the present invention and within the spirit and principles of the present invention, shall still fall within the protection scope of the present invention.
Claims
1. A dynamic feature selection and allocation method based on quality fraction distribution, characterized in that, include: Step 1: In each training epoch of the object detection model, construct a matching matrix between samples and labels using the intersection-union ratio (IU) as the metric. Step 2: For each label, obtain its sample matching score through the matching matrix, and normalize the obtained sample matching score to get the matching score; Step 3: Sort the matched samples of each label in descending order according to the matching score, and calculate the difference in matching scores between adjacent samples in the sort; Step 4: Set the preset value for positive sample selection topk and loop termination value score_gap The matching score difference matrix is obtained based on the matching score difference between adjacent samples in the permutation, and then combined with the preset value of the positive sample selection. topk and loop termination value score_ gap Positive samples are selected one by one from the matching score difference matrix, and the unselected samples are treated as negative samples. Step 5: Calculate the classification loss of the object detection model based on the selected positive samples. and localization regression loss Classification loss and localization regression loss Add to obtain the final loss Based on the final loss Optimize the parameter samples during the training process of the object detection model.
2. The dynamic feature selection and allocation method based on quality fraction distribution according to claim 1, characterized in that, The expression for the matching matrix established in step 1 is: (1); In formula (1), gt For annotation, m The number of annotations. n The number of samples. IoU For intersection, union, and comparison, sample As a sample, i Refers to the first i Candidate box samples sample , j Refers to the first j A label box gt , Refers to the 0th annotation box gt Cross-union score with the 0th sample IoU , Refers to the first j A label box gt Cross-union score with the 0th sample IoU , Refers to the first m A label box gt Cross-union score with the 0th sample IoU , Refers to the 0th annotation box gt With the i Crossover ratio score between samples IoU , Refers to the first j A label box gt With the i Crossover ratio score between samples IoU , Refers to the first m A label box gt With the i Crossover ratio score between samples IoU , Refers to the 0th annotation box gt With the n Crossover ratio score between samples IoU , Refers to the first m A label box gt With the n Crossover ratio score between samples IoU .
3. The dynamic feature selection and allocation method based on quality fraction distribution according to claim 1, characterized in that, The formula for calculating the matching score in step 2 is: (2); In formula (2), The sample matching score for each sample. The matching score for each sample. This is the normalization function.
4. The dynamic feature selection and allocation method based on quality fraction distribution according to claim 1, characterized in that, Step 4 specifically includes: Select the first from the matching score difference matrix topk A set of 10 samples constitutes a candidate positive sample set. Two candidate positive samples are selected from the candidate positive sample set in a top-to-bottom order. and Perform calculations and select The selected samples are considered positive samples, and the unselected samples are considered negative samples. For the first i +1 mark matching score and the first i The difference in matching scores of each label For the first i +2 matching scores and the first i The difference in matching scores for +1 label.
5. The dynamic feature selection and allocation method based on quality fraction distribution according to claim 1, characterized in that, Step 5 specifically includes: The classification loss is calculated based on the predicted sample class labels, predicted class values, and IoU scores between positive samples and their corresponding bounding boxes in the positive and negative sample sets. ; The localization regression loss is calculated based on the predicted bounding box coordinates and labeled bounding box coordinates of positive samples and the predicted bounding box coordinates of negative samples. ; Classification loss and localization regression loss Add to obtain the final loss ; Classification loss The calculation formula is: (3); In formula (3), For the first i Each predicted sample and its corresponding bounding box IoU Fraction, For the first i Predicted values for each category, For the first i The class label of each predicted sample, To determine the final number of positive samples, The number of all samples. For the classification task loss function; Positioning Regression Loss The calculation formula is: (4); In formula (4), For the first i The coordinates of each prediction box. For the coordinates of the corresponding annotation box, For the location task loss function; Final loss The calculation formula is: (5)。