Two-dimensional detection and SGBM three-dimensional distance measurement method based on improved YOLOv13

By improving the YOLOv13 network and combining the SHSA mechanism and SGBM algorithm, the problem of low cross-view ranging accuracy in 3D spatial perception was solved, achieving high-precision and efficient target detection and ranging in complex road environments, and improving the robustness of the autonomous driving system.

CN121837352APending Publication Date: 2026-04-10SHENZHEN POLYTECHNIC
View PDF 0 Cites 1 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN POLYTECHNIC
Filing Date
2025-12-24
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing methods have low cross-view ranging accuracy at the level of 3D spatial perception, especially in complex dynamic scenes with poor performance in small target detection and dynamic occlusion.

Method used

An improved YOLOv13 network is used in conjunction with a single-head self-attention (SHSA) mechanism for 2D detection, and the SGBM algorithm is used for 3D ranging. Depth values ​​are calculated by acquiring disparity maps through a stereo camera, which enhances the model's perception of global context information and improves computational efficiency.

Benefits of technology

It significantly improves the accuracy and real-time performance of target detection and 3D ranging in complex road environments, effectively addressing challenges such as small target detection, dynamic occlusion, and changes in lighting, thus providing support for autonomous driving technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121837352A_ABST
    Figure CN121837352A_ABST
Patent Text Reader

Abstract

The invention discloses a two-dimensional detection and SGBM three-dimensional ranging method based on improved YOLOv13, belongs to the field of computer vision, and particularly relates to the two-dimensional detection and SGBM three-dimensional ranging method based on the improved YOLOv13. The objective of the invention is to solve the problem of low cross-view-angle distance measurement precision in a three-dimensional space perception level of the existing method. The method comprises the following steps of: obtaining a trained YOLOv13-SHSA network model; the binocular camera obtains a left view and a right view; inputting the left view into the trained network model, and outputting three detection results by three detection heads of the trained network model; processing the three detection results to obtain detection frames and confidence coefficients of a plurality of targets in the left view; obtaining a disparity map of the left and right views; calculating a depth value corresponding to each pixel point in the disparity map according to the disparity map and the binocular camera parameters; and calculating the distance of the target object based on the depth map, the detection frames of the multiple targets in the left view and the confidence coefficient.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the field of computer vision, and particularly relates to a two-dimensional detection and SGBM three-dimensional ranging method based on improved YOLOv13. BACKGROUND

[0002] The evolution of automatic driving perception systems sets higher thresholds for the robustness and efficiency of target detection and three-dimensional ranging technology in complex dynamic scenes. Currently, mainstream detection algorithms (represented by YOLO) perform poorly in dealing with small targets, dynamic occlusion and extreme lighting conditions. The main reason is that the downsampling process of traditional convolutional networks inevitably causes the loss of small target fine-grained information, resulting in missed detection. At the three-dimensional spatial perception level, efficient cross-view ranging methods still encounter bottlenecks in accuracy improvement. SUMMARY

[0003] The purpose of the application is to solve the problem of low three-dimensional spatial perception level cross-view ranging accuracy of existing methods, and propose a two-dimensional detection and SGBM three-dimensional ranging method based on improved YOLOv13.

[0004] The specific process of a two-dimensional detection and SGBM three-dimensional ranging method based on improved YOLOv13 is as follows:

[0005] Step one, obtain an image training set; step two, construct a YOLOv13-SHSA network model; step three, train the constructed YOLOv13-SHSA network model based on the image training set to obtain a trained YOLOv13-SHSA network model; step four, a binocular camera obtains a left view and a right view; input the left view into the trained YOLOv13-SHSA network model, and the three detection heads of the trained YOLOv13-SHSA network model output three detection results; adopt a non-maximum suppression method to process the three detection results to obtain detection frames and confidence of multiple targets in the left view; obtain a disparity map of the left view and the right view based on an SGBM algorithm; calculate the depth value corresponding to each pixel point in the disparity map according to the disparity map and the binocular camera parameters to generate a depth map; and calculate the distance of the target object based on the depth map, the detection frames and the confidence of multiple targets in the left view.

[0006] The application has the following beneficial effects:

[0007] This invention proposes a two-dimensional object detection technique based on an improved YOLOv13 and a three-dimensional ranging technique using SGBM, to enhance the detection capability of pedestrians, vehicles, and other targets in complex road environments. The VOC2007 dataset is used as the experimental data source. Regarding the model architecture, this invention improves the YOLOv13 network. Specifically, the YOLOv13 network architecture is improved by incorporating a Single-Head Self-Attention (SHSA) mechanism into the backbone network. The SHSA mechanism enhances the model's perception of global contextual information, effectively improving target detection in complex scenes such as vehicle occlusion and nighttime glare. For three-dimensional ranging, this invention employs the SGBM (Semi-Global Block Matching) stereo matching algorithm. The SGBM algorithm is a technique for depth image calculation in global matching stereo vision. It estimates the disparity between pixel blocks in two images by matching them, thereby calculating the depth information of the object. The advantage of the SGBM algorithm lies in its utilization of the correlation between pixel blocks, taking into account the information of surrounding pixels when calculating disparity. Therefore, it can obtain relatively accurate depth images and effectively handle complex conditions in real-world scenarios. Furthermore, the SGBM algorithm employs several optimization strategies, resulting in a certain degree of improvement in computational speed. Through the above technical solutions, this invention significantly improves the accuracy and real-time performance of target detection and 3D ranging in complex road environments, effectively addressing challenges such as small target detection, dynamic occlusion, and changes in illumination, providing strong support for the development of autonomous driving technology. Attached Figure Description

[0008] Figure 1 This is a flowchart of the two-dimensional detection and SGBM three-dimensional ranging technology method of YOLOv13-SHSA according to the present invention; Figure 2 This is a schematic diagram of the network structure of the YOLOv13-SHSA two-dimensional detection and SGBM three-dimensional ranging technology of the present invention; Figure 3 This is a schematic diagram illustrating the principle of SHSA in the method of the present invention; Figure 4 The images show a comparison of YOLOv13-SHSA and YOLOv13 in the method of the present invention. Image a is a comparison of mAP50 of YOLOv13-SHSA and YOLOv13 in the method of the present invention, and image b is a comparison of mAP95 of YOLOv13-SHSA and YOLOv13 in the method of the present invention. Figure 5 This is a graph showing the results of the YOLOv13-SHSA training metric Precision on the training set in the method of this invention; Figure 6 This is a graph showing the training metric Recall of YOLOv13-SHSA on the training set in the method of this invention; Figure 7The image shows the training metrics mAP@0.5 of YOLOv13-SHSA on the training set in the method of this invention. Figure 8 The graph shows the training metrics mAP@0.5:0.95 of YOLOv13-SHSA on the training set in the method of this invention. Figure 9 This is a performance metric curve of YOLOv13-SHSA on the training set val_box in the method of this invention, where val_box represents the validation set boundingbox; Figure 10 This is a performance index curve of YOLOv13-SHSA on the training set val_cls in the method of this invention, where val_cls represents the mean classification loss of the validation set; Figure 11 This is a performance index curve of YOLOv13-SHSA on the training set val_dfl in the method of this invention, where val_dfl represents the mean loss of the validation set; Figure 12 The images show the visual detection results of YOLOv13 on the test set in the method of this invention. (a) is the detection result of a bird, (b) is the detection result of a horse, and (c) is the detection result of a human. Figure 13 The images show the visual detection results of YOLOv13-SHSA on the test set in the method of this invention. (a) is the detection result of birds, (b) is the detection result of horses, and (c) is the detection result of humans. Figure 14 This is a visualization of the detection results of YOLOv13 on the YOLOv13-SGBM algorithm in the method of this invention; Figure 15 This is a visualization of the detection results of YOLOv13-SHSA on the YOLOv13-SGBM algorithm in the method of this invention. Detailed Implementation

