Improved laser spot detection method and system based on YOLO model
By improving the data enhancement and loss function of the YOLO model and combining it with multi-scale feature processing, the problems of sample imbalance and feature capture difficulty in laser spot detection are solved, achieving high-precision and efficient laser spot detection.
Patent Information
- Application Number
- CN202510801610.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-16
- Publication Date
- 2025-10-10
AI Technical Summary
Existing laser spot detection technology faces problems such as limited and uneven sample size, difficulty in accurately capturing spot features using traditional methods, inaccurate bounding box positioning, and slow regression process, which affect detection accuracy and efficiency.
An improved method based on the YOLO model is adopted to optimize the model training process and improve detection accuracy and efficiency through data enhancement, diversified class normalization loss function and adaptive hierarchical intersection regression loss function, combined with a lightweight multi-scale feature processing module.
It improves the accuracy and efficiency of laser spot detection, is suitable for industrial applications, and operates efficiently in environments with limited computing resources.
Smart Images

Figure CN120766091A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of laser spot tracking technology, and in particular to a laser spot detection method and system based on an improved YOLO model. Background Art
[0002] In numerous fields utilizing laser technology, such as laser processing, laser communications, and laser medical treatment, the quality of the laser spot plays a critical role in system performance and effectiveness. However, during the inspection process, the laser spot may exhibit irregular shapes, uneven energy distribution, and unusual bright or dark spots. These issues directly impact the accuracy and reliability of laser applications. Deep learning-based automated inspection technology enables precise and efficient quality assessment, playing a significant role in improving inspection quality and efficiency.
[0003] Currently, deep learning-based laser spot detection faces numerous challenges. For one thing, the sample size is limited and unevenly distributed. The number of samples for different types of spot defects varies significantly, with some key defect types having fewer samples. This leads to insufficient feature extraction for minority categories during the model learning process, which reduces the model's recognition performance for these categories and affects the overall accuracy and reliability of detection. Furthermore, traditional detection methods are inadequate in handling the diversity and complexity of laser spots. The shape, size, and energy distribution of laser spots are highly internalized and diverse. Traditional computer vision techniques often struggle to accurately capture these features, prone to false detections and missed detections, and unable to meet the requirements of high-precision detection. Furthermore, the traditional IoU loss function fails to fully account for the actual characteristics of the spot when dealing with the diversity of spot shapes and scale variations. This leads to inaccurate bounding box positioning and a slow regression process, compromising detection accuracy and efficiency. Therefore, a new technical solution is needed to improve the accuracy and efficiency of laser spot detection. Summary of the Invention
[0004] Purpose of the invention: In order to solve the problems arising from the existing technology, the present invention provides a laser spot detection method based on an improved YOLO model, aiming to solve the problems of limited sample size in laser spot detection, long-tail effect caused by sample imbalance, bounding box positioning error, slow regression process, diverse spot shapes, inconsistent scales, etc., and improve the accuracy and efficiency of laser spot detection.
[0005] Technical solution: The present invention provides a laser spot detection method based on an improved YOLO model, comprising:
[0006] (1) Collecting spot images;
[0007] (2) enhancing the spot image data, including at least one of replicating the spot image data, randomly scaling, adjusting the color, and adjusting the brightness;
[0008] (3) Light spot image annotation, that is, marking the location of the light spot to obtain the light spot image dataset;
[0009] (4) Model construction: Based on YOLOv9, the lightweight multi-scale feature processing module MSBCSPELAN is used to replace the RepNCSPELAN4 module, and the diversified class normalization loss function and the adaptive hierarchical cross-point regression loss function are set;
[0010] (5) Model training: dividing the data in the light spot image dataset into a training set, a validation set, and a test set, and training the constructed model;
[0011] (6) Performance evaluation: Evaluate the performance of the model in the test set using precision, recall, F1 score, mAP50, mAP50:95, number of parameters, and GFLOPS. Adjust the parameters of the model based on the evaluation results, and repeat (4) to (6) until the model performance evaluation reaches the optimal level.
[0012] Furthermore, the diversified class normalized loss function L Dcn , the formula is:
[0013]
[0014] Among them, N represents the number of samples, n represents the number of sample types, is the one-hot encoding of the i-th sample, is the predicted probability of the i-th sample, is the sliding adjustment factor, is the smoothing adjustment factor, is the weight compensation factor;
[0015] Sliding adjustment factor Adjust the contribution of each sample to the loss based on the IoU value, assigning higher weights to samples near the threshold μ. The formula is:
[0016]
[0017] Among them, δ is a small constant used to fine-tune the IoU threshold and define the range of boundary samples, and parameters k1 and k2 are used to control the weight ratio between boundary samples and absolute positive samples;
[0018] Smoothing adjustment factor Use the formula to dynamically adjust the impact of negative samples in class imbalanced data on the tail category gradient. The formula is:
[0019]
[0020] Where ∈ is a small positive number used to prevent division by zero, represents the number of samples in category T, N max Count the samples of the most frequently occurring category;
[0021] Weight compensation factor It is used to adjust the logit difference, especially by amplifying the logit difference of the tail category. The formula is:
[0022]
[0023] in, Represents the logit value of the sample for its true category T, x j Represents the logit value of the sample for the non-target category J, J≠T, Represents the highest logit value among all non-true categories of the sample, Represents the difference in the model's confidence between the correct class and the class least likely to be correct.
[0024] Furthermore, the adaptive hierarchical intersection regression loss function L AHIoU , adding the sample's IoU value, shape, and centroid information into the calculation, the formula is:
[0025] L AHIoU =L measure +IoU-IoU inner -IoU Mid
[0026] Among them, L measure is the bounding box regression loss function, IoU is the IoU value of the sample, IoU inner is the IoU value of the adaptive auxiliary frame, IoU Mid is the sample IoU value in the medium-low range;
[0027] IoU Mid Discard difficult samples whose IoU values are lower than the threshold d, set their output to 0, use a nonlinear growth component to gradually increase the loss for low IoU value samples in the medium-low level range, and use a linear growth component to provide a smooth gradient signal for high IoU value samples in the medium-low level range. The formula is:
[0028]
[0029] Where d and σ represent the lower and upper limits of the regulations, respectively;
[0030] Bounding box regression loss function L measure The IoU value of the sample, the distance between the center of the predicted box and the center of the real box shape, the distance between the center position of the prediction box and the center of mass position centroid , a penalty term Ω related to the bounding box shape shape Add to calculation, the formula is:
[0031] L measure =1-IoU+distance shape +distance centroid +0.5×Ω shape
[0032] The distance between the center of the predicted box and the true box shape The formula is:
[0033]
[0034] Among them, (x c ,y c )and Represent the center coordinates of the predicted box and the real box respectively, c is the diagonal length of the minimum closed bounding box,
[0035]
[0036] Among them, w gt and h gt Represents the width and height of the real frame respectively, and scale is the scaling factor;
[0037] The distance between the center of the prediction box and the center of mass centroid The formula is:
[0038]
[0039] Among them, (x c ,y c ) represents the center coordinate of the prediction box, (x ctr ,y ctr ) is the coordinate of the center of mass of the target object;
[0040] The penalty term Ω related to the bounding box shape shape The formula is:
[0041]
[0042] Among them, t represents the dimension of the bounding box, and its value is w,h, where w and h represent the width and height of the predicted box respectively, θ is the parameter of the penalty term, w t and w h Used to dynamically adjust width and height, the formula is:
[0043]
[0044] The IoU value of the adaptive auxiliary box dynamically adjusts the proportion of the bounding box based on the different IoU ranges of the samples. For samples with high IoU in the IoU range, a smaller auxiliary box is used, and for samples with low IoU in the IoU range, a larger auxiliary box is used. The formula is:
[0045]
[0046] Among them, inter is the product of the horizontal and vertical intersection lengths of the real box and the auxiliary box, and union is the ratio of the area of the real box and the auxiliary box to the scale factor. The formula is:
[0047]
[0048] union=(w gt *h gt )*(radio) 2 +(w*h)*(radio) 2 -inter
[0049] in, Indicates the boundary position of the real box, (b l ,b r ,b t ,b b ) represents the boundary position of the auxiliary frame, radio is the scale factor, w gt and h gt They represent the width and height of the real box, w and h represent the width and height of the predicted box, respectively.
[0050] Furthermore, the diversified class normalization loss L Dcn and adaptive layer-wise cross-point regression loss L AHIoU Add up to get the total loss, the formula is:
[0051] Total loss = classification loss L Dcn + regression loss L AHIoU .
[0052] Furthermore, the lightweight multi-scale feature processing module MSBCSPELAN uses a hierarchical feature fusion strategy to split the input features into multiple branches, each branch is responsible for processing a different texture subset, uses 1×1 convolution to reduce feature and channel dimensions, uses depthwise separable convolution to extract spatial features of channels and exchange channel information, uses a heterogeneous convolution kernel selection protocol to select convolution kernels of different sizes, uses convolution kernels of different sizes in different branches, captures spot image features of different scales, and processes multi-scale features at different network stages; the convolution kernel sizes include 9×9, 7×7, 5×5 or 3×3.
[0053] The application also provides a laser spot detection system based on a YOLO model improvement, comprising:
[0054] An image collection module is used to collect spot images.
[0055] A data enhancement module is used to enhance spot image data, and at least one of the following is included: spot image data replication, random scaling, color adjustment, and brightness adjustment.
[0056] A labeling module is used to label spot images, i.e., to label the location of the spot, to obtain a spot image dataset.
[0057] A model construction module is based on YOLOv9, replaces the RepNCSPELAN4 module with a lightweight multi-scale feature processing module MSBCSPELAN, sets a diversified class normalization loss function and an adaptive hierarchical intersection point regression loss function.
[0058] A model training module is used to divide the data in the spot image dataset into a training set, a validation set, and a test set, and train the constructed model.
[0059] A performance evaluation module is used to evaluate the performance of the model in the test set through precision, recall rate, F1 score, mAP50, mAP50:95, parameter quantity, and GFLOPS indicators, and adjust the parameters of the model according to the evaluation results until the model performance evaluation reaches the optimal.
[0060] Further, the model construction module, the diversified class normalization loss function L Dcn , the formula is:
[0061]
[0062] wherein N represents the number of samples, n represents the number of sample types, is the one-hot encoding of the i-th sample, is the prediction probability of the i-th sample, is a sliding adjustment factor, is a smoothing adjustment factor, is a weight compensation factor;
[0063] The sliding adjustment factor adjusts the contribution of each sample to the loss based on the IoU value, and assigns higher weights to samples near the threshold μ, the formula is:
[0064]
[0065] wherein δ is a small constant used to fine-tune the IoU threshold and define the range of boundary samples, and parameters k1 and k2 are used to control the weight ratio between boundary samples and absolute positive samples.
[0066] Smooth adjustment factor The formula for dynamically adjusting the influence of negative samples on the tail category gradient in class imbalance data is:
[0067]
[0068] where ∈ is a small positive number to prevent division by zero, N max is the sample count of the most frequent class;
[0069] Weight compensation factor Used to adjust the logit difference, especially by amplifying the logit difference of the tail class, the formula is:
[0070]
[0071] where, x j is the logit value of the sample for the true class T, x is the highest logit value among all non-real classes of the sample, is the confidence difference between the correct class and the least likely correct class.
[0072] Further, the model construction module, the adaptive hierarchical intersection regression loss function L AHIoU , adds the IoU value, shape and centroid information of the sample to the calculation, the formula is:
[0073] L AHIoU = L measure + IoU-IoU inner -IoU Mid
[0074] where L measure is the bounding box regression loss function, IoU is the IoU value of the sample, IoU inner is the IoU value of the adaptive auxiliary box, IoU Mid is the sample IoU value in the medium-low level range;
[0075] IoU Mid Discard difficult samples with IoU values below the threshold d, set their output to 0, use a nonlinear growth component to gradually increase the loss for low IoU value samples in the medium-low level range, and use a linear growth component to provide a smooth gradient signal for high IoU value samples in the medium-low level range, the formula is:
[0076]
[0077] Where d and σ represent the lower and upper limits of the regulations, respectively;
[0078] Bounding box regression loss function L measure The IoU value of the sample, the distance between the center of the predicted box and the center of the real box shape , the distance between the center position of the prediction box and the center of mass position centroid , a penalty term Ω related to the bounding box shape shape Add to calculation, the formula is:
[0079] L measure =1-IoU+distance shape +distance centroid +0.5×Ω shape
[0080] The distance between the center of the predicted box and the true box shape The formula is:
[0081]
[0082] Among them, (x c ,y c )and Represent the center coordinates of the predicted box and the real box respectively, c is the diagonal length of the minimum closed bounding box,
[0083]
[0084] Among them, w gt and h gt Represent the width and height of the real box respectively, and scale is the scaling factor;
[0085] The distance between the center of the prediction box and the center of mass centroid The formula is:
[0086]
[0087] Among them, (x c ,y c ) represents the center coordinate of the prediction box, (x ctr ,y ctr ) is the coordinate of the center of mass of the target object;
[0088] The penalty term Ω related to the bounding box shape shape The formula is:
[0089]
[0090] Among them, t represents the dimension of the bounding box, and its value is w,h, where w and h represent the width and height of the predicted box respectively, θ is the parameter of the penalty term, w t and w h Used to dynamically adjust width and height, the formula is:
[0091]
[0092] The IoU value of the adaptive auxiliary box dynamically adjusts the proportion of the bounding box based on the different IoU ranges of the samples. For samples with high IoU in the IoU range, a smaller auxiliary box is used, and for samples with low IoU in the IoU range, a larger auxiliary box is used. The formula is:
[0093]
[0094] Among them, inter is the product of the horizontal and vertical intersection lengths of the real box and the auxiliary box, and union is the ratio of the area of the real box and the auxiliary box to the scale factor. The formula is:
[0095]
[0096] union=(w gt *h gt )*(radio) 2 +(w*h)*(radio) 2 -inter
[0097] in, Indicates the boundary position of the real box, (b l ,b r ,b t ,b b ) represents the boundary position of the auxiliary frame, radio is the scale factor, w gt and h gt They represent the width and height of the real box, w and h represent the width and height of the predicted box, respectively.
[0098] Furthermore, in the model building module, the diversified class normalization loss L Dcn and adaptive layer-wise cross-point regression loss L AHIoU Add up to get the total loss, the formula is:
[0099] Total loss = classification loss L Dcn + regression loss L AHIoU .
[0100] Further, the model construction module, the lightweight multi-scale feature processing module MSBCSPELAN uses a hierarchical feature fusion strategy to segment the input features into multiple branches, each branch is responsible for processing different texture subsets, uses 1x1 convolution to reduce the feature and channel dimension, uses depth separable convolution to extract spatial features of the channel and interact channel information, uses a heterogeneous convolution kernel selection protocol to select different size convolution kernels, uses different size convolution kernels in different branches to capture different scale of spot image features, and processes multi-scale features in different network stages;The size of the convolution kernel includes 9x9, 7x7, 5x5 or 3x3.
[0101] Beneficial effects: compared with the prior art, the laser spot detection method and system based on the improved YOLO model have excellent performance in precision, recall rate, F1 score and MAP and other key indicators, while maintaining a relatively lightweight structure, having low parameter calculation and calculation complexity, and being suitable for industrial applications and capable of efficient operation in an environment with limited computing resources, especially in a laser spot detection environment involving complex and unbalanced data sets. BRIEF DESCRIPTION OF DRAWINGS
[0102] Figure 1 The implementation flowchart of the laser spot detection method of the present application is shown in the figure.
[0103] Figure 2 The architecture diagram of the present application is shown in the figure, which improves the RepNCSPELAN4 module to the MSBCSPELAN module based on the YOLOv9 model.
[0104] Figure 3 The architecture diagram of the MSBCSPELAN module designed by the present application is shown in the figure, including structure and working process.
[0105] Figure 4 The effect comparison diagram of the actual detection of the present application on different YOLO models is shown in the figure. DETAILED DESCRIPTION
[0106] The present application will be further illustrated below in conjunction with the drawings and specific embodiments, and it should be understood that the following specific embodiments are only used to illustrate the present application and not to limit the scope of the present application, and after reading the present application, those skilled in the art can make various equivalent modifications of the present application, which all fall within the scope defined by the appended claims of the present application.
[0107] Example one
[0108] Please refer to Figures 1 to 3 The embodiment provides a laser spot detection method based on an improved YOLO model, which comprises:
[0109] (1) Collecting spot images. In this embodiment, the spot images are downloaded from a public dataset of actual laser application scenarios.
[0110] (2) enhancing the spot image data, including at least one of replicating, randomly scaling, color adjusting, and brightness adjusting the spot image data to increase the number and diversity of minority class samples in the spot image;
[0111] (3) Spot image annotation: In this embodiment, the labelimg software is used to annotate the location of the spot to obtain a spot image dataset; the location is the spatial coordinates and range of the spot image, including the center point coordinates of the bounding box, the width and height of the bounding box;
[0112] (4) Model construction, including replacing the RepNCSPELAN4 module with the lightweight multi-scale feature processing module MSBCSPELAN based on YOLOv9, setting the diversified class normalization loss function and the adaptive hierarchical cross-point regression loss function;
[0113] (5) Model training. In this embodiment, 70% of the data in the spot image dataset is used as a training set for model training, 20% is used as a validation set for model verification, and 10% is used as a test set for model testing.
[0114] (6) Performance evaluation: The performance of the model in the test set is evaluated by the precision, recall rate, F1 score, mAP50, mAP50:95, parameter quantity and GFLOPS indicators. The parameters of the model are adjusted according to the evaluation results. (4) to (6) are repeated until the model performance evaluation reaches the optimal level. In this embodiment, the threshold parameter δ and the weight factor k are manually adjusted. 1, k2 and penalty term parameter θ.
[0115] In the model building step, the diversified class normalized loss function L Dcn , the formula is:
[0116]
[0117] Among them, N represents the number of samples, n represents the number of sample types, is the one-hot encoding of the i-th sample, is the predicted probability of the i-th sample, is the sliding adjustment factor, is the smoothing adjustment factor, is the weight compensation factor;
[0118] Sliding adjustment factor The setting of is based on the IoU value to regulate the contribution of each sample to the loss. By using the adaptive learning threshold parameter μ, samples with IoU values lower than μ are classified as negative samples, and samples exceeding μ are classified as positive samples. However, samples near the threshold μ are often difficult to accurately define the boundary characteristics of their IoU values. This ambiguity can easily lead to misclassification, which in turn has an adverse effect on the training effect of the model. In order to enhance the performance and robustness of the model, the sliding adjustment factor assigns a greater weight to the boundary samples, significantly improving the relative loss values of these difficult-to-classify samples, prompting the model to focus more attention on those misclassified instances that are more difficult to correctly classify, and enhancing the model's ability to handle boundary cases. The formula is:
[0119]
[0120] Among them, δ is a small constant used to fine-tune the IoU threshold and define the range of boundary samples. The parameter k1,k is used to control the weight ratio between boundary samples and absolute positive samples, and the sum is 1;
[0121] Due to data class imbalance, during training, the number of head category samples is large, and their impact on model loss and gradient contribution is extremely significant; in contrast, the tail category samples are scarce, making it impossible to obtain sufficient gradient information for effective learning. Therefore, a smoothing mitigation factor is introduced. Dynamically adjust the impact of negative samples on the tail category gradient to reduce the dominant effect of negative samples; when the number of tail category samples is Relatively small, The value of is relatively low. This smaller smoothing mitigation factor can reduce the impact of negative samples, indirectly enhance the learning of tail categories from positive samples, and prompt the model to focus more attention on limited positive samples, thereby improving the learning ability and recognition performance of tail category samples. The formula is:
[0122]
[0123] Where ∈ is a small positive number used to prevent division by zero, represents the number of samples in category T, N max is the sample count of the most frequently occurring category;
[0124] In order to enhance the classification ability of tail categories, L Dcn Introducing an additional loss penalty for misclassifying tail category samples as head category samples, i.e., a weight compensation factor By adjusting the logit difference, the model's ability to handle prediction uncertainty is enhanced, especially by amplifying the logit difference of the tail category to enhance the model's ability to distinguish samples. The formula is:
[0125]
[0126] in, Represents the logit value of the sample for its true class T, x j Represents the logit value of the sample for the non-target category J, J≠T, Represents the highest logit value among all non-true categories of the sample, Represents the difference in the model's confidence between the correct class and the class least likely to be correct.
[0127] In the model building step, the adaptive hierarchical intersection regression loss function L AHIoU , combined with the IoU value, shape and centroid information calculation of the spot sample, the positioning accuracy of the bounding box is optimized. The formula is:
[0128] L AHIoU =L measure +IoU-IoU inner -IoU Mid
[0129] Among them, L measure is the bounding box regression loss function, IoU is the IoU value of the sample, IoU inner is the IoU value of the adaptive auxiliary frame, IoU Mid is the sample IoU value in the medium-low range.
[0130] In the bounding box regression process, samples with different IoU value ranges contribute unevenly to model training, so IoU Mid First, we remove difficult samples whose IoU values are lower than the threshold d and set their output to 0, so that they do not participate in the loss calculation and gradient update, and focus on the medium and low level range (d <IoU<σ)的样本;由于传统损失函数在处理中等低电平范围内低IoU值(d<IoU<d+0.3)的样本时会出现梯度过大导致训练不稳定,处理中等低电平范围内高IoU值(d+0.3<IoU<σ)的样本时梯度信号效率低下,难以有效分解优化边界点,因此IoU Mid A composite loss function containing nonlinear growth components and linear growth components is used to process samples with low IoU values and high IoU values in the medium and low level range respectively. The nonlinear growth component is used to provide a gradually increasing loss for samples in the low IoU value range, and the linear growth component is used to generate a smooth gradient signal for samples in the high IoU value range, so that the loss function is more sensitive in the medium and low level range, which is beneficial to the adjustment and optimization of the bounding box. Mid The formula is:
[0131]
[0132] Where d and σ represent the lower and upper limits of the regulations, respectively;
[0133] Since traditional bounding box regression methods usually only focus on the geometric relationship between the real box and the predicted box, and mainly rely on IoU to determine the regression loss, they largely ignore the changes in the shape and scale of the bounding box, which affect the accuracy of the bounding box regression. In addition, the SAM image segmentation model is applied to preprocess the input image to automatically generate a segmentation mask for the target area. Based on the segmentation mask, a bounding box is generated for each light spot and its center of mass is calculated. It is found that when the shape of the light spot is close to a circle, the geometric center of the bounding box almost coincides with the center of mass, while for irregularly shaped light spots, there is a significant displacement between the two. Therefore, compared with the geometric center of the bounding box, the center of mass can accurately reflect the shape distribution and provide more accurate positioning information.
[0134] So L measure The difference in bounding box shape, the displacement between the centroid and the bounding box center are added to the loss calculation, and the formula is:
[0135] L measure =1-IoU+distance shape +distance centroid +0.5×Ω shape
[0136] Among them, IoU is the IoU value of the sample, distance shape is the distance between the center of the predicted box and the real box, distance centroid is the distance between the center position of the prediction box and the center of mass position, Ω shape is the penalty term related to the bounding box shape.
[0137] The distance between the center of the predicted box and the true box shape The formula is:
[0138]
[0139] Among them, (x c ,y c )and Represent the center coordinates of the predicted box and the real box respectively, c is the diagonal length of the minimum closed bounding box,
[0140]
[0141] Among them, w gt and h gt Represents the width and height of the real box respectively, scale is the scaling factor related to the target size in the dataset, ww and hh are the weight coefficients in the horizontal and vertical directions respectively, through distanceshape The bounding box can be resized.
[0142] The distance between the center of the prediction box and the center of mass centroid The formula is:
[0143]
[0144] Among them, (x c ,y c ) represents the center coordinate of the prediction box, (x ctr ,y ctr ) is the coordinate of the center of mass of the target object;
[0145] By distance centroid It can capture more subtle shape and position differences, thereby improving the bounding box regression accuracy.
[0146] In order to make the shape difference of the bounding box more prominent in the loss calculation, a shape-related penalty term Ω is designed shape , the formula is:
[0147]
[0148] Among them, t represents the dimension of the bounding box, and its value is w,h, where w and h represent the width and height of the predicted box respectively, which is different from the width and height of the real box (w gt ,hw t ) to form a contrast, used to calculate the shape difference, w t and w h Used to dynamically adjust width and height, the formula is:
[0149]
[0150] Among them, ww and hh are the weight coefficients in the horizontal and vertical directions respectively; when the width and height difference between the predicted box and the real box |ww gt |,|hh gt When | is small, w t tends to 0, tends to 0, when the penalty term is small;
[0151] θ is the penalty term Ω shape The power parameter is used to control the nonlinear degree of the penalty intensity and determine the rate at which the loss changes with the width and height difference. A larger θ will strengthen the penalty for obvious shape errors and is suitable for scenes that require strict shape matching, such as regular morphology detection of laser spots. If θ is too small, such as θ = 1, the penalty term Ω shape Close to linearity, the discrimination of size differences is reduced, which makes the model insensitive to shape and affects positioning accuracy;
[0152] In this implementation, the penalty term optimizes the bounding box shape using the following logic:
[0153] (1) Differentiation Constraints: Utilization Weight the difference in bounding box width and height, prioritizing the dimensions that are more relevant to the true box shape. For example, when the aspect ratio is very different, the long axis is emphasized.
[0154] (2) Nonlinear enhancement: Performance evaluation found that the model performance is optimal when θ = 4, which significantly improves mAP50 and recall. By using a high power of θ = 4, the width and height of the predicted box are forced to quickly approach the true box, especially applying a stronger correction signal to samples with large differences.
[0155] (3) Collaboration with other losses: penalty term Ω shape Combined with L measure The distance between the centroids cetroid and shape distance shape , forming multi-dimensional constraints on the "position + shape + center of mass" of the bounding box, improving the positioning accuracy and shape matching of laser spot detection.
[0156] Since the traditional IoU loss function shows different gradient changes in different IoU value intervals, and this change cannot be adaptively adjusted according to the different characteristics of the samples, IoU inner Adaptive auxiliary boxes are introduced to dynamically adjust the scale of the bounding box based on the different IoU ranges of the samples. For high IoU samples (0.7 < IoU < 1), smaller auxiliary boxes are used for loss calculation to accelerate convergence. For low IoU samples (0 < IoU < 0.3), larger auxiliary boxes are used to improve the regression speed. The formula is:
[0157]
[0158] Among them, inter is the product of the horizontal and vertical intersection lengths of the real box and the auxiliary box, and union is the ratio of the area of the real box and the auxiliary box to the scale factor. The formula is:
[0159]
[0160] union=(w gt *h gt )*(radio) 2 +(w*h)*(radio) 2 -inter
[0161] in, Indicates the boundary position of the real box, (b l ,b r ,b t ,b b) represents the boundary position of the auxiliary frame, radio is the scale factor, w gt and h gt Represent the width and height of the real box, w and h represent the width and height of the predicted box respectively;
[0162] In the model building step, the diversified class normalization loss L Dcn and adaptive layer-wise cross-point regression loss L AHIoU Add up to the total loss, the formula is:
[0163] Total loss = classification loss L Dcn + regression loss L AHIoU
[0164] During the model construction step, the original RepNCSPELAN4 module in YOLOv9 is difficult to effectively fuse features of different scales and mainly relies on 3×3 convolution kernels to capture features, which limits its ability to perceive multi-scale features. Therefore, the lightweight multi-scale feature processing module MSBCSPELAN is used to replace the original RepNCSPELAN4 module in YOLOv9.
[0165] MSBCSPELAN integrates the concept of the MSBlock module into the RepNCSPELAN4 module, adopts a hierarchical feature fusion strategy and a heterogeneous convolution kernel selection protocol, uses convolution kernels of different sizes, including 9×9, 7×7, 5×5, and 3×3, to capture the image features of light spots of different scales, processes multi-scale features at different network stages, enhances the model's ability to recognize light spot targets of different sizes, improves detection accuracy, and reduces the number of model parameters.
[0166] The specific operating mechanism of MSBCSPELAN is as follows: When the MSBCSPELAN module runs, it first splits the input features into multiple branches, each responsible for processing a different texture subset. Each branch then performs feature transformation using 1×1 convolution to reduce the channel dimension and reduce subsequent computational effort. Depthwise separable convolution is then performed, independently performing spatial convolution on each channel to extract spatial features. Point-wise convolution (1×1 convolution) is then used to enable information exchange between channels. Finally, another round of 1×1 convolution further enhances features and reduces the number of parameters. Different branches utilize a heterogeneous convolution kernel selection protocol to select convolution kernels of different sizes, such as 9×9, 7×7, 5×5, and 3×3, to capture image features at different scales, processing multi-scale features at different network stages. Finally, the features of each branch are fused, enabling the detector to more effectively recognize and process objects of varying sizes, enhancing the network's ability to capture multi-scale features.
[0167] Example 2
[0168] See also Figures 1 to 3As shown, based on the first embodiment, this embodiment provides a laser spot detection system based on an improved YOLO model, including:
[0169] An image collection module, configured to collect light spot images. In this embodiment, the light spot images are downloaded from a public dataset of actual laser application scenarios.
[0170] a data enhancement module for enhancing the spot image data, including at least one of replicating, randomly scaling, adjusting color, and adjusting brightness of the spot image data to increase the number and diversity of minority class samples in the spot image;
[0171] A labeling module is used to label the spot image. In this embodiment, the labelimg software is used to label the location of the spot to obtain a spot image dataset. The location is the spatial coordinates and range of the spot image, including the center point coordinates of the bounding box, the width and height of the bounding box;
[0172] The model building module is based on YOLOv9, replacing the RepNCSPELAN4 module with the lightweight multi-scale feature processing module MSBCSPELAN, setting the diversified class normalization loss function and the adaptive hierarchical cross-point regression loss function;
[0173] Model training module: In this embodiment, 70% of the data in the spot image dataset is used as a training set for model training, 20% as a validation set for model verification, and 10% as a test set for model testing;
[0174] The performance evaluation module is used to evaluate the performance of the model in the test set through the precision, recall rate, F1 score, mAP50, mAP50:95, parameter number and GFLOPS indicators, and adjust the parameters of the model according to the evaluation results until the model performance evaluation reaches the optimal level. In this embodiment, the threshold parameter δ, weight factors k1, k2 and penalty parameter θ are manually adjusted.
[0175] In the model building module, the diversified class normalized loss function L Dcn , the formula is:
[0176]
[0177] Among them, N represents the number of samples, n represents the number of sample types, is the one-hot encoding of the i-th sample, is the predicted probability of the i-th sample, is the sliding adjustment factor, is the smoothing adjustment factor, is the weight compensation factor;
[0178] Sliding adjustment factor The setting of is based on the IoU value to regulate the contribution of each sample to the loss. By using the adaptive learning threshold parameter μ, samples with IoU values lower than μ are classified as negative samples, and samples exceeding μ are classified as positive samples. However, samples near the threshold μ are often difficult to accurately define the boundary characteristics of their IoU values. This ambiguity can easily lead to misclassification, which in turn has an adverse effect on the training effect of the model. In order to enhance the performance and robustness of the model, the sliding adjustment factor assigns a greater weight to the boundary samples, significantly improving the relative loss values of these difficult-to-classify samples, prompting the model to focus more attention on those misclassified instances that are more difficult to correctly classify, and enhancing the model's ability to handle boundary cases. The formula is:
[0179]
[0180] Among them, δ is a small constant used to fine-tune the IoU threshold and define the range of boundary samples. The parameter k1,k is used to control the weight ratio between boundary samples and absolute positive samples, and the sum is 1;
[0181] Due to data class imbalance, during training, the number of head category samples is large, and their impact on model loss and gradient contribution is extremely significant; in contrast, the tail category samples are scarce, making it impossible to obtain sufficient gradient information for effective learning. Therefore, a smoothing mitigation factor is introduced. Dynamically adjust the impact of negative samples on the tail category gradient to reduce the dominant effect of negative samples; when the number of tail category samples is Relatively small, The value of is relatively low. This smaller smoothing mitigation factor can reduce the impact of negative samples, indirectly enhance the learning of tail categories from positive samples, and prompt the model to focus more attention on limited positive samples, thereby improving the learning ability and recognition performance of tail category samples. The formula is:
[0182]
[0183] Where ∈ is a small positive number used to prevent division by zero, represents the number of samples in category T, N max is the sample count of the most frequently occurring category;
[0184] In order to enhance the classification ability of tail categories, L Dcn Introducing an additional loss penalty for misclassifying tail category samples as head category samples, i.e., a weight compensation factor By adjusting the logit difference, the model's ability to handle prediction uncertainty is enhanced, especially by amplifying the logit difference of the tail category to enhance the model's ability to distinguish samples. The formula is:
[0185]
[0186] in, Represents the logit value of the sample for its true class T, x j Represents the logit value of the sample for the non-target category J, J≠T, Represents the highest logit value among all non-true categories of the sample, Represents the difference in the model's confidence between the correct class and the class least likely to be correct.
[0187] In the model building module, the adaptive hierarchical intersection regression loss function L AHIoU , combined with the IoU value, shape and centroid information calculation of the spot sample, the positioning accuracy of the bounding box is optimized. The formula is:
[0188] L AHIoU =L measure +IoU-IoU inner -IoU Mid
[0189] Among them, L measure is the bounding box regression loss function, IoU is the IoU value of the sample, IoU inner is the IoU value of the adaptive auxiliary frame, IoU Mid is the sample IoU value in the medium-low range.
[0190] In the bounding box regression process, samples with different IoU value ranges contribute unevenly to model training, so IoU Mid First, we remove difficult samples whose IoU values are lower than the threshold d and set their output to 0, so that they do not participate in the loss calculation and gradient update, and focus on the medium and low level range (d <IoU<σ)的样本;由于传统损失函数在处理中等低电平范围内低IoU值(d<IoU<d+0.3)的样本时会出现梯度过大导致训练不稳定,处理中等低电平范围内高IoU值(d+0.3<IoU<σ)的样本时梯度信号效率低下,难以有效分解优化边界点,因此IoU Mid A composite loss function containing nonlinear growth components and linear growth components is used to process samples with low IoU values and high IoU values in the medium and low level range respectively. The nonlinear growth component is used to provide a gradually increasing loss for samples in the low IoU value range, and the linear growth component is used to generate a smooth gradient signal for samples in the high IoU value range, so that the loss function is more sensitive in the medium and low level range, which is beneficial to the adjustment and optimization of the bounding box. Mid The formula is:
[0191]
[0192] Where d and σ represent the lower and upper limits of the regulations, respectively;
[0193] Since traditional bounding box regression methods usually only focus on the geometric relationship between the real box and the predicted box, and mainly rely on IoU to determine the regression loss, they largely ignore the changes in the shape and scale of the bounding box, which affect the accuracy of the bounding box regression. In addition, the SAM image segmentation model is applied to preprocess the input image to automatically generate a segmentation mask for the target area. Based on the segmentation mask, a bounding box is generated for each light spot and its center of mass is calculated. It is found that when the shape of the light spot is close to a circle, the geometric center of the bounding box almost coincides with the center of mass, while for irregularly shaped light spots, there is a significant displacement between the two. Therefore, compared with the geometric center of the bounding box, the center of mass can accurately reflect the shape distribution and provide more accurate positioning information.
[0194] So L measure The difference in bounding box shape, the displacement between the centroid and the bounding box center are added to the loss calculation, and the formula is:
[0195] L measure =1-IoU+distance shape +distance centroid +0.5×Ω shape
[0196] Among them, IoU is the IoU value of the sample, distance shape is the distance between the center of the predicted box and the real box, distance centroid is the distance between the center position of the prediction box and the center of mass position, Ω shape is the penalty term related to the bounding box shape.
[0197] The distance between the center of the predicted box and the true box shape The formula is:
[0198]
[0199] Among them, (x c ,y c )and Represent the center coordinates of the predicted box and the real box respectively, c is the diagonal length of the minimum closed bounding box,
[0200]
[0201] Among them, w gt and h gtRepresents the width and height of the real box respectively, scale is the scaling factor related to the target size in the dataset, ww and hh are the weight coefficients in the horizontal and vertical directions respectively, through distance shape The bounding box can be resized.
[0202] The distance between the center of the prediction box and the center of mass centroid The formula is:
[0203]
[0204] Among them, (x c ,y c ) represents the center coordinate of the prediction box, (x ctr ,y ctr ) is the coordinate of the center of mass of the target object;
[0205] By distance centroid It can capture more subtle shape and position differences, thereby improving the bounding box regression accuracy.
[0206] In order to make the shape difference of the bounding box more prominent in the loss calculation, a shape-related penalty term Ω is designed shape , the formula is:
[0207]
[0208] Among them, t represents the dimension of the bounding box, and its value is w,h, where w and h represent the width and height of the predicted box respectively, which is different from the width and height of the real box (w gt ,h gt ) to form a contrast, used to calculate the shape difference, w t and w h Used to dynamically adjust width and height, the formula is:
[0209]
[0210] Among them, ww and hh are the weight coefficients in the horizontal and vertical directions respectively; when the width and height difference between the predicted box and the real box |ww gt |,|hh gt When | is small, w t tends to 0, tends to 0, when the penalty term is small;
[0211] θ is the penalty term Ω shape The power parameter is used to control the nonlinear degree of the penalty intensity and determine the rate at which the loss changes with the width and height difference. A larger θ will strengthen the penalty for obvious shape errors and is suitable for scenes that require strict shape matching, such as regular morphology detection of laser spots. If θ is too small, such as θ = 1, the penalty term Ωshape Close to linearity, the discrimination of size differences is reduced, which makes the model insensitive to shape and affects positioning accuracy;
[0212] In this embodiment, the penalty term optimizes the bounding box shape using the following logic:
[0213] (1) Differentiation Constraints: Utilization Weight the difference in bounding box width and height, prioritizing the dimensions that are more relevant to the true box shape. For example, when the aspect ratio is very different, the long axis is emphasized.
[0214] (2) Nonlinear enhancement: Performance evaluation found that the model performance is optimal when θ = 4, which significantly improves mAP50 and recall. By using a high power of θ = 4, the width and height of the predicted box are forced to quickly approach the true box, especially applying a stronger correction signal to samples with large differences.
[0215] (3) Collaboration with other losses: penalty term Ω shape Combined with L measure The distance between the centroids cetroid and shape distance shape , forming multi-dimensional constraints on the "position + shape + center of mass" of the bounding box, improving the positioning accuracy and shape matching of laser spot detection.
[0216] Since the traditional IoU loss function shows different gradient changes in different IoU value intervals, and this change cannot be adaptively adjusted according to the different characteristics of the samples, IoU inner Adaptive auxiliary boxes are introduced to dynamically adjust the scale of the bounding box based on the different IoU ranges of the samples. For high IoU samples (0.7 < IoU < 1), smaller auxiliary boxes are used for loss calculation to accelerate convergence. For low IoU samples (0 < IoU < 0.3), larger auxiliary boxes are used to improve the regression speed. The formula is:
[0217]
[0218] Among them, inter is the product of the horizontal and vertical intersection lengths of the real box and the auxiliary box, and union is the ratio of the area of the real box and the auxiliary box to the scale factor. The formula is:
[0219]
[0220] union=(w gt *h gt )*(radio) 2 +(w*h)*(radio) 2 -inter
[0221] in, Indicates the boundary position of the real box, (b l ,b r ,b t ,b b ) represents the boundary position of the auxiliary frame, radio is the scale factor, w gt and h gt Represent the width and height of the real box, w and h represent the width and height of the predicted box respectively;
[0222] In the model building module, the diversified class normalization loss L Dcn and adaptive layer-wise cross-point regression loss L AHIoU Add up to the total loss, the formula is:
[0223] Total loss = classification loss L Dcn + regression loss L AHIoU
[0224] In the model construction module, the original RepNCSPELAN4 module in YOLOv9 is difficult to effectively fuse features of different scales and mainly relies on 3×3 convolution kernels to capture features, which limits its ability to perceive multi-scale features. Therefore, the lightweight multi-scale feature processing module MSBCSPELAN is used to replace the original RepNCSPELAN4 module in YOLOv9;
[0225] MSBCSPELAN integrates the concept of the MSBlock module into the RepNCSPELAN4 module, adopts a hierarchical feature fusion strategy and a heterogeneous convolution kernel selection protocol, uses convolution kernels of different sizes, including 9×9, 7×7, 5×5, and 3×3, to capture the image features of light spots of different scales, processes multi-scale features at different network stages, enhances the model's ability to recognize light spot targets of different sizes, improves detection accuracy, and reduces the number of model parameters.
[0226] The specific operating mechanism of MSBCSPELAN is as follows: When the MSBCSPELAN module runs, it first splits the input features into multiple branches, each responsible for processing a different texture subset. Each branch then performs feature transformation using 1×1 convolution to reduce the channel dimension and reduce subsequent computational effort. Depthwise separable convolution is then performed, independently performing spatial convolution on each channel to extract spatial features. Point-wise convolution (1×1 convolution) is then used to enable information exchange between channels. Finally, another round of 1×1 convolution further enhances features and reduces the number of parameters. Different branches utilize a heterogeneous convolution kernel selection protocol to select convolution kernels of different sizes, such as 9×9, 7×7, 5×5, and 3×3, to capture image features at different scales, processing multi-scale features at different network stages. Finally, the features of each branch are fused, enabling the detector to more effectively recognize and process objects of varying sizes, enhancing the network's ability to capture multi-scale features.
[0227] Example 3
[0228] See also Figure 4 , which is a comparative example of different YOLO algorithms performing real-time detection of light spots generated in actual laser spot detection scenarios. The following describes the detailed implementation steps of the improved laser spot detection method and system based on the YOLO model proposed in the present invention.
[0229] The YOLO-spot model in this embodiment is a model used in the laser spot detection method and system based on the improved YOLO model provided by the present invention. Its parameters are the parameters used to achieve optimal performance through model training and evaluation. As a key parameter for controlling difficult-to-classify samples, the size of δ directly affects the model's sensitivity to boundary information. Experiments show that when δ = 0.1, the model achieves optimal performance in all core indicators, especially in recall rate, F1 score, and MAP. 50 and MAP 50:95 In terms of accuracy, an ideal balance is achieved. While a smaller δ refines the distinction between boundary samples and absolute positive samples, the lack of significant differentiation may cause the model to perform poorly when learning the characteristics of boundary samples. This effect is particularly pronounced in complex scenes, resulting in under-recognition of boundary samples. Conversely, when δ is increased to 0.12, the difference between boundary samples and absolute positive samples is overemphasized. This excessive penalty for boundary samples causes the model to ignore some key features of absolute positive samples, ultimately leading to overall performance degradation.
[0230] On this basis, k1 and k2 adjust the weight distribution of boundary samples and absolute positive samples in the loss function. The increase of k value indicates that the model attaches more importance to boundary samples, while the increase of k2 indicates that the model is more inclined to learn the characteristics of absolute positive samples. Through experiments, it is found that when δ=0.1, k1:k2=0.6:0.4, the model has a better performance in F1 score and MAP 50 and MA P 50:95 This demonstrates that moderately increasing the weight of boundary samples helps the model more accurately capture the characteristics of complex boundary samples, thereby improving overall detection accuracy. The combination of k1:k2 = 0.6:0.4 demonstrates high accuracy, but because the model overemphasizes absolute positive samples and underemphasizes the weight of boundary samples, this leads to deficiencies in handling complex boundary cases and relatively weak generalization capabilities.
[0231] The trained and well-performing model is applied to actual laser spot detection scenarios to perform real-time detection of the spot generated by the laser system, ensuring the quality and stability of laser applications. The improved YOLO-Spot is compared with the results of different current YOLO models, including YOLOv3, YOLOv5-1, YOLOv6-1, YOLOv7, YOLOv8-1, YOLOv8-x, YOLOv9, YOLOv9-c, YOLOv10-1, and YOLOX-x.
[0232] from Figure 4 As can be seen, YOLO-spot outperforms other YOLO models in accuracy, recall, F1 score, mAP50, and mAP50:95. Compared to YOLOv9, the proposed YOLO-spot significantly improves the accuracy and efficiency of laser spot detection, with its MAP50 and MAP50:95 increases of 15.4% and 15.7%, respectively. The model's parameter calculations are reduced by 0.4M and GFLOPS by 1.1, while accuracy is increased by 3.4%, recall by 21.5%, and F1 score by 14.8%. Its lower parameter calculation and computational complexity make it more suitable for industrial applications, particularly in laser spot detection environments involving complex and unbalanced datasets.
Claims
1. A laser spot detection method based on an improved YOLO model, characterized in that: include: (1) Collecting spot images; (2) enhancing the spot image data, including at least one of replicating the spot image data, randomly scaling, adjusting the color, and adjusting the brightness; (3) Light spot image annotation, that is, marking the location of the light spot to obtain the light spot image dataset; (4) Model construction: Based on YOLOv9, the lightweight multi-scale feature processing module MSBCSPELAN is used to replace the RepNCSPELAN4 module, and the diversified class normalization loss function and the adaptive hierarchical cross-point regression loss function are set; (5) Model training: dividing the data in the light spot image dataset into a training set, a validation set, and a test set, and training the constructed model; (6) Performance evaluation: Evaluate the performance of the model in the test set using precision, recall, F1 score, mAP50, mAP50:95, number of parameters, and GFLOPS. Adjust the parameters of the model based on the evaluation results, and repeat (4) to (6) until the model performance evaluation reaches the optimal level.
2. The improved laser spot detection method based on the YOLO model according to claim 1 is characterized in that: The diversified class normalized loss function L Dcn , the formula is: Among them, N represents the number of samples, n represents the number of sample types, is the one-hot encoding of the i-th sample, is the predicted probability of the i-th sample, is the sliding adjustment factor, is the smoothing adjustment factor, is the weight compensation factor; Sliding adjustment factor Adjust the contribution of each sample to the loss based on the IoU value, assigning higher weights to samples near the threshold μ. The formula is: Among them, δ is a small constant used to fine-tune the IoU threshold and define the range of boundary samples, and parameters k1 and k2 are used to control the weight ratio between boundary samples and absolute positive samples; Smoothing adjustment factor Use the formula to dynamically adjust the impact of negative samples in class imbalanced data on the tail category gradient. The formula is: Where ∈ is a small positive number used to prevent division by zero, Indicates the number of samples in category T, N max Count the samples of the most frequently occurring category; Weight compensation factor It is used to adjust the logit difference, especially by amplifying the logit difference of the tail category. The formula is: in, Represents the logit value of the sample for its true category T, x j Represents the logit value of the sample for the non-target category J, J≠T, Represents the highest logit value among all non-true categories of the sample, Represents the difference in the model's confidence between the correct class and the class least likely to be correct.
3. The improved laser spot detection method based on the YOLO model according to claim 2 is characterized in that: The adaptive layered intersection regression loss function L AHIoU , adding the sample's IoU value, shape, and centroid information into the calculation, the formula is: L AHIoU =L measure +IoU-IoU inner -IoU Mid Among them, L measure is the bounding box regression loss function, IoU is the IoU value of the sample, IoU inner is the IoU value of the adaptive auxiliary frame, IoU Mid is the sample IoU value in the medium-low range; IoU Mid Discard difficult samples whose IoU values are lower than the threshold d, set their output to 0, use a nonlinear growth component to gradually increase the loss for low IoU value samples in the medium-low level range, and use a linear growth component to provide a smooth gradient signal for high IoU value samples in the medium-low level range. The formula is: Where d and σ represent the lower and upper limits of the regulations, respectively; Bounding box regression loss function L measure The IoU value of the sample, the distance between the center of the predicted box and the center of the real box shape , the distance between the center position of the prediction box and the center of mass position centroid , a penalty term Ω related to the bounding box shape shape Add to calculation, the formula is: L measure =1-IoU+distance shape +distance centroid +0.5×Ω shape The distance between the center of the predicted box and the true box shape The formula is: Among them, (x c ,y c )and Represent the center coordinates of the predicted box and the real box respectively, c is the diagonal length of the minimum closed bounding box, Among them, w gt and h gt Represent the width and height of the real box respectively, and scale is the scaling factor; The distance between the center of the prediction box and the center of mass centroid The formula is: Among them, (x c ,y c ) represents the center coordinate of the prediction box, (x ctr ,y ctr ) is the coordinate of the center of mass of the target object; The penalty term Ω related to the bounding box shape shape The formula is: Among them, t represents the dimension of the bounding box, and its value is w,h, where w and h represent the width and height of the predicted box respectively, θ is the parameter of the penalty term, w t and w h Used to dynamically adjust width and height, the formula is: The IoU value of the adaptive auxiliary box dynamically adjusts the proportion of the bounding box based on the different IoU ranges of the samples. For samples with high IoU in the IoU range, a smaller auxiliary box is used, and for samples with low IoU in the IoU range, a larger auxiliary box is used. The formula is: Among them, inter is the product of the horizontal and vertical intersection lengths of the real box and the auxiliary box, and union is the ratio of the area of the real box and the auxiliary box to the scale factor. The formula is: union=(w gt *h gt )*(radio) 2 +(w*h)*(radio) 2 -inter in, Indicates the boundary position of the real box, (b l ,b r ,b t ,b b ) represents the boundary position of the auxiliary frame, radio is the scale factor, w gt and h gy They represent the width and height of the real box, w and h represent the width and height of the predicted box, respectively.
4. The improved laser spot detection method based on the YOLO model according to claim 3 is characterized in that: The diversified class normalization loss L Dcn and adaptive layer-wise cross-point regression loss L AHIoU Add up to get the total loss, the formula is: Total loss = classification loss L Dcn + regression loss L AHIoU .
5. The improved laser spot detection method based on the YOLO model according to claim 1, characterized in that: The lightweight multi-scale feature processing module MSBCSPELAN uses a hierarchical feature fusion strategy to split the input features into multiple branches, each branch is responsible for processing a different texture subset, uses 1×1 convolution to reduce feature and channel dimensions, uses depthwise separable convolution to extract spatial features of channels and exchange channel information, uses a heterogeneous convolution kernel selection protocol to select convolution kernels of different sizes, uses convolution kernels of different sizes in different branches, captures spot image features of different scales, and processes multi-scale features at different network stages; the convolution kernel sizes include 9×9, 7×7, 5×5, or 3×3.
6. A laser spot detection system based on an improved YOLO model, characterized in that: include: An image collection module, used for collecting light spot images; A data enhancement module, which enhances the spot image data, including at least one of replication, random scaling, color adjustment, and brightness adjustment of the spot image data; The labeling module is used to label the spot image, that is, to mark the location of the spot and obtain the spot image dataset; The model building module is based on YOLOv9, replacing the RepNCSPELAN4 module with the lightweight multi-scale feature processing module MSBCSPELAN, setting the diversified class normalization loss function and the adaptive hierarchical cross-point regression loss function; A model training module is used to divide the data in the light spot image dataset into a training set, a validation set and a test set, and train the constructed model; The performance evaluation module is used to evaluate the performance of the model in the test set through precision, recall rate, F1 score, mAP50, mAP50:95, parameter number and GFLOPS indicators, and adjust the parameters of the model according to the evaluation results until the model performance evaluation reaches the optimal level.
7. The laser spot detection system improved based on the YOLO model according to claim 6, characterized in that: Model building module, the diversified class normalized loss function L Dcn , the formula is: Among them, N represents the number of samples, n represents the number of sample types, is the one-hot encoding of the i-th sample, is the predicted probability of the i-th sample, is the sliding adjustment factor, is the smoothing adjustment factor, is the weight compensation factor; Sliding adjustment factor Adjust the contribution of each sample to the loss based on the IoU value, assigning higher weights to samples near the threshold μ. The formula is: Among them, δ is a small constant used to fine-tune the IoU threshold and define the range of boundary samples, and parameters k1 and k2 are used to control the weight ratio between boundary samples and absolute positive samples; Smoothing adjustment factor Use the formula to dynamically adjust the impact of negative samples in class imbalanced data on the tail category gradient. The formula is: Where ∈ is a small positive number used to prevent division by zero, Indicates the number of samples in category T, N max Count the samples of the most frequently occurring category; Weight compensation factor It is used to adjust the logit difference, especially by amplifying the logit difference of the tail category. The formula is: in, Represents the logit value of the sample for its true category T, x j Represents the logit value of the sample for the non-target category J, J≠T, Represents the highest logit value among all non-true categories of the sample, Represents the difference in the model's confidence between the correct class and the class least likely to be correct.
8. The laser spot detection system based on the improved YOLO model according to claim 7, characterized in that: Model building module, the adaptive hierarchical intersection regression loss function L AHIoU , adding the sample's IoU value, shape, and centroid information into the calculation, the formula is: L AHIoU =L measure +IoU-IoU inner -IoU Mid Among them, L measure is the bounding box regression loss function, IoU is the IoU value of the sample, IoU inner is the IoU value of the adaptive auxiliary frame, IoU Mid is the sample IoU value in the medium-low range; IoU Mid Discard difficult samples whose IoU values are lower than the threshold d, set their output to 0, use a nonlinear growth component to gradually increase the loss for low IoU value samples in the medium-low level range, and use a linear growth component to provide a smooth gradient signal for high IoU value samples in the medium-low level range. The formula is: Where d and σ represent the lower and upper limits of the regulations, respectively; Bounding box regression loss function L measure The IoU value of the sample, the distance between the center of the predicted box and the center of the real box shape , the distance between the center position of the prediction box and the center of mass position centroid , a penalty term Ω related to the bounding box shape shape Add to calculation, the formula is: L measure =1-IoU+distance shape +distance centroid +0.5×Ω shape The distance between the center of the predicted box and the true box shape The formula is: Among them, (x c ,y c )and Represent the center coordinates of the predicted box and the real box respectively, c is the diagonal length of the minimum closed bounding box, Among them, w gt and h gt Represent the width and height of the real box respectively, and scale is the scaling factor; The distance between the center of the prediction box and the center of mass centroid The formula is: Among them, (x c ,y c ) represents the center coordinate of the prediction box, (x ctr ,y ctr ) is the coordinate of the center of mass of the target object; The penalty term Ω related to the bounding box shape shape The formula is: Among them, t represents the dimension of the bounding box, and its value is w,h, where w and h represent the width and height of the predicted box respectively, θ is the parameter of the penalty term, w t and w h Used to dynamically adjust width and height, the formula is: The IoU value of the adaptive auxiliary box dynamically adjusts the proportion of the bounding box based on the different IoU ranges of the samples. For samples with high IoU in the IoU range, a smaller auxiliary box is used, and for samples with low IoU in the IoU range, a larger auxiliary box is used. The formula is: Among them, inter is the product of the horizontal and vertical intersection lengths of the real box and the auxiliary box, and union is the ratio of the area of the real box and the auxiliary box to the scale factor. The formula is: union=(w gt *h gt )*(radio) 2 +(w*h)*(radio) 2 -inter in, Indicates the boundary position of the real box, (b l ,b r ,b t ,b b ) represents the boundary position of the auxiliary frame, radio is the scale factor, w gt and h gt They represent the width and height of the real box, w and h represent the width and height of the predicted box, respectively.
9. The laser spot detection system based on the improved YOLO model according to claim 8, characterized in that: Model building module, the diversified class normalization loss L Dcn and adaptive layer-wise cross-point regression loss L AHIoU Add up to get the total loss, the formula is: Total loss = classification loss L Dcn + regression loss L AHIoU .
10. The laser spot detection system based on the improved YOLO model according to claim 6, characterized in that: Model building module, the lightweight multi-scale feature processing module MSBCSPELAN uses a hierarchical feature fusion strategy to split the input features into multiple branches, each branch is responsible for processing different texture subsets, uses 1×1 convolution to reduce feature and channel dimensions, uses depthwise separable convolution to extract spatial features of channels and exchange channel information, uses a heterogeneous convolution kernel selection protocol to select convolution kernels of different sizes, uses convolution kernels of different sizes in different branches, captures spot image features of different scales, and processes multi-scale features at different network stages; the convolution kernel sizes include 9×9, 7×7, 5×5 or 3×3.