A training method and device for an image-based target detection model
By calculating the added sample metric and target feature difference metric and automatically conducting model training, the problem of inefficient model training in the existing technology is solved, and the continuous iterative optimization and efficient optimization of the model are achieved.
Patent Information
- Application Number
- CN202111613829.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-27
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2041-12-27
AI Technical Summary
In the prior art, model training methods cannot achieve continuous iterative optimization of the model, and there is a problem of inefficiency.
By calculating the new sample number metric and the new sample target feature difference metric, the comprehensive metric is calculated. When the comprehensive metric is greater than the preset value, the model to be trained until the model is not in the process of adding new samples.
The continuous iterative optimization of the model is realized, the optimization efficiency is improved, the operability of model optimization is improved, and the training model meets the practical application needs.
Smart Images

Figure CN114511752B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a model training method and device. Background Art
[0002] Deep learning is the process of learning the inherent laws and representation levels of sample data. The information obtained in the learning process is very helpful for interpreting data such as text, images, and sounds. Its ultimate goal is to enable machines to have analytical learning capabilities like humans and to recognize data such as text, images, and sounds. Deep learning is a complex machine learning algorithm that has achieved results in speech and image recognition that far exceed related traditional technologies.
[0003] Deep learning is widely used in ADAS systems, especially deep learning algorithms based on target detection, which is the technical basis for completing various tasks such as image-based vehicle detection, pedestrian detection, lane line detection, etc. In actual applications, ADAS usage scenarios are very complex, and it is necessary to improve the generalization ability of target detection models.
[0004] In the prior art, the generalization ability of the model can be improved by training the model from the following perspectives, including data perspective, model design perspective, and model training perspective. However, in practical applications, the above model training method cannot achieve continuous iterative optimization of the model and has the problem of low efficiency. Summary of the invention
[0005] The embodiments of the present invention provide a model training method and device, which can realize continuous iterative optimization of the model and improve the optimization efficiency.
[0006] A first aspect of an embodiment of the present application provides a model training method, comprising:
[0007] When it is determined that the model to be trained is in the process of adding new samples, the number of new samples and the difference of target features of the new samples are calculated;
[0008] Calculate the comprehensive metric based on the metric of the number of newly added samples and the metric of the difference of the target characteristics of the newly added samples;
[0009] When it is determined that the comprehensive metric is greater than the first preset value, the model to be trained is trained until it is determined that the model to be trained is not in the process of adding new samples, and the model training is completed.
[0010] In a possible implementation manner of the first aspect, the newly added sample quantity metric is calculated as follows:
[0011] The initial value of the number of newly added samples is set to zero, and when it is determined that the model to be trained is in the process of adding new samples, the number of newly added samples is updated to obtain a first number of newly added samples;
[0012] When it is determined that the first number of newly added samples is greater than the second preset value, the first number of newly added samples is used as a measure of the number of newly added samples.
[0013] In a possible implementation manner of the first aspect, the target feature difference measure of the newly added samples is calculated, specifically:
[0014] When it is determined that the model to be trained is in the process of adding a new sample, a first cluster center distance between the first feature vector and the second feature vector is calculated; wherein the first feature vector is the target feature vector of the original sample, and the second feature vector is the target feature vector of the newly added sample;
[0015] When the first cluster center distance is greater than the third preset value, it is recorded as the second cluster center distance;
[0016] The number of second cluster center distances is calculated, and the number of second cluster center distances is used as a measure of the difference in target feature of the newly added samples.
[0017] In a possible implementation manner of the first aspect, after calculating the newly added sample quantity metric and the newly added sample target feature difference metric, the method further includes:
[0018] Update the original sample set according to the newly added samples.
[0019] In a possible implementation of the first aspect, determining that the model to be trained is in the process of adding a new sample is specifically:
[0020] When the model to be trained has started or is continuing to collect and label new samples, it is determined that the model to be trained is in the process of adding new samples.
[0021] A second aspect of an embodiment of the present application provides a model training device, including: a first calculation module, a second calculation module and a training module;
[0022] The first calculation module is used to calculate the number of new samples and the difference of target features of new samples when it is determined that the model to be trained is in the process of adding new samples;
[0023] The second calculation module is used to calculate the comprehensive metric based on the newly added sample quantity metric and the newly added sample target feature difference metric;
[0024] The training module is used to train the model to be trained when it is determined that the comprehensive metric is greater than a first preset value, and complete the model training when it is determined that the model to be trained is not in the process of adding new samples.
[0025] In a possible implementation manner of the second aspect, the newly added sample quantity metric is calculated as follows:
[0026] The initial value of the number of newly added samples is set to zero, and when it is determined that the model to be trained is in the process of adding new samples, the number of newly added samples is updated to obtain a first number of newly added samples;
[0027] When it is determined that the first number of newly added samples is greater than the second preset value, the first number of newly added samples is used as a measure of the number of newly added samples.
[0028] In a possible implementation manner of the second aspect, the target feature difference measure of the newly added samples is calculated, specifically:
[0029] When it is determined that the model to be trained is in the process of adding a new sample, a first cluster center distance between the first feature vector and the second feature vector is calculated; wherein the first feature vector is the target feature vector of the original sample, and the second feature vector is the target feature vector of the newly added sample;
[0030] When the first cluster center distance is greater than the third preset value, it is recorded as the second cluster center distance;
[0031] The number of second cluster center distances is calculated, and the number of second cluster center distances is used as a measure of the difference in target feature of the newly added samples.
[0032] In a possible implementation manner of the second aspect, after calculating the newly added sample quantity metric and the newly added sample target feature difference metric, the method further includes:
[0033] Update the original sample set according to the newly added samples.
[0034] In a possible implementation manner of the second aspect, determining that the model to be trained is in the process of adding a new sample is specifically as follows:
[0035] When the model to be trained has started or is continuing to collect and label new samples, it is determined that the model to be trained is in the process of adding new samples.
[0036] Compared with the prior art, an embodiment of the present invention provides a model training method and device, the method comprising: when it is determined that the model to be trained is in the process of adding new samples, calculating the new sample quantity metric and the new sample target feature difference metric; calculating the comprehensive metric based on the new sample quantity metric and the new sample target feature difference metric; when it is determined that the comprehensive metric is greater than a first preset value, training the model to be trained until it is determined that the model to be trained is not in the process of adding new samples, completing the model training.
[0037] Its beneficial effect is that: when the embodiment of the present invention is in the process of adding new samples, after calculating the comprehensive metric based on the new sample metric and the new sample target feature difference metric, the model is trained when the comprehensive metric is greater than the preset value; that is, when the new sample meets the preset conditions, the embodiment of the present invention can automatically perform model training until no more samples are added, and then the model training ends. As long as the model is in the process of adding new samples and the new samples meet the preset conditions, the model is continuously trained, which can achieve continuous iterative optimization of the model, improve optimization efficiency, improve the operability of model optimization, and ensure that the trained model meets the actual application needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 It is a flowchart of a model training method provided by one embodiment of the present invention;
[0039] Figure 2 is a schematic diagram of a new sample quantity measurement calculation process provided by an embodiment of the present invention;
[0040] Figure 3 1 is a schematic diagram of a calculation process for measuring the difference of target features of new samples provided by an embodiment of the present invention;
[0041] Figure 4 It is a schematic diagram of a specific process of a training model provided by an embodiment of the present invention;
[0042] Figure 5 It is a structural schematic diagram of a model training device provided by one embodiment of the present invention. DETAILED DESCRIPTION
[0043] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0044] Reference Figure 1 , is a flow chart of a model training method provided by an embodiment of the present invention, including S101-S103:
[0045] S101: When it is determined that the model to be trained is in the process of adding new samples, a measure of the number of new samples and a measure of the difference of target features of the new samples are calculated.
[0046] The models to be trained include target detection models such as Faster R-CNN, SSD and YOLO.
[0047] In this embodiment, the calculation of the newly added sample quantity metric is specifically as follows:
[0048] The initial value of the number of newly added samples is set to zero, and when it is determined that the model to be trained is in the process of adding new samples, the number of newly added samples is updated to obtain a first number of newly added samples;
[0049] When it is determined that the first number of newly added samples is greater than a second preset value, the first number of newly added samples is used as the metric of the number of newly added samples.
[0050] In this embodiment, the calculation of the difference measure of the target feature of the newly added samples is specifically as follows:
[0051] When it is determined that the model to be trained is in the process of adding a new sample, a first cluster center distance between the first feature vector and the second feature vector is calculated; wherein the first feature vector is a target feature vector of the original sample, and the second feature vector is a target feature vector of the newly added sample;
[0052] When the first cluster center distance is greater than a third preset value, it is recorded as a second cluster center distance;
[0053] The number of the second cluster center distances is calculated, and the number of the second cluster center distances is used as a measure of the difference of the target features of the newly added samples.
[0054] In this embodiment, after calculating the newly added sample quantity metric and the newly added sample target feature difference metric, the following step is also included:
[0055] Update the original sample set according to the newly added samples.
[0056] In a specific embodiment, the step of determining that the model to be trained is in the process of adding new samples is as follows:
[0057] When the model to be trained has started or is continuing to collect and label new samples, it is determined that the model to be trained is in the process of adding new samples.
[0058] S102: Calculate a comprehensive metric based on the newly added sample quantity metric and the newly added sample target feature difference metric.
[0059] Furthermore, the calculation process of the comprehensive metric is as follows:
[0060] p = a*n+(1-a)*m;
[0061] Among them, p is a comprehensive measure, n is a measure of the number of newly added samples, m is a measure of the difference in target features of newly added samples, a∈(0, 1), and a can be adjusted according to actual needs.
[0062] S103: When it is determined that the comprehensive metric is greater than a first preset value, the model to be trained is trained until it is determined that the model to be trained is not in the process of adding new samples, and the model training is completed.
[0063] To further illustrate the specific process of calculating the number of new samples, please refer to Figure 2 , Figure 2 It is a schematic diagram of a new sample quantity measurement calculation process provided by an embodiment of the present invention.
[0064] S201: setting the initial value of the number of newly added samples to zero;
[0065] S202: Determine whether a new sample is being added, if so, proceed to S203; if not, end;
[0066] S203: Update the number of newly added samples to obtain a first number of newly added samples;
[0067] S204: Determine whether the first newly added sample quantity is greater than the second preset value, if so, proceed to S205; if not, return to S202;
[0068] S205: after taking the first newly added sample quantity as the newly added sample quantity measurement, the value of the first newly added sample quantity is set to zero;
[0069] S206: adding the newly added samples to the original sample set;
[0070] S207: Calculate the comprehensive metric based on the newly added sample quantity metric, and after training the model, return to step 202.
[0071] To further illustrate the specific process of calculating the difference measure of the target features of the newly added samples, please refer to Figure 3 , Figure 3 It is a schematic diagram of a calculation process of a new sample target feature difference metric provided by an embodiment of the present invention.
[0072] S301: Determine whether a new sample is being added, if yes, proceed to S302; if no, end;
[0073] S302: Calculate the first cluster center distance between the target feature vector of the original sample and the target feature vector of the newly added sample;
[0074] The first cluster center distance between the target feature vector of the original sample and the target feature vector of the newly added sample is calculated as follows:
[0075] Calculate the first statistical distribution characteristic of the target feature vector of the original sample; calculate the second statistical distribution characteristic of the target feature vector of the newly added sample; and calculate the first cluster center distance between the target feature vector of the original sample and the target feature vector of the newly added sample based on the first statistical distribution characteristic and the second statistical distribution characteristic.
[0076] S303: Determine whether the first cluster center distance is greater than a third preset value, if so, proceed to S304; if not, return to step S301;
[0077] S304: Recording the first cluster center distance greater than the third preset value as the second cluster center distance, calculating the number of the second cluster center distances, and using the number of the second cluster center distances as a measure of the difference of the target features of the newly added samples;
[0078] S305: adding the newly added samples to the original sample set;
[0079] S306: After calculating the comprehensive metric based on the new sample target feature difference metric, train the model and return to step 301.
[0080] To further illustrate the specific process of training a model based on a comprehensive metric, please refer to Figure 4 , Figure 4 It is a schematic diagram of a specific process of a training model provided by an embodiment of the present invention.
[0081] S401: Determine whether a new sample is being added, if so, proceed to S402; if not, end;
[0082] S402: Calculate a comprehensive metric based on the newly added sample quantity metric and the newly added sample target feature difference metric;
[0083] S403: Determine whether the comprehensive metric is greater than a first preset value, if so, proceed to S404; if not, return to S401;
[0084] S404: Add the newly added samples to the original sample set and train the model, and return to step 401.
[0085] For further explanation of the model training setup, please refer to Figure 5 , Figure 5 It is a structural diagram of a model training device provided by an embodiment of the present invention, including: a first calculation module 501, a second calculation module 502 and a training module 503.
[0086] The first calculation module 501 is used to calculate the number metric of new samples and the difference metric of target features of new samples when it is determined that the model to be trained is in the process of adding new samples.
[0087] In this embodiment, the calculation of the newly added sample quantity metric is specifically as follows:
[0088] The initial value of the number of newly added samples is set to zero, and when it is determined that the model to be trained is in the process of adding new samples, the number of newly added samples is updated to obtain a first number of newly added samples;
[0089] When it is determined that the first number of newly added samples is greater than a second preset value, the first number of newly added samples is used as the metric of the number of newly added samples.
[0090] In this embodiment, the calculation of the difference measure of the target feature of the newly added samples is specifically as follows:
[0091] When it is determined that the model to be trained is in the process of adding a new sample, a first cluster center distance between the first feature vector and the second feature vector is calculated; wherein the first feature vector is a target feature vector of the original sample, and the second feature vector is a target feature vector of the newly added sample;
[0092] When the first cluster center distance is greater than a third preset value, it is recorded as a second cluster center distance;
[0093] The number of the second cluster center distances is calculated, and the number of the second cluster center distances is used as a measure of the difference of the target features of the newly added samples.
[0094] In this embodiment, after calculating the newly added sample quantity metric and the newly added sample target feature difference metric, the following step is also included:
[0095] Update the original sample set according to the newly added samples.
[0096] In a specific embodiment, the step of determining that the model to be trained is in the process of adding new samples is as follows:
[0097] When the model to be trained has started or is continuing to collect and label new samples, it is determined that the model to be trained is in the process of adding new samples.
[0098] The second calculation module 502 is used to calculate a comprehensive metric based on the newly added sample quantity metric and the newly added sample target feature difference metric;
[0099] The training module 503 is used to train the model to be trained when it is determined that the comprehensive metric is greater than a first preset value, and complete the model training when it is determined that the model to be trained is not in the process of adding new samples.
[0100] In the embodiment of the present invention, the first calculation module first calculates the new sample quantity metric and the new sample target feature difference metric when determining that the model to be trained is in the process of adding new samples; then the second calculation module calculates the comprehensive metric based on the new sample quantity metric and the new sample target feature difference metric; finally, the training module trains the model to be trained when determining that the comprehensive metric is greater than a first preset value, until it is determined that the model to be trained is not in the process of adding new samples, and the model training is completed.
[0101] In the process of adding new samples, the embodiment of the present invention calculates the comprehensive metric based on the new sample metric and the new sample target feature difference metric, and then trains the model when the comprehensive metric is greater than a preset value; that is, the embodiment of the present invention can automatically perform model training when the new samples meet the preset conditions, and end the model training until no more samples are added. As long as the model is in the process of adding new samples and the new samples meet the preset conditions, the model is continuously trained, which can achieve continuous iterative optimization of the model, improve optimization efficiency, improve the operability of model optimization, and ensure that the trained model meets the actual application needs.
[0102] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A training method for an image-based target detection model, characterized in that: include: When it is determined that the model to be trained is in the process of adding new samples, the number of new samples and the difference of target features of the new samples are calculated; The model to be trained is a target detection model, wherein the calculation of the measure of the number of newly added samples is specifically as follows: setting the initial value of the number of newly added samples to zero, and when it is determined that the model to be trained is in the process of adding new samples, updating the number of newly added samples to obtain a first number of newly added samples; when it is determined that the first number of newly added samples is greater than a second preset value, using the first number of newly added samples as the measure of the number of newly added samples; the calculation of the measure of the difference in target features of the newly added samples is specifically as follows: when it is determined that the model to be trained is in the process of adding new samples, calculating a first cluster center distance between a first feature vector and a second feature vector; wherein the first feature vector is a target feature vector of the original sample, and the second feature vector is a target feature vector of the newly added sample; when the first cluster center distance is greater than a third preset value, it is recorded as a second cluster center distance; calculating the number of the second cluster center distances, and using the number of the second cluster center distances as the measure of the difference in target features of the newly added samples; Calculating a comprehensive metric based on the newly added sample quantity metric and the newly added sample target feature difference metric; When it is determined that the comprehensive metric is greater than a first preset value, the model to be trained is trained until it is determined that the model to be trained is not in the process of adding new samples, and the model training is completed.
2. The method for training an image-based target detection model according to claim 1, characterized in that: After calculating the newly added sample quantity metric and the newly added sample target feature difference metric, the method further includes: Update the original sample set according to the newly added samples.
3. The method for training an image-based target detection model according to claim 1, characterized in that: The determination that the model to be trained is in the process of adding new samples is specifically as follows: When the model to be trained has started or is continuing to collect and label new samples, it is determined that the model to be trained is in the process of adding new samples.
4. A training device for an image-based target detection model, characterized in that: include: A first computing module, a second computing module and a training module; Wherein, the first calculation module is used to calculate the new sample quantity metric and the new sample target feature difference metric when it is determined that the model to be trained is in the process of adding new samples; the model to be trained is a target detection model, wherein the calculation of the new sample quantity metric is specifically: the initial value of the new sample quantity is set to zero, and when it is determined that the model to be trained is in the process of adding new samples, the new sample quantity is updated to obtain a first new sample quantity; when it is determined that the first new sample quantity is greater than a second preset value, the first new sample quantity is used as the new sample quantity metric; the calculation of the new sample target feature difference metric is specifically: when it is determined that the model to be trained is in the process of adding new samples, the first cluster center distance between the first feature vector and the second feature vector is calculated; wherein the first feature vector is the target feature vector of the original sample, and the second feature vector is the target feature vector of the new sample; when the first cluster center distance is greater than a third preset value, it is recorded as the second cluster center distance; the number of the second cluster center distance is calculated, and the number of the second cluster center distance is used as the new sample target feature difference metric; The second calculation module is used to calculate a comprehensive metric based on the newly added sample quantity metric and the newly added sample target feature difference metric; The training module is used to train the model to be trained when it is determined that the comprehensive metric is greater than a first preset value, and complete the model training when it is determined that the model to be trained is not in the process of adding new samples.
5. The training device for an image-based target detection model according to claim 4, characterized in that: After calculating the newly added sample quantity metric and the newly added sample target feature difference metric, the method further includes: Update the original sample set according to the newly added samples.
6. The training device for an image-based target detection model according to claim 4, characterized in that: The determination that the model to be trained is in the process of adding new samples is specifically as follows: When the model to be trained has started or is continuing to collect and label new samples, it is determined that the model to be trained is in the process of adding new samples.
Citation Information
Patent Citations
Model training method, device and equipment
CN109800798A
Target detection model training method and system, terminal equipment and storage medium
CN112580734A