Loss function optimization method and system for improving tiny target detection performance
By modeling the elliptical bounding box of the object detection model into a two-dimensional Gaussian distribution and correcting the Wasserstein distance, the problem of scale invariance and slow convergence speed of the object detection model when positioning small targets is solved, and faster convergence and Higher detection accuracy.
Patent Information
- Application Number
- CN202411060067.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-05
- Publication Date
- 2024-12-03
AI Technical Summary
When the existing object detection model is positioned in small targets, using IoU as a loss function has problems such as missing scale invariance and slow convergence speed and unsatisfactory detection accuracy during optimization.
By modeling the elliptical bounding box of the object detection model into a two-dimensional Gaussian distribution, and correcting the Wasserstein distance and exponentially normalizing the exponential form based on the dynamic gradient gain factor, the normalized Wasserstein distance is obtained as a loss function, which is used to update the model parameter.
The target detection model's attention to small targets is improved, the dynamic joint optimization process is promoted, the detection accuracy and convergence speed are enhanced, false positives and missed reports are reduced, and the bounding box regression performance is shown.
Smart Images

Figure CN119068171A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of target detection technology, and in particular to a loss function optimization method and system for improving tiny target detection performance. Background Art
[0002] Object detection is an important task in computer vision, which aims to identify objects of predefined categories in images or videos and provide their location information. Deep learning plays a key role in object detection. In object detection, there are many object detection models based on deep learning, such as the R-CNN series (R-CNN, Fast R-CNN, Faster R-CNN, etc.), the YOLO series (YOLOv1, YOLOv2, etc.) and SSD.
[0003] The loss function is used in deep learning to measure the difference between the model's predicted value and the true value. For target detection tasks, the loss usually consists of classification loss and position regression loss. First, the classification loss deals with the problem of target recognition, that is, the accuracy of predicting the target category. Commonly used classification loss functions include Binary Cross-Entropy (BCE) and Focal Loss. Among them, Binary Cross-Entropy is mainly used for binary classification tasks, and the loss is evaluated by calculating the gap between the predicted value and the actual value; Focal Loss adds an adjustment factor on the basis of cross entropy to solve the problem of class imbalance, so that the target detection model pays more attention to samples that are difficult to classify.
[0004] Secondly, the position regression loss focuses on the accuracy of the model's prediction of the target position. Common forms include loss functions based on the intersection over union (IoU) and its variants GIoU, DIoU and CIoU, etc. These loss functions evaluate the loss by calculating the intersection over union or other geometric relationships between the predicted box and the true box, thereby promoting the accuracy of the target detection model in spatial positioning.
[0005] The total loss of the target detection model is usually the weighted sum of the classification loss and the position regression loss. This combination enables the target detection model to optimize both classification accuracy and positioning accuracy during training, ultimately improving the overall performance of target detection. Through continuous iterative training, the target detection model gradually reduces the prediction error and enhances the detection capability under the guidance of the loss function. Therefore, the loss function plays a vital role in the learning process of target detection. It not only affects the efficiency of model training, but also directly determines the final performance of the model.
[0006] However, detectors that use IoU as a loss function have shortcomings in the localization of tiny targets when detecting targets. Wasserstein distance (also known as bulldozer distance, Wasserstein distance, etc.) is used as an alternative to the loss function based on intersection over union (IoU) to measure the similarity of two bounding boxes, but Wasserstein distance lacks scale invariance, and may have slow convergence speed and unsatisfactory detection accuracy during the optimization process. Summary of the invention
[0007] The purpose of this application is to provide a loss function optimization method and system for improving the performance of small target detection, so as to solve or alleviate the problems existing in the above-mentioned prior art.
[0008] In order to achieve the above objectives, this application provides the following technical solutions:
[0009] The present application provides a loss function optimization method for improving small target detection performance, including:
[0010] Step S101, modeling an elliptical bounding box of a target detection model through a two-dimensional Gaussian distribution; wherein the target detection model is used to locate and identify a target object through the elliptical bounding box; the elliptical bounding box includes a target box and a prediction box;
[0011] Step S102: According to the model size of the elliptical bounding box, based on a preset dynamic gradient gain factor, the Wasserstein distance between the target box and the prediction box of the target detection model is corrected, and the obtained dynamic Wasserstein distance is normalized in an exponential form to obtain a normalized Wasserstein distance;
[0012] Step S103: using the normalized Wasserstein distance as a loss function to update the model parameters of the target detection model.
[0013] Preferably, in step S101, according to the formula:
[0014]
[0015] Modeling the elliptical bounding box;
[0016] Wherein, μ is the mean vector of the two-dimensional Gaussian distribution, Σ is the covariance matrix of the two-dimensional Gaussian distribution; (c x , c y ) are the center coordinates of the elliptical bounding box, w and h are the width semi-axis and height semi-axis of the elliptical bounding box respectively.
[0017] Preferably, in step S102, according to the formula:
[0018]
[0019] Determine the target box of the target detection model With prediction box The dynamic Wasserstein distance between In the formula, The target box of the target detection model With prediction box Wasserstein distance between them;
[0020] According to the formula:
[0021]
[0022] The dynamic Wasserstein distance Perform exponential normalization to obtain the normalized Wasserstein distance
[0023] Preferably, in step S103, based on the gradient descent method, the network layer weights of the target detection model are cyclically updated to minimize the loss function until the value of the loss function reaches a preset threshold or the number of cycles reaches a preset number of iterations, and the model parameter update of the target detection model is completed.
[0024] The embodiment of the present application also provides a loss function optimization system for improving the performance of small target detection, comprising: a bounding box modeling unit, configured to model an elliptical bounding box of a target detection model through a two-dimensional Gaussian distribution; wherein the target detection model is used to locate and identify a target object through the elliptical bounding box;
[0025] A normalized Wasserstein distance unit is configured to correct the Wasserstein distance between the target box and the prediction box of the target detection model according to the model size of the elliptical bounding box and based on a preset dynamic gradient gain factor, and apply exponential normalization to the obtained dynamic Wasserstein distance to obtain a normalized Wasserstein distance;
[0026] The function optimization unit is configured to use the normalized Wasserstein distance as a loss function to update the model parameters of the target detection model.
[0027] Beneficial effects:
[0028] The loss function optimization method for improving the performance of small target detection provided in the embodiment of the present application is as follows: first, the elliptical bounding box of the target detection model is modeled by a two-dimensional Gaussian distribution; then, according to the model size of the elliptical bounding box and based on a preset dynamic gradient gain factor, the Wasserstein distance between the target box and the prediction box of the target detection model is corrected, and the obtained dynamic Wasserstein distance is normalized in exponential form to obtain the normalized Wasserstein distance; finally, the normalized Wasserstein distance is used as the loss function to update the model parameters of the target detection model.
[0029] Thus, the Wasserstein distance is adjusted by a dynamic gradient gain factor of 4Σ t Normalization is performed and scale invariance is introduced to enhance its effectiveness, promote the dynamic joint optimization process, and enhance the target detection model's attention to small targets by adjusting the gradient; the normalized Wasserstein distance (Dynamic-NWD) is used as the bounding box regression loss function, which makes the target detection model have faster convergence speed and detection accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] The drawings constituting part of the present application are used to provide a further understanding of the present application. The exemplary embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. Among them:
[0031] Figure 1 A schematic flow chart of a loss function optimization method for improving small target detection performance according to some embodiments of the present application;
[0032] Figure 2 A schematic diagram of the training logic of the target detection model provided according to some embodiments of the present application;
[0033] Figure 3 A schematic diagram of the structure of a loss function optimization system for improving small target detection performance according to some embodiments of the present application. DETAILED DESCRIPTION
[0034] The present application will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments. Each example is provided by way of explanation of the present application and does not limit the present application. In fact, it will be clear to those skilled in the art that modifications and variations may be made in the present application without departing from the scope or spirit of the present application. For example, a feature shown or described as a part of an embodiment may be used in another embodiment to produce yet another embodiment. Therefore, it is desired that the present application includes such modifications and variations within the scope of the appended claims and their equivalents.
[0035] At present, deep learning-based object detection models are widely used in the field of object detection. In object detection tasks, the loss function based on intersection over union (IoU) is the first choice of most object detectors. However, due to the increased sensitivity to small object position deviations, detectors using IoU as a loss function perform poorly when detecting objects. To this end, the existing technology often uses Wasserstein distance as an alternative method to measure the similarity of Gaussian distribution bounding boxes to solve the problem that object detectors using IoU as a loss function do not perform well when detecting objects; however, the Wasserstein distance lacks scale invariance and the mechanism of Wasserstein distance used to independently optimize the center of mass may lead to slow convergence and sub-optimal detection accuracy.
[0036] Based on this, the embodiment of the present application proposes a loss function optimization method to improve the performance of small target detection, and the Wasserstein distance is optimized by a dynamic gradient gain factor 4Σ t Normalization is performed and scale invariance is introduced to enhance the effectiveness of the loss function, promote the dynamic joint optimization process, and enhance the target detection model's attention to small targets by adjusting the gradient; the normalized Wasserstein distance (Dynamic-NWD) is used as the bounding box regression (BBR) loss function, which makes the target detection model have faster convergence speed and detection accuracy.
[0037] like Figure 1 , Figure 2 As shown, the loss function optimization method for improving the small target detection performance includes:
[0038] Step S101: Model the elliptical bounding box of the target detection model through a two-dimensional Gaussian distribution.
[0039] The target detection model is used to locate and identify target objects. The training process of the target detection model (deep learning network model) is a process of continuously adjusting the model parameters by minimizing the loss function. The process mainly includes: forward propagation, loss calculation, back propagation and parameter update.
[0040] First, in the forward propagation, the target detection model receives the preprocessed input data (such as images or videos, etc.), and calculates the output result (the prediction result of the target detection model) according to the current network parameters of the target detection model (such as parameter weights, biases, etc.). In this process, the input data is passed from the input layer of the target detection model to the output layer to obtain the prediction result; at the same time, the input data is passed from the input layer to the hidden layer through weighting and biasing.
[0041] Here, the goal of forward propagation is to guide back propagation to adjust the network parameters of the target detection model by calculating the error between the output (predicted value) of the target detection model and the true value to minimize the loss function.
[0042] Secondly, the loss is calculated by calculating the loss function to quantify the difference between the predicted value and the true value of the target detection model. The loss is evaluated by the gap between the predicted value and the true value of the target detection model to measure the prediction performance of the target detection model. Through continuous iterative training, the target detection model can gradually reduce the prediction error and enhance the detection capability under the guidance of the loss function.
[0043] In this application, when performing target detection, the target detection model uses a bounding box to identify the spatial position of the target object in the input data (image or video frame, etc.) to locate and identify the target object in the input data (image or video frame, etc.). The bounding box appears in the form of a rectangular box to identify the spatial position of the target object in the input data (image or video frame, etc.).
[0044] Generally, there are two ways to represent a bounding box: one is to define it by the coordinates of the upper left corner (x1, y1) and the lower right corner (x2, y2) of the rectangular box, and the other is to define it by the center coordinates (x, y) of the rectangular box and the width w and height h of the rectangular box. In this application, the bounding box (target box and prediction box) of the target detection model is modeled by a two-dimensional Gaussian distribution, and a continuous distance function is used to reflect the similarity between the target box and the prediction box of the target detection model. Among them, the continuous distance function can use KL divergence (Kullback-Leibler Divergence, for short) or other functions. The larger the function value of the continuous distance function, the greater the similarity between the target box and the prediction box.
[0045] The bounding box in this application is an ellipse, and the center coordinates of the ellipse bounding box (c x , c y ) corresponds to the mean vector μ of the two-dimensional Gaussian distribution, and the square semi-axis length of the elliptical bounding box corresponds to the covariance matrix Σ of the two-dimensional Gaussian distribution. Specifically, as shown in the following formula:
[0046]
[0047] Where w is the width semi-axis of the elliptical bounding box, and h is the height semi-axis of the elliptical bounding box.
[0048] Step S102: According to the model size of the elliptical bounding box and based on the dynamic gradient gain factor, the Wasserstein distance between the target box and the prediction box of the target detection model is corrected, and the exponential normalization is applied to the obtained dynamic Wasserstein distance to obtain the normalized Wasserstein distance.
[0049] In this application, the elliptical bounding box of the target detection model is modeled as a two-dimensional Gaussian distribution, and the Wasserstein distance between the target box and the prediction box of the target detection model is calculated. Specifically, according to the formula:
[0050]
[0051] Determine the target box of the object detection model and prediction box The Wasserstein distance between In the formula, μ p , μ t The target box and prediction box The mean vector of the two-dimensional Gaussian distribution of Σ p ,Σ t The target box and prediction box The covariance matrix of the two-dimensional Gaussian distribution; w p 、w t The target box and prediction box Length; h p , g t The target box and prediction box The center distance represents the width of the target box. and prediction box The center distance of , coupling tern represents the coupling term.
[0052] Then, based on the dynamic gradient gain factor 4Σ t , according to the formula:
[0053]
[0054] Target box for target detection model and prediction box The Wasserstein distance between Correction is made to obtain the dynamic Wasserstein distance
[0055] Furthermore, there are The dynamic Wasserstein distance between for:
[0056]
[0057] In this application, based on scale invariance, for a full rank matrix M and |M|≠0, the full rank matrix M is calculated according to:
[0058]
[0059] Target frame and prediction box Transform to get the target frame and prediction box Where, X p′ Target box Two-dimensional Gaussian distribution, X t′ For the prediction box Two-dimensional Gaussian distribution of ;
[0060] have The dynamic Wasserstein distance between Representation The first term of the center distance between is expressed as:
[0061]
[0062] The second term of the coupling term is expressed as:
[0063]
[0064] Therefore, we have:
[0065]
[0066] Here, As a distance metric, it is difficult to directly use it as a similarity metric (similarity metrics are usually expressed as values between 0 and 1, which are used to measure the difference between the target box and the predicted box). Based on this, in this application, the dynamic Wasserstein distance obtained is The exponential form is used to normalize , thereby obtaining an improved metric that is more suitable for similarity assessment. Specifically, according to the formula:
[0067]
[0068] Dynamic Wasserstein distance Perform exponential normalization to obtain the normalized Wasserstein distance (i.e. Dynamic-NWD).
[0069] Step S103: using the normalized Wasserstein distance as a loss function to update the model parameters of the target detection model.
[0070] Typically, object detection models are trained in a backward pass that allows them to update their weights by calculating the gradient of the loss function with respect to the network parameters, thereby gradually improving performance over successive training iterations. The core of the backpropagation process is to calculate these gradients using the chain rule and pass the error from the output layer back to earlier layers of the network.
[0071] The back propagation process starts at the last layer of the target detection model, which is the loss function layer. The loss function calculates the difference between the predicted value and the actual value of the target detection model to obtain an initial error value. Then, based on the chain rule, the back propagation algorithm is used to calculate the gradient of each layer output relative to its input of the target detection model, and then the gradient of the weight parameters of each layer is calculated.
[0072] Through back propagation, the network of the target detection model can adjust itself according to the feedback of the loss function and gradually reduce the prediction error. In each iteration, the weight of the network layer is updated by the gradient of each layer to minimize the loss function. That is, based on the gradient descent method, the network layer weights of the target detection model are cyclically updated to minimize the loss function until the loss function reaches the preset threshold or the number of cycles reaches the preset number of iterations, and the model parameter update of the target detection model is completed.
[0073] In the parameter update process, you can use gradient descent methods, such as Stochastic Gradient Descent (SGD), SGD with momentum, Ada grad, RMSprop, and Adam, etc. According to the mathematical properties corresponding to different methods (such as learning rate decay, momentum term or adaptive learning rate, etc.), guide the direction and step size of parameter update to achieve effective parameter update. Repeat this process until the value of the loss function no longer decreases significantly or reaches the predetermined number of iterations, and the target detection model training is completed.
[0074] Based on Wasserstein distance The regression loss is a semi-coupled loss, which is used for the Wasserstein distance The inherent gradient of is analyzed, and we have:
[0075]
[0076] When the Wasserstein distance When the center point is used as the loss function, its independent optimization mechanism lacks the ability to dynamically adjust the gradient according to the target size. The optimization speed of the center point usually exceeds the optimization speed of the width and height of the detection box, which makes the detection results of the target detection model inaccurate, hinders the convergence of the target detection model during training, and leads to a slow convergence speed of the target detection model.
[0077] The asynchronous optimization between the center point, height, and width of the detection box results in the object detection model requiring a lot of computing power to fine-tune the size of the detection box within a limited number of iterations when training a large-scale dataset, and often fails to produce the expected results. The scale invariance of the target detection model is impeded.
[0078] In this application, the dynamic gradient gain factor 4Σ t , the Wasserstein distance between the target box and the prediction box is corrected to obtain the dynamic Wasserstein distance Dynamic Wasserstein distance For analysis, there are:
[0079]
[0080] Compared to Wasserstein distance The center point is used as the loss function, when the dynamic Wasserstein distance When the center point is used as the loss function, in scenes involving smaller sizes or obviously short edges, the loss function can assign larger gradient gains to speed up convergence and increase the object detection model's attention to optimizing the center point offset.
[0081] The dynamic gradient gain factor not only helps the dynamic joint optimization process, but also dynamically adjusts the gradient to pay more attention to small targets. Compared with the loss function based on intersection over union (IoU) and the loss function based on Wasserstein distance, Dynamic-NWD has a faster convergence speed and is also better than the loss function based on IoU and the loss function based on Wasserstein distance in terms of accuracy. Compared with the limitations of the IoU loss function in the bounding box regression of small targets, Dynamic-NWD not only has obvious convergence effect, but also shows better performance in the bounding box regression of small targets; compared with the loss function based on Wasserstein distance, Dynamic-NWD significantly reduces false positives and false negatives, and has better bounding box regression performance.
[0082] In this application, the dynamic gradient gain factor 4Σ t , the Wasserstein distance between the target box and the prediction box is corrected so that the dynamic Wasserstein distance And through the dynamic Wasserstein distance Applying an exponential form of normalization results in an improved metric that is more suitable for similarity assessment. Therefore, the normalized Wasserstein distance is (i.e. Dynamic-NWD) is used as the loss function. For the height size h and width size w of the detection box, the dynamic gradient gain factor 4Σ t , which enables the target detection model to dynamically adjust the position optimization according to the target size, not only accelerating the convergence speed of the height size h and width size w. Moreover, it also produces a refinement effect, making the penalty of matching loss more severe for smaller target height or width, prompting the target detection model to make more precise regression adjustments in the final adjustment stage of the training process.
[0083] like Figure 3 As shown, the embodiment of the present application also provides a loss function optimization system for improving small target detection performance, including:
[0084] The bounding box modeling unit 301 is configured to model the elliptical bounding box of the target detection model through a two-dimensional Gaussian distribution; wherein the target detection model is used to locate and identify the target object through the elliptical bounding box; the elliptical bounding box includes a target box and a prediction box;
[0085] The normalized Wasserstein distance unit 302 is configured to calculate the normalized Wasserstein distance based on the model size of the elliptical bounding box and the preset dynamic gradient gain factor 4Σ t , the Wasserstein distance between the target box and the prediction box of the target detection model is corrected, and the exponential normalization is applied to the obtained dynamic Wasserstein distance to obtain the normalized Wasserstein distance;
[0086] The function optimization unit 303 is configured to update the model parameters of the target detection model by using the normalized Wasserstein distance as a loss function.
[0087] The loss function optimization system for improving small target detection performance provided in the embodiments of the present application can implement the steps and processes of the loss function optimization method for improving small target detection performance in any of the above embodiments and achieve the same technical effects, which will not be described one by one here.
[0088] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A loss function optimization method for improving small target detection performance, characterized in that: include: Step S101, modeling an elliptical bounding box of a target detection model through a two-dimensional Gaussian distribution; wherein the target detection model is used to locate and identify a target object through the elliptical bounding box; the elliptical bounding box includes a target box and a prediction box; Step S102: According to the model size of the elliptical bounding box, based on a preset dynamic gradient gain factor, the Wasserstein distance between the target box and the prediction box of the target detection model is corrected, and the obtained dynamic Wasserstein distance is normalized in an exponential form to obtain a normalized Wasserstein distance; Step S103: using the normalized Wasserstein distance as a loss function to update the model parameters of the target detection model.
2. The loss function optimization method for improving small target detection performance according to claim 1, characterized in that: In step S101, according to the formula: Modeling the elliptical bounding box; Wherein, μ is the mean vector of the two-dimensional Gaussian distribution, Σ is the covariance matrix of the two-dimensional Gaussian distribution; (c x , c y ) are the center coordinates of the elliptical bounding box, w and h are the width semi-axis and height semi-axis of the elliptical bounding box respectively.
3. The loss function optimization method for improving small target detection performance according to claim 1, characterized in that: In step S102, According to the formula: Determine the target box of the target detection model and prediction box The dynamic Wasserstein distance between In the formula, The target box of the target detection model and prediction box Wasserstein distance between them; According to the formula: The dynamic Wasserstein distance Perform exponential normalization to obtain the normalized Wasserstein distance 4. The loss function optimization method for improving small target detection performance according to claim 1, characterized in that: In step S103, Based on the gradient descent method, the network layer weights of the target detection model are cyclically updated to minimize the loss function until the value of the loss function reaches a preset threshold or the number of cycles reaches a preset number of iterations, and the model parameter update of the target detection model is completed.
5. A loss function optimization system for improving small target detection performance, characterized in that: include: A bounding box modeling unit, configured to model an elliptical bounding box of a target detection model through a two-dimensional Gaussian distribution; wherein the target detection model is used to locate and identify a target object through the elliptical bounding box; the elliptical bounding box includes a target box and a prediction box; A normalized Wasserstein distance unit is configured to correct the Wasserstein distance between the target box and the prediction box of the target detection model according to the model size of the elliptical bounding box and based on a preset dynamic gradient gain factor, and apply exponential normalization to the obtained dynamic Wasserstein distance to obtain a normalized Wasserstein distance; The function optimization unit is configured to use the normalized Wasserstein distance as a loss function to update the model parameters of the target detection model.
Citation Information
Cited By
Loss function acquisition method for small target detection
CN119919704A
Task collaborative optimization method for monocular 3D object detection
CN119942067A
