Sample balanced learning class incremental target count modeling method and device

By introducing sample rebalancing loss and gradient decay loss into the incremental target counting task, the catastrophic forgetting problem caused by the imbalance between old and new class samples in dynamic environments is solved, thus improving the accuracy and stability of the counting model.

CN118015352BActive Publication Date: 2026-11-24NANJING UNIV OF INFORMATION SCI & TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410144769.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-02-01
Publication Date
2026-11-24
Estimated Expiration
2044-02-01

AI Technical Summary

Technical Problem

In dynamically changing environments, incremental target counting tasks face the catastrophic forgetting problem caused by the imbalance in the distribution of samples from old and new classes, which existing technologies struggle to solve effectively.

Method used

A combined strategy of sample rebalancing loss and gradient decay loss is adopted. By dynamically adjusting the sample loss contribution and constraining gradient information, the network parameters are optimized to alleviate the forgetting of old classes and enhance the perception of new classes.

Benefits of technology

It improves the counting accuracy and generalization ability of the incremental target counting model, balances the stability and plasticity of the model, and reduces the forgetting phenomenon of old classes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118015352B_ABST
    Figure CN118015352B_ABST
Patent Text Reader

Abstract

This invention belongs to the field of computer vision, specifically a sample-balanced learning method for incremental target counting modeling. It aims to solve the catastrophic forgetting problem caused by the imbalance between old and new class samples during incremental target counting, while simultaneously improving the model's ability to perceive new classes and helping the model achieve a better balance between stability and plasticity. This invention mainly includes two proposed new loss functions: (1) a sample rebalancing loss function, which dynamically rebalances the loss contributions of old and new class samples based on the difficulty of sample counting, enabling the model to focus more on old class samples to alleviate catastrophic forgetting while improving its ability to perceive new class samples; and (2) a gradient decay loss function, which dynamically constrains the gradient information of the counting model, maximizing the retention of old knowledge without compromising its plasticity, thus achieving a better balance between stability and plasticity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision, specifically to a sample-balanced learning-based incremental target counting modeling method and apparatus. Background Technology

[0002] Target counting is a crucial task in computer vision, aiming to statistically determine the number of targets of interest. Common target types include people, vehicles, animals, plants, and pests. Based on this statistical information, effective target management can be implemented, and proactive interventions can be made to prevent unnecessary losses.

[0003] In the real world, the environment and categories are constantly changing. Fixed-category target counting tasks are no longer suitable for these dynamic changes. Incremental target learning adds tasks based on changes in category and target statistics, enabling the learning and prediction of new categories. However, this task faces catastrophic forgetting while learning new tasks. An effective solution is to select some samples from the old classes and samples from the new classes to train the new model, i.e., a reproducibility-based strategy. However, due to the uneven distribution of samples between the old and new classes, the model often favors the new class while ignoring the old class, resulting in significant catastrophic forgetting. Summary of the Invention

[0004] Objective of the Invention: To address the aforementioned problems, this invention proposes a sample rebalancing learning method and apparatus for incremental target counting modeling. The invention utilizes two key loss functions: sample rebalancing loss and gradient decay loss, which can improve the counting accuracy and generalization ability of the incremental target counting model.

[0005] Technical solution: The present invention provides a sample-balanced learning-based incremental target counting modeling method:

[0006] Step S1: Load the training dataset and perform online data augmentation on the data in the dataset;

[0007] Step S2: Construct a network model for incremental target counting;

[0008] Step S3: Set the network training parameters and calculate the classification loss, distillation loss, sample rebalancing loss, and gradient decay loss to optimize the network parameters.

[0009] Step S4: Validate the current trained model using the validation dataset and save the model with the smaller error;

[0010] Step S5: If the iteration count for the current category is complete, select representative samples to construct an example set and combine it with the sample data for the new category to form a new training dataset; if the iteration count for the current category is not complete, proceed to step S3.

[0011] Step S6: Test the saved model using the test data to obtain the final counting result.

[0012] Furthermore, the feature is that, in step S1, the online data augmentation of the data in the dataset is performed as follows:

[0013] Step S1-1: Randomly scale the image;

[0014] Step S1-2: The image is cropped at random locations, with a crop size of 400*400;

[0015] Steps S1-3: The image is randomly flipped with a probability of 0.5;

[0016] Steps S1-4: Perform gamma correction on the image, with a correction coefficient range of 0.5-1.5 and a probability of 0.3;

