Target detection model training method and system and storage medium
By using adaptive probability as a label in the object detection model training, adjusting the score label of the target box, the problem of overfitting in the prior art is solved, and a more continuous and interpretable model confidence score is achieved.
Patent Information
- Application Number
- CN202411689568.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-03-14
AI Technical Summary
Existing object detection models are prone to overfitting problems during training, which leads to large and discontinuous scores when the model detects targets with blurred features, occlusion or misaligned proportions, increasing the risk of misidentification.
By using the adaptive probability as a label for model training, the initial score value of the target box is adjusted to form a preliminary score label, and the initial score label is adjusted through the inference score label to obtain the final score label to reduce overfitting.
It effectively reduces the overfitting phenomenon, so that the training model confidence score has better interpretable significance and continuity, and reduces the jumpability of the score.
Smart Images

Figure CN119625458A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of deep learning target detection, and in particular to a target detection model training method, system and storage medium. Background Art
[0002] Object detection is an important task in the field of computer vision, which aims to identify and locate the target objects of interest from images or videos. With the rapid development of deep learning technology, object detection algorithms have made significant progress and have been widely used in fields such as autonomous driving, intelligent security, and face recognition.
[0003] Traditional target detection algorithms use feature extractors to extract fixed features, such as Haar features, HOG (histogram of gradients) and LBP (local binary pattern features), etc. These features can detect targets by describing local texture, shape and other information of the image.
[0004] In recent years, with the rise of deep learning technology, deep learning-based object detection algorithms have gradually become mainstream. This type of method automatically learns feature representations in images by training convolutional neural networks (CNNs) and achieves accurate detection of targets. The main advantages of modern methods are their powerful feature representation and generalization capabilities, which can handle complex and changing target morphologies and background environments. Specifically, deep learning-based object detection algorithms can be divided into two categories: one-stage detectors and two-stage detectors. One-stage detectors such as YOLO (You Only Look Once) and SSD (Single Shot MultiBox Detector) achieve fast object detection by directly setting a large number of predefined anchor boxes on the image and predicting their categories and positions. Two-stage detectors such as Faster R-CNN (Faster Region-based Convolutional Neural Network) first generate a series of candidate regions through a region proposal network (RPN), and then classify and regress each candidate region to achieve more accurate object detection. Summary of the invention
[0005] In view of the problems existing in the prior art, a target detection model training method, system and storage medium are provided, which effectively solve the problem of overfitting by using adaptive probability as label for model training.
[0006] The first aspect of the present invention provides a target detection model training method, comprising:
[0007] Obtain the image data and label files in the existing training set, and calculate the mean and variance of the aspect ratio, area, and norm value of each type of target box in the label file;
[0008] Traverse the aspect ratio, area, and norm value of the target frame respectively and compare them with the mean and variance of the target frame of this type. Adjust the initial score of the target frame according to the comparison results to form a preliminary score label.
[0009] Use the preliminary score labels for preliminary training to obtain the inference score labels of each target box, and use the inference score labels to adjust the preliminary score labels to obtain the final score labels;
[0010] The final score label is used as the target value for regression to complete the target detection model training.
[0011] As a preferred solution, the specific process of forming the preliminary score label includes:
[0012] Generate an initial target box score;
[0013] Traverse the information in the label file and determine the aspect ratio of the target frame and the r of the target frame of this type. m -k*r d Or r of this type of target box m +k*r d , adjust the target frame score;
[0014] Traverse the information in the label file and judge the area of the target box and the a of the target box of this type m -k*a d Or a of this type of target box m +k*a d , adjust the target frame score;
[0015] Traverse the information in the label file and judge the norm value ratio of the target box to the target box n of this type. m -k*n d Or n of this type of target box m +k*n d , adjust the target frame score;
[0016] The target frame score obtained by adjusting the aspect ratio, area and norm value is used as the preliminary score label of the target frame.
[0017] As a preferred solution, the process of obtaining the final score label includes:
[0018] The target monitoring model is trained for 300 rounds based on the preliminary score labels. The target frames inferred by the model are matched one by one with the target frames in the label file using the data of the saved model inference training set. The inference score labels of each target frame are recorded, and the final score labels are calculated based on the preliminary score labels and the inference score labels.
[0019] As a preferred solution, the final score label calculation formula is:
[0020] final score =a*score+(1-a)*score_infer
[0021] Among them, final_score is the final score label, score is the preliminary score label, a is the weight parameter, and score_infer is the inference score label.
[0022] As a preferred solution, the final score is used as the target value of regression for model training. When calculating the mean square error loss, for the true value of the sample, the negative sample value is 0, and the positive sample value is calculated to obtain the final score.
[0023] As a preferred solution, the final score is used as the target value of regression for model training. When calculating the binary cross entropy loss, for the distribution of real samples, the negative sample value is 0 and the positive sample value is calculated to obtain the final score.
[0024] A second aspect of the present invention proposes a system comprising a memory and a processor, wherein the memory stores a computer program that can be loaded by the processor and executes the target detection model training method described in the first aspect.
[0025] The third aspect of the present invention proposes a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, are used to implement a process corresponding to the target detection model training method described in the first aspect.
[0026] Compared with the prior art, the beneficial effects of adopting the above technical scheme are as follows: the present invention proposes a target detection training method with score probability as label, which can adaptively adjust the regression value of the target with relatively vague features, has a more reasonable distribution, can effectively reduce the overfitting phenomenon, and can make the confidence score of the model after training have better interpretability, and is more continuous and reduces jumps. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 This is a flow chart of the target detection model training method proposed in the present invention. DETAILED DESCRIPTION
[0028] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar modules or modules with the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be construed as limitations on the present application. On the contrary, the embodiments of the present application include all changes, modifications and equivalents that fall within the spirit and connotation of the appended claims.
[0029] Regardless of the existing target detector, during training, the confidence of the true label is considered to be 100%. In the cross entropy, 100% is taken as the true distribution of the target, and the probability of the target being the background is considered to be 0. For clear and definite targets, this is of course no problem; but for targets with fuzzy features (insufficient clarity, too small targets or severe occlusion), taking 100% as the true distribution is overfitting. The result of such training is large and discontinuous score jumps, and an increased risk of misidentification. Based on this, an embodiment of the present invention proposes a target detection model training method that uses adaptive probability as a label, that is, the calibrated target is considered to have a probability, rather than a definite value of 100%. This is more in line with objective laws. For example, if the image is blurred, occluded, or the proportions are imbalanced due to occlusion, and the features are unclear, we reduce some scores for such data to make the training smoother and less prone to overfitting. Please refer to Figure 1 , the specific plan is as follows:
[0030] Step 1: Get the image data and its label file in the training set, and count the mean and variance of the aspect ratio, area, and norm value of each type of target box in the label file.
[0031] In this step, the mean aspect ratio r of each type of target box in the existing label file is counted m , variance r d ; Area mean a m , area variance a d ; norm value mean n m , variance n d , used for subsequent adaptive score calculation.
[0032] It should be noted that the training set can be obtained from a public resource library or made by yourself. The training set contains image data and label files corresponding to the images. Generally speaking, each image in the training set corresponds to a txt file, which is the label file. The label file consists of labels that record annotation information one by one. Each label records the coordinates, width, height, and category (such as person, car, etc.) of the target box in the image.
[0033] Step 2: Traverse the mean and variance of the aspect ratio, area, and norm value respectively to form a preliminary score label.
[0034] Usually, when using the training set to train the target monitoring model, the score of each target frame in the image is set to 1, but the model obtained by fixedly setting it to 1 has overfitting phenomenon. Therefore, in this embodiment, the aspect ratio, area, and norm value data of the target frame are used to adjust the score of the corresponding target frame to form a preliminary score label. The details are as follows:
[0035] For aspect ratio: traverse the information in the label file, if the aspect ratio of the target box is smaller than the r of the target box of this type m -k*r d Or greater than the r of the target box of this type m +k*r d The label score is reduced, and the amount of reduction is related to the hyperparameter k. For example, when the hyperparameter k is 2, the label score is reduced by 0.05, and when the hyperparameter k is 3, the label score is reduced by 0.1. The specific value of the hyperparameter k is determined by the specific scenario and specific effect.
[0036] For the area and norm values, the label scores are adjusted in the same way.
[0037] For example, for area, traverse the information in the label file, if the target box area is smaller than a of the target box of this type m -k*a d Or larger than a of the target box of this type m +k*a d Then the label score is reduced; for the norm value, the information in the label file is traversed, and if the norm value of the target box is less than the n of the target box of this type m -k*n d Or greater than n of this type of target box m +k*n d The label score is reduced.
[0038] It should be noted that the final preliminary score label is the final score after the aspect ratio, area and norm value are superimposed and adjusted, and there is no restriction on the order of adjusting the aspect ratio, area and norm value.
[0039] Step 3: Use the preliminary score labels to perform preliminary training to obtain the inference score labels of each target box, and use the inference score labels to adjust the preliminary score labels to obtain the final score labels.
[0040] The target monitoring model is trained for 300 rounds based on the preliminary score labels. The target frames inferred by the model are matched with the target frames in the label file one by one using the data of the saved model inference training set. The inference score labels of each target frame are recorded and the final score labels are calculated:
[0041] final score =a*score+(1-a)*score_infer
[0042] Among them, final_score is the final score label, score is the preliminary score label, a is the weight parameter, which is set to 0.8 in this embodiment, and score_infer is the inference score label.
[0043] The calculated final score label final_score can be used as the final probability label for model training.
[0044] Step 4: Use the final score label as the target value for regression to complete the target detection model training.
[0045] In target detection, the score-related losses mainly include mean square error loss and binary cross entropy loss. In this embodiment, the calculation method of mean square error loss and binary cross entropy loss is adjusted during the model training process. Specifically,
[0046] For the mean square error loss MES, it is calculated as follows:
[0047]
[0048] Among them, y i represents the true value of the i-th sample, Represents the predicted value of the i-th sample. Generally, y i is 0 or 1. For negative samples, in this embodiment, keep y i = 0 remains unchanged, but for the positive sample y i =The score label can replace the original 1, so that a smoother mean square error score can be obtained.
[0049] Compared with the mean square error loss, the binary cross entropy loss BCE has stronger adaptability and better convergence speed. The calculation method is as follows:
[0050]
[0051] Specifically, y refers to the distribution of real samples, and usually takes 0 or 1 to represent negative samples or positive samples. In this embodiment, y is replaced by the corresponding label probability to replace the original value 1.
[0052] The target detection training method using score probability as label proposed in the present invention can adaptively adjust the regression value of the target with relatively vague features, has a more reasonable distribution, can effectively reduce the overfitting phenomenon, can make the confidence score of the trained model have better interpretable meaning, and is more continuous and reduces jumps.
[0053] An embodiment of the present invention further proposes a system, including a memory and a processor, wherein the memory stores a computer program corresponding to the target detection model training method as described above that can be loaded and executed by the processor.
[0054] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer readable medium, and the computer program includes a program code for executing the method shown in the flowchart.
[0055] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, - but not limited to - an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0056] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0057] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0058] As another aspect, the present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the target detection model training method described in the above embodiment.
[0059] As another aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by an electronic device, the electronic device implements the target detection model training method described in the above embodiment.
[0060] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.
[0061] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation methods of the present application.
[0062] For those skilled in the art, the specific meanings of the above terms in the present invention can be understood in specific situations; the drawings in the embodiments are used to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings herein can be arranged and designed in various different configurations.
[0063] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in the field can change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A target detection model training method, characterized in that: include: Obtain the image data and label files in the existing training set, and calculate the mean and variance of the aspect ratio, area, and norm value of each type of target box in the label file; Traverse the aspect ratio, area, and norm value of the target frame respectively and compare them with the mean and variance of the target frame of this type. Adjust the initial score of the target frame according to the comparison results to form a preliminary score label. Use the preliminary score labels for preliminary training to obtain the inference score labels of each target box, and use the inference score labels to adjust the preliminary score labels to obtain the final score labels; The final score label is used as the target value for regression to complete the target detection model training.
2. The target detection model training method according to claim 1, characterized in that: The specific process of forming the preliminary score label includes: Generate an initial target box score; Traverse the information in the label file and determine the aspect ratio of the target frame and the r of the target frame of this type. m -k*r d Or r of this type of target box m +k*r d , adjust the target frame score; Traverse the information in the label file and judge the area of the target box and the a of the target box of this type m -k*a d Or a of this type of target box m +k*a d , adjust the target frame score; Traverse the information in the label file and judge the norm value ratio of the target box to the target box n of this type. m -k*n d Or n of this type of target box m +k*n d , adjust the target frame score; The target frame score obtained by adjusting the aspect ratio, area and norm value is used as the preliminary score label of the target frame.
3. The target detection model training method according to claim 2, characterized in that: The process of obtaining the final score label includes: The target monitoring model is trained for 300 rounds based on the preliminary score labels. The target frames inferred by the model are matched one by one with the target frames in the label file using the data of the saved model inference training set. The inference score labels of each target frame are recorded, and the final score labels are calculated based on the preliminary score labels and the inference score labels.
4. The target detection model training method according to claim 3, characterized in that: The final score label calculation formula is: final score =a*score+(1-a)*score_infer Among them, final_score is the final score label, score is the preliminary score label, a is the weight parameter, and score_infer is the inference score label.
5. The target detection model training method according to claim 3, characterized in that: The final score is used as the target value of regression for model training. When calculating the mean square error loss, for the true value of the sample, the negative sample value is 0, and the positive sample value is calculated to obtain the final score.
6. The target detection model training method according to claim 5, characterized in that: The final score is used as the target value of regression for model training. When calculating the binary cross entropy loss, for the distribution of real samples, the negative sample value is 0, and the positive sample value is calculated to obtain the final score.
7. A system, characterized in that: It includes a memory and a processor, wherein the memory stores a computer program corresponding to the target detection model training method as described in any one of claims 1 to 6 that can be loaded and executed by the processor.
8. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the program instructions are executed by the processor, they are used to implement the process corresponding to the target detection model training method described in any one of claims 1 to 6.