Target detection model rotating box regression loss function construction method and system
By constructing a rotation box regression loss function that uses Mahalanobis distance center alignment and discretized IoU approximation, the problems of boundary discontinuity and square ambiguity in rotating target detection are solved, achieving more stable and accurate rotating target detection results. This is applicable to fields such as remote sensing image analysis, autonomous driving, and industrial quality inspection.
Patent Information
- Application Number
- CN202611438670.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-16
- Publication Date
- 2026-11-24
AI Technical Summary
Existing rotating target detection technologies suffer from problems such as boundary discontinuities, regression ambiguity for square targets, and inconsistencies between optimized targets and final evaluation metrics, resulting in insufficient accuracy and stability of detection models in rotating target detection.
A decoupled rotation box regression loss function, which combines Mahalanobis distance center alignment and discretized IoU approximation, is adopted. By weighted fusion of Mahalanobis distance center alignment loss and discretized IoU loss, a rotation box regression loss function for the target detection model is constructed, achieving more stable and accurate rotation target detection.
It improves the accuracy and stability of rotating target detection, provides reliable optimized signals under different aspect ratios and angles, avoids gradient bias and regression ambiguity, is suitable for single-stage and iterative detectors, and improves detection performance.
Smart Images

Figure CN123160979A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of target detection technology, and in particular to a method and system for constructing a rotation box regression loss function for target detection models. Background Technology
[0002] Rotated target detection is a key technology in remote sensing image analysis, autonomous driving, and industrial quality inspection. Unlike general target detection, rotated targets (such as aircraft, ships, and vehicles in remote sensing images) usually have arbitrary orientations and need to be accurately represented using rotated bounding boxes (RBBs). Rotated bounding boxes are typically represented using a five-parameter notation: (x, y, w, h, θ), where (x, y) are the coordinates of the center point, w and h are the width and height, respectively, and θ is the rotation angle (usually defined in the range of [-90°, 90°)). Ideally, the regression loss function should directly optimize the final evaluation metric, namely the rotation intersection-union ratio (SkewIoU). However, the calculation of SkewIoU involves operations such as intersection of non-convex polygons and vertex sorting, and its gradient is not differentiable, making it unsuitable as a direct training loss function for neural networks. Therefore, existing technologies have had to employ various alternative schemes to indirectly approximate this goal.
[0003] Early alternatives primarily relied on parametric regression methods, such as the Smooth L1 loss, which directly regressed the five parameters. This approach suffers from two inherent problems: first, angular boundary discontinuities, where the loss function jumps dramatically at angular boundaries due to the periodicity of θ, misleading gradient updates; and second, the square-like problem, where, for targets with an aspect ratio close to 1:1, predicted boxes at different angles are geometrically almost equivalent, but the parameters differ significantly, causing regression ambiguity. Later, angular encoding methods (such as CSL, DCL, and PSC) emerged, transforming angular regression into a classification or dense encoding task, alleviating the boundary discontinuity problem to some extent, but failing to fundamentally solve the square-like problem, and requiring complex manual design of encoding schemes. In recent years, Gaussian distribution-based methods (such as GWD, KLD, and KFIoU) have made progress. These methods model the rotated boxes as a two-dimensional Gaussian distribution, using the distance between distributions as the loss, which can smoothly handle boundary and square-like problems. However, their optimization objectives deviate from SkewIoU, especially for square-like targets, where the Gaussian distribution degenerates into a circle, completely losing directional information. Furthermore, the gradient characteristics of these methods are unstable under different aspect ratios, affecting the convergence speed and accuracy of training.
[0004] In summary, existing technologies still face significant challenges in achieving geometric alignment optimization highly consistent with SkewIoU, robustly handling boundary discontinuities, and eliminating regression ambiguities for square-like targets. Therefore, constructing a loss function for the rotating target detection model to improve its ability to detect rotating targets is a pressing issue that needs to be addressed. Summary of the Invention
[0005] To address the issues of discontinuous boundaries and ambiguous regression of square targets in existing rotating target detection processes, this invention provides a method and system for constructing a rotating bounding box regression loss function for a target detection model. Based on Mahalanobis distance center alignment and discretized IoU approximation, a decoupled rotating bounding box regression loss function is constructed to achieve more stable, accurate, and highly aligned rotating target detection with evaluation metrics through model training.
[0006] According to the design scheme provided by the present invention, on the one hand, a method for constructing a rotating bounding box regression loss function for an object detection model is provided, comprising:
[0007] The training data is input into the object detection model to obtain the predicted bounding box of the rotated object corresponding to the training data, wherein the training data is labeled with the true bounding box of the rotated object.
[0008] The Mahalanobis distance center alignment loss is calculated based on the Mahalanobis distance between the Gaussian distribution of the real bounding box mapping and the center point of the predicted bounding box.
[0009] Based on the real bounding box and the predicted bounding box, the discretized IoU loss is calculated using the ray casting method;
[0010] The dynamic activation weights are determined using Mahalanobis distance, and the Mahalanobis distance center alignment loss and discretized IoU loss are weighted and fused according to the dynamic activation weights to obtain the total loss function.
[0011] As a method for constructing the rotation box regression loss function for the target detection model of this invention, the Mahalanobis distance center alignment loss is further calculated based on the Mahalanobis distance between the Gaussian distribution of the true bounding box mapping and the center point of the predicted bounding box, including:
[0012] The real bounding box is modeled as an anisotropic two-dimensional Gaussian distribution;
[0013] Calculate the Mahalanobis distance between the center point of the predicted bounding box and the two-dimensional Gaussian distribution;
[0014] By mapping the Mahalanobis distance to the [0, 1) interval using an exponential function, the Mahalanobis distance center alignment loss is obtained.
[0015] As a method for constructing the rotation box regression loss function for the target detection model of this invention, further, based on the true bounding box and the predicted bounding box and using the ray casting method to calculate the discretized IoU loss, it includes:
[0016] Sampling points along a uniform angular direction on the real bounding box yields an ordered discrete set of sampling points.
[0017] All sampling points are mapped to the local coordinate system of the predicted bounding box through coordinate transformation;
[0018] For each sampling point in the local coordinate system of the predicted bounding box, calculate its polar angle in the local coordinate system of the predicted bounding box, and find the corresponding point with the same polar angle direction on the predicted bounding box;
[0019] For each polar direction, compare the distances from the sampling point and the corresponding point to the center, and construct the intersection polygon vertices and the union polygon vertices based on the distances;
[0020] The areas of the intersection and union polygons are calculated using the triangle decomposition method. The discretized IoU value is then calculated based on the area of both polygons, and the discretized IoU loss is determined based on the discretized IoU value.
[0021] As a method for constructing the rotation box regression loss function of the target detection model of the present invention, further, constructing intersection polygon vertices and union polygon vertices based on distance includes:
[0022] Select the point that is closer to the center between the sampling point and the corresponding point as the vertex of the intersection polygon;
[0023] Select the point that is farther from the center between the sampling point and the corresponding point, and use it as the vertex of the union polygon.
[0024] As a method for constructing the rotation box regression loss function of the target detection model in this invention, the dynamic activation weights are further determined using Mahalanobis distance, including:
[0025] Determine whether the center of the predicted bounding box is located within the actual bounding box based on Mahalanobis distance;
[0026] Set smoothing parameters and offset thresholds to control the steepness of the activation curve, and calculate dynamic activation weights based on the Sigmoid function.
[0027] As a method for constructing the rotation box regression loss function of the target detection model in this invention, the dynamic activation weight calculation process is further expressed as follows: Where β is a smoothing parameter controlling the steepness of the activation curve, and δ is the offset threshold. The Mahalanobis distance, This is the Sigmoid function.
[0028] As a method for constructing the rotation box regression loss function of the target detection model of the present invention, it further includes:
[0029] Based on the total loss value corresponding to the total loss function, adjust the parameters of the target detection model and return to the step of inputting training data into the target detection model until the total loss value meets the preset optimization conditions or the number of times the model parameters are adjusted reaches the preset number of loops.
[0030] Furthermore, this invention also provides a system for constructing a rotation box regression loss function for an object detection model, comprising: a prediction module, a first loss calculation module, a second loss calculation module, and a total loss calculation module, wherein...
[0031] The prediction module is used to input training data into the target detection model to obtain the predicted bounding box of the rotated target corresponding to the training data, wherein the training data is labeled with the true bounding box of the rotated target.
[0032] The first loss calculation module is used to calculate the Mahalanobis distance center alignment loss based on the Mahalanobis distance between the Gaussian distribution of the real bounding box mapping and the center point of the predicted bounding box.
[0033] The second loss calculation module is used to calculate the discretized IoU loss based on the real bounding box and the predicted bounding box and using the ray casting method.
[0034] The total loss calculation module is used to determine the dynamic activation weights using Mahalanobis distance, and to perform weighted fusion of the Mahalanobis distance center alignment loss and discretized IoU loss based on the dynamic activation weights to obtain the total loss function.
[0035] The beneficial effects of this invention are:
[0036] 1. This invention decomposes the rotation box regression into a center alignment stage based on Mahalanobis distance (M-Loss) and a shape fine-tuning stage based on discretized IoU approximation (D-IoU Loss). It achieves smooth collaboration between the two stages by dynamically activating weights, and achieves more stable, more accurate, and highly aligned rotation target detection with evaluation metrics through model training.
[0037] 2. This invention directly approximates SkewIoU through D-IoU loss, ensuring that the optimization objective and the final evaluation metric are geometrically consistent. The D-IoU loss employs a differentiable ray casting algorithm, constructing intersection and union polygons from the center point along uniform angular directions. This accurately approximates the true rotational intersection-union ratio, ensuring that the gradient direction is completely consistent with the goal of improving SkewIoU. This avoids gradient bias caused by inconsistencies between the parameter space and metric space in Smooth L1 and GWD, and overcomes the correlation degradation problem of KLD and KFIoU in high-error regions. It provides reliable, metric-aligned optimization signals under various error conditions, fundamentally improving regression accuracy. Since D-IoU loss directly optimizes spatial overlap rather than parameter similarity, this invention fundamentally eliminates the influence of angular periodicity and square-like ambiguity. Gradient calculation relies on geometric boundaries rather than angular values, thus avoiding jumps at angular range boundaries. For targets with an aspect ratio close to 1:1, the gradient automatically weakens, correctly reflecting the geometric equivalence of the square frame after a 90° rotation. In contrast, Gaussian methods (GWD, KLD, KFIoU) fail in this case, completely losing directional information and leading to regression ambiguity.
[0038] 3. The MD-IoU of this invention can serve as a plug-and-play replacement for the regression loss of existing arbitrary rotating target detectors, without requiring modification to the network structure or the addition of extra branches. Cross-architecture experiments show that it can stably improve performance on single-stage (RetinaNet), iterative (R3Det), and two-stage (RoI Transformer) detectors, with the largest improvement on the simplest detector, effectively compensating for insufficient optimization of the basic architecture. Although D-IoU involves discretization sampling and polygon area calculation, due to the use of vectorized matrices, the computation time remains almost unchanged when the number of sampling points N varies from 24 to 60, and the performance fluctuation is minimal, demonstrating good robustness. Attached Figure Description
[0039] Figure 1 This is a schematic diagram illustrating the process of constructing the rotation box regression loss function for the target detection model in the embodiment;
[0040] Figure 2 This is a schematic diagram of the overall framework of the MD-IoU loss function in the embodiment;
[0041] Figure 3 This is a schematic diagram of the D-IoU ray projection algorithm in the embodiment. Detailed Implementation
[0042] To make the objectives, technical solutions, and advantages of this invention clearer and more understandable, the invention will be further described in detail below with reference to the accompanying drawings and technical solutions.
[0043] Existing regression loss functions for rotating target detection suffer from several drawbacks: inconsistency between the optimization direction and the final evaluation metric SkewIoU; boundary discontinuities and ambiguity related to square-like structures; and difficulty in simultaneously achieving stable traction over long distances and high-precision local fine-tuning. Therefore, this invention provides an embodiment, see [link to embodiment]. Figure 1 As shown, a method for constructing a rotation box regression loss function for an object detection model is provided, comprising:
[0044] S101. Input the training data into the target detection model to obtain the predicted bounding box of the rotated target corresponding to the training data, wherein the training data is labeled with the true bounding box of the rotated target.
[0045] S102. Calculate the Mahalanobis distance center alignment loss based on the Mahalanobis distance between the Gaussian distribution of the real bounding box mapping and the center point of the predicted bounding box.
[0046] Specifically, the real bounding box can be modeled as an anisotropic two-dimensional Gaussian distribution; the Mahalanobis distance between the center point of the predicted bounding box and the two-dimensional Gaussian distribution can be calculated; the Mahalanobis distance can be mapped to the interval [0, 1) through an exponential function to obtain the Mahalanobis distance center alignment loss.
[0047] like Figure 2 As shown, the real rotated box is modeled as an anisotropic two-dimensional Gaussian distribution. Let the parameters of the real rotated box be (x... g , y g , w g , h g , θ g The corresponding two-dimensional Gaussian distribution mean μ=(x) g ,y g ) T The covariance matrix is:
[0048]
[0049] in Let be the rotation matrix. k is the scaling factor; when k=4, the 1σ confidence ellipse of the Gaussian distribution is exactly aligned with the physical boundary of the ground truth box. The covariance matrix is determined by the width, height, and orientation of the ground truth box, and the 1σ confidence ellipse is aligned with the ground truth box boundary. This alignment property allows Mahalanobis distance to accurately reflect the geometric positional relationship of the prediction center relative to the ground truth box.
[0050] To avoid directly calculating the inverse of the covariance matrix, a coordinate transformation method can be used to efficiently calculate the Mahalanobis distance. First, the center point (x...) of the predicted bounding box... p , y p Transform to the local coordinate system of the true bounding box:
[0051]
[0052]
[0053] Calculate the center point (x) of the prediction box p ,y p The Mahalanobis distance D between the distribution and the Gaussian distribution M :
[0054] This distance is anisotropic, meaning that offsets along the minor axis of the target are penalized more severely, while offsets along the major axis are penalized less severely. This anisotropic property makes L M It can provide gradient signals that are both rotation-aware and scale-aware, unlike the uniform penalty of Euclidean distance.
[0055] In the local coordinate system of the ground truth bounding box, the square of the Mahalanobis distance can be directly expressed as the normalized sum of squared coordinates:
[0056]
[0057] Mapping the Mahalanobis distance to the interval [0,1) using an exponential function yields the M-Loss value:
[0058]
[0059] This loss function works when the prediction center is far from the ground truth box (D M A larger gradient (closer to 1) provides a strong gradient signal close to 1, quickly pulling the predicted center into the ground truth bounding box; when the predicted center is close to the ground truth bounding box (D... M As the gradient approaches zero, the loss value approaches zero, and the gradient naturally decays, ensuring the stability of long-distance optimization.
[0060] S103. Calculate the discretized IoU loss based on the real bounding box and the predicted bounding box, using the ray casting method.
[0061] Specifically, several points can be sampled along a uniform angular direction on the true bounding box to obtain an ordered discrete sampling point set; all sampling points are mapped to the local coordinate system of the predicted bounding box through coordinate transformation; for each sampling point in the local coordinate system of the predicted bounding box, its polar angle in the local coordinate system of the predicted bounding box is calculated, and a corresponding point with the same polar angle direction is found on the predicted bounding box; for each polar angle direction, the distances from the sampling point and the corresponding point to the center are compared, and the vertices of the intersection polygon and the union polygon are constructed based on the distance; the areas of the intersection polygon and the union polygon are calculated using the triangle decomposition method, and the discretized IoU value is calculated based on the area of the two polygons, and the discretized IoU loss is determined based on the discretized IoU value.
[0062] like Figure 2 and 3As shown, N points are sampled along a uniform angle direction on the boundary of the real bounding box. In the experiment, N=36. N equally spaced angle values ϕ are generated. i Make it cover the interval [0, 2π] and ensure that the beginning and end coincide:
[0063]
[0064] The actual sampling direction is obtained by superimposing the rotation angle of the real bounding box onto the sampling angle.
[0065] Calculate the radial distance t in each direction. i For a rectangular boundary, from the center along the direction ψ i The distance between the intersection point of the ray and the boundary is:
[0066]
[0067] By combining the center point offset and rotation matrix, the coordinates of the sampling point in the global coordinate system are obtained.
[0068]
[0069] in, The rotation matrix of the true bounding box has the following complete form:
[0070]
[0071] The sampling points are distributed at equal angular intervals along the boundaries of the ground truth bounding box, forming an ordered set of discrete points. ,in .
[0072] All sampling points are mapped to the local coordinate system of the prediction box through coordinate transformation. Let the prediction box parameters be... The transformation formula is:
[0073]
[0074] Where R(θ) p ) is the rotation matrix of the prediction box, and its complete form is:
[0075]
[0076] After unfolding, we get:
[0077]
[0078] .
[0079] This transformation converts the sampling points from the world coordinate system to a local coordinate system with the center of the prediction box as the origin and the principal axes of the prediction box as the coordinate axes, which facilitates subsequent comparisons.
[0080] For each sampling point P i '', calculate its polar angle in the local coordinate system of the prediction box. And find corresponding points with the same polar angle direction on the boundary of the prediction box. Since the prediction box is a convex quadrilateral, there is one and only one boundary point in each polar direction.
[0081] The prediction box is an axis-aligned rectangle in the local coordinate system. From the origin along the direction... Distance between the intersection point of the ray and the rectangular boundary for:
[0082]
[0083] For each polar direction, compare the distance from the sampling point to the center with the distance from the corresponding point, and select the point with the closer distance as the vertex of the intersection polygon: And select the points that are farther away as vertices of the union polygon: .
[0084] The shorter and longer distances correspond to the distances from the vertices of the intersecting and union polygons to their centers, respectively. Using the distances along adjacent angular directions, the areas of the intersection and union are calculated by summing the areas of the triangles; this result is equivalent to calculating the area using the coordinates of the polygon vertices. Because the angles of the beginning and end coincide, therefore , .
[0085] Calculate the area S of the intersection polygon using the triangle decomposition method. inter Area S of the union polygon union :
[0086]
[0087]
[0088] Calculate the D-IoU value and obtain the D-IoU Loss:
[0089]
[0090] Since the entire calculation process is differentiable (including coordinate transformation, polar angle calculation, and area calculation), D-IoU Loss can be directly used for gradient backpropagation.
[0091] S104. Use Mahalanobis distance to determine dynamic activation weights, and then perform weighted fusion of Mahalanobis distance center alignment loss and discretized IoU loss based on the dynamic activation weights to obtain the total loss function.
[0092] Specifically, the Mahalanobis distance can be used to determine whether the center of the predicted bounding box is located within the actual bounding box; smoothing parameters and offset thresholds that control the steepness of the activation curve can be set, and dynamic activation weights can be calculated based on the Sigmoid function.
[0093] Using the calculated Mahalanobis distance D M Determine whether the predicted center has entered the true bounding box. When D... M When <1, the prediction center is located inside the true bounding box (i.e., inside the 1σ confidence ellipse).
[0094] Design the Sigmoid function as a dynamic activation weight:
[0095]
[0096] β controls the steepness of the activation curve, and δ is the offset threshold.
[0097] The complete MD-IoU loss function is expressed as follows: ,in For M-Loss, For D-IoU Loss, For dynamic activation weights
[0098] When D M When <δ (indicating center alignment), w a When D approaches 1, activate the D-IoU loss for fine-tuning; conversely, when D... M When w is ≥δ (indicating center misalignment) a Approaching 0, training is mainly dominated by M-Loss.
[0099] In the experiment, β=15 and δ=0.8 were chosen. β=15 allows the activation weights to change rapidly near the threshold, achieving a smooth but rapid transition; δ=0.8 is slightly less than 1, when D M When <0.8, w a When D approaches 1, activate the D-IoU loss for fine-tuning; conversely, when D... M When ≥0.8, w a Approaching 0, training is mainly dominated by M-Loss.
[0100] Based on the total loss value corresponding to the total loss function, adjust the parameters of the target detection model and return to the step of inputting training data into the target detection model until the total loss value meets the preset optimization conditions or the number of times the model parameters are adjusted reaches the preset number of loops.
[0101] Furthermore, based on the above method, this embodiment of the invention also provides a system for constructing a rotation box regression loss function for an object detection model, comprising: a prediction module, a first loss calculation module, a second loss calculation module, and a total loss calculation module, wherein,
[0102] The prediction module is used to input training data into the target detection model to obtain the predicted bounding box of the rotated target corresponding to the training data, wherein the training data is labeled with the true bounding box of the rotated target.
[0103] The first loss calculation module is used to calculate the Mahalanobis distance center alignment loss based on the Mahalanobis distance between the Gaussian distribution of the real bounding box mapping and the center point of the predicted bounding box.
[0104] The second loss calculation module is used to calculate the discretized IoU loss based on the real bounding box and the predicted bounding box and using the ray casting method.
[0105] The total loss calculation module is used to determine the dynamic activation weights using Mahalanobis distance, and to perform weighted fusion of the Mahalanobis distance center alignment loss and discretized IoU loss based on the dynamic activation weights to obtain the total loss function.
[0106] To verify the effectiveness of this solution, the following explanation is provided based on experimental data:
[0107] In the experiments, PyTorch 1.11.0 and CUDA 11.3 were used as the deep learning framework, and the implementation was based on the MMRotate (v0.3.4) toolbox. RetinaNet was chosen as the base detector, and ResNet-50 was used as the backbone network. The original L1 regression loss of RetinaNet was replaced with the MD-IoU loss of this invention. RetinaNet is a classic single-stage detector, whose head network contains classification and regression branches; the experiments only modified the loss function of the regression branch.
[0108] Training was performed on the DOTA-v1.0 dataset. Input images were cropped into 1024×1024 image patches and augmented using random flipping. Training lasted 12 epochs with SGD as the optimizer, an initial learning rate of 0.0025, momentum of 0.9, and weight decay of 0.0001. The learning rate was decayed to 0.1 times its original value at epochs 8 and 11. Batch size was set to 2. These training configurations were fully consistent with the RetinaNet baseline to ensure a fair comparison.
[0109] Experiments were conducted on the DOTA-v1.0 test set using the proposed solution, and the results are as follows: the proposed solution achieved an mAP50 of 70.85%, an improvement of 2.96 percentage points compared to the baseline (67.89%) using Smooth L1. The most significant improvement was observed in the helicopter (HC) category, which increased from 30.19% to 47.02%; the roundabout (RA) category also saw an improvement from 64.28% to 66.37%. In terms of AP75, MD-IoU also maintained competitiveness, achieving a good balance between detection rate and positioning accuracy.
[0110] The experimental data above demonstrate that the proposed solution achieves more stable, accurate, and highly aligned target detection results with the evaluation metrics, and can be applied to the detection of rotating targets such as aircraft, ships, and vehicles in remote sensing images.
[0111] Unless otherwise specifically stated, the relative steps, numerical expressions, and values of the components and steps described in these embodiments do not limit the scope of the invention.
[0112] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section.
[0113] The units and method steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been generally described in terms of functionality in the foregoing description. 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 implementations are not considered to be beyond the scope of this invention.
[0114] Those skilled in the art will understand that all or part of the steps in the above methods can be implemented by a program instructing related hardware, and the program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk. Optionally, all or part of the steps in the above embodiments can also be implemented using one or more integrated circuits. Accordingly, each module / unit in the above embodiments can be implemented in hardware or as a software functional module. This invention is not limited to any particular combination of hardware and software.
[0115] Finally, it should be noted that the above-described embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, 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 the present invention, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A method for constructing a rotation box regression loss function for an object detection model, characterized in that, Include: The training data is input into the object detection model to obtain the predicted bounding box of the rotated object corresponding to the training data, wherein the training data is labeled with the true bounding box of the rotated object. The Mahalanobis distance center alignment loss is calculated based on the Mahalanobis distance between the Gaussian distribution of the real bounding box mapping and the center point of the predicted bounding box. Based on the real bounding box and the predicted bounding box, the discretized IoU loss is calculated using the ray casting method; The dynamic activation weights are determined using Mahalanobis distance, and the Mahalanobis distance center alignment loss and discretized IoU loss are weighted and fused according to the dynamic activation weights to obtain the total loss function.
2. The method for constructing the rotation box regression loss function for the target detection model according to claim 1, characterized in that, The Mahalanobis distance center alignment loss is calculated based on the Mahalanobis distance between the center points of the predicted bounding box and the Gaussian distribution of the true bounding box mapping, including: The real bounding box is modeled as an anisotropic two-dimensional Gaussian distribution; Calculate the Mahalanobis distance between the center point of the predicted bounding box and the two-dimensional Gaussian distribution; By mapping the Mahalanobis distance to the [0, 1) interval using an exponential function, the Mahalanobis distance center alignment loss is obtained.
3. The method for constructing the rotation box regression loss function for the target detection model according to claim 1, characterized in that, Based on the true bounding box and the predicted bounding box, the discretized IoU loss is calculated using the ray casting method, including: Sampling points along a uniform angular direction on the real bounding box yields an ordered discrete set of sampling points. All sampling points are mapped to the local coordinate system of the predicted bounding box through coordinate transformation; For each sampling point in the local coordinate system of the predicted bounding box, calculate its polar angle in the local coordinate system of the predicted bounding box, and find the corresponding point with the same polar angle direction on the predicted bounding box; For each polar direction, compare the distances from the sampling point and the corresponding point to the center, and construct the intersection polygon vertices and the union polygon vertices based on the distances; The areas of the intersection and union polygons are calculated using the triangle decomposition method. The discretized IoU value is then calculated based on the area of both polygons, and the discretized IoU loss is determined based on the discretized IoU value.
4. The method for constructing the rotation box regression loss function for the target detection model according to claim 3, characterized in that, Construct intersection and union polygon vertices based on distance, including: Select the point that is closer to the center between the sampling point and the corresponding point as the vertex of the intersection polygon; Select the point that is farther from the center between the sampling point and the corresponding point, and use it as the vertex of the union polygon.
5. The method for constructing the rotation box regression loss function for the target detection model according to claim 1, characterized in that, Determining dynamic activation weights using Mahalanobis distance includes: Determine whether the center of the predicted bounding box is located within the actual bounding box based on Mahalanobis distance; Set smoothing parameters and offset thresholds to control the steepness of the activation curve, and calculate dynamic activation weights based on the Sigmoid function.
6. The method for constructing the rotation box regression loss function for the target detection model according to claim 1 or 5, characterized in that, The dynamic activation weight calculation process is represented as follows: Where β is a smoothing parameter controlling the steepness of the activation curve, and δ is the offset threshold. The Mahalanobis distance, This is the Sigmoid function.
7. The method for constructing the rotation box regression loss function for the target detection model according to claim 1, characterized in that, Also includes: Based on the total loss value corresponding to the total loss function, adjust the parameters of the target detection model and return to the step of inputting training data into the target detection model until the total loss value meets the preset optimization conditions or the number of times the model parameters are adjusted reaches the preset number of loops.
8. A system for constructing a rotation box regression loss function for an object detection model, characterized in that, It includes: a prediction module, a first loss calculation module, a second loss calculation module, and a total loss calculation module, wherein, The prediction module is used to input training data into the target detection model to obtain the predicted bounding box of the rotated target corresponding to the training data, wherein the training data is labeled with the true bounding box of the rotated target. The first loss calculation module is used to calculate the Mahalanobis distance center alignment loss based on the Mahalanobis distance between the Gaussian distribution of the real bounding box mapping and the center point of the predicted bounding box. The second loss calculation module is used to calculate the discretized IoU loss based on the real bounding box and the predicted bounding box and using the ray casting method. The total loss calculation module is used to determine the dynamic activation weights using Mahalanobis distance, and to perform weighted fusion of the Mahalanobis distance center alignment loss and discretized IoU loss based on the dynamic activation weights to obtain the total loss function.
9. An electronic device, characterized in that, include: At least one processor, and a memory coupled to said at least one processor; The memory stores a computer program that can be executed by the at least one processor to implement the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed, enables the implementation of the method as described in any one of claims 1 to 7.