[0017] Step S1-5: Convert the image to grayscale with a probability of 0.1.

[0018] Furthermore, the feature is that, in step S2, constructing the incremental target counting network model specifically includes:

[0019] The backbone network is used to extract high-level semantic information from the network input;

[0020] The regression module is used to perform feature transfer on high-level semantic information to achieve regression of the target density map;

[0021] Classification module: Uses advanced semantic information to identify the category of network input;

[0022] The incremental module adds value to the output nodes of the last regression layer of the regression module and the classification module based on the number of new categories.

[0023] Furthermore, the feature is that in step S3, network training parameters are set, and classification loss, sample rebalancing loss, and gradient decay loss are calculated to optimize the network parameters. The specific steps are as follows:

[0024] Step S3-1: Set necessary parameters such as the number of training iterations, learning rate, and example set memory size (number). Before network training, if it is in the base class learning stage, initialize the class increment target counting network model. If it is not in the base class stage, directly initialize the current stage network model using the network model trained in the previous stage; during network training, skip step S3-1.

[0025] Step S3-2: Feed the training data into the incremental target counting network model to obtain the target density map y predicted by the network in stage t.t And classification results p t If stage t is not the base class stage, the samples in the example set Ψ are fed into the network model trained in stage t-1 to obtain the target density map y. t-1 And classification results p t-1 ;

[0026] Step S3-3: Calculate the sum of classification loss, distillation loss, sample rebalancing loss, and gradient decay loss;

[0027] Step S3-4: Optimize the parameters in the network model using the Adam optimizer;

[0028] Furthermore, the characteristic is that in step S3-3, the sample rebalancing loss L rebalance The details are as follows:

[0029] L rebalance =[P i a +β]*L den

[0030]

[0031] Where |·| represents the absolute value, and ∑ represents the sum of all elements in the density plot. This represents the output of the predicted density map for the i-th sample in stage t. Let P represent the label of the i-th sample in stage t, α represent the focusing parameter, and P represent the focusing parameter. i α Let L represent the modulation factor of the i-th sample, β represent the hyperparameter of the sample rebalancing loss, and L represent the modulation factor of the i-th sample. den The MSE loss is calculated as follows:

[0032]

[0033] Where N represents the total number of training samples in each batch, and ||·||2 represents the 2-norm.

[0034] Furthermore, the characteristic is that in step S3-3, the gradient decay loss L decay The details are as follows:

[0035]

[0036] Among them, h t φ represents the number of categories in stage t. h Let represent the weight of the h-th output head, ω represent the hyperparameter of the gradient decay loss, and ||·||1 represent the 1-norm.

[0037] Furthermore, the characteristic is that, in step S3-3, the sum L of classification loss, distillation loss, sample rebalancing loss, and gradient decay loss is calculated. total The details are as follows:

[0038] L total =L cls +(1-l)*L rebalance +l*L kd +L decay

[0039] Where λ represents the hyperparameter between losses, and the distillation loss L kd :

[0040]

[0041] in, Let ||·||2 represent the predicted density map output of the samples in the i-th paradigm set Ψ at stage t-1, where ||·||2 represents the 2-norm;

[0042] Cross-entropy loss L cls :

[0043]

[0044] in, This represents the classification label of the i-th sample. This represents the result of class identification for the i-th sample.

[0045] The present invention discloses a sample equalization learning-type incremental target counting device, comprising a processor and a computer program stored in a memory and executable on the processor, wherein the processor executes the program to implement the above-described method.

[0046] Beneficial effects: Compared with the prior art, the beneficial effects of the present invention are as follows:

[0047] 1) This invention designs a sample rebalancing loss that dynamically adjusts its loss contribution based on the counting error of the sample, thereby alleviating the model's forgetting of old classes while enhancing its ability to perceive new classes and improving counting accuracy.

[0048] 2) This invention designs a gradient decay loss, which, by constraining the gradient information of the counting model, can retain old knowledge to the maximum extent without compromising the plasticity of the model, and better help the counting model achieve a balance between stability and plasticity. Attached Figure Description

[0049] Figure 1 This is a flowchart of a method according to an embodiment of the present invention;

[0050] Figure 2This is a schematic diagram of the network structure according to an embodiment of the present invention. Detailed Implementation

[0051] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments.

[0052] Embodiments of the present invention, such as Figure 1 As shown, it includes the following steps:

[0053] Step S1: Load the training dataset and perform online data augmentation on the data in the dataset;

[0054] Step S1-1: Randomly scale the image;

[0055] Step S1-2: The image is cropped at random locations, with a crop size of 400*400;

[0056] Steps S1-3: The image is randomly flipped with a probability of 0.5;

[0057] Steps S1-4: Perform gamma correction on the image, with a correction coefficient range of 0.5-1.5 and a probability of 0.3;

[0058] Step S1-5: Convert the image to grayscale with a probability of 0.1.

[0059] Step S2: Construct a network model for incremental target counting;

[0060] The incremental target counting network model specifically includes:

[0061] The backbone network is used to extract high-level semantic information from the network input. In this embodiment, a pre-trained VGG-16 model is used.

[0062] The regression module is used to perform feature transfer on high-level semantic information to achieve regression of the target density map. In this embodiment, a series of convolutional layers are used.

[0063] The classification module uses high-level semantic information to identify the category of the network input. In this embodiment, adaptive pooling layers and linear layers are used.

[0064] The incremental module adds to the output nodes of the last regression layer of the regression module and the classification module based on the number of new categories.

[0065] Step S3: Set the network training parameters and calculate the classification loss, distillation loss, sample rebalancing loss, and gradient decay loss to optimize the network parameters.

[0066] Step S3-1: Set necessary parameters such as the number of training iterations, learning rate, and example set memory size (number). Before network training, if it is in the base class learning stage, initialize the class increment target counting network model. If it is not in the base class stage, directly initialize the current stage network model using the network model trained in the previous stage; during network training, skip step S3-1.

[0067] Step S3-2: Feed the training data into the incremental target counting network model to obtain the target density map y predicted by the network in stage t. t And classification results p t If stage t is not the base class stage, the samples in the example set Ψ are fed into the network model trained in stage t-1 to obtain the target density map y. t-1 And classification results p t-1 ;

[0068] Step S3-3: Calculate the sum of classification loss, distillation loss, sample rebalancing loss, and gradient decay loss;

[0069] Among them, the sample rebalancing loss L rebalance The details are as follows:

[0070] L rebalance =[P i a +β]*L den

[0071]

[0072] Where |·| represents the absolute value, and ∑ represents the sum of all elements in the density plot. This represents the output of the predicted density map for the i-th sample in stage t. Let P represent the label of the i-th sample in stage t, α represent the focusing parameter, and P represent the focusing parameter. i α Let L represent the modulation factor of the i-th sample, β represent the hyperparameter of the sample rebalancing loss, and L represent the modulation factor of the i-th sample. den The MSE loss is calculated as follows:

[0073]

[0074] Where N represents the total number of samples in each batch of training.

[0075] Wherein, gradient decay loss L decay The details are as follows:

[0076]

[0077] Among them, h t φ represents the number of categories in stage t.h ω represents the weight of the h-th output head, and ω represents the hyperparameter of the gradient decay loss.

[0078] Among them, the sum L of classification loss, distillation loss, sample rebalancing loss and gradient decay loss is calculated. total The details are as follows:

[0079] L total =L cls +(1-l)*L rebalance +l*L kd +L decay

[0080] Where λ represents the hyperparameter between losses, and the distillation loss L kd :

[0081]

[0082] in, This represents the output of the predicted density map for the samples in the i-th paradigm set Ψ at stage t-1;

[0083] Cross-entropy loss L cls :

[0084]

[0085] in, This represents the classification label of the i-th sample. This represents the result of class identification for the i-th sample.

[0086] Step S3-4: Optimize the parameters in the network model using the Adam optimizer;

[0087] Step S4: Validate the current trained model using the validation dataset and save the model with the smaller error;

[0088] Step S5: If the iteration count for the current category is complete, select representative samples to construct an example set and combine it with the sample data for the new category to form a new training dataset; if the iteration count for the current category is not complete, proceed to step S3.

[0089] Step S6: Test the saved model using the test data to obtain the final counting result.

[0090] This embodiment also provides a sample-balanced learning-based incremental target counting modeling device, including a processor and a computer program stored in a memory and executable on the processor. When the processor executes the program, it implements the above-described method.

[0091] This embodiment was compared with other state-of-the-art methods on Part A of the EoCo dataset, and the results are shown in Table 1. In this embodiment, the network performance was evaluated using MAE (mean absolute error) and MSE (mean squared error), where a lower MAE indicates more accurate network prediction and a lower MSE indicates more stable results.