[0009] Specific Implementation Method 1: This implementation method, based on an improved YOLOv13 2D detection and SGBM 3D ranging, involves the following steps: Step 1: Obtain an image training set; Step 2: Construct a YOLOv13-SHSA network model; Step 3: Train the constructed YOLOv13-SHSA network model using the image training set to obtain a trained YOLOv13-SHSA network model; Step 4: Use a binocular camera to acquire left and right views; input the left view into the trained YOLOv13-SHSA network. The trained YOLOv13-SHSA network model outputs three detection results from its three detector heads. Non-maximum suppression is used to process these three results, yielding bounding boxes and confidence scores for multiple targets (people, vehicles, dogs, etc.) in the left view. Disparity maps of the left and right views are obtained using the SGBM algorithm. Based on the disparity maps and binocular camera parameters, the depth value corresponding to each pixel in the disparity map is calculated to generate a depth map. The distance to the target object is calculated based on the depth map, the bounding boxes, and the confidence scores (categories) of multiple targets in the left view.

[0010] Specific Implementation Method Two: This implementation method differs from Specific Implementation Method One in that: in step one, the image training set is obtained; the specific process is as follows: the VOC2007 dataset is used as the image training set; the VOC2007 dataset contains 20 categories, namely: airplane, bicycle, bird, boat, bottle, bus, car, cat, chair, cow, dining table, dog, horse, motorcycle, person, potted plant, sheep, sofa, train, and television.

[0011] This invention uses the VOC2007 dataset as the experimental data source. The VOC2007 dataset is widely used for object detection and image segmentation tasks, containing images and corresponding annotations for 20 categories. To facilitate effective model training, validation, and testing, the entire dataset is divided into three parts: a training set, a validation set, and a test set. The training set comprises 80% of the total data, containing 17,202 images, used for model learning and parameter optimization. The validation set contains the remaining 10%, totaling 2,150 images, used to evaluate the model's actual performance and generalization ability. The test set comprises 10% of the total dataset, totaling 2,151 images, used to evaluate the performance of the finally trained model. This division ensures sufficient training data while retaining enough test and validation samples to verify the model's effectiveness. The publicly available VOC2007 dataset was obtained. This dataset contains 20 categories, including pedestrians, animals, vehicles, and indoor objects. The dataset is divided into training, validation, and test sets in an 8:1:1 ratio. All images cover all 20 categories, helping the model effectively handle diverse situations in real-world roads. The training set contains 17,202 images, accounting for 80% of the total. Its core function is to serve as the foundation for parameter learning and feature extraction, enabling the model to grasp the basic features and complex patterns of the detected targets from a large number of samples. The validation set contains 2,150 images, accounting for 10%, mainly used for model selection and hyperparameter optimization during training. By periodically evaluating the model's performance on the validation set, its generalization ability can be monitored, and the learning rate can be adjusted accordingly, or training can be terminated early to effectively prevent overfitting. The test set also contains 2,151 images, accounting for 10%. It is strictly isolated throughout the model development phase and used only for final evaluation of the model's performance on completely unknown data. Its performance metrics objectively reflect the model's potential for practical applications. This division ensures the rigor of the model development process: the training set is responsible for model building, the validation set for iterative optimization, and the test set for performance evaluation. These three work together to guarantee the accuracy and reliability of the final model. Other steps and parameters are the same as in Implementation Method 1.

[0012] Specific Implementation Method Three: This implementation method differs from Specific Implementation Method One or Two in that: in step two, a YOLOv13-SHSA network model is constructed; the specific process is as follows:

[0013] The YOLOv13-SHSA network model includes: Backbone network, Neck network, and Head network;

[0014] The backbone network includes: a first convolutional layer, a second convolutional layer, a third DS-C3k2 layer, a fourth convolutional layer, a fifth DS-C3k2 layer, a sixth depth-separable convolutional layer DSConv, a seventh A2C2f layer, an eighth depth-separable convolutional layer DSConv, a ninth A2C2f layer, and a tenth SHSA layer.

[0015] The Neck network comprises: an 11th upsampling layer (Upsample), a 12th cascaded layer, a 13th DS-C3k2 layer, a 14th upsampling layer (Upsample), a 15th cascaded layer, a 16th DS-C3k2 layer, a 17th convolutional layer, an 18th cascaded layer, a 19th DS-C3k2 layer, a 20th convolutional layer, a 21st cascaded layer, a 22nd DS-C3k2 layer, and a 23rd Hyperace layer; Hyperace represents an adaptive association enhancement mechanism based on a hypergraph.

[0016] The detection head network includes: detection head 1, detection head 2, and detection head 3; each of detection heads 1, 2, and 3 includes a detection box branch and a confidence branch; the detection box branch includes, in sequence: a 24th convolutional layer, a 25th convolutional layer, and a 26th two-dimensional convolutional layer; the 26th two-dimensional convolutional layer outputs the detection box; the confidence branch includes, in sequence: a 27th depthwise separable convolutional layer, a 28th convolutional layer, a 29th depthwise separable convolutional layer, a 30th convolutional layer, and a 31st two-dimensional convolutional layer; the 31st two-dimensional convolutional layer outputs the confidence score.

[0017] The YOLOv13 network architecture is improved by incorporating a Single-Head Self-Attention (SHSA) mechanism into the backbone network. SHSA enhances the model's perception of global contextual information, effectively improving target detection in complex scenarios such as vehicle occlusion and nighttime glare. Specifically, YOLOv13 consists of three main parts: Backbone, Neck, and Head. The Backbone part of the backbone network uses the SHSA mechanism for feature extraction. The core of the SHSA mechanism is a single-head design, which divides the input features along the channel dimension and applies multi-scale feature enhancement global self-attention computation only to a subset of channels, while retaining the remaining channels through identity mapping. This allows the model to maintain its ability to model long-distance dependencies in road scenes while significantly reducing computational complexity. This module plays a crucial role in autonomous driving visual perception systems. By optimizing memory access patterns and improving computational efficiency, it effectively solves the challenges of demanding real-time requirements in complex urban scenarios such as multi-target interactions at intersections and adverse weather conditions, while significantly improving inference speed while maintaining high accuracy. This improved module enhances multi-scale features based on standard SHSA. First, LayerNorm normalization is applied to selected channels. Then, multi-scale features are extracted in parallel using three 3×3 convolutions with different dilation rates (d=1, 2, 3). These features are then concatenated and fused, and a unified 1×1 convolution projection is used to generate query Q, key K, and value V vectors. This multi-scale preprocessing enables the model to simultaneously capture local details and global contextual information, significantly enhancing its ability to perceive multi-scale targets in complex road scenes. SHSA is a partial input channel aggregation of spatial features (… Applying a single attention layer to the header does not affect the other channels. We will Set 1 / 4.67 as the default value. Formally, the SHSA layer can be described as:

[0018]

[0019]

[0020]

[0021]

[0022] in, , , , For projection weights, To query the dimensions and keys (default is 16), For join operations, the superscript T indicates transpose. To achieve consistent memory access, we will initialize... Each channel serves as a representative of the entire feature map. Furthermore, the final projection of SHSA is applied to all channels, not just the initial one. This ensures that attention features are effectively propagated to the remaining channels. This module plays a crucial role in autonomous driving visual perception systems. By optimizing memory access patterns and improving computational efficiency, it effectively alleviates the challenges of stringent real-time requirements in complex urban scenarios such as multi-target interactions at intersections and adverse weather conditions, while significantly increasing inference speed while maintaining high accuracy. Other steps and parameters are the same as in specific implementation methods one or two.

[0023] Specific Implementation Method Four: This implementation method differs from Specific Implementation Methods One to Three in that: in step three, the constructed YOLOv13-SHSA network model is trained based on the image training set to obtain the trained YOLOv13-SHSA network model; the specific process is as follows:

[0024] Step 3: 1. Input the image into the backbone network; the backbone network outputs a feature map. The specific process is as follows:

[0025] The image is sequentially input into the first convolutional layer, the second convolutional layer, the third DS-C3k2 layer, the fourth convolutional layer, and the fifth DS-C3k2 layer. The fifth DS-C3k2 layer outputs a feature map. Feature map The input is sequentially processed by the 6th depthwise separable convolutional layer DSConv and the 7th layer A2C2f. The 7th layer A2C2f outputs a feature map. Feature map The input is sequentially processed by the 8th depthwise separable convolutional layer DSConv and the 9th layer A2C2f. The 9th layer A2C2f outputs a feature map. ; 9th layer A2C2f output feature map Input the 10th layer SHSA, output the feature map of the 10th layer SHSA ;

[0026] Step 3.2 Feature Map Input the 23rd layer Hyperace, output the feature map of the 23rd layer Hyperace. Feature map Input the 23rd layer Hyperace, output the feature map of the 23rd layer Hyperace. Feature map Input the 23rd layer Hyperace, output the feature map of the 23rd layer Hyperace. ;

[0027] Step 33: Feature Map With feature map By adding elements one by one, we obtain the feature map. Feature map With feature map By adding elements one by one, we obtain the feature map. Feature map With feature map By adding elements one by one, we obtain the feature map. ;

[0028] Steps 3 and 4: Feature Map Input to the 11th upsampling layer (Upsample), output the feature map. Feature map With feature map Input the 12th cascaded layer (concatenated), output feature map Feature map Input to the 13th layer DS-C3k2, output feature map of the 13th layer DS-C3k2 Feature map Input to the 14th upsampling layer (Upsample), output the feature map. Feature map With feature map Input to the 15th cascaded layer; output feature map from the 15th cascaded layer. Feature map Input to the 16th layer DS-C3k2, output feature map of the 16th layer DS-C3k2 ;

[0029] Step 3.5: Output feature map of DS-C3k2 at layer 16 With feature map By adding elements one by one, we obtain the feature map. ; DS-C3k2 output feature map of layer 13 With feature map By adding elements one by one, we obtain the feature map. ;

[0030] Step 36: Feature Map Input to the 17th convolutional layer; output feature map from the 17th convolutional layer. Feature map With feature map Input to the 18th cascaded layer; output feature map from the 18th cascaded layer. Feature map Input to the 19th layer DS-C3k2, output feature map of the 19th layer DS-C3k2 Feature map Input to the 20th convolutional layer; output feature map from the 20th convolutional layer. Feature map With feature map Input to the 21st cascaded layer, output feature map from the 21st cascaded layer. Feature map Input to the 22nd layer DS-C3k2, output feature map of the 22nd layer DS-C3k2 ;

[0031] Step 37, Feature Map Input detection head 1, detection head 1 outputs detection result 1; detection result 1 includes detection box 1 and confidence score 1; feature map With feature map The feature map is obtained by adding elements one by one. Feature map Input detection head 2, detection head 2 outputs detection result 2; detection result 2 includes detection box 2 and confidence score 2; feature map With feature map The feature map is obtained by adding elements one by one. Feature map Input detection head 3, and detection head 3 outputs detection result 3; detection result 3 includes detection box 3 and confidence score 3.

[0032] Step 38: Repeat steps 31 to 37 until the loss function converges to obtain the trained YOLOv13-SHSA network model; the loss function is the loss function of detector head 1, the loss function of detector head 2, and the loss function of detector head 3. Other steps and parameters are the same as in specific implementation methods one to three.

[0033] Specific Implementation Method Five: This implementation method differs from Specific Implementation Methods One to Four in that: the 10th SHSA layer includes a Layer Normalization layer (LayerNorm) and a convolutional kernel size of... The dilated convolutional layer 1 has a kernel size of [missing value]. The dilated convolutional layer 2 has a kernel size of [missing information]. The dilated convolutional layer 3, the splicing layer, and the convolutional kernel size are... The convolutional layer 4, the self-attention mechanism, and the splicing layer; the size of the convolutional kernel is [missing information]. The dilation rate of dilated convolution 1 The value is 1; the kernel size is The dilation rate of dilated convolution 2 The value is 2; the kernel size is The dilation rate of dilated convolution 3 The value is 3. Other steps and parameters are the same as in one of the specific implementation methods one to four.

[0034] Specific Implementation Method Six: This implementation method differs from Specific Implementation Methods One through Five in that the working process of the 10th layer SHSA is as follows:

[0035] Output feature map of layer 9, A2C2f. passage Divided into and ; ;

[0036] aisle Corresponding feature map Input layer normalization layer LayerNorm, output feature map ; feature map The input convolution kernel size is The dilated convolutional layer 1 has a kernel size of [missing value]. Dilated convolutional layer 1 output feature map ; feature map The input convolution kernel size is The dilated convolutional layer 2 has a kernel size of [missing value]. Dilated convolutional layer 2 output feature map ; feature map The input convolution kernel size is The dilated convolutional layer 3 has a kernel size of [missing value]. Dilated convolutional layer 3 output feature map ;

[0037] feature map Feature map Feature map Input to the concatenation layer, output feature map. ;

[0038] feature map The input convolution kernel size is Convolutional layer 4, with a kernel size of [missing value]. Convolutional layer 4 output feature map Feature map Divided by channel , , ( , , Feature maps corresponding to different channels );

[0039] , , Input is the Self-Attention mechanism, output is the feature map. Feature map and channels Corresponding feature map Input to the concatenation layer, output feature map. .

[0040] The other steps and parameters are the same as those in any of the specific implementation methods one to five.

[0041] Specific Implementation Method Seven: This implementation method differs from Specific Implementation Methods One to Six in that: the image size in the training set is 640×640; the amount of input data per batch during training is 32, the number of training rounds is 300, and the learning rate is 0.01.

[0042] The other steps and parameters are the same as those in one of the specific implementation methods one to six.

[0043] Specific Implementation Method Eight: This implementation method differs from Specific Implementation Methods One through Seven in that the loss function is:

[0044]

