An improved yolov6 target detection method introducing dynamic position loss

CN116012686BActive Publication Date: 2026-10-27YUNENTROPY INTELLIGENT TECH (WUXI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310072259.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-07
Publication Date
2026-10-27
Estimated Expiration
2043-02-07

AI Technical Summary

Technical Problem

第一类是以Fast-Rcnn(fast regions with convolutional neural network features)系列为代表的双阶段(Two-Stage)检测方法,此类方法将检测任务分为两个阶段,即第一阶段通过提议网络提出候选区域集合,第二阶段对候选区域使用卷积神经网络(convolutional neural network,CNN)进行分类和边界框回归进而得到最终结果,其特点是准确率高,但是速度较慢

Benefits of technology

[0042]本发明的有益效果:为了解决多尺度预测时特征融合能力有限的问题,本发明基于可变形卷积设计了新的Neck来进行特征融合,自适应调整采样点位置,增大感受野有效提升了特征融合能力。其次针对目标检测算法中位置损失函数存在的局限性,本发明提出了动态交并比损失函数,能够在训练的不同阶段动态调整不同损失的贡献,更符合目标检测训练逻辑,有针对性地约束网络。本发明基于上述方法改进了YOLOv6模型,显著提升了模型精度,并且可以即插即用,方便地应用到其他目标检测模型地训练任务中去。对于动态交并比损失函数,本发明通过分析目标检测任务整个流程的边界框特点,首先提出了动态损失这个想法,然而具体的动态权重即公式20中的γ和υ的设计后续仍有改进空间。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116012686B_ABST
    Figure CN116012686B_ABST
Patent Text Reader

Abstract

The application provides an improved YOLOv6 target detection method introducing a dynamic position loss, and belongs to the field of target detection. Target detection is one of the most popular directions in the field of computer vision. In order to further improve the performance of the target detection algorithm and solve the limitations of the position loss function in the training process of the target detection algorithm, a dynamic intersection over union loss function based on the intersection over union is proposed. The connection between the internal components of the position loss function is fully considered. Different weights can be dynamically given to the position loss components at different stages of training, so as to achieve the purpose of more targetedly constraining the network. Secondly, in order to solve the deficiency of the target detection network in the feature fusion link, deformable convolution is applied to the PAN structure, and a deformable convolution-based DePAN Neck that can be plugged in and used is designed to improve the multi-scale feature fusion capability of the model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of target detection, specifically relating to an improved YOLOv6 target detection method that incorporates dynamic position loss. Background Technology

[0002] Object detection aims to identify objects of interest within an image, determining their location and category. Other areas of computer vision, such as object tracking and person re-identification, also rely on object detection as a prerequisite, making it one of the most popular research areas in both academia and industry. With the rapid development of deep learning, object detection has shifted from traditional digital image processing algorithms to deep learning-based algorithms. Currently, deep learning-based object detection algorithms can be divided into two categories. The first category is the two-stage detection method, represented by the Fast-R-CNN (fast regions with convolutional neural network features) series. This type of method divides the detection task into two stages: the first stage proposes a set of candidate regions using a proposal network, and the second stage uses a convolutional neural network (CNN) to classify and regress bounding boxes on these candidate regions to obtain the final result. Its advantages include high accuracy but relatively slow speed. The second category is the one-stage detection method, represented by the YOLO (you only look once) series. This type of method extracts image features and then directly regresses the bounding boxes to obtain the category, achieving almost end-to-end detection. Its advantages are speed, but initially, its accuracy is not high. With continuous algorithm improvements, the current one-stage detection algorithm boasts both faster speed and higher accuracy than the two-stage algorithm.

[0003] Despite the various object detection algorithms proposed, almost all one-stage detection networks can be abstractly viewed as consisting of three parts: Backbone, Neck, and Head. For example... Figure 1 As shown, the Backbone part is used to extract features of different scales in the image, the Neck part performs feature fusion and other operations on the multi-scale features extracted by the Backbone, and the Head part uses the features fused by the Neck to make predictions. Finally, the bounding box positions of objects in the image and the category to which the objects belong are output.

[0004] Large differences in object size within an image have always been a major challenge in object detection. Early one-stage detectors, such as YOLOv1, used only a single-scale feature map for detection. Figure 2 (a) in the original text resulted in poor performance of the network for small target detection. Later, YOLOv3 used FPN (feature pyramid network) (a) Figure 2 In section (b), the Neck fusion of multi-scale features greatly improves detection performance. Subsequent Neck implementations, such as SPP (spatial pyramid pooling) and PAN (path aggregation network), have demonstrated the crucial role of the Neck in the detection network.

[0005] The loss function for object detection generally consists of two parts: class loss and location loss. The YOLO series also requires an additional confidence loss. Class loss calculates the error between the predicted and actual object classes, while location loss calculates the error between the predicted and actual bounding boxes.

[0006] The One-Stage algorithm's accuracy is unsatisfactory for two main reasons. First, the designed Neck fusion feature capability is limited, resulting in poor performance in small target detection. Second, the positional loss function is inadequate; existing positional loss functions do not consider the relationships between their internal components, leading to inaccurate network optimization. Summary of the Invention

[0007] To address the shortcomings of current object detection tasks in these two aspects, this invention first proposes a dynamic Intersection over Union (IoU) loss function. This function dynamically assigns different weights to each component of the position loss based on the different positional states between the ground truth bounding box and the predicted bounding box, allowing the network to optimize the bounding box position more effectively at different stages. Secondly, this invention applies deformable convolution to the Neck part, designing a plug-and-play Neck based on a PAN structure to perform feature fusion, thereby improving the network's ability to detect small objects.

[0008] In the experimental section, this invention uses YOLOv6 as the baseline network. To evaluate the performance of the method, this invention is trained and tested on the same COCO2017 dataset as the original paper. The main contributions of this invention are as follows:

[0009] (1) A position loss function and Neck part for target detection were designed, which can be applied to various target detection networks in a plug-and-play manner.

[0010] (2) The method of the present invention is applied to three sizes of YOLOv6 models to improve their performance.

[0011] (3) Verify the effectiveness of the proposed method on the COCO2017 dataset.

[0012] The technical solution of the present invention:

[0013] An improved YOLOv6 target detection method incorporating dynamic position loss is proposed, with the following steps:

[0014] (1) Perform Mosaic data augmentation on the data by randomly cropping and scaling the four images, and then randomly arranging and splicing them together to form a single image.

[0015] (2) Construct DePAN Neck based on deformable convolution and perform multi-scale feature fusion;

[0016] (3) Use DePAN Neck in YOLOv6 to replace the original Neck section;

[0017] (4) Use dynamic intersection-union loss as the location loss function to calculate the location loss between the predicted bounding box coordinates and the label bounding box coordinates;

[0018] (5) Use VariFocal Loss as the class loss function to calculate the class loss between the model output and the label, and combine it with the position loss as the final total loss;

[0019] (6) The Cosine Warmup strategy sets the learning rate and warmupepochs to n, that is, the first n epochs use a smaller learning rate for warm-up, and after n epochs, the preset learning rate is used and the learning rate is adjusted according to the cosine annealing strategy.

[0020] (7) Use the SGD optimizer with momentum to backpropagate the loss and update the parameters to train the model;

[0021] (8) Use the model trained in step (7) to perform target detection.

[0022] In step (2), the DePAN Neck receives features of different scales extracted from the backbone. For high-level features, a 1×1 convolution is first applied, followed by upsampling through transposed convolution. The features are then concatenated with adjacent low-level features in the channel dimension and fused using DeConvBlock. For low-level features, a 3×3 convolution is applied for downsampling, followed by concatenation with adjacent high-level features in the channel dimension. The concatenated features are then fused using DeConvBlock. Finally, the fused features are input into the Head section for classification and regression prediction. The DeConvBlock structure is composed of N DeConv Cells stacked repeatedly.

[0023] The loss function of the dynamic intersection-union ratio loss in step (4) consists of four parts: IoU loss, distance loss, angle loss, and shape loss, as detailed below:

[0024] (1) Angle loss: The angle loss is no longer optimized according to different cases. Regardless of whether the included angle α is less than π / 4, it is optimized towards π / 4. That is, the predicted bounding box is constrained to move closer to the true bounding box along the direction of included angle π / 4.

[0025] The angle loss Λ is defined as:

[0026]

[0027]

[0028]

[0029]

[0030] Where b x b y These represent the x and y coordinates of the center point of the bounding box, respectively, where gt represents the true bounding box, and c w c h These represent the horizontal and vertical distances between the center point of the true bounding box and the center point of the predicted bounding box, respectively.

[0031] (2) Distance loss Δ and shape loss Ω are defined as follows:

[0032]

[0033]

[0034]

[0035]

[0036] In the distance loss, ρ and c represent the center point distances between the predicted bounding box and the ground truth bounding box, respectively; in the shape loss, w, h, and w gt h gt θ represents the width and height of the predicted bounding box and the ground truth bounding box, respectively; θ is used to control the global weights of the shape loss.

[0037] (3) DYIoU Loss is defined as:

[0038] L dyiou =1-IoU+λ(Δ+γΛ+υΩ) (20)

[0039] γ = 1 - e -Δ (twenty one)

[0040]

[0041] Here, λ is a global parameter used to weigh the contributions of IoU and the three losses of distance, angle, and shape, and remains unchanged throughout the training task. For the angle loss and shape loss, weights γ and υ are assigned respectively, and these two weights decrease and increase respectively as the distance loss Δ decreases. That is, during network training, the contribution of the angle loss is dynamically reduced and the contribution of the shape loss is increased.

[0042] The beneficial effects of this invention are as follows: To address the limited feature fusion capability in multi-scale prediction, this invention designs a new Neck based on deformable convolution for feature fusion, adaptively adjusting the sampling point position and increasing the receptive field to effectively improve feature fusion capability. Secondly, addressing the limitations of the positional loss function in object detection algorithms, this invention proposes a dynamic intersection-union-ratio (IUU) loss function, which can dynamically adjust the contribution of different losses at different training stages, better aligning with object detection training logic and specifically constraining the network. Based on the above methods, this invention improves the YOLOv6 model, significantly enhancing model accuracy, and is plug-and-play, easily applicable to the training tasks of other object detection models. Regarding the dynamic IUU loss function, this invention first proposes the idea of ​​dynamic loss by analyzing the bounding box characteristics of the entire object detection task process; however, the design of the specific dynamic weights, i.e., γ and υ in Equation 20, still has room for improvement. Attached Figure Description

[0043] Figure 1 One-Stage detector abstract structure.

[0044] Figure 2 Detection methods at different scales, where (a) is single-scale feature detection and (b) is multi-scale fusion feature detection.

[0045] Figure 3 SIoU Loss (angle loss).

[0046] Figure 4 Bounding box state during the initial training phase.

[0047] Figure 5 Bounding box state during the later stages of training.

[0048] Figure 6 DYIoU Loss (Angle Loss).

[0049] Figure 7 DYIoU Loss: Distance loss and shape loss.

[0050] Figure 8 Convolution and deformable convolution sampling methods, where (a) is convolution and (a) is deformable convolution.

[0051] Figure 9 DePAN Neck structure.

[0052] Figure 10 DeConv Cell structure.

[0053] Figure 11 Comparison of inference results between YOLOv6-N and the improved YOLOv6-N.

[0054] Figure 12(a) shows the position loss during training, and Figure 12(b) shows the mAP. 0.5:0.95 Figure 12(c) shows mAP 0.5 Line graph. Detailed Implementation

[0055] 1.1 Target Detection

[0056] Object detection tasks aim to identify the location and category of objects in an image. Traditional object detection methods primarily rely on digital image processing to extract traditional features of the target region, such as histogram of oriented gradients (HOG) and scale-invariant feature transform (SIFT), and then use classifiers like support vector machines (SVM) to classify the region. However, this approach suffers from low accuracy and poor robustness. In recent years, with the rapid development of deep learning, deep learning-based object detection methods have achieved significant success, far surpassing traditional methods in both speed and accuracy. Generally, algorithms can be categorized into two types based on their detection process: two-stage methods that first extract the object region and then perform classification, and single-stage methods that directly regress the image to obtain the target's location coordinates and category. The Fast-R-CNN series is a representative example of two-stage detection algorithms. R-CNN pioneered the application of deep learning to object detection tasks. It first uses a selective search algorithm to generate a large number of proposed regions on the image, corresponding to the first stage of the two-stage algorithm. Then, a CNN extracts features from each proposed region. Finally, an SVM is trained for each category to predict the category of the proposed region, corresponding to the second stage of the two-stage algorithm. Because R-CNN requires re-inputting each proposed region into the CNN for feature extraction, it is extremely slow. Fast R-CNN, on the other hand, only uses the CNN to extract features once, obtaining a feature map of the image. The proposed regions in the original image are then directly mapped onto this feature map without re-extracting features, saving significant computation time. Furthermore, it incorporates the final regression and classification into the CNN, resulting in a significant speed improvement over R-CNN. Faster R-CNN successfully integrates region proposal, feature extraction, regression, and classification into the entire model, further improving both speed and accuracy. While the two-stage detection algorithm offers high accuracy, its inherent limitations make it significantly slower than single-stage detection.

[0057] Single-stage detection algorithms abandon the cumbersome region proposal stage and perform detection end-to-end, with the YOLO series as a representative example. YOLOv1 uses CNN to extract features from the original image and directly regresses and classifies bounding boxes, significantly improving speed compared to two-stage algorithms, but its accuracy is not ideal. YOLOv2 introduced an anchor box mechanism, where position prediction is no longer a blind, brute-force regression, but rather calculates the offset from the actual bounding box based on a pre-given anchor box size, greatly improving convergence speed and detection accuracy. YOLOv3 added FPN as a neck and fused multi-scale features for prediction, further improving both speed and accuracy. YOLOv3 became one of the most widely used models in industry. Recently, the Meituan team designed the more efficient EfficientRep Backbone, RepPAN NECK, and Efficient Decoupled Head based on the RepVGG concept, and used a new SIoU Loss as the position loss function, proposing YOLOv6, which surpasses other algorithms of similar size in both speed and accuracy.

[0058] 1.2 Loss Function

[0059] The loss function for object detection tasks typically consists of two parts: class loss and location loss. YOLO, however, adds an additional confidence error, where confidence refers to the probability that the model predicts the bounding box contains an object.

[0060] Common category losses include Cross Entropy Loss and Focal Loss. For location losses, YOLOv1 uses mean squared error to calculate the error between the center coordinates and dimensions of the predicted and ground truth bounding boxes. However, the mean squared error loss has limited constraint capabilities and is sensitive to bounding box scale, resulting in low model accuracy. Most current location losses are based on the intersection over union (IoU) ratio, such as IoU Loss (intersection over union loss), GIoU Loss (generalized IoU loss), DIoU Loss (distance IoU loss), and CIoULoss (complete IoU loss). IoU refers to the ratio of the intersection to the union of two bounding boxes. IoULoss is defined as:

[0061] L iou =1-IoU (1)

[0062] However, the biggest drawback of IoULoss is that when two bounding boxes do not intersect, the loss is always 1 regardless of their distance, meaning it cannot measure the distance between the two bounding boxes. To solve this problem, GIoU Loss was proposed. GIoULoss is defined as:

[0063]

[0064] Where C represents the minimum bounding rectangle area of ​​the predicted box A and the ground truth box B, thus solving the problem when the bounding boxes do not overlap. However, when the two boxes are in an inclusive relationship, GIoU Loss degenerates into IoU Loss, and DIoU Loss was proposed to solve this problem. DIoU Loss is defined as:

[0065]

[0066] Where ρ(b,b) gt ) represents the distance between the center points of the two bounding boxes, and c represents the diagonal length of the minimum bounding rectangle.