[0092] Table 1. Quantitative comparison results of this embodiment with other methods on EoCo Part A.

[0093]

[0094] The above description is merely a preferred embodiment of the present invention and should not be construed as limiting the scope of the invention. Therefore, any equivalent variations made in accordance with the claims of the present invention are still within the scope of the present invention.

Claims

1. A sample-balanced learning-based incremental target counting modeling method, characterized in that, The method includes the following steps: Step S1: Load the training dataset and perform online data augmentation on the data in the dataset; Step S2: Construct a network model for incremental target counting; Step S3: Set the network training parameters and calculate the classification loss, distillation loss, sample rebalancing loss, and gradient decay loss to optimize the network parameters. Step S4: Validate the current trained model using the validation dataset and save the model with the smaller error; Step S5: If the iteration count for the current category is complete, select representative samples to construct an example set and combine it with the sample data for the new category to form a new training dataset; if the iteration count for the current category is not complete, proceed to step S3. Step S6: Test the saved model using the test data to obtain the final counting result; In step S1, the online data augmentation of the data in the dataset is performed as follows: Step S1-1: Randomly scale the image; Step S1-2: The image is cropped at random locations, with a crop size of 400*400; Steps S1-3: The image is randomly flipped with a probability of 0.5; Steps S1-4: Perform gamma correction on the image, with a correction coefficient range of 0.5-1.5 and a probability of 0.3; Step S1-5: The image is converted to grayscale with a probability of 0.1; In step S2, constructing the incremental target counting network model specifically includes: The backbone network is used to extract high-level semantic information from the network input; The regression module is used to perform feature transfer on high-level semantic information to achieve regression of the target density map; The classification module uses high-level semantic information to identify the category of the network input; The incremental module adds value to the output nodes of the last regression layer of the regression module and the classification module based on the number of new categories. In step S3, the network training parameters are set, and the classification loss, sample rebalancing loss, and gradient decay loss are calculated to optimize the network parameters. The specific steps are as follows: Step S3-1: Set the necessary parameters for training; before network training, if it is in the base class learning stage, initialize the class increment target counting network model; if it is not in the base class stage, directly use the network model trained in the previous stage to initialize the network model in the current stage; during network training, skip step S3-1. Step S3-2: Feed the training data into the incremental target counting network model to obtain the first... Target density map predicted by stage network and classification results If the first The stage is not the base class stage; it will be the example set. The samples in the first The target density map is obtained from the network model trained in each stage. and classification results ; Step S3-3: Calculate the sum of classification loss, distillation loss, sample rebalancing loss, and gradient decay loss; Step S3-4: Optimize the parameters in the network model using the Adam optimizer; Step S3-3, sample rebalancing loss The details are as follows: in, Represents absolute value. This represents calculating the sum of all elements in the density plot. Indicates the first Phase 1 The predicted density map output for each sample. Indicates the first Phase 1 The label of each sample, Indicates the focus parameter, Indicates the first Modulation factor of each sample The hyperparameter representing the sample rebalancing loss, The MSE loss is calculated as follows: in This represents the total number of samples in each training batch. It represents the 2-norm.

2. The sample-balanced learning class incremental target counting modeling method according to claim 1, characterized in that, Step S3-3, gradient decay loss The details are as follows: in, Indicates the first The number of stage categories Indicates the first The weight of each output head, The hyperparameter representing the gradient decay loss, It represents the 1-norm.

3. The sample-balanced learning class incremental target counting modeling method according to claim 1, characterized in that, In step S3-3, the sum of classification loss, distillation loss, sample rebalancing loss, and gradient decay loss is calculated. The details are as follows: in, Hyperparameters representing the differences in losses, distillation loss : , in, Indicates the first Phase 1 A collection of examples The output of the predicted density map of the samples. Represents the 2-norm; Cross-entropy loss : in, Indicates the first Classification labels for each sample, Indicates the first The results of classifying each sample.

4. A sample-balanced learning-based incremental target counting device, comprising a processor and a computer program stored in a memory and executable on the processor, characterized in that: When the processor executes the program, it implements the method described in any one of claims 1-3.

Citation Information

Patent Citations

  • Model distillation method and device, electronic equipment and storage medium

    CN111738436A

  • Target detection method and device based on incremental learning

    CN113205142A