[0045] in, The adaptive multi-scale focal IoU loss function (AMS-FIoU) is used. Size weight; for Loss item, This is the intersection-union ratio (IoU) between the predicted bounding box and the ground truth bounding box.

[0046] , These are hyperparameters, set to 0.5 and 0.1 respectively; This is the intersection-union ratio (IoU) between the scaled predicted bounding box and the scaled ground truth bounding box. The focus of the loss; This is a dynamic adjustment factor. The working principle of the AMS-FIoU loss function is based on: using size weights... Prioritize and optimize small target detection, focus items Reduce easy sample weights to decrease overfitting; internal alignment term Improving Bounding Box Localization Accuracy. When training the YOLOv13-SHSA model, AMS-FIoU effectively handles complex scenes, such as vehicle occlusion or low-light conditions at night, enhancing detection capabilities through a multi-scale adaptive mechanism. This invention proposes an Adaptive Multi-Scale Focal IoU Loss (AMS-FIoU). This loss function significantly enhances the model's detection accuracy for small targets and complex occlusion scenes by introducing size-adaptive weights and an internal IoU alignment mechanism. Its core lies in fusing focal loss to optimize the balance between easy and difficult samples and utilizing dynamic adjustment factors to improve training stability, thereby achieving more robust 2D target detection performance in challenging environments such as vehicle occlusion and nighttime reflections. Specifically, AMS-FIoU integrates multi-scale feature alignment and focal weighting, aiming to improve the robustness and accuracy of the YOLOv13 model in complex road scenes, especially optimizing small target localization. Other steps and parameters are the same as in specific implementation methods one through seven.

[0047] Specific Implementation Method Nine: This implementation method differs from Specific Implementation Methods One through Eight in that the size weighting... The calculation method is shown in the following formula: This weight increases the loss contribution of small targets, thereby enhancing the model's attention to small targets; to enhance the detection capability of small targets, size-adaptive weights are introduced. Size factor The calculation method is shown in the following formula: ;in, Input image size; The actual frame width. This is the actual frame height;

[0048] The Loss Items The calculation method is shown in the following formula: ;

[0049] The focal loss item The calculation method is shown in the following formula: ;

[0050] in, Calculate the category confidence score for the predicted bounding box; As the focus weight, ;

[0051] To address the sample imbalance problem during training, this invention introduces a focus loss term to weight the hard samples;

[0052] The intersection-over-union ratio of the scaled predicted bounding box and the scaled ground truth bounding box The calculation method is shown in the following formula: ;in, This represents the intersection area of ​​the scaled predicted bounding box and the scaled ground truth bounding box.

[0053] This represents the area of ​​the union of the scaled predicted bounding box and the scaled ground truth bounding box.

[0054] The process of obtaining the scaled predicted bounding box and the scaled ground truth bounding box is as follows:

[0055] To improve the regression accuracy of bounding boxes, especially for small targets, this invention adds an internal alignment term and sets a scaling factor. , Based on scaling factor The predicted bounding box is shrunk inward to obtain a scaled predicted bounding box; based on the scaling factor... Shrink the real bounding box inward to obtain the scaled real bounding box.

[0056] The other steps and parameters are the same as those in one of the specific implementation methods one to eight.

[0057] Specific Implementation Method Ten: This implementation method differs from Specific Implementation Methods One through Nine in that the dynamic adjustment factor... As the number of training cycles increases, let the total number of training cycles be . The current cycle is ,but The calculation method is shown in the following formula: The other steps and parameters are the same as those in any of the specific implementation methods one through nine.

[0058] By adjusting and optimizing the hyperparameters of the YOLOv13 model and adopting a standard evaluation system, we can comprehensively evaluate the performance of YOLOv13-SHSA in road condition detection. In the experiments, reasonable hyperparameter settings (such as image input size, batch size, training epochs, and learning rate) significantly improved the model's detection accuracy and efficiency. Evaluation metrics such as recall, F1-score, precision, and mean average precision (mAP@0.5, with an IoU threshold of 0.5) provide a scientific basis for the improved model performance.

[0059] The trained YOLOv13-SHSA model was tested using a test set to evaluate its performance. Specifically:

[0060] After inputting the test set into the YOLOv13-SHSA model, the model will detect each image and output item information, including the item's category, location, and confidence score. Then, we will compare the model's predictions with the true labels of the images in the test set to calculate accuracy and recall. Key performance indicators such as scores are used. This comprehensive evaluation method not only measures the overall performance of the model but also reveals its strengths and weaknesses in detecting different types of items. Through detailed analysis of the test results, we can gain a deeper understanding of the application effect of the YOLOv13-SHSA model in real-world scenarios and provide technical support for subsequent optimization and deployment. This systematic verification process will help us objectively evaluate the actual performance of the model and ensure its stability and effectiveness in security inspection work. The method proposed in this invention is compared with the YOLOv13 baseline detection algorithm on the VOC2007 dataset, showing that the YOLOv13-SHSA model has achieved a significant improvement in detection accuracy compared to the baseline algorithm. The method proposed in this invention is compared with the YOLOv13 baseline detection algorithm on the VOC2007 dataset, showing that the YOLOv13-SHSA model has achieved a significant improvement in detection accuracy compared to the baseline algorithm. To verify the detection performance of the YOLOv13-SHSA model in real-world road environments and its effectiveness in 3D perception tasks, this invention deploys the optimal weights obtained from training onto a YOLOv13-SGBM ranging system integrating the SGBM stereo matching algorithm for testing. The specific process is as follows: First, data input and stereo alignment are performed: the system loads pre-calibrated binocular camera parameters and performs epipolar correction on the left and right views to ensure image row alignment, providing a geometric basis for subsequent stereo matching. Then, the YOLOv13-SHSA model is used to detect targets in the left view, identifying key targets such as vehicles and pedestrians, and outputting their category information and pixel-level bounding box coordinates. Next, 3D coordinate mapping is performed: the detection boxes in the left view are mapped to the corresponding areas in the right view, and the disparity map of the target area is calculated based on the SGBM algorithm. SGBM, as a semi-global stereo matching algorithm, can stably estimate target disparity while maintaining high computational efficiency through pixel block matching and cost aggregation strategies. Finally, based on intrinsic parameters such as camera focal length and baseline distance, the disparity value is mapped to the actual coordinates of the target in 3D space using the disparity-depth conversion formula. The experiment selected video footage of road sections with low traffic volume during the day as the test scenario, which included various targets such as pedestrians, electric vehicles, and stationary vehicles on the roadside, simulating typical objects in a real driving environment. Test results show that the system can accurately identify and locate various targets, effectively verifying the effectiveness and superiority of the YOLOv13-SHSA model in detecting complex road conditions.

[0061] The beneficial effects of the present invention are verified using the following embodiments:

[0062] Example 1:

[0063] Step 1: Obtain the publicly available VOC2007 dataset. This dataset contains 20 categories, including pedestrians, animals, vehicles, and indoor objects. The dataset is divided into training, validation, and test sets in an 8:1:1 ratio. All images cover all 20 categories, helping the model effectively handle diverse situations in real-world roads. The training set contains 17,202 images, accounting for 80% of the total. Its core function is to serve as the foundation for parameter learning and feature extraction, enabling the model to grasp the basic features and complex patterns of the detected targets from a large number of samples. The validation set contains 2,150 images, accounting for 10%, mainly used for model selection and hyperparameter optimization during training. By periodically evaluating model performance on the validation set, the trend of its generalization ability can be monitored, and the learning rate can be adjusted accordingly, or training can be terminated early to effectively prevent overfitting. The test set also contains 2,151 images, accounting for 10%. It is strictly isolated throughout the model development phase and is only used for the final evaluation of the model's performance on completely unknown data. Its performance metrics objectively reflect the model's practical application potential. This division ensures the rigor of the model development process: the training set is responsible for model building, the validation set is responsible for iterative optimization, and the test set provides performance evaluation. The three work together to ensure the accuracy and reliability of the final model.

[0064]

[0065] Step 2: Construct the YOLOv13-SHSA network model; the specific process is as follows:

[0066] The YOLOv13-SHSA network model includes: Backbone network, Neck network, and Head network;

[0067] The backbone network includes: a first convolutional layer, a second convolutional layer, a third DS-C3k2 layer, a fourth convolutional layer, a fifth DS-C3k2 layer, a sixth depth-separable convolutional layer DSConv, a seventh A2C2f layer, an eighth depth-separable convolutional layer DSConv, a ninth A2C2f layer, and a tenth SHSA layer.

[0068] The Neck network includes: an 11th upsample layer, a 12th cascaded layer, a 13th DS-C3k2 layer, a 14th upsample layer, a 15th cascaded layer, a 16th DS-C3k2 layer, a 17th convolutional layer, an 18th cascaded layer, a 19th DS-C3k2 layer, a 20th convolutional layer, a 21st cascaded layer, a 22nd DS-C3k2 layer, and a 23rd Hyperace layer.

[0069] Hyperace represents an adaptive association enhancement mechanism based on hypergraphs;

[0070] The detection head network includes: detection head 1, detection head 2, and detection head 3;

[0071] Each of the detection heads 1, 2, and 3 includes a detection frame branch and a confidence branch;

[0072] The detection box branches sequentially include: the 24th convolutional layer, the 25th convolutional layer, and the 26th two-dimensional convolutional layer; the 26th two-dimensional convolutional layer outputs the detection box.

[0073] The confidence branch includes, in sequence: the 27th depthwise separable convolutional layer, the 28th convolutional layer, the 29th depthwise separable convolutional layer, the 30th convolutional layer, and the 31st two-dimensional convolutional layer; the 31st two-dimensional convolutional layer outputs the confidence level.

[0074] The YOLOv13 network architecture is improved by incorporating a Single-Head Self-Attention (SHSA) mechanism into the backbone network. SHSA enhances the model's awareness of global contextual information, effectively improving target detection in complex scenarios such as vehicle occlusion and nighttime glare. Specifically:

[0075] YOLOv13 mainly consists of three parts: Backbone, Neck, and Head. The Backbone part of the backbone network uses the SHSA mechanism for feature extraction.

[0076] The core of the SHSA mechanism is a single-head design, which divides input features along the channel dimension. It applies global self-attention computation with multi-scale feature enhancement to only a subset of channels, while preserving the remaining channels through identity mapping. This allows the model to maintain its ability to model long-distance dependencies in road scenes while significantly reducing computational complexity. This module plays a crucial role in autonomous driving visual perception systems. By optimizing memory access patterns and improving computational efficiency, it effectively addresses the challenges of real-time performance in complex urban scenarios such as multi-target interactions at intersections and adverse weather conditions, while significantly increasing inference speed while maintaining high accuracy. This improved module enhances multi-scale features based on the standard SHSA. First, LayerNorm normalization is performed on selected channels. Then, multi-scale features are extracted in parallel using three 3×3 convolutions with different dilation rates (d=1,2,3). These features are then concatenated and fused, and a unified 1×1 convolution projection is used to generate query Q, key K, and value V vectors. This multi-scale preprocessing enables the model to capture both local details and global contextual information, significantly enhancing its ability to perceive multi-scale targets in complex road scenes. SHSA is a partial input channel for spatial feature aggregation. Applying a single attention layer to the header does not affect the other channels. We will Set 1 / 4.67 as the default value. The SHSA layer is described as follows:

[0077]

[0078]

[0079]

[0080]

[0081]

[0082] in, , , , For projection weights, To query the dimensions and keys (default is 16), For join operations, the superscript T indicates transpose. To achieve consistent memory access, we will initialize... Each channel serves as a representative of the entire feature map. Furthermore, the final projection of SHSA is applied to all channels, not just the initial one. This module ensures that attention features are effectively propagated to the remaining channels. It plays a crucial role in autonomous driving vision perception systems, effectively alleviating the challenges of demanding real-time requirements in complex urban scenarios such as multi-target interactions at intersections and adverse weather conditions by optimizing memory access patterns and improving computational efficiency. Simultaneously, it significantly increases inference speed while maintaining high accuracy.