[0067] The author believes that a good location loss function should consider three factors: IoU, center point distance, and bounding box shape. Therefore, the author proposes the CIoU Loss definition as follows:

[0068]

[0069]

[0070]

[0071] Among them, w, h, w gt h gt These represent the width and height of the predicted bounding box and the width and height of the ground truth bounding box, respectively. It can be seen that CioULoss, based on DioU Loss, introduces aspect ratio, making the loss function more comprehensive. YOLOv6, on the other hand, uses the latest SIoU Loss (scyllaiouloss) as its loss function. SIoU Loss further incorporates the angle information between the two bounding boxes, such as... Figure 3 The authors argue that the loss function should consider the angle α between the bounding boxes. When α is less than π / 4, α should be constrained to be equal to 0, meaning the center point of the predicted bounding box should move closer to the X-axis where the center point of the true bounding box is located. When α is greater than π / 4, β should be minimized, moving closer to the Y-axis.

[0072] The angle loss Λ is defined as:

[0073]

[0074]

[0075] SIoU distance loss is defined as:

[0076]

[0077]

[0078] Where c w c h W, H, etc. Figure 3 As shown in the diagram. It is evident that the angle loss in SIoU ultimately exists as a component of the distance loss. Adding the shape loss Ω, which measures the shape, the final SIoU Loss is defined as:

[0079]

[0080] However, the latest SIoU Loss still has some problems. First, for angles less than π / 4, it optimizes along the X-axis, and vice versa. This inconsistent optimization behavior is detrimental to network training. Second, the authors integrated the angle loss into the distance loss, which fails to clearly reflect the constraint effect of the angle loss on the network. Finally, and this is a common problem with this series of IoU loss functions, it does not fully consider the intrinsic relationships between the components within the loss function, and cannot enable the network to optimize in a targeted manner at different stages of training. These are precisely the problems that this invention aims to solve.

[0081] 2.1 Dynamic Cross-Union Ratio Loss (DYIoU Loss)

[0082] Observing the entire object detection task training process, it is not difficult to find that in the early stages of training, such as Figure 4 The distance between the ground truth bounding box and the predicted bounding box is often large. Even if the width and height of the two bounding boxes are exactly the same, the prediction effect is still very poor. Therefore, the network should pay more attention to the angle loss at this time. The constraint on the angle can make the center points of the two bounding boxes get closer more quickly. Reflected in the loss function, the weight of the angle loss should be increased, while the weight of the shape loss should be appropriately reduced. In the middle and late stages of training, such as... Figure 5 When bounding boxes are close together, the network can optimize the center point distance even without adhering to the constrained angles. Overemphasizing angle loss at this point can interfere with training. Shape becomes the primary factor affecting detection performance, so the network should focus more on shape loss. This is reflected in the loss function by reducing the weight of angle loss and increasing the weight of shape loss.

