A real-time strip surface defect detection method
By introducing GSConv, GSResBottleneck, MSCA, Dysample, and Focal Loss into the YOLOv8n model, SteelGuard-YOLO was constructed, which solved the problem of balancing detection accuracy and speed in strip surface defect detection and achieved efficient and robust defect detection.
Patent Information
- Application Number
- CN202511028997.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-25
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2045-07-25
AI Technical Summary
Existing deep learning models struggle to meet the dual requirements of detection accuracy and speed under complex working conditions in strip steel surface defect detection. They are also sensitive to lighting conditions and background noise, making them unsuitable for real industrial environments.
Based on YOLOv8n, we introduce GSConv, GSResBottleneck, multi-scale collaborative attention mechanism MSCA, lightweight Dysample upsampling, and Focal Loss to build the SteelGuard-YOLO model. We optimize feature extraction and loss function design to enhance the robustness and real-time performance of the model.
It significantly reduces the number of model parameters and computational complexity, improves detection accuracy and robustness, can adapt to complex industrial environments, and enhances the quality and efficiency of strip steel production.
Smart Images

Figure CN120525894B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a real-time strip steel surface defect detection method. Background Art
[0002] In the modern manufacturing system, strip steel, as a key core product of the metal industry, is widely used in a variety of fields, including construction, automobiles, high-end machinery manufacturing, aerospace, and electronic packaging, forming a critical foundation for industrial production and national defense construction. With the rapid development of precision manufacturing, intelligent production, and high-end equipment manufacturing, the market has placed higher demands on the surface quality, safety, stability, and consistency of strip steel products. During the production process, the coupling of multiple factors such as the raw material metallographic structure, rolling parameters, and online ambient lighting often leads to surface defects such as cracks, peeling, scratches, and pits. This not only increases the cost of subsequent heat treatment and coating processes, but also seriously threatens the reliability of the end product. Therefore, strip steel defect detection technology is of great significance for improving product quality and manufacturing efficiency.
[0003] Since the late 20th century, academia and industry have proposed a variety of strip steel defect detection technologies, including traditional methods such as eddy current testing, infrared imaging, magnetic flux leakage, and manual visual inspection. However, these methods often suffer from high detection costs, limited coverage, and insufficient real-time performance. With the rapid advancement of computer vision, deep learning, and edge computing technologies, real-time visual inspection systems based on object detection have become the mainstream of research and application.
[0004] Object detection, a key research area in computer vision, has a long history. Before the widespread application of deep learning, this field primarily relied on detection frameworks based on image processing and traditional machine learning methods. Related research can be broadly categorized into three categories: First, image processing methods based on artificially designed features, such as local binary patterns (LBP), histograms of oriented gradients (HOG), and gray-level co-occurrence matrices (GLCMs), are used to extract low-level features of surface defects in images; second, traditional signal processing methods based on frequency domain and statistical feature extraction, including Fourier transforms, wavelet transforms, and Gabor filters; and third, algorithms that employ classic machine learning models for defect detection, such as decision trees and autoregressive models. While these methods have achieved some progress in metal surface defect detection, detection performance faces significant bottlenecks due to the sensitivity of traditional image features to factors such as lighting conditions and background noise, as well as the limited representation capabilities of shallow features in complex scenes. Therefore, although many scholars have proposed various detection models based on traditional machine learning, their promotion and application in actual industrial environments are still greatly limited.
[0005] In recent years, with the rapid development of artificial intelligence (AI) and the significant increase in the computing power of graphics processing units (GPUs), deep learning technology has shown broad application prospects in the field of metal surface defect detection. Convolutional Neural Networks (CNNs), with their end-to-end automatic feature extraction capabilities, have demonstrated excellent performance in object detection and image classification tasks, attracting widespread attention. Currently, a large number of studies have attempted to apply deep learning methods to metal surface defect detection. Lin et al. proposed a multi-model cascade CNN structure based on MobileNet, aiming to improve the accuracy performance in industrial optical defect detection, although real-time issues were not considered; Li et al. constructed an integrated model with complex parameters to improve the detection capability of industrial railway defects; Zhou et al. introduced the attention mechanism into the YOLOv5s network structure, effectively improving the detection accuracy of the model in complex scenarios; Zhang et al. integrated the lightweight convolution layer GSConv into YOLOv5s, improving the detection speed of strip defects at the expense of some accuracy; Lv et al. designed a high-precision strip surface defect detection model based on YOLOv7; Li et al. further simplified the model complexity based on YOLOv7 while maintaining strong detection capabilities; Wu et al. optimized the structure of YOLOv5n by introducing lightweight convolution and attention mechanisms, and constructed an efficient and lightweight steel surface defect detection framework, but the discrimination accuracy was low.
[0006] While the aforementioned research has made some progress in improving model performance, existing methods have yet to achieve an ideal balance between detection accuracy and efficiency. Furthermore, these models are often trained and evaluated based on datasets constructed under ideal experimental conditions, making them difficult to address in-real-world applications, such as interference factors like overexposure and uneven brightness. In typical industrial scenarios, such as strip steel surface defect detection, detection systems face extremely high robustness and real-time requirements. Existing deep learning models struggle to simultaneously meet the dual requirements of detection accuracy and speed under complex conditions, necessitating further optimization and breakthroughs.
[0007] Therefore, a real-time strip surface defect detection method is provided. Summary of the Invention
[0008] In response to the shortcomings of the existing technology, the present invention provides a real-time strip surface defect detection method, which significantly reduces the number of model parameters and computational complexity while maintaining excellent detection performance and high-speed reasoning capabilities, and can meet the metal forging industry's stringent requirements for online detection systems.
[0009] The technical solution to achieve the above purpose is:
[0010] A real-time strip steel surface defect detection method comprising:
[0011] Step S1: select NEU-DET as the surface defect detection dataset and randomly divide the dataset into training and test sets in a ratio of 8:2;
[0012] Step S2, preprocessing the surface defect detection data set;
[0013] Step S3: Based on YOLOv8n, a defect detection model SteelGuard-YOLO is constructed;
[0014] Step S4: training the defect detection model SteelGuard-YOLO using the training set, and using the trained defect detection model SteelGuard-YOLO to detect the test set, and outputting the detection results;
[0015] In step S3, the defect detection model SteelGuard-YOLO is constructed, including:
[0016] In the backbone network of the YOLOv8n framework, GSConv (lightweight convolution technology) is introduced to replace the traditional convolution layer Conv, and GSConv integrates standard convolution and depth-separable convolution structure;
[0017] While maintaining the same feature learning capabilities as standard convolution, GSConv introduces group shift operations and integrates them with point convolution, resulting in the GSResBottleneck (a neural network module that combines grid sampling technology and residual bottleneck structure) structure.
[0018] Based on the GSResBottleneck structure, the ResGSCSP module is designed by combining the generalized deep learning optimization strategy and the One-Shot aggregation idea.
[0019] The multi-scale collaborative attention mechanism MSCA is introduced into the Neck structure of the YOLOv8n framework and placed before the SPPF (Spatial Pyramid Pooling) module. The lightweight Dysample upsampling method is used to replace the original nearest neighbor interpolation method.
[0020] Finally, in terms of loss function design, Focal Loss (deep learning loss function) is introduced to dynamically assign different weights to easy-to-classify samples and difficult-to-classify samples.
[0021] Preferably, in step S1, NEU-DET (Northeastern University Surface Defect Detection Dataset) includes six types of typical defects: cracks, inclusions, patches, concave-convex surfaces, curled oxides, and scratches, and each type includes 300 grayscale images with a resolution of 200×200 pixels.
[0022] Preferably, in step S2, the preprocessing operation includes but is not limited to data enhancement processing.
[0023] Preferably, in step S3, both the GSResBottleneck structure and the ResGSCSP module introduce residual connections, and the calculation expression is:
[0024] ;
[0025] Where, and are the input and output of the residual block, It is a series of GSConv, activation function and normalization operations.
[0026] Preferably, in step S3, a multi-scale collaborative attention mechanism MSCA is introduced, and the input feature map tensor is set to:
[0027] ;
[0028] Where, is the number of channels and the spatial size, and are the spatial dimensions of the input feature map, i.e. the height and width of the feature map. The multi-scale attention mechanism MSCA first converts Divided into Group characteristics, namely:
[0029] ;
[0030] For each set of features Perform one-dimensional adaptive average pooling in the horizontal and vertical directions to obtain spatial context:
[0031] ;
[0032] ;
[0033] Where, For the Group at level The average eigenvalue of the row, For the Rank The column position index, For the Group in vertical The average eigenvalue of the column;
[0034] Then add the learnable position encoding vectors , construct location information enhancement features:
[0035] ;
[0036] ;
[0037] Where, To inject the pooled features after horizontal position encoding, is the original horizontal pooling result, is a learnable horizontal position encoding vector, To inject the pooled features after vertical position encoding, is the original vertical pooling result, A learnable vertical position encoding vector;
[0038] The features in the above two directions are concatenated into a two-dimensional representation:
[0039] ;
[0040] Where, It is the feature splicing operation;
[0041] Depthwise separable convolutions are applied sequentially to capture the joint spatial dependencies of long and short distances:
[0042] ;
[0043] ;
[0044] Where, is the feature response after DWConv, is the feature response after PWConv, For Do depthwise separable convolution, For Perform point-wise convolution;
[0045] Then generate spatial attention weights through Sigmoid activation:
[0046] ;
[0047] ;
[0048] Where, is the horizontal spatial attention weight, For the front The result after Sigmoid activation of row features, is the vertical spatial attention weight, For the rear The result of Sigmoid and transposition of row features, is the transpose operation;
[0049] Get the spatially weighted output:
[0050] ;
[0051] right Perform channel compression to extract global channel semantics:
[0052] ;
[0053] Where, It is a channel compression operation;
[0054] Input two layers of point-by-point convolutional network for gated transformation:
[0055] ;
[0056] Where, is the channel gating coefficient vector;
[0057] The weight dimension is:
[0058] ;
[0059] ;
[0060] The activation function is:
[0061] ;
[0062] ;
[0063] The final channel weighted feature is expressed as:
[0064] ;
[0065] right application Convolution integrates spatial-channel features and adds them to the original features to achieve efficient fusion:
[0066] ;
[0067] In order to enhance the effective transmission of information flow, the fused features are further adaptively weighted through the residual attention mechanism:
[0068] ;
[0069] Where, It is an adaptive weighting function that can dynamically assign different weights according to the importance of input features.
[0070] The final output features are:
[0071] .
[0072] Preferably, in step S3, a lightweight Dysample upsampling method is used to replace the original nearest neighbor interpolation method, including:
[0073] Use grid_sample function to sample set The provided coordinates are input to the feature map Resampling is performed based on the bilinear interpolation method to achieve feature mapping and generate new feature maps , specifically defined as follows:
[0074] ;
[0075] Assume the upsampling factor is , through a layer of linear transformation, the number of channels is changed from Map to , generate the offset tensor:
[0076] ;
[0077] Then, the offset tensor is transformed into Rearrange to size The coordinate offset field and the original regular sampling grid Add them together to get the dynamic sampling set:
[0078] ;
[0079] ;
[0080] Finally, using the Bilinear interpolation function of right Resample and directly generate high-resolution feature maps .
[0081] Preferably, in step S3, in terms of loss function design, Focal Loss is introduced to dynamically assign different weights to easy-to-classify samples and difficult-to-classify samples, including:
[0082] Assume that the standard multi-class cross entropy loss function is defined as:
[0083] ;
[0084] Where, The output of the model is The predicted probability of the class, is the actual label;
[0085] Based on the loss function, by introducing The modulation coefficient makes the network focus more on predicting the gradient feedback of low confidence and difficult-to-distinguish samples during training. It is expressed as:
[0086] ;
[0087] Where, is an adjustable hyperparameter;
[0088] When a sample is misclassified, The value is small, then the modulation coefficient Close to 1, consistent with the standard cross entropy loss;
[0089] For easily separable samples, When the value is large, the modulation coefficient approaches 0, which significantly reduces its contribution to the total loss.
[0090] Compared with the prior art, the present invention has the following beneficial effects:
[0091] Based on GSConv, this paper proposes GSResBottleneck and designs an efficient cross-stage partial network (CSP) module ResGSCSP in combination with the One-Shot aggregation strategy, which improves detection accuracy while reducing computational complexity and inference time.
[0092] The present invention introduces a multi-scale collaborative attention mechanism MSCA before the SPFF layer to strengthen the model's ability to focus on key features, improve feature expression and robustness, and further enhance the generalization performance of cross-scale targets;
[0093] In the neck network, the present invention adopts Dysample upsampling instead of traditional nearest neighbor upsampling to generate higher quality feature maps, thereby enhancing the deep feature fusion capability of the model.
[0094] This paper introduces Focal Loss as a loss function, which significantly improves the recognition accuracy of difficult-to-classify defect samples and the robustness of the overall model by dynamically assigning different weights to easy-to-classify samples and difficult samples.
[0095] In summary, this paper takes into account the interference factors in strip steel production and uses five data perturbation methods, including contrast perturbation, brightness perturbation, and Gaussian noise, on the original data to test the robustness of the SteelGuard-YOLO method. The results show that SteelGuard-YOLO has advanced generalization performance, making it suitable for real production environments and effectively improving the quality and efficiency of strip steel production. BRIEF DESCRIPTION OF THE DRAWINGS
[0096] Figure 1 This is a flow chart of a real-time strip steel surface defect detection method of the present invention;
[0097] Figure 2 Schematic diagram comparing the AP performance of SteelGuard-YOLO and classic target detection methods in the present invention;
[0098] Figure 3 It is a schematic diagram of the detection results of the benchmark YOLOv8n and the SteelGuard-YOLO method proposed in this invention on various interference data sets. DETAILED DESCRIPTION
[0099] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0100] like Figure 1 As shown, a real-time strip surface defect detection method includes:
[0101] In step S1, NEU-DET is selected as the surface defect detection dataset, and the dataset is randomly divided into a training set and a test set in a ratio of 8:2.
[0102] In the embodiment, NEU-DET includes six typical defects: cracks (Cr), inclusions (In), patches (Pa), uneven surfaces (Ps), curled oxides (Rs) and scratches (Sc). Each type includes 300 grayscale images with a resolution of 200 × 200 pixels, totaling 1,800 samples.
[0103] Step S2: preprocessing the surface defect detection data set.
[0104] In an embodiment, the preprocessing operation includes but is not limited to data enhancement processing.
[0105] In step S3, a defect detection model SteelGuard-YOLO is constructed based on YOLOv8n.
[0106] In the embodiment, the defect detection model SteelGuard-YOLO is constructed, including:
[0107] In the backbone network of the YOLOv8n framework, GSConv replaces the traditional convolutional layer (Conv). GSConv fuses the standard convolution (SC) and depthwise separable convolution (DSC) structures. In the classic CNN architecture, the input image undergoes a series of transformations to map spatial information into channel space. However, this spatial compression inevitably leads to a loss of semantic information. SC is computationally expensive, and as model parameters increase, inference speed decreases significantly. In contrast, DSC processes each channel independently to reduce computational complexity and improve inference efficiency. However, its feature extraction and fusion capabilities are slightly inferior to SC, which affects the model's expressiveness.
[0108] In order to balance computational efficiency and feature extraction capabilities, GSConv integrates the SC and DSC structures, retaining implicit connections between channels and reducing computational complexity, thereby achieving an effective balance between model accuracy and inference speed.
[0109] While maintaining feature learning capabilities comparable to standard convolution, GSConv introduces a grouped shift operation and integrates it with pointwise convolution, resulting in the GSResBottleneck structure. This reduces computational costs to nearly half of standard convolution. A dual-branch design is used at the bottleneck: one branch is a lightweight feature map based on GSConv, and the other is an identity map, achieving efficient feature fusion through residual connections.
[0110] Based on the GSResBottleneck structure, the ResGSCSP module is designed by combining the generalized deep learning optimization strategy and One-Shot aggregation idea.
[0111] In the embodiment, both the GSResBottleneck structure and the ResGSCSP module introduce residual connections, and the calculation expression is:
[0112] ;
[0113] Where, and are the input and output of the residual block, It is a series of GSConv, activation function and normalization operations; the residual connection not only alleviates the gradient vanishing and gradient exploding problems in deep network training, but also accelerates the convergence process.
[0114] In summary, the GSResBottleneck and ResGSCSP structures inherit the advantages of low-cost and efficient feature generation of GSConv, while achieving a good balance between lightweight and high precision through reasonable residual and cross-stage information flow design, providing solid technical support for online detection of strip surface defects.
[0115] The multi-scale collaborative attention mechanism MSCA is introduced into the Neck structure of the YOLOv8n framework and placed before the SPPF module. The lightweight Dysample upsampling method is used to replace the original nearest neighbor interpolation method.
[0116] In the embodiment, in the task of strip surface defect detection, the model not only needs to capture the detailed features of defects of different sizes, but also needs to take into account the global semantic information to avoid ignoring the global context caused by excessive reliance on convolution translation invariance of local features. To this end, a multi-scale collaborative attention mechanism MSCA is introduced. Assume that the input feature map tensor is:
[0117] ;
[0118] Where, is the number of channels and the spatial size, and are the spatial dimensions of the input feature map, i.e. the height and width of the feature map. The multi-scale attention mechanism MSCA first converts Divided into Group characteristics, namely:
[0119] ;
[0120] For each set of features Perform one-dimensional adaptive average pooling in the horizontal and vertical directions to obtain spatial context:
[0121] ;
[0122] ;
[0123] Where, For the Group at level The average eigenvalue of the row, For the Rank The column position index, For the Group in vertical The average eigenvalue of the column;
[0124] Then add the learnable position encoding vectors , construct location information enhancement features:
[0125] ;
[0126] ;
[0127] Where, To inject the pooled features after horizontal position encoding, is the original horizontal pooling result, is a learnable horizontal position encoding vector, To inject the pooled features after vertical position encoding, is the original vertical pooling result, A learnable vertical position encoding vector;
[0128] The features in the above two directions are concatenated into a two-dimensional representation:
[0129] ;
[0130] Where, It is the feature splicing operation;
[0131] Depthwise separable convolutions are applied sequentially to capture the joint spatial dependencies of long and short distances:
[0132] ;
[0133] ;
[0134] Where, is the feature response after DWConv, is the feature response after PWConv, For Do depthwise separable convolution, For Perform point-wise convolution;
[0135] Then generate spatial attention weights through Sigmoid activation:
[0136] ;
[0137] ;
[0138] Where, is the horizontal spatial attention weight, For the front The result after Sigmoid activation of row features, is the vertical spatial attention weight, For the rear The result of Sigmoid and transposition of row features, is the transpose operation;
[0139] Get the spatially weighted output:
[0140] ;
[0141] This mechanism helps to accurately respond to defect areas with regular directionality (such as longitudinal scratches and transverse depressions), improving the recognition of small target defects;
[0142] right Perform channel compression to extract global channel semantics:
[0143] ;
[0144] Where, It is a channel compression operation;
[0145] Input two layers of point-by-point convolutional network for gated transformation:
[0146] ;
[0147] Where, is the channel gating coefficient vector;
[0148] The weight dimension is:
[0149] ;
[0150] ;
[0151] The activation function is:
[0152] ;
[0153] ;
[0154] The final channel weighted feature is expressed as:
[0155] ;
[0156] In complex industrial environments, this module can adaptively enhance channel dimensions that are strongly correlated with defects, improving the model's stability under low-contrast and non-uniform lighting conditions.
[0157] right application Convolution integrates spatial-channel features and adds them to the original features to achieve efficient fusion:
[0158] ;
[0159] In order to enhance the effective transmission of information flow, the fused features are further adaptively weighted through the residual attention mechanism:
[0160] ;
[0161] Where, It is an adaptive weighting function that can dynamically assign different weights according to the importance of input features.
[0162] The final output features are:
[0163] .
[0164] In summary, MSCA achieves efficient perception and collaborative enhancement of features at different scales through sophisticated channel grouping and cross-space learning design. Compared to traditional deep convolutional networks, this mechanism effectively improves the detection of difficult-to-distinguish defects such as tiny cracks and pits on the strip surface while maintaining computational efficiency, providing a reliable and lightweight attention solution for industrial online defect detection systems.
[0165] In the embodiment, feature upsampling is an image processing operation and one of the key operations in modern convolutional network architectures. It is used to convert low-resolution feature maps into high-resolution ones to improve the model's ability to capture details and local information. There are currently two mainstream upsampling methods. One is linear interpolation, including nearest neighbor interpolation and bilinear interpolation, which are widely used in sub-pixel space, but cannot fully capture semantic information and easily lead to feature loss. Deconvolution is another common upsampling method, which achieves size expansion through convolution operations. However, deconvolution usually uses the same convolution kernel to operate on the entire feature map, which limits the ability to perceive local changes when processing images, makes it difficult to effectively capture local details, and increases the number of parameters of the model.
[0166] In the task of strip surface defect detection, small-scale defects (such as microcracks, pores, and tiny pits) are easily obscured by pixel distortion. Therefore, a lightweight Dysample upsampling method is used to replace the original nearest neighbor interpolation method, including:
[0167] Use grid_sample function to sample set The provided coordinates are input to the feature map Resampling is performed based on the bilinear interpolation method to achieve feature mapping and generate new feature maps , specifically defined as follows:
[0168] ;
[0169] Assume the upsampling factor is , through a layer of linear transformation, the number of channels is changed from Map to , generate the offset tensor:
[0170] ;
[0171] Then, the offset tensor is transformed into Rearrange to size The coordinate offset field and the original regular sampling grid Add them together to get the dynamic sampling set:
[0172] ;
[0173] ;
[0174] Finally, using the Bilinear interpolation function of right Resample and directly generate high-resolution feature maps .
[0175] In summary, the lightweight DySample upsampling method, which replaces the traditional nearest-neighbor interpolation method, achieves precise magnification of tiny defect areas by learning pixel-level offsets without expensive dynamic convolution calculations, significantly reducing resource consumption. In strip surface defect detection, DySample can better preserve defect edge and texture information while maintaining real-time performance, improving the detector's recognition accuracy for small-scale, low-contrast defects.
[0176] Finally, in terms of loss function design, Focal Loss is introduced to dynamically assign different weights to easy-to-classify samples and difficult-to-classify samples.
[0177] In the embodiment, the loss function plays a core role in the model optimization process, affecting both training efficiency and final performance. In the task of strip surface defect detection, samples of different defect types have different classification difficulties, and some easily confused samples will interfere with model training. In order to enhance the model's attention to difficult-to-classify samples, a dynamic modulation factor can be introduced on the basis of multi-category cross entropy loss, thereby reducing the contribution of easy-to-classify samples to gradient updates and improving overall detection accuracy. In terms of loss function design, Focal Loss is introduced to dynamically assign different weights to easy-to-classify samples and difficult-to-classify samples, including:
[0178] Assume that the standard multi-class cross entropy loss function is defined as:
[0179] ;
[0180] Where, The output of the model is The predicted probability of the class, is the actual label;
[0181] Based on the loss function, by introducing The modulation coefficient makes the network focus more on predicting the gradient feedback of low confidence and difficult-to-distinguish samples during training. It is expressed as:
[0182] ;
[0183] Where, is an adjustable hyperparameter;
[0184] When a sample is misclassified, The value is small, then the modulation coefficient Close to 1, consistent with the standard cross entropy loss;
[0185] For easily separable samples, The value is large, the modulation coefficient approaches 0, which significantly reduces its contribution to the total loss. As the size of the sample increases, the network's attention to difficult-to-distinguish samples is further enhanced, which helps to improve the ability to identify subtle features and easily confused defects in strip surface defect detection.
[0186] Step S4: Train the defect detection model SteelGuard-YOLO using the training set, and use the trained defect detection model SteelGuard-YOLO to detect the test set, and output the detection results.
[0187] In order to intuitively demonstrate the advanced nature of the proposed SteelGuard-YOLO, this paper compares it with the baseline model YOLOv8n. The experimental results are shown in Table 1.
[0188]
[0189] Table 1
[0190] The proposed SteelGuard-YOLO was verified using the test set. The experimental results are shown in Table 1. 0.5 It represents the average precision calculated when the IoU (Intersection over Union) threshold is set to 0.5, and mAP 0.5:0.95 It is a more stringent comprehensive evaluation indicator. The average precision is calculated when the IoU threshold varies from 0.5 to 0.95. The SteelGuard-YOLO proposed in this paper has a lower precision, recall rate, and mAP when the amount of calculation and the number of parameters are reduced by 11.6% and 7.4% respectively. 0.5 and mAP 0.5:0.95 They increased by 1.4%, 3.1%, 4.1% and 3.0% respectively.
[0191] In addition, to further analyze SteelGuard-YOLO's ability to detect strip surface defects, the present invention selected multiple images from the test set for visual comparison. The comparison results show that when detecting insignificant strip defects, especially cracks (Cr), patches (Pa), and curled oxides (Rs), the baseline YOLOv8n model has obvious omissions and false detections; the improved SteelGuard-YOLO performs more robustly, can effectively avoid detection errors, and demonstrates superior defect recognition capabilities and robustness.
[0192] To fully verify the superiority of the MSCA attention mechanism in strip surface defect detection, this paper replaces the lightweight YOLOv8n backbone network with Coordinate Attention (CA), Squeeze-and-Excitation (SE), Nonlocal Block ND (NonlocalBlockND), Convolutional BlockAttention Module (CBAM) and Spatial-Channel Synergic Attention (SCSA), and conducts comparative experiments under a unified dataset and training strategy.
[0193] Among them, CA attention effectively establishes pixel-level position dependency through spatial coordinate encoding and channel direction perception, thereby improving the model's positioning accuracy for defect areas; SE attention adaptively adjusts the weights of each channel based on global channel statistics to compensate for the information loss caused by uneven feature responses between channels; NonlocalBlockND uses non-local operations to calculate the similarity between any two points, realizing global context modeling of long-distance dependencies, but its high-order correlation calculation has a large overhead on high-resolution feature maps; CBAM connects channel and spatial attention sub-modules in series, and successively performs global average pooling and maximum pooling to optimize channel allocation, and then uses cross-channel compression to highlight key spatial areas. Although it can improve detection performance, it is inferior to lightweight designs such as MSCA in terms of real-time and resource utilization; SCSA adopts the collaborative interaction of space and channels and multi-scale semantic fusion strategy, taking into account local details and global semantics, but its multi-branch structure also increases network complexity.
[0194]
[0195] Table 2
[0196] As shown in Table 2, after introducing the MSCA attention mechanism on the basis of YOLOv8n, the overall detection performance of the model reached the best. Compared with the original YOLOv8n, MSCA achieved 69.5%, 72.5%, 76.4%, and 43.2% in precision (P), recall (R), mAP0.5, and mAP0.5:0.95, respectively. 0.5 and mAP 0.5:0.95 All achieved optimal performance. Although the MSCA model's precision was slightly lower than that of some other attention mechanisms, it achieved an optimal balance between precision and recall, significantly enhancing the model's robustness in detection tasks. Furthermore, the introduction of MSCA did not significantly increase FLOPs or parameter size, further demonstrating that this mechanism can effectively improve the model's detection performance in strip surface defect detection tasks while maintaining its lightweight nature.
[0197] To systematically evaluate the effectiveness of each improved module in strip surface defect detection, we conducted systematic ablation experiments on each component based on the lightweight YOLOv8n architecture, as shown in Table 3. Model 0 serves as the baseline YOLOv8n, and the remaining models sequentially introduce modules such as MSCA, DySample, ResGSCSP, and Focal Loss (FL) to quantify the impact of each component on detection performance, computational complexity, and parameter size.
[0198]
[0199] Table 3
[0200] The experimental results in Table 3 reveal the following key findings:
[0201] (1) MSCA (Model 1): The addition of MSCA significantly enhances the detection capability. Specifically, MSCA realizes cross-space-channel joint modeling by reshaping and grouping the channel dimension and combining it with parallel 3×3 depthwise separable convolution; the dynamic channel gating mechanism further adaptively amplifies and suppresses relevant features, effectively avoiding the dimensional bottleneck in traditional attention. This lightweight design enhances the representation capability of small defects such as cracks and pits in multi-scale space, while only incurring negligible computational overhead. Experimental results show that the MSCA module improves precision (P), recall (R), and mAP. 0.5 and mAP 0.5:0.95 The improvements were 1.9%, 2.2%, 2.4% and 2.4% respectively, fully verifying its efficient feature extraction and expression capabilities.
[0202] (2) DySample upsampling (Model 2): After the introduction of DySample, recall (R), mAP 0.5 and mAP0.5:0.95 All significantly improved (by 1.0%, 0.8%, and 0.7%, respectively), demonstrating that its dynamic upsampling mechanism and lightweight decomposition design enhance multi-scale feature expression capabilities while adding only a minimal number of parameters. Although the recall rate (R) decreased slightly from 70.3% to 70.2%, this may be due to DySample's lower response threshold to edge blur or background noise when increasing feature sensitivity. However, from an overall perspective, DySample effectively improves detection robustness while maintaining model efficiency through its cross-scale feature aggregation strategy and dynamic sampling point segmentation technology.
[0203] (3) ResGSCSP lightweight branch (Model 3): Using the GSConv-based ResGSCSP structure, the model FLOPs is reduced from 6.9G to 6.0G and the number of parameters is reduced from 2.57M to 2.32M, while maintaining the target detection performance. This verifies the advantages of this branch in balancing detection accuracy and resource saving.
[0204] (4) Introduction of Focal Loss (Model 4): After replacing the loss function with Focal Loss, the recall rate increased by 0.8% and mAP 0.5 and mAP 0.5:0.95 The results show that FocalLoss helps the model focus on difficult-to-classify samples, improving overall recall and small object detection capabilities without increasing computational overhead or parameter size.
[0205] (5) Models 5 to 8 represent combined optimization experiments using different improved modules. The introduction of multiple improved components only slightly increases the computational complexity and parameter count, and overall improves target detection accuracy. Furthermore, the introduction of ResGSCSP effectively reduces the computational cost of the model while ensuring detection performance, fully demonstrating the feasibility of multi-module collaborative optimization in strip defect detection.
[0206] (6) Model 9, as the model proposed in this study, performs well in this task. Compared with the baseline YOLOv8n, the SteelGuard-YOLO model reduces the amount of computation and the number of parameters by 11.6% and 9.7% respectively, while the precision, recall, and mAP are improved. 0.5 and mAP 0.5:0.95 These improvements were 1.4%, 3.1%, 4.1%, and 3.0%, respectively. This result fully demonstrates that SteelGuard-YOLO significantly enhances the detection performance of minute defects on the strip surface while maintaining lightweight deployment capabilities, providing an efficient and reliable solution for industrial online inspection.
[0207] This paper selects object detection models of comparable size to YOLOv8n as comparison baselines, including YOLOv3-tiny, YOLOv5n, YOLOv9t, YOLOv10n, and YOLO11n. It also incorporates larger mainstream models such as YOLOv3, YOLOv9c, and RTDETR-resnet50, aiming to comprehensively evaluate the performance advantages of the proposed SteelGuard-YOLO model. Furthermore, to further validate the model's advanced nature, this paper also introduces several representative improved models from current research, including SDD-YOLO and EcoDetect-YOLOv2. The training results of each model, using a unified experimental environment and parameter settings, are shown in Table 4.
[0208]
[0209] Table 4
[0210] As shown in Table 4, SteelGuard-YOLO achieves the highest mAP while maintaining a lightweight level of 6.0GFLOPs and 2.32M parameters. 0.5 (78.1%) and mAP 0.5:0.95 (43.8%). Although its precision and recall are not the best among all models, it shows a more balanced P–R trade-off at a very low computational cost.
[0211] Specifically, EcoDetect-YOLOv2 demonstrates superior detection performance compared to models of similar scale, such as YOLOv8n, YOLOv9t, YOLO11n, and SDD-YOLO. Compared to larger models such as YOLOv5s, YOLOv8s, YOLOv9c, and RTDETR-ResNet50, SteelGuard-YOLO also leads in mAP, while reducing computational complexity by approximately 60%–95%. In summary, the proposed SteelGuard-YOLO achieves optimal overall detection performance while maintaining low computational complexity, fully demonstrating its efficiency and robustness.
[0212] To verify SteelGuard-YOLO's detection performance for different defect types, we compared it with several classic target detection models. Table 5 summarizes the AP values of each model for six defect types: cracks (Cr), inclusions (In), patches (Pa), uneven surfaces (Ps), curled oxides (Rs), and scratches (Sc).
[0213]
[0214] Table 5
[0215] Results show that the SteelGuard-YOLO model achieves optimal performance in detecting four types of defects: cracks (Cr), inclusions (In), patches (Pa), and uneven surfaces (Ps). In particular, the SteelGuard-YOLO model significantly outperforms all other models for detecting cracks (Cr) and inclusions (In). It also leads mainstream lightweight and medium-sized networks for detecting curled oxides (Rs) and scratches (Sc), fully demonstrating its superiority in detecting both small and complex defects. Figure 2 The visual display of the AP values of each model further highlights the comprehensive leading position of SteelGuard-YOLO in the task of strip surface defect detection.
[0216] Figure 2 The overall and category-specific performance of SteelGuard-YOLO was visually compared with several leading object detection models, using visualizations of the AP and centroid of each category. The results demonstrate that SteelGuard-YOLO significantly outperforms other models in overall detection capabilities, achieving the highest AP values for four key defect categories: cracks (Cr), inclusions (In), patches (Pa), and uneven surfaces (Ps), demonstrating its excellent adaptability and robustness to multiple surface defect types.
[0217] When capturing images of metal surfaces in real industrial scenarios, they are often interfered with by various objective environmental factors, such as overexposure, insufficient lighting, and image blur. To systematically evaluate the adaptability and robustness of the proposed SteelGuard-YOLO model in complex environments, we performed five typical interference enhancement processes on the images in the original dataset: increasing brightness by 50%, decreasing brightness by 50%, increasing contrast by 50%, decreasing contrast by 50%, and adding 5% Gaussian noise.
[0218] Figure 3 The detection results of the benchmark YOLOv8n and the SteelGuard-YOLO method proposed in this paper on various interference datasets are listed.
[0219] It can be seen that SteelGuard-YOLO maintains higher precision (P), recall (R), and mAP than YOLOv8n, whether in images with significant changes in brightness or contrast or after adding noise. 0.5 and mAP 0.5:0.95 Metrics. YOLOv8n mAP under all interference conditions 0.5 and mAP 0.5:0.95The average decreases were 4.5% and 4.1%, respectively, while SteelGuard-YOLO only decreased by approximately 3.6% and 2.4%. Overall, SteelGuard-YOLO not only exhibited less performance fluctuation under noise and illumination variations, but also achieved detection results on disturbed images that even surpassed those of YOLOv8n on original, uninterrupted images, fully demonstrating the proposed method's exceptional robustness and generalization capabilities for online detection of strip surface defects.
[0220] In summary, the present invention designs an efficient cross-stage local network ResGSCSP by fusing the lightweight convolution module GSConv with the One-Shot aggregation strategy, which significantly reduces the number of model parameters and computational complexity; the multi-scale collaborative attention mechanism (MSCA) introduced before feature fusion effectively enhances the ability to focus on faint and small defects; in the neck network, Dysample upsampling replaces the traditional nearest neighbor interpolation, which not only improves the quality of deep feature maps, but also speeds up the inference speed; in addition, FocalLoss is used to dynamically allocate the weights of easy-to-classify and difficult-to-classify samples, which greatly improves the model's recognition accuracy for complex and tiny surface defects. Experimental results show that SteelGuard-YOLO reduces the amount of computation and the number of parameters by 11.6% and 7.4% respectively, and the Precision, Recall, and mAP are higher than those of the baseline YOLOv8n model on the NEU-DET dataset. 0.5 and mAP 0.5:0.95 The mAP performance of the proposed method is improved by 1.4%, 3.1%, 4.1% and 3.0% respectively; under typical interference conditions such as contrast perturbation, brightness perturbation and adding Gaussian noise, its mAP performance ... 0.5 and mAP 0.5:0.95 They only dropped by about 3.6% and 2.4% respectively, which fully verified the high precision, real-time performance and robustness of the method in industrial sites.
[0221] While embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions, and variations may be made to these embodiments without departing from the principles and spirit of the invention, and that the scope of the invention is defined by the appended claims and their equivalents.
Claims
1. A real-time strip surface defect detection method, characterized in that: include: Step S1: select NEU-DET as the surface defect detection dataset and randomly divide the dataset into training and test sets in a ratio of 8:2; Step S2, preprocessing the surface defect detection data set; Step S3: Based on YOLOv8n, a defect detection model SteelGuard-YOLO is constructed; Step S4: training the defect detection model SteelGuard-YOLO using the training set, and using the trained defect detection model SteelGuard-YOLO to detect the test set, and outputting the detection results; In step S3, the defect detection model SteelGuard-YOLO is constructed, including: In the backbone network of the YOLOv8n framework, GSConv is introduced to replace the traditional convolution layer Conv, and GSConv integrates standard convolution and depth-separable convolution structure; While maintaining the same feature learning capabilities as standard convolution, GSConv introduces group shift operations and integrates them with point convolution to obtain the GSResBottleneck structure. Based on the GSResBottleneck structure, the ResGSCSP module is designed by combining the generalized deep learning optimization strategy and the one-shot aggregation idea. The multi-scale collaborative attention mechanism MSCA is introduced into the Neck structure of the YOLOv8n framework and placed before the SPPF module. The lightweight Dysample upsampling method is used to replace the original nearest neighbor interpolation method. Finally, in terms of loss function design, Focal Loss is introduced to dynamically assign different weights to easy-to-classify samples and difficult-to-classify samples; In step S3, a lightweight Dysample upsampling method is used to replace the original nearest neighbor interpolation method, including: Use grid_sample function to sample set The provided coordinates are input to the feature map Resampling is performed as a resampling process, which is based on the bilinear interpolation method to achieve feature mapping and generate a new feature map , specifically defined as follows: ; Assume the upsampling factor is , through a layer of linear transformation, the number of channels is changed from Map to , generate the offset tensor: ; Then, the offset tensor is transformed into Rearrange to size The coordinate offset field and the original regular sampling grid Add them together to get the dynamic sampling set: ; ; Finally, using the Bilinear interpolation function of right Resample and directly generate high-resolution feature maps .
2. A real-time strip steel surface defect detection method according to claim 1, characterized in that: In step S1, NEU-DET includes six typical defects: cracks, inclusions, patches, uneven surfaces, curled oxides, and scratches. Each type includes 300 grayscale images with a resolution of 200 × 200 pixels.
3. The method for real-time strip steel surface defect detection according to claim 1, characterized in that: In step S2, the preprocessing operation includes data enhancement processing.
4. The method for real-time strip steel surface defect detection according to claim 1, wherein: In step S3, both the GSResBottleneck structure and the ResGSCSP module introduce residual connections, and the calculation expression is: ; Where, and are the input and output of the residual block, It is a series of GSConv, activation function and normalization operations.
5. The method for real-time strip steel surface defect detection according to claim 1, characterized in that: In step S3, the multi-scale collaborative attention mechanism MSCA is introduced, and the input feature map tensor is set to: ; Where, is the number of channels and the spatial size, and are the spatial dimensions of the input feature map, i.e. the height and width of the feature map. The multi-scale attention mechanism MSCA first converts Divided into Group characteristics, namely: ; For each set of features Perform one-dimensional adaptive average pooling in the horizontal and vertical directions to obtain spatial context: ; ; Where, For the Group at level The average eigenvalue of the row, For the Rank The column position index, For the Group in vertical The average eigenvalue of the column; Then add the learnable position encoding vectors , construct location information enhancement features: ; ; Where, To inject the pooled features after horizontal position encoding, is the original horizontal pooling result, is a learnable horizontal position encoding vector, To inject the pooled features after vertical position encoding, is the original vertical pooling result, A learnable vertical position encoding vector; The features in the above two directions are concatenated into a two-dimensional representation: ; Where, It is the feature splicing operation; Depthwise separable convolutions are applied sequentially to capture the joint spatial dependencies of long and short distances: ; ; Where, is the feature response after DWConv, is the feature response after PWConv, For Do depthwise separable convolution, For Perform point-wise convolution; Then generate spatial attention weights through Sigmoid activation: ; ; Where, is the horizontal spatial attention weight, For the front The result after Sigmoid activation of row features, is the vertical spatial attention weight, For the rear The result of Sigmoid and transposition of row features, is the transpose operation; Get the spatially weighted output: ; right Perform channel compression to extract global channel semantics: ; Where, It is a channel compression operation; Input two layers of point-by-point convolutional network for gated transformation: ; Where, is the channel gating coefficient vector; The weight dimension is: ; ; The activation function is: ; ; The final channel weighted feature is expressed as: ; right application Convolution integrates spatial-channel features and adds them to the original features to achieve efficient fusion: ; In order to enhance the effective transmission of information flow, the fused features are further adaptively weighted through the residual attention mechanism: ; Where, It is an adaptive weighting function that can dynamically assign different weights according to the importance of input features; The final output features are: 。 6. The method for real-time strip steel surface defect detection according to claim 1, characterized in that: In step S3, in terms of loss function design, Focal Loss is introduced to dynamically assign different weights to easy-to-classify samples and difficult-to-classify samples, including: Assume that the standard multi-class cross entropy loss function is defined as: ; Where, The output of the model is The predicted probability of the class, is the actual label; Based on the loss function, by introducing The modulation coefficient makes the network focus more on predicting the gradient feedback of low confidence and difficult-to-distinguish samples during training. It is expressed as: ; Where, is an adjustable hyperparameter; When a sample is misclassified, The value is small, the modulation coefficient Close to 1, consistent with the standard cross entropy loss; For easily separable samples, When the value is large, the modulation coefficient approaches 0, which significantly reduces its contribution to the total loss.
Citation Information
Patent Citations
Method and apparatus for detecting metal surface defects
WO2022160170A1