[0083] Step 3: Train the constructed YOLOv13-SHSA network model based on the image training set to obtain the trained YOLOv13-SHSA network model. The specific process is as follows: Step 3:1. Input the image into the backbone network. The backbone network outputs a feature map. Specifically, the image is sequentially input into the 1st convolutional layer, the 2nd convolutional layer, the 3rd DS-C3k2 layer, the 4th convolutional layer, and the 5th DS-C3k2 layer. The 5th DS-C3k2 layer outputs a feature map. Feature map The input is sequentially processed by the 6th depthwise separable convolutional layer DSConv and the 7th layer A2C2f. The 7th layer A2C2f outputs a feature map. Feature map The input is sequentially processed by the 8th depthwise separable convolutional layer DSConv and the 9th layer A2C2f. The 9th layer A2C2f outputs a feature map. ; 9th layer A2C2f output feature map Input the 10th layer SHSA, output the feature map of the 10th layer SHSA Step 3.2 Feature Map Input the 23rd layer Hyperace, output the feature map of the 23rd layer Hyperace. Feature map Input the 23rd layer Hyperace, output the feature map of the 23rd layer Hyperace. Feature map Input the 23rd layer Hyperace, output the feature map of the 23rd layer Hyperace. Step 3.3 Feature Map With feature map By adding elements one by one, we obtain the feature map. Feature map With feature map By adding elements one by one, we obtain the feature map. Feature map With feature map By adding elements one by one, we obtain the feature map. Steps 3 and 4: Feature Map Input to the 11th upsampling layer (Upsample), output the feature map. Feature map With feature map Input the 12th cascaded layer (concatenated), output feature map Feature map Input to the 13th layer DS-C3k2, output feature map of the 13th layer DS-C3k2 Feature map Input to the 14th upsampling layer (Upsample), output the feature map. Feature map With feature map Input to the 15th cascaded layer; output feature map from the 15th cascaded layer. Feature map Input to the 16th layer DS-C3k2, output feature map of the 16th layer DS-C3k2 Step 3.5: Output feature map of the 16th layer DS-C3k2 With feature map By adding elements one by one, we obtain the feature map. ; DS-C3k2 output feature map of layer 13 With feature map By adding elements one by one, we obtain the feature map. Step 36: Feature Map Input to the 17th convolutional layer; output feature map from the 17th convolutional layer. Feature map With feature map Input to the 18th cascaded layer; output feature map from the 18th cascaded layer. Feature map Input to the 19th layer DS-C3k2, output feature map of the 19th layer DS-C3k2 Feature map Input to the 20th convolutional layer; output feature map from the 20th convolutional layer. Feature map With feature map Input to the 21st cascaded layer, output feature map from the 21st cascaded layer. Feature map Input to the 22nd layer DS-C3k2, output feature map of the 22nd layer DS-C3k2 Step 37, Feature Map Input detection head 1, detection head 1 outputs detection result 1; detection result 1 includes detection box 1 and confidence score 1; feature map With feature map The feature map is obtained by adding elements one by one. Feature map Input detection head 2, detection head 2 outputs detection result 2; detection result 2 includes detection box 2 and confidence score 2; feature map With feature map The feature map is obtained by adding elements one by one. Feature map Input detection head 3, and detection head 3 outputs detection result 3; detection result 3 includes detection box 3 and confidence score 3; Step 38: Repeat steps 31 to 37 until the loss function converges to obtain the trained YOLOv13-SHSA network model; the loss function is the loss function of detection head 1, the loss function of detection head 2, and the loss function of detection head 3. The 10th SHSA layer includes a LayerNorm normalization layer and a convolutional kernel size of [missing information]. The dilated convolutional layer 1 has a kernel size of [missing value]. The dilated convolutional layer 2 has a kernel size of [missing information]. The dilated convolutional layer 3, the splicing layer, and the convolutional kernel size are... The convolutional layer 4, the self-attention mechanism, and the splicing layer; the size of the convolutional kernel is [missing information]. The dilation rate of dilated convolution 1 The value is 1; the kernel size is The dilation rate of dilated convolution 2 The value is 2; the kernel size is The dilation rate of dilated convolution 3 The value is 3. The working process of the 10th layer SHSA is as follows: the feature map output from the 9th layer A2C2f is... passage Divided into and ; ;aisle Corresponding feature map Input layer normalization layer LayerNorm, output feature map ; feature map The input convolution kernel size is The dilated convolutional layer 1 has a kernel size of [missing value]. Dilated convolutional layer 1 output feature map ; feature map The input convolution kernel size is The dilated convolutional layer 2 has a kernel size of [missing value]. Dilated convolutional layer 2 output feature map ; feature map The input convolution kernel size is The dilated convolutional layer 3 has a kernel size of [missing value]. Dilated convolutional layer 3 output feature map ; feature map Feature map Feature map Input to the concatenation layer, output feature map. ; feature map The input convolution kernel size is Convolutional layer 4, with a kernel size of [missing value]. Convolutional layer 4 output feature map Feature map Divided by channel , , ( , , Feature maps corresponding to different channels ); , , Input is the Self-Attention mechanism, output is the feature map. Feature map and channels Corresponding feature map Input to the concatenation layer, output feature map. .

[0084] The images in the training set are 640×640 pixels in size; the input data size per batch during training is 32, the number of training rounds is 300, and the learning rate is 0.01. Other steps and parameters are the same as in any of the specific implementation methods one to six.

[0085] Specific Implementation Method Eight: This implementation method differs from Specific Implementation Methods One through Seven in that the loss function is:

[0086]

[0087] in, The adaptive multi-scale focal IoU loss function (AMS-FIoU) is used. Size weight; for Loss item, This is the intersection-union ratio (IoU) between the predicted bounding box and the ground truth bounding box.

[0088] , These are hyperparameters, set to 0.5 and 0.1 respectively; This is the intersection-union ratio (IoU) between the scaled predicted bounding box and the scaled ground truth bounding box. The focus of the loss; This is a dynamic adjustment factor. The working principle of the AMS-FIoU loss function is based on: using size weights... Prioritize and optimize small target detection, focus items Reduce easy sample weights to decrease overfitting; internal alignment term Improving Bounding Box Localization Accuracy. When training the YOLOv13-SHSA model, AMS-FIoU effectively handles complex scenes, such as vehicle occlusion or low-light conditions at night, enhancing detection capabilities through a multi-scale adaptive mechanism. This invention proposes an Adaptive Multi-Scale Focal IoU Loss (AMS-FIoU). This loss function significantly enhances the model's detection accuracy for small targets and complex occlusion scenes by introducing size-adaptive weights and an internal IoU alignment mechanism. Its core lies in fusing focus loss to optimize the balance between easy and difficult samples and utilizing dynamic adjustment factors to improve training stability, thereby achieving more robust 2D target detection performance in challenging environments such as vehicle occlusion and nighttime reflections. Specifically, AMS-FIoU integrates multi-scale feature alignment and focus weighting, aiming to improve the robustness and accuracy of the YOLOv13 model in complex road scenes, especially optimizing the localization of small targets. The size weights... The calculation method is shown in the following formula: This weight increases the loss contribution of small targets, thereby enhancing the model's attention to small targets; to enhance the detection capability of small targets, size-adaptive weights are introduced. Size factor The calculation method is shown in the following formula: ;in, Input image size; The actual frame width. The actual bounding box height; Loss Items The calculation method is shown in the following formula: The focal loss term The calculation method is shown in the following formula: ;in, Calculate the category confidence score for the predicted bounding box; As the focus weight, To address the sample imbalance problem during training, this invention introduces a focus loss term to weight hard samples; the intersection-union ratio (IU) of the scaled predicted bounding box and the scaled ground truth bounding box... The calculation method is shown in the following formula: ;in, This represents the intersection area of ​​the scaled predicted bounding box and the scaled ground truth bounding box. The area is the union of the scaled predicted bounding box and the scaled ground truth bounding box. The process of obtaining the scaled predicted bounding box and the scaled ground truth bounding box is as follows: To improve the regression accuracy of the bounding box, especially for small targets, this invention adds an internal alignment term; a scaling factor is set. , Based on scaling factor The predicted bounding box is shrunk inward to obtain a scaled predicted bounding box; based on the scaling factor... The true bounding box is shrunk inwards to obtain a scaled true bounding box. The dynamic adjustment factor... As the number of training cycles increases, let the total number of training cycles be . The current cycle is ,but The calculation method is shown in the following formula: .

[0089] The method for training a deep learning model suitable for binocular vision system detection in road scenes by inputting the training dataset into the improved YOLOv13-SHSA is as follows: 1. Modify the YOLOv13 cfg file, changing the `classes` parameter in the dataset's YAML file to the number of classes in the dataset. 2. Set the hyperparameters of the network model, including an input image size of 640×640 for training the dataset and testing model performance, a batch size of 32, 300 training epochs, and a learning rate of 0.01. This invention uses an evaluation system from object detection methods to evaluate the model, including precision (AP) and recall for each class. F1 score, accuracy And the mean average precision (mAP) at 0.5 (with an IoU threshold of 0.5). The calculation formula is as follows:

[0090] ; ; ;

[0091] ; ;

[0092] In the evaluation system, true positive True negative False positives and false negatives These are four basic metrics, corresponding to the number of correctly identified positive samples, the number of correctly identified negative samples, the number of negative samples misclassified as positive samples, and the number of missed positive samples. Precision and recall can be further used to calculate... Score. Furthermore, by plotting precision-recall curves (PR curves) at different confidence thresholds and calculating the area under the curves, the average precision, which measures the model's performance in identifying a specific category, can be obtained. Since the purpose of the improved model proposed in this invention is to enhance the object detection capability of the YOLOv13 algorithm, the main performance indicator for evaluating the model is mAP@0.5. Therefore, comparing the average accuracy of the YOLOv13 model and the YOLOv13-SHSA proposed in this invention on the VOC2007 dataset demonstrates that the improved model has higher detection accuracy. Figure 4 As shown. The YOLOv13-SHSA model was trained using the training set, and the training results are as follows. Figure 5 , Figure 6 , Figure 7 , Figure 8 , Figure 9 , Figure 10 , Figure 11 As shown. `val_box` represents the validation set bounding box; its value decreases and eventually stabilizes after 150 training epochs. `val_dfl` represents the mean validation set loss; the mean loss stabilizes after 200 training epochs. `val_cls` represents the mean validation set classification loss; the mean loss converges after 200 training epochs. `Precision` represents the percentage of correctly identified positive classes in the validation set; the precision value stabilizes after 250 training epochs. `Recall` describes how many real positive examples are recalled by the binary classifier from the perspective of actual results; the recall rate gradually converges after 180 training epochs.

[0093] Step 4: Validate the performance of the trained YOLOv13-SHSA model using the validation and test sets.

[0094] Step 41: The trained YOLOv13-SHSA model is validated using validation and test sets. Multiple metrics are used to comprehensively evaluate the model's detection performance. Step 42: Table 2 shows the comparison results of the proposed method and the YOLOv13 baseline model's object detection algorithm in terms of detection performance. The comparison clearly shows that the proposed method exhibits higher detection accuracy and stronger robustness, surpassing the baseline algorithm.

[0095]

[0096] The detection performance of the proposed YOLOv13-SHSA model on the test set is as follows: Figure 12 , Figure 13As shown, the YOLOv13-SHSA model can accurately detect targets such as pedestrians and vehicles in complex road environments.

[0097] The validated weight file is then fed into the YOLOv13-SGBM algorithm for binocular ranging to verify the effectiveness of the YOLOv13-SHSA model for road environment detection. The specific steps are as follows:

[0098] Data Input and Alignment: Load the binocular camera calibration parameters and perform epipolar correction. Use the YOLOv13-SHSA model to detect targets (such as vehicles and pedestrians) in the left view, and output the target category and 2D bounding box coordinates.

[0099] 3D coordinate mapping: The target area in the right view is cropped, a disparity map is generated using the SGBM algorithm, and the 3D coordinates of the target are calculated according to the disparity-depth transformation formula.

[0100] The SGBM stereo matching algorithm is a technique for depth image calculation in global matching stereo vision. It estimates the disparity between pixel blocks in two images (left and right) and then calculates the depth information of an object. The advantage of the SGBM algorithm lies in its utilization of the correlation between pixel blocks, considering the information of surrounding pixels when calculating disparity, thus obtaining a relatively accurate depth image and effectively handling complex conditions in real-world scenarios. Furthermore, it employs several optimization strategies, resulting in a certain degree of improvement in computation speed. This invention selected a video clip of a road segment with low traffic volume during the day for testing. The traffic included pedestrians, electric vehicles, and parked cars, conforming to a relatively realistic and complex testing environment. Under the algorithm's operation, all these objects were successfully identified, as shown in the detection results image. Figure 14 , Figure 15 As shown, this demonstrates the effectiveness and superiority of the present invention in road condition detection.

[0101] This invention may have other embodiments. Without departing from the spirit and essence of this invention, those skilled in the art can make various corresponding changes and modifications according to this invention, but these corresponding changes and modifications should all fall within the protection scope of the appended claims.

Claims

1. A two-dimensional detection and three-dimensional ranging method based on improved YOLOv13 and SGBM, characterized in that: The specific process of the method is as follows: Step 1: Obtain the image training set; Step 2: Construct the YOLOv13-SHSA network model; Step 3: Train the constructed YOLOv13-SHSA network model based on the image training set to obtain the trained YOLOv13-SHSA network model. Step 4: The binocular camera acquires the left and right views; Input the left view into the trained YOLOv13-SHSA network model, and the three detection heads of the trained YOLOv13-SHSA network model will output three detection results; The nonmaximum suppression method was used to process the three detection results to obtain the detection boxes and confidence scores of multiple targets in the left view; Disparity maps of the left and right views are obtained based on the SGBM algorithm; Based on the disparity map and the parameters of the binocular camera, the depth value corresponding to each pixel in the disparity map is calculated to generate a depth map; The distance to the target object is calculated based on the depth map, the detection boxes of multiple targets in the left view, and the confidence scores.

2. The two-dimensional detection and SGBM three-dimensional ranging method based on improved YOLOv13 according to claim 1, characterized in that: The process of obtaining the image training set in step one is as follows: The VOC2007 dataset was used as the image training set. The VOC2007 dataset contains 20 categories, namely: Airplane, bicycle, bird, boat, bottle, bus, car, cat, chair, cow, dining table, dog, horse, motorcycle, person, potted plant, sheep, sofa, train, television.

3. The two-dimensional detection and SGBM three-dimensional ranging method based on the improved YOLOv13 according to claim 2, characterized in that: Step two involves constructing the YOLOv13-SHSA network model; the specific process is as follows: The YOLOv13-SHSA network model includes: Backbone network, Neck network, and Head network; The backbone network includes: a first convolutional layer, a second convolutional layer, a third DS-C3k2 layer, a fourth convolutional layer, a fifth DS-C3k2 layer, a sixth depth-separable convolutional layer DSConv, a seventh A2C2f layer, an eighth depth-separable convolutional layer DSConv, a ninth A2C2f layer, and a tenth SHSA layer. The Neck network includes: an 11th upsample layer, a 12th cascaded layer, a 13th DS-C3k2 layer, a 14th upsample layer, a 15th cascaded layer, a 16th DS-C3k2 layer, a 17th convolutional layer, an 18th cascaded layer, a 19th DS-C3k2 layer, a 20th convolutional layer, a 21st cascaded layer, a 22nd DS-C3k2 layer, and a 23rd Hyperace layer. Hyperace represents an adaptive association enhancement mechanism based on hypergraphs; The detection head network includes: detection head 1, detection head 2, and detection head 3; Each of the detection heads 1, 2, and 3 includes a detection frame branch and a confidence branch; The detection box branches sequentially include: the 24th convolutional layer, the 25th convolutional layer, and the 26th two-dimensional convolutional layer; The confidence branches include, in sequence: the 27th depthwise separable convolutional layer, the 28th convolutional layer, the 29th depthwise separable convolutional layer, the 30th convolutional layer, and the 31st two-dimensional convolutional layer.

4. The two-dimensional detection and SGBM three-dimensional ranging method based on improved YOLOv13 according to claim 3, characterized in that: In step three, the constructed YOLOv13-SHSA network model is trained based on the image training set to obtain the trained YOLOv13-SHSA network model; the specific process is as follows: Step 3:

1. Input the image into the backbone network; the backbone network outputs a feature map. The specific process is as follows: The image is sequentially input into the first convolutional layer, the second convolutional layer, the third DS-C3k2 layer, the fourth convolutional layer, and the fifth DS-C3k2 layer. The fifth DS-C3k2 layer outputs a feature map. ; Feature map The input is sequentially processed by the 6th depthwise separable convolutional layer DSConv and the 7th layer A2C2f. The 7th layer A2C2f outputs a feature map. ; Feature map The input is sequentially processed by the 8th depthwise separable convolutional layer DSConv and the 9th layer A2C2f. The 9th layer A2C2f outputs a feature map. ; 9th layer A2C2f output feature map Input the 10th layer SHSA, output the feature map of the 10th layer SHSA ; Step 3.2 Feature Map Input the 23rd layer Hyperace, output the feature map of the 23rd layer Hyperace. ; Feature map Input the 23rd layer Hyperace, output the feature map of the 23rd layer Hyperace. ; Feature map Input the 23rd layer Hyperace, output the feature map of the 23rd layer Hyperace. ; Step 33: Feature Map With feature map By adding elements one by one, we obtain the feature map. ; Feature map With feature map By adding elements one by one, we obtain the feature map. ; Feature map With feature map By adding elements one by one, we obtain the feature map. ; Steps 3 and 4: Feature Map Input to the 11th upsampling layer (Upsample), output the feature map. ; Feature map With feature map Input the 12th cascaded layer and output the feature map. ; Feature map Input to the 13th layer DS-C3k2, output feature map of the 13th layer DS-C3k2 ; Feature map Input to the 14th upsampling layer (Upsample), output the feature map. ; Feature map With feature map Input to the 15th cascaded layer; output feature map from the 15th cascaded layer. ; Feature map Input to the 16th layer DS-C3k2, output feature map of the 16th layer DS-C3k2 ; Step 3.5: Output feature map of DS-C3k2 at layer 16 With feature map By adding elements one by one, we obtain the feature map. ; DS-C3k2 output feature map of layer 13 With feature map By adding elements one by one, we obtain the feature map. ; Step 36: Feature Map Input to the 17th convolutional layer; output feature map from the 17th convolutional layer. ; Feature map With feature map Input to the 18th cascaded layer; output feature map from the 18th cascaded layer. ; Feature map Input to the 19th layer DS-C3k2, output feature map of the 19th layer DS-C3k2 ; Feature map Input to the 20th convolutional layer; output feature map from the 20th convolutional layer. ; Feature map With feature map Input to the 21st cascaded layer, output feature map from the 21st cascaded layer. ; Feature map Input to the 22nd layer DS-C3k2, output feature map of the 22nd layer DS-C3k2 ; Step 37, Feature Map Input detection head 1, and detection head 1 outputs detection result 1; detection result 1 includes detection box 1 and confidence level 1. Feature map With feature map The feature map is obtained by adding elements one by one. Feature map Input detection head 2, and detection head 2 outputs detection result 2; detection result 2 includes detection box 2 and confidence score 2. Feature map With feature map The feature map is obtained by adding elements one by one. Feature map Input detection head 3, and detection head 3 outputs detection result 3; detection result 3 includes detection box 3 and confidence score 3. Step 38: Repeat steps 31 to 37 until the loss function converges to obtain the trained YOLOv13-SHSA network model. The loss functions are the loss functions of detector head 1, detector head 2, and detector head 3.

5. The two-dimensional detection and SGBM three-dimensional ranging method based on improved YOLOv13 according to claim 4, characterized in that: The 10th SHSA layer includes a LayerNorm normalization layer and a convolutional kernel size of [missing information]. The dilated convolutional layer 1 has a kernel size of [missing value]. The dilated convolutional layer 2 has a kernel size of [missing information]. The dilated convolutional layer 3, the splicing layer, and the convolutional kernel size are...

4. Convolutional layer, Self-Attention mechanism, and splicing layer; The size of the convolution kernel is The dilation rate of dilated convolution 1 =1; The size of the convolution kernel is The dilation rate of dilated convolution 2 It is 2; The size of the convolution kernel is The dilation rate of dilated convolution 3 The value is 3.

6. The two-dimensional detection and SGBM three-dimensional ranging method based on the improved YOLOv13 according to claim 5, characterized in that: The working process of the 10th layer SHSA is as follows: Output feature map of layer 9, A2C2f. passage Divided into and ; ; aisle Corresponding feature map Input layer normalization layer LayerNorm, output feature map ; feature map The input convolution kernel size is The dilated convolutional layer 1 has a kernel size of [missing value]. Dilated convolutional layer 1 output feature map ; feature map The input convolution kernel size is The dilated convolutional layer 2 has a kernel size of [missing value]. Dilated convolutional layer 2 output feature map ; feature map The input convolution kernel size is The dilated convolutional layer 3 has a kernel size of [missing value]. Dilated convolutional layer 3 output feature map ; feature map Feature map Feature map Input to the concatenation layer, output feature map. ; feature map The input convolution kernel size is Convolutional layer 4, with a kernel size of [missing value]. Convolutional layer 4 output feature map ; Feature map Divided by channel , , ; , , Input is the Self-Attention mechanism, output is the feature map. ; Feature map and channels Corresponding feature map Input to the concatenation layer, output feature map. .

7. The two-dimensional detection and SGBM three-dimensional ranging method based on improved YOLOv13 according to claim 6, characterized in that: The images in the training set are 640×640 pixels in size. During training, the input data size per batch was 32, the number of training rounds was 300, and the learning rate was 0.

01.

8. The two-dimensional detection and SGBM three-dimensional ranging method based on improved YOLOv13 according to claim 7, characterized in that: The loss function is: in, An adaptive multi-scale focal intersection-union ratio loss function; Size weight; for Loss item, This is the intersection-union ratio (IoU) between the predicted bounding box and the ground truth bounding box. , These are hyperparameters, set to 0.5 and 0.1 respectively; This is the intersection-union ratio (IoU) between the scaled predicted bounding box and the scaled ground truth bounding box. The focus of the loss; It is a dynamic adjustment factor.

9. The two-dimensional detection and SGBM three-dimensional ranging method based on improved YOLOv13 according to claim 8, characterized in that: The size weight The calculation method is shown in the following formula: Size factor The calculation method is shown in the following formula: in, Input image size; The actual frame width. This is the actual frame height; The Loss Items The calculation method is shown in the following formula: The focal loss item The calculation method is shown in the following formula: in, Calculate the category confidence score for the predicted bounding box; As the focus weight, ; The intersection-over-union ratio of the scaled predicted bounding box and the scaled ground truth bounding box The calculation method is shown in the following formula: in, This represents the intersection area of ​​the scaled predicted bounding box and the scaled ground truth bounding box. This represents the area of ​​the union of the scaled predicted bounding box and the scaled ground truth bounding box. The process of obtaining the scaled predicted bounding box and the scaled ground truth bounding box is as follows: Set scaling factor , ; Based on scaling factor Shrink the prediction box inward to obtain a scaled prediction box; Based on scaling factor Shrink the real bounding box inward to obtain the scaled real bounding box.

10. The two-dimensional detection and SGBM three-dimensional ranging method based on the improved YOLOv13 according to claim 9, characterized in that: The dynamic adjustment factor As the number of training cycles increases, let the total number of training cycles be . The current cycle is ,but The calculation method is shown in the following formula: 。

Citation Information

Cited By

  • Marine target detection and three-dimensional point cloud perception method based on infrared binocular vision

    CN122157239A