Object detection model training methods, devices and electronic equipment
By calculating the crossover ratio and class probability to determine sample weights and adjusting the loss function, the problem of undifferentiated sample importance in existing technologies is solved, and higher-precision target detection model training is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN XUMI YUNTU SPACE TECH CO LTD
- Filing Date
- 2022-10-20
- Publication Date
- 2026-05-26
Smart Images

Figure CN115661520B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, apparatus and electronic device for training a target detection model. Background Technology
[0002] With the continuous development of science and technology, computer vision technology has also developed rapidly. Among them, object detection technology is an important branch of computer vision technology. Object detection refers to detecting the location of each preset category of target object in the image to be detected and determining the specific classification of each target object. Therefore, object detection technology has broad application prospects in fields such as face recognition, vehicle recognition, and dynamic tracking.
[0003] In current mainstream object detection technologies, regression loss and classification loss are used to guide the training of object detection models. The regression loss employs smooth regression, treating regression as an independent task without distinguishing the importance of samples. Similarly, the classification loss treats classification as an independent task, with sample importance only related to classification probability and unrelated to regression performance. Therefore, existing training methods for object detection models reduce training effectiveness, resulting in lower accuracy. Summary of the Invention
[0004] In view of this, embodiments of this application provide a method, apparatus, and electronic device for training an object detection model, in order to solve the problems of reduced training effect and low accuracy of the trained object detection model in the prior art.
[0005] A first aspect of this application provides a method for training an object detection model, comprising: acquiring sampled positive samples, wherein the positive samples contain object boxes corresponding to sample images; classifying the positive samples using a classification branch in a pre-built object detection model to obtain the class probability of each positive sample, and regressing the positive samples using a regression branch to obtain the regression result of each positive sample; calculating the intersection-union ratio (IUR) of each positive sample based on the regression result and the object boxes, and determining the weight of each positive sample according to the class probability and / or IUR; adjusting the smooth regression loss in the object detection model using the weights to obtain the adjusted regression loss, and training the object detection model using the adjusted regression loss.
[0006] A second aspect of this application provides an object detection model training apparatus, comprising: a sample acquisition module configured to acquire sampled positive samples, wherein the positive samples contain object boxes corresponding to sample images; a classification and regression module configured to classify the positive samples using a classification branch in a pre-built object detection model to obtain the class probability of each positive sample, and to regress the positive samples using a regression branch to obtain the regression result of each positive sample; a calculation and determination module configured to calculate the intersection-union ratio (IUR) corresponding to each positive sample based on the regression result and the object boxes, and to determine the weight corresponding to each positive sample based on the class probability and / or IUR; and a training adjustment module configured to adjust the smooth regression loss in the object detection model using the weights to obtain the adjusted regression loss, and to train the object detection model using the adjusted regression loss.
[0007] A third aspect of this application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the above-described method.
[0008] The above-described technical solutions adopted in the embodiments of this application can achieve the following beneficial effects:
[0009] By acquiring positive samples from sampling, each positive sample contains the target bounding box corresponding to the sample image; classifying the positive samples using the classification branch of a pre-built object detection model to obtain the class probability of each positive sample; and regressing the positive samples using the regression branch to obtain the regression result for each positive sample; based on the regression result and the target bounding box, calculating the intersection-over-union ratio (IoU) for each positive sample; and determining the weight corresponding to each positive sample based on the class probability and / or IoU; adjusting the smoothing regression loss in the object detection model using the weights to obtain the adjusted regression loss; and using the adjusted regression loss to train the object detection model. This application improves the training effect of the object detection model by adjusting and improving the original regression loss and classification loss, and uses the improved regression loss and classification loss to guide the training of the object detection model, thereby obtaining a more accurate object detection model. Attached Figure Description
[0010] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1 This is a flowchart illustrating the target detection model training method provided in the embodiments of this application;
[0012] Figure 2 This is a schematic diagram of the structure of the target detection model training device provided in the embodiments of this application;
[0013] Figure 3 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0014] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0015] In current mainstream object detection technologies, regression loss and classification loss are used to guide the training of object detection models. Regression loss employs smooth regression, treating regression as an independent task without distinguishing sample importance. Similarly, classification loss (such as Focal loss) treats classification as an independent task, where sample importance is only related to classification probability and not to regression performance. Therefore, existing training methods for object detection models reduce training effectiveness, resulting in lower accuracy.
[0016] In view of this, this application addresses the problems of regression loss and classification loss in mainstream object detection technologies by using the intersection-union ratio (IU / Classification Probability) to guide smoothing regression loss, making the loss positively correlated with the regression and classification abilities of the samples; and by using IU / Centrality to guide classification loss, ensuring that the weight of the classification loss is not only derived from the classification ability itself, but also receives weighted guidance from the regression ability. Using the improved loss function of this application, the two major sub-tasks of detection (i.e., regression and classification tasks) are treated uniformly, which can further improve model accuracy.
[0017] Figure 1 This is a flowchart illustrating the target detection model training method provided in the embodiments of this application. Figure 1 The training method for the object detection model can be executed by the server. For example... Figure 1 As shown, the training method for this object detection model can specifically include:
[0018] S101, Obtain the positive samples obtained from sampling, where the positive samples contain the target bounding boxes corresponding to the sample images;
[0019] S102, use the classification branch in the pre-built target detection model to classify the positive samples and obtain the class probability of each positive sample. Use the regression branch to regress the positive samples and obtain the regression result of each positive sample.
[0020] S103, Based on the regression results and the target box, calculate the crossover ratio (CR) for each positive sample, and determine the weight of each positive sample according to the class probability and / or CR;
[0021] S104. Adjust the smooth regression loss in the object detection model using weights to obtain the adjusted regression loss, and use the adjusted regression loss to train the object detection model.
[0022] Specifically, the object detection model in this application embodiment can employ a single-stage object detector or a multi-stage object detector. A single-stage object detector extracts feature maps of different scales from the model's backbone network, performs a series of feature fusion operations, and then simultaneously classifies and regresses the predicted bounding boxes. Single-stage object detectors include, but are not limited to, the YOLO (You Only Look Once) model, the RetinaNet model, the Fully Convolutional One-Stage Object Detection (FCOS) model, the CenterNet model, the EfficientDet model, and so on.
[0023] Multi-stage object detectors use multi-level Region Proposal Networks (RPNs) to gradually mitigate the positive and negative sample distribution by differentiating between foreground and background. Finally, they perform refined object classification and prediction on the effective foreground regions (ROIs). Multi-stage object detectors include, but are not limited to, Faster R-CNN models, cascaded R-CNN network models, and hybrid task cascaded models.
[0024] Furthermore, in mainstream deep learning-based multi-object detection tasks, the detection head typically has a regression branch and a classification branch, which perform regression and classification on anchor points or anchor boxes, respectively. The classification task is responsible for classifying anchor points or anchor boxes into multiple categories, while the regression task is responsible for regressing the positional deviation values (x, y, h, w) of the anchor point or anchor box, representing the position coordinates x and y of the center point and the height h and width w of the detection box, respectively.
[0025] In some embodiments, in object detection tasks, the regression branch is typically supervised using smooth L1 loss, as shown in the formula:
[0026] 0.5*x2 if|x|<1
[0027] |x|-0.5 otherwise
[0028] In smoothed L1 loss, when the regression positional bias is less than 1, "squared loss" is used; otherwise, "single-order loss" is used. Smoothed L1 loss is a general regression loss, and object detection tasks directly use this loss, treating regression as an independent task and ignoring the fact that classification and regression influence each other in detection tasks. Secondly, different samples have different levels of importance.
[0029] In some embodiments, during batch training, it is assumed that K positive samples are obtained, each with its corresponding ground truth (GT). The classification branch of the detector head classifies these K samples, obtaining the class probability p for each sample. i The regression branch performs regression on these K samples, obtaining the regression result (predbbox) for each sample. The regression result can be used to calculate the intersection-over-union (IoU) with the target bounding box. The IoU for each sample is u. i The intersection-union ratio (IUGR) is the ratio between the intersection and the union of two target boxes b1 and b2. The intersection and union of these two boxes are calculated separately, and then the ratio between them is calculated.
[0030] Specifically, in one optional example, the weight corresponding to each positive sample is determined based on the crossover-union ratio (CUI), including calculating the weight using the following formula:
[0031]
[0032] Among them, v i u represents the weight corresponding to each positive sample. i σ represents the crossover ratio (CRO) for each positive sample, U represents the adjustment factor, and U represents the average of all historically calculated CROs. This represents the average crossover / union ratio of the current batch.
[0033] Specifically, in regression tasks, the importance of a sample is positively correlated with the crossover ratio (CUP) and also with the class probability.
[0034] In the above weighting formula, the denominator is the moving average of the cross-union ratios (CUPRs) of all positive samples. The first term in the denominator, U, represents the historical average CUPR, and σ is an adjustment factor, which can be set to 0.9. The second term in the denominator is the average CUPR of the current batch, and the numerator is the CUPR of each positive sample. The weighting formula for positive samples actually characterizes the regression ability of that positive sample in the current batch; the stronger the regression ability, the greater the weight.
[0035] However, the above weight calculation formula only considers the intersection-union ratio of positive samples. The importance of a sample (i.e., weight) is not only positively correlated with the intersection-union ratio of the samples, but also related to the class probability. Therefore, in calculating the weight of positive samples, the embodiments of this application also introduce the class probability.
[0036] In some optional implementations of this embodiment, the weight corresponding to each positive sample is determined based on the class probability and the intersection-union ratio, including calculating the weight using the following formula:
[0037]
[0038] Among them, v i u represents the weight corresponding to each positive sample. i σ represents the crossover ratio (CRO) for each positive sample, U represents the adjustment factor, and U represents the average of all historically calculated CROs. p represents the average crossover / union ratio of the current batch. i This represents the class probability of each positive sample.
[0039] Specifically, based on the first weight calculation formula mentioned above, this embodiment of the application can also use the class probability corresponding to each positive sample as the exponent term p. i This is added to the weight calculation formula. In other words, when the intersection-union ratio of positive samples remains constant, the classification probability p... i The higher the value, the greater the weight of the sample. The calculated weight of the positive sample is used as the "joint guidance weight of intersection-union ratio and classification probability" for that sample, and the original smoothed L1 loss is adjusted using the "joint guidance weight of intersection-union ratio and classification probability".
[0040] Furthermore, in an optional example, the smoothed regression loss employs a smoothed L1 loss function, adjusting the smoothed regression loss in the object detection model using weights, including adjusting the smoothed L1 loss function using the following formula:
[0041] v i 2 *(0.5*x 2 if|x|<1
[0042] v i *(|x|-0.5) otherwise
[0043] Among them, v i This represents the weight corresponding to each positive sample. When the positional deviation of the regression is less than 1, the squared loss is used; when the positional deviation of the regression is not less than 1, the single loss is used.
[0044] Specifically, the weights of the "intersection over union ratio - classification probability joint guidance" are added to the original smooth regression loss (i.e., smooth L1 loss function), and the smooth L1 loss function is adjusted to obtain the improved smooth regression loss function. This improved smooth regression loss function is then used to guide the training of the object detection model, thereby improving the training effect and detection accuracy of the object detection model.
[0045] The above embodiments provide a detailed explanation of the adjustment process of the smoothed L1 loss function in the object detection model using category probability and / or intersection-union ratio (IU). In addition to improving the smoothed L1 loss function using the "joint guidance of IU-classification probability" weights, this application also proposes a classification loss using the "joint guidance of IU-centrality". The adjustment process of the original classification loss is explained in detail below with reference to specific embodiments.
[0046] In some embodiments, after determining the weight corresponding to each positive sample, the method further includes: determining the sample centrality corresponding to each positive sample, and determining the relative centrality of each target box in the positive sample based on the sample centrality; adjusting the classification loss in the object detection model using the weight corresponding to each positive sample and the relative centrality of each target box in the positive sample to obtain the adjusted classification loss, and training the object detection model using the adjusted classification loss.
[0047] Specifically, the classification loss in detection generally uses the Focal loss function. The formula is:
[0048] loss = -(1-p t ) τ *log(p t )
[0049] The Focal loss function is used in mainstream classification tasks and is an improvement on the cross-entropy loss function, used for identifying hard examples. However, directly applying the Focal loss function to object detection ignores the interaction between regression and classification. In object detection classification tasks, the importance of a sample is related to its regression ability; therefore, the weight calculation formula can be directly reused.
[0050]
[0051] Considering that the correlation with specific samples is greater in classification tasks, the formula is improved as follows:
[0052]
[0053] In this formula, α takes the value 0.6 and σ takes the value 0.7.
[0054] Specifically, in one optional example, the sample centrality for each positive sample is determined using the following formula:
[0055]
[0056] Among them, c i Let l represent the sample centrality of each positive sample, l represent the distance between the sample center point and the left boundary of the target box, r represent the distance between the sample center point and the right boundary of the target box, t represent the distance between the sample center point and the top boundary of the target box, and b represent the distance between the sample center point and the bottom boundary of the target box.
[0057] Furthermore, in an optional example, the relative centrality of each target box in the positive samples is determined based on the sample centrality, including calculating the relative centrality using the following formula:
[0058]
[0059] Among them, ct i c represents the relative centrality of each bounding box. i The mean(∑) represents the sample centrality of each positive sample. j c j ) represents the average centrality of each category.
[0060] In the formula for calculating the relative centrality of the target box (i.e., the anchor box), the relative centrality ct of each anchor box is obtained by dividing the centrality of the specific sample by the average centrality of the class, based on the calculated centrality of each positive sample and the average centrality of each class. i .
[0061] In some embodiments, after calculating the relative centrality of each anchor box, the classification loss function is adjusted based on the weights corresponding to each positive sample and the relative centrality of each anchor box, resulting in a classification loss function that utilizes the "cross-over-union ratio-centrality joint guidance". In practical applications, the classification loss uses the Focal loss function, adjusting the classification loss in the object detection model using the weights corresponding to each positive sample and the relative centrality of each target box in the positive sample. This adjustment includes using the following formula to adjust the Focal loss function:
[0062]
[0063] Among them, w i ct represents the weight corresponding to each positive sample. i p represents the relative centrality of each bounding box. t This represents the class probability of each positive sample.
[0064] Specifically, the adjusted Focal loss function is used as the classification loss function of the "crossover ratio-centrality joint guidance", and then the classification loss function of the "crossover ratio-centrality joint guidance" is used to guide the training of the object detection model.
[0065] According to the technical solution provided in the embodiments of this application, this application proposes a smooth regression loss jointly guided by "Intersection over Union (IoU) and classification probability" and a classification loss jointly guided by "IoU and centrality". By using IoU and classification probability to guide the smooth regression loss, the loss is positively correlated with the regression ability and classification ability of the samples; by using IoU and centrality to guide the classification loss, the weight of the classification loss is not only derived from the classification ability itself, but also receives weighted guidance from the regression ability. Using the adjusted loss function of the embodiments of this application to train the object detection model, by treating the two major sub-tasks of detection in a unified manner, the training of the object detection model can be better guided, resulting in a more accurate object detection model.
[0066] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.
[0067] Figure 2 This is a schematic diagram of the structure of the target detection model training device provided in the embodiments of this application. Figure 2 As shown, the target detection model training device includes:
[0068] The sample acquisition module 201 is configured to acquire positive samples obtained from sampling, and the positive samples contain the target bounding boxes corresponding to the sample images;
[0069] The classification and regression module 202 is configured to classify positive samples using the classification branch in the pre-built object detection model to obtain the class probability of each positive sample, and to regress the positive samples using the regression branch to obtain the regression result of each positive sample.
[0070] The calculation and determination module 203 is configured to calculate the crossover ratio (CR) for each positive sample based on the regression results and the target box, and determine the weight for each positive sample based on the class probability and / or CR.
[0071] The training module 204 is adjusted to adjust the smooth regression loss in the object detection model using weights, resulting in an adjusted regression loss, which is then used to train the object detection model.
[0072] In some embodiments, Figure 2 The calculation and determination module 203 determines the weight corresponding to each positive sample based on the intersection-union ratio, including calculating the weight using the following formula:
[0073]
[0074] Among them, v i u represents the weight corresponding to each positive sample. i σ represents the crossover ratio (CRO) for each positive sample, U represents the adjustment factor, and U represents the average of all historically calculated CROs. This represents the average crossover / union ratio of the current batch.
[0075] In some embodiments, Figure 2 The calculation and determination module 203 determines the weight corresponding to each positive sample based on the class probability and the intersection-union ratio, including calculating the weight using the following formula:
[0076]
[0077] Among them, v i u represents the weight corresponding to each positive sample. i σ represents the crossover ratio (CRO) for each positive sample, U represents the adjustment factor, and U represents the average of all historically calculated CROs. p represents the average crossover / union ratio of the current batch. i This represents the class probability of each positive sample.
[0078] In some embodiments, the smooth regression loss uses the smooth L1 loss function. Figure 2 The training module 204 adjusts the smooth regression loss in the object detection model using weights, including adjusting the smooth L1 loss function using the following formula:
[0079] v 2 *(0.5*x 2 if|x|<1
[0080] v*(|x|-0.5) otherwise
[0081] Among them, v i This represents the weight corresponding to each positive sample. When the positional deviation of the regression is less than 1, the squared loss is used; when the positional deviation of the regression is not less than 1, the single loss is used.
[0082] In some embodiments, Figure 2 After determining the weights corresponding to each positive sample, the adjustment training module 204 determines the sample centrality corresponding to each positive sample and determines the relative centrality of each target box in the positive sample based on the sample centrality. Using the weights corresponding to each positive sample and the relative centrality of each target box in the positive sample, the classification loss in the object detection model is adjusted to obtain the adjusted classification loss. The adjusted classification loss is then used to train the object detection model.
[0083] In some embodiments, Figure 2 The training module 204 uses the following formula to determine the sample centrality for each positive sample:
[0084]
[0085] Among them, c i Let l represent the sample centrality of each positive sample, l represent the distance between the sample center point and the left boundary of the target box, r represent the distance between the sample center point and the right boundary of the target box, t represent the distance between the sample center point and the top boundary of the target box, and b represent the distance between the sample center point and the bottom boundary of the target box.
[0086] In some embodiments, Figure 2 The adjustment training module 204 determines the relative centrality of each target box in the positive samples based on the sample centrality, including calculating the relative centrality using the following formula:
[0087]
[0088] Among them, ct i c represents the relative centrality of each bounding box. i The mean(∑) represents the sample centrality of each positive sample. j c j ) represents the average centrality of each category.
[0089] In some embodiments, the classification loss uses the Focal loss function. Figure 2 The training module 204 adjusts the classification loss in the object detection model using the weights corresponding to each positive sample and the relative centrality of each target box in the positive sample. This includes adjusting the Focal loss function using the following formula:
[0090]
[0091] Among them, w i ct represents the weight corresponding to each positive sample. i This represents the relative centrality of each target box.
[0092] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0093] Figure 3 This is a schematic diagram of the structure of the electronic device 3 provided in an embodiment of this application. Figure 3As shown, the electronic device 3 of this embodiment includes a processor 301, a memory 302, and a computer program 303 stored in the memory 302 and executable on the processor 301. When the processor 301 executes the computer program 303, it implements the steps in the various method embodiments described above. Alternatively, when the processor 301 executes the computer program 303, it implements the functions of each module / unit in the various device embodiments described above.
[0094] For example, computer program 303 may be divided into one or more modules / units, which are stored in memory 302 and executed by processor 301 to complete this application. The one or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of computer program 303 in electronic device 3.
[0095] Electronic device 3 can be a desktop computer, laptop, handheld computer, cloud server, or other electronic device. Electronic device 3 may include, but is not limited to, processor 301 and memory 302. Those skilled in the art will understand that... Figure 3 This is merely an example of electronic device 3 and does not constitute a limitation on electronic device 3. It may include more or fewer components than shown, or combine certain components, or different components. For example, electronic device may also include input / output devices, network access devices, buses, etc.
[0096] Processor 301 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0097] The memory 302 can be an internal storage unit of the electronic device 3, such as a hard disk or RAM. The memory 302 can also be an external storage device of the electronic device 3, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card. Furthermore, the memory 302 can include both internal and external storage units of the electronic device 3. The memory 302 is used to store computer programs and other programs and data required by the electronic device. The memory 302 can also be used to temporarily store data that has been output or will be output.
[0098] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0099] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0100] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0101] In the embodiments provided in this application, it should be understood that the disclosed apparatus / computer devices and methods can be implemented in other ways. For example, the apparatus / computer device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. Multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0102] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0103] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0104] If an integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program may include computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added to or subtracted according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electrical carrier signals and telecommunication signals.
[0105] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A method for training an object detection model, characterized in that, include: Obtain positive samples obtained from sampling, wherein the positive samples contain the target bounding boxes corresponding to the sample images; The positive samples are classified using the classification branch of the pre-built target detection model to obtain the class probability of each positive sample, and the positive samples are regressed using the regression branch to obtain the regression result of each positive sample. Based on the regression results and the target box, the crossover ratio (CR) for each positive sample is calculated, and the weight for each positive sample is determined according to the class probability and / or the CR. The smooth regression loss in the target detection model is adjusted using the weights to obtain the adjusted regression loss, and the target detection model is trained using the adjusted regression loss. After determining the weight corresponding to each positive sample, the method further includes: Determine the sample centrality for each positive sample, and determine the relative centrality of each target box in the positive sample based on the sample centrality; The classification loss in the object detection model is adjusted using the weights corresponding to each positive sample and the relative centrality of each target box in the positive sample to obtain the adjusted classification loss. The object detection model is then trained using the adjusted classification loss.
2. The method according to claim 1, characterized in that, The weight of each positive sample is determined based on the intersection-union ratio, including calculating the weight using the following formula: in, This represents the weight corresponding to each positive sample. This represents the crossover-union ratio (CUIR) for each positive sample. Indicates the regulating factor. This represents the average of all intersection-union ratios calculated historically. This represents the average crossover / union ratio of the current batch.
3. The method according to claim 1, characterized in that, Based on the category probability and the intersection-union ratio, the weight corresponding to each positive sample is determined, including calculating the weight using the following formula: in, This represents the weight corresponding to each positive sample. This represents the crossover-union ratio (CUIR) for each positive sample. Indicates the regulating factor. This represents the average of all intersection-union ratios calculated historically. This represents the average crossover / union ratio of the current batch. This represents the class probability of each positive sample.
4. The method according to claim 1, characterized in that, The smooth regression loss uses a smoothed L1 loss function. Adjusting the smooth regression loss in the object detection model using the weights includes adjusting the smoothed L1 loss function using the following formula: if |x|<1 otherwise in, The value represents the weight of each positive sample, v represents the weight, and x represents the error between the predicted value and the true value. When the positional deviation of the regression is less than 1, the squared loss is used; when the positional deviation of the regression is not less than 1, the single loss is used.
5. The method according to claim 1, characterized in that, The sample centrality corresponding to each positive sample is determined using the following formula: in, This represents the sample centrality corresponding to each positive sample. This represents the distance between the center point of the sample and the left boundary of the target bounding box. This represents the distance between the center point of the sample and the right boundary of the target bounding box. This represents the distance between the center point of the sample and the upper boundary of the target bounding box. This represents the distance between the center point of the sample and the lower boundary of the target bounding box.
6. The method according to claim 1, characterized in that, Determining the relative centrality of each target box in the positive samples based on the sample centrality includes calculating the relative centrality using the following formula: in, This represents the relative centrality of each bounding box. This represents the sample centrality corresponding to each positive sample. This represents the average centrality of each category.
7. The method according to claim 1, characterized in that, The classification loss employs the Focal loss function. The classification loss in the object detection model is adjusted using the weights corresponding to each positive sample and the relative centrality of each target box within the positive sample. This adjustment includes using the following formula to adjust the Focal loss function: in, This represents the weight corresponding to each positive sample. This represents the relative centrality of each bounding box. This represents the class probability of each positive sample. This indicates a fixed parameter.
8. A target detection model training device, characterized in that, include: The sample acquisition module is configured to acquire positive samples obtained from sampling, wherein the positive samples contain the target bounding boxes corresponding to the sample images; The classification and regression module is configured to classify the positive samples using the classification branch in the pre-built object detection model to obtain the class probability of each positive sample, and to regress the positive samples using the regression branch to obtain the regression result of each positive sample. The calculation and determination module is configured to calculate the intersection-union ratio (IUR) for each positive sample based on the regression results and the target box, and determine the weight for each positive sample based on the class probability and / or the IUR. The training module is configured to adjust the smooth regression loss in the object detection model using the weights to obtain the adjusted regression loss, and then use the adjusted regression loss to train the object detection model. The adjustment training module is used to determine the sample centrality corresponding to each positive sample, and to determine the relative centrality of each target box in the positive sample based on the sample centrality; using the weights corresponding to each positive sample and the relative centrality of each target box in the positive sample, the classification loss in the target detection model is adjusted to obtain the adjusted classification loss, and the target detection model is trained using the adjusted classification loss.
9. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 1 to 7.