[0083] Based on this idea, this invention designs a dynamic intersection over union loss (DYIoU Loss) function to dynamically adjust the weights of different components of the position loss function at different training stages. The loss function consists of four parts: IoU loss, distance loss, angle loss, and shape loss.

[0084] (1) Angle loss: The angle loss is no longer optimized according to different cases. Regardless of whether the included angle α is less than π / 4, it is optimized towards π / 4. That is, the predicted bounding box is constrained to move closer to the true bounding box along the direction of included angle π / 4.

[0085] The angle loss Λ is defined as:

[0086]

[0087]

[0088]

[0089]

[0090] Where b x b y These represent the x and y coordinates of the center point of the bounding box, respectively, where gt represents the true bounding box, and c w c h These represent the horizontal and vertical distances between the center point of the true bounding box and the center point of the predicted bounding box, respectively. Figure 6 As shown in the diagram. Compared to the angle loss in SIoU, this consistent behavior in the present invention is more conducive to network training.

[0091] (2) Distance loss Δ and shape loss Ω are defined as follows:

[0092]

[0093]

[0094]

[0095]

[0096] In the distance loss, ρ and c represent the distance between the center points of the predicted bounding box and the ground truth bounding box, respectively (e.g., ...). Figure 7 w, h, w in shape loss gt h gtθ represents the width and height of the predicted bounding box and the ground truth bounding box, respectively. θ controls the global weights of the shape loss, using the same settings as SIoU, and is set to 4 on the COCO dataset.

[0097] (3) DYIoU Loss is defined as:

[0098] L dyiou =1-IoU+λ(Δ+γΛ+υΩ) (20)

[0099] γ = 1 - e -Δ (twenty one)

[0100]

[0101] Here, λ is a global parameter used to balance the contributions of IoU and the three losses of distance, angle, and shape. It remains unchanged throughout the training task, and this invention ultimately selects 0.5 on the COCO dataset. For the angle loss and shape loss, weights γ and υ are assigned respectively. These two weights decrease and increase respectively as the distance loss Δ decreases. That is, during network training, the contribution of the angle loss is dynamically reduced, and the contribution of the shape loss is increased.

[0102] DYIoU Loss effectively addresses the problems associated with other location-based losses. First, it ensures network consistency by eliminating optimization along different coordinate axes based on angle. Second, the angle loss is no longer integrated with the location loss but exists as an independent component, making the constraint of angle on the network more intuitive. Finally, it assigns dynamic weights to the loss, dynamically adjusting the contribution of different losses at different stages of network training.

[0103] 2.2 Neck Structure with Deformable Convolution

[0104] The current mainstream design philosophy of Neck is to fuse feature maps of different scales. Fusion methods include element-wise addition, such as FPN and SPP, and channel-level concatenation, such as the improved PAN in YOLOv4. High-level features often contain semantic information of the image and have small feature maps, so they need to be upsampled before being fused with low-level features. Low-level features often contain image shape information and have larger feature maps, so they need to be downsampled before being fused with high-level features.

[0105] Because convolution has a limited receptive field and a fixed convolution pattern, the sampling position cannot be flexibly adjusted. Figure 8(a)). Therefore, convolutions used in Neck often fail to effectively preserve information from feature maps of different dimensions. Deformable convolutions, on the other hand, train a bias matrix to allow the convolution to adaptively adjust the sampling position, increase the receptive field, capture more useful features in the image, and improve feature extraction capabilities. Figure 8 (b)). Based on this characteristic, this invention improves the YOLOv6 Neck by combining deformable convolution and proposing the DePAN Neck (deformablepath aggregation network neck) structure (e.g., Figure 9 This is used to fuse features at different scales.

[0106] The DePAN Neck receives features at different scales extracted from the backbone. For high-level features, it first performs a 1×1 convolution followed by upsampling via a transposed convolution, then concatenates them with adjacent low-level features along the channel dimension. Finally, it fuses the features using DeConvBlock. Figure 9 The process involves a top-down fusion step. For low-level features, 3×3 convolutions are used for downsampling, followed by concatenation with adjacent high-level features along the channel dimension. The concatenated features are then fused using DeConvBlock, resulting in a fused feature that is input into the Header for classification and regression prediction. The DeConvBlock structure involves repeatedly stacking N DeConv Cells (…). Figure 10 The DePAN Neck structure is not limited to a specific model; it is plug-and-play and can be extended to various types of object detection tasks.

[0107] 3.1 Dataset

[0108] To evaluate the effectiveness of the proposed method, this invention uses the same COCO2017 dataset as the baseline network YOLOv6 in the original paper. COCO2017 is a large dataset containing 118,278 training images and 5,000 validation images. On average, each image contains 3.5 targets. Furthermore, this invention also conducted extensive experiments on the publicly available PASCAL VOC2012 dataset to further validate the effectiveness of the method. VOC2012 contains 5,717 training images and 5,823 validation images, covering 20 categories.

[0109] 3.2 Evaluation Indicators

[0110] This invention uses mAP, the most commonly used metric in object detection, as its evaluation standard. Regarding its calculation method, precision and recall are defined as follows:

[0111]

[0112]

[0113] TP, FP, and FN represent true positives, false positives, and false negatives, respectively. AP (Average Precision) is the area under the Precision-Recall curve. mAP is the average AP across all classes. 0.5 This represents the mAP value when the IoU threshold is 0.5. 0.5:0.95 This represents the average of 10 mAP values ​​obtained by setting the IoU threshold from 0.5 to 0.95 with a step size of 0.05.

[0114] 3.3 Experimental Details

[0115] This invention applies the proposed method to three YOLOv6 models: YOLOv6-N, YOLOv6-T, and YOLOv6-S, implemented using the PyTorch deep learning framework. The experimental setup used an RTX-3090 graphics card. The optimizer employed SGD, and the image input size and data augmentation settings remained the same as in the original YOLOv6 model. Since the batch size in the original YOLOv6 model was 256, while this invention uses 64, the initial learning rate was reduced to one-quarter of the original setting; that is, the initial learning rate for YOLOv6-N was set to 0.005, and the initial learning rates for YOLOv6-T and YOLOv6-S were set to 0.0025. Cosine annealing was used to adjust the learning rate, and the number of epochs was set to 400. Pre-training was not used during training.

[0116] 3.4 Experimental Results and Analysis

[0117] This invention applies the proposed method to three network sizes: YOLOv6-N, YOLOv6-T, and YOLOv6-S. The detection accuracy is shown in Table 1, where * indicates the mAP of the three networks using the method of this invention on the basis of the original model. 0.5:0.95 They increased by 2.9, 2.1, and 0.8 percentage points respectively, mAP 0.5 The accuracy rates were improved by 3.0, 2.3, and 0.9 percentage points respectively. To further evaluate the algorithm's performance on small targets, the detection accuracy for small targets was statistically analyzed, as shown in Table 2, with mAP... 0.5:0.95 The improvements were 1.2, 1.3, and 0.6 percentage points respectively. To more intuitively demonstrate the performance improvement of the algorithm, Figure 11 A comparison of the inference results for images using the original algorithm and the improved algorithm is presented. The experimental results show that training with the proposed DePANNeck and DYIoU Loss significantly improves the model's performance.

[0118] 3.5 Ablation Experiment

[0119] To verify the effectiveness of each module, this invention designed a series of controlled variable experiments, using two scales, YOLOv6-N and YOLOv6-T, to test the impact of using or not using the methods proposed in this invention on model performance. The experimental settings were the same as in Section 3.3, and training was conducted on the COCO training set. The results are shown in Table 3, where + indicates that only DYIoU Loss was used as the position loss for training on the original model, and ++ indicates that both DYIoU Loss and DePANNeck were used for improved model training. Figures 12(a), 12(b), and 12(c) show the position loss and mAP curves during the YOLOv6-N training process. As can be seen from the results in Table 3, gradually adding the methods proposed in this invention to the original model can significantly improve the model's accuracy, especially after using the DePAN Neck feature fusion, the effect is even more significant.

[0120] To further verify the effectiveness of the proposed dynamic position loss, a series of ablation experiments were designed on the VOC2012 dataset to conduct an in-depth analysis of the DYIoU Loss.

[0121] First, experiments were conducted on the dynamic weights γ for angle loss and υ for shape loss in Formula 20. The effects of using and not using each dynamic weight were observed on detection accuracy, and the results are shown in Table 4. × and √ represent the use and non-use of the corresponding dynamic weights, respectively. The experimental results show that the detection accuracy is highest when both dynamic weights γ and υ are used simultaneously. When only dynamic weight γ is used without υ, the accuracy decreases, but the loss still converges. However, when dynamic weight γ is not used, we found that the loss fails to converge regardless of whether dynamic weight υ is used or not, resulting in extremely low detection accuracy. Therefore, assigning dynamic weights to the angle loss in DYIoU Loss is necessary. Furthermore, to verify the impact of different global parameters λ in Formula 20 on model accuracy, this invention selected four values: 0.25, 0.5, 0.75, and 1.0 for experiments. The experimental results are shown in Table 5. The detection accuracy is highest when λ equals 0.5.

[0122] Table 1. Comparison of detection accuracy of different models on the COCO2017 validation set, unit: %

[0123]

[0124] Table 2 Comparison of detection accuracy for small target objects, unit: %

[0125]

[0126]

[0127] Table 3. Comparison results of ablation experiments, unit: %

[0128]

[0129] Table 4 Comparison of detection accuracy with and without dynamic weights, unit: %

[0130]

[0131] Table 5 Comparison of detection accuracy using different λ parameters, unit: %

[0132]

Claims

1. An improved YOLOv6 target detection method incorporating dynamic position loss, characterized in that, The steps are as follows: (1) Perform Mosaic data augmentation on the data. After randomly cropping and scaling the four images, they are randomly arranged and spliced ​​together to form a single image. (2) Construct a DePAN Neck based on deformable convolution to perform multi-scale feature fusion; (3) Use DePAN Neck in YOLOv6 to replace the original Neck part; (4) Use dynamic intersection-union loss as the location loss function to calculate the location loss between the predicted bounding box coordinates and the label bounding box coordinates; The loss function of the dynamic intersection-union ratio loss in (4) consists of four parts: IoU loss, distance loss, angle loss, and shape loss, as detailed below: ① Angle loss: The angle loss is no longer optimized based on different cases, regardless of the included angle. α Whether it is less than π / 4, optimize it towards π / 4, that is, constrain the predicted bounding box to move closer to the true bounding box along the direction of the included angle π / 4. Angular loss Λ Defined as: (12) (13) (14) (15) in b x , b y These represent the x and y coordinates of the center point of the bounding box, respectively. gt Represents the true bounding box. c w , c h These represent the horizontal and vertical distances between the center point of the true bounding box and the center point of the predicted bounding box, respectively. ② Distance loss Δ With shape loss Ω Defined as: (16) (17) (18) (19) Among the distance loss ρ The distance between the center points of the predicted bounding box and the ground truth bounding box is represented by 'c'; 'c' represents the diagonal length of the minimum bounding rectangle between the predicted and ground truth bounding boxes; in shape loss... w , h , w gt , h gt These represent the width and height of the predicted bounding box and the ground truth bounding box, respectively. θ Global weights used to control shape loss; ③DYIoU Loss is defined as: (20) (21) (22) in λ These are global parameters used to balance the contributions of IoU and the three losses of distance, angle, and shape, and remain unchanged throughout the training task; while the angle loss and shape loss are assigned weights respectively. γ and υ These two weights decrease with distance. Δ The contribution of angle loss is reduced and the contribution of shape loss is increased respectively as the network training process decreases; (5) Use VariFocal Loss as the class loss function to calculate the class loss between the model output and the label, and combine it with the position loss as the final total loss; (6) The Cosine Warmup strategy sets the learning rate and the warmupepochs are set to n, that is, the first n epochs are warmed up with a small learning rate, and after n epochs, the preset learning rate is used and the learning rate is adjusted according to the cosine annealing strategy. (7) Use the SGD optimizer with momentum to backpropagate the loss and update the parameters to train the model; (8) Use the model trained in step (7) to perform target detection.

2. The improved YOLOv6 target detection method with dynamic position loss according to claim 1, characterized in that, In step (2), the DePAN Neck receives features of different scales extracted from the backbone. For high-level features, a 1×1 convolution is first applied, followed by upsampling through transposed convolution. The features are then concatenated with adjacent low-level features in the channel dimension and fused using DeConvBlock. For low-level features, a 3×3 convolution is applied for downsampling, followed by concatenation with adjacent high-level features in the channel dimension. The concatenated features are then fused using DeConvBlock. Finally, the fused features are input into the Head part for classification and regression prediction. The DeConvBlock structure is composed of N DeConv Cells stacked repeatedly.