Steel surface defect detection method and system based on improved YOLO detection model

CN122928889APending Publication Date: 2026-10-16CHANGCHUN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611428060.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-15
Publication Date
2026-10-16

AI Technical Summary

Technical Problem

[0004]然而,YOLO的单阶段设计也暴露出在定位精度上低于两阶段算法,对小目标与密集目标检测能力偏低,对遮挡与极端比例目标鲁棒性差等问题,这很大程度影响了缺陷目标检测的综合能力

Benefits of technology

[0016]本发明提供的基于改进YOLO检测模型的钢材表面缺陷检测方法,能够在小目标及低对比度缺陷检测中,以较低计算成本,实现了检测性能的全面提升,解决钢材表面缺陷检测准确率低、误检率和漏判率高等问题。具体地,本发明引入幽灵换洗卷积模块替换骨干网络和颈部网络中的标准卷积,减少冗余信息的生成,减少计算消耗开支,减少模型参数量,增强模型非线性表达能力。另外,本发明设计了多尺度空洞注意力卷积模块用于增强特征提取能力并构建了C3k2-MAC模块,用于提高网络对不同尺度特征的感知能力,有效融合了多尺度上下文信息与关键区域增强能力,从而提高了网络对复杂场景、多尺度目标以及细粒度纹理特征的建模能力。C3k2-MAC模块能够在保持较低参数量与计算复杂度的同时,增强整体网络在钢板表面缺陷检测任务中的性能表现。本发明还简化了检测头结构,采用高效组卷积与简化预测分支,实现较少的参数和计算消耗完成边界框回归与类别预测,用于平衡计算效率与检测精度,满足实时工业检测场景对效率与轻量化部署的需求。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122928889A_ABST
    Figure CN122928889A_ABST
Patent Text Reader

Abstract

The application is suitable for the technical field of defect detection and deep learning, and provides a steel surface defect detection method and system based on an improved YOLO detection model, which comprises the following steps: constructing an improved YOLO detection model; the improved YOLO detection model comprises an improved convolution module, an improved feature extraction module and an improved detection head; obtaining a steel surface defect dataset and preprocessing the same to obtain preprocessed data, and dividing the preprocessed data into a training set and a test set; inputting the training set into the improved YOLO detection model for training to obtain a surface defect detection model; and based on the surface defect detection model, predicting the surface defects of a steel to be detected and outputting the predicted steel plate surface defect category, a prediction frame and a confidence. The application can realize comprehensive improvement of detection performance in small target and low contrast defect detection with low calculation cost, and solves the problems of low steel surface defect detection accuracy, high false detection rate and high missed judgment rate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of defect detection and deep learning technology, and particularly relates to a method and system for detecting defects on the surface of steel based on an improved YOLO detection model. Background Technology

[0002] Steel (such as steel plates) is a cornerstone material of modern industry; a core material supporting the manufacturing industry; and a structural material for infrastructure construction. However, in the production process of steel plates, from steelmaking to rolling, various factors such as the raw materials themselves, abnormal production processes, poor equipment condition, and external environment can cause surface defects such as cracks, inclusions, patches, pitting, iron oxide scale, and scratches. These defects lead to a decline in the quality of strip steel, which directly affects the safety of products in downstream industries, resulting in additional production costs and resource waste. Therefore, effective surface defect detection can ensure the stable and efficient production of steel from three dimensions: quality, cost, and safety.

[0003] Currently, traditional manual visual inspection is inefficient, unable to meet the demands of high-speed production lines, and highly susceptible to factors such as operator fatigue and experience, resulting in low accuracy, high false positive and false negative rates. As the manufacturing industry moves towards intelligent, high-speed, and large-scale development, automated inspection has become the mainstream development direction due to its efficiency and accuracy advantages. YOLO is a single-stage inspection algorithm that generates object category probabilities and location coordinates in just one step. Its core advantages lie in its end-to-end real-time performance and simplicity, making it highly suitable for detecting surface defects in steel plates.

[0004] However, YOLO's single-stage design also reveals shortcomings, such as lower localization accuracy compared to two-stage algorithms, weaker detection capabilities for small and dense targets, and poor robustness to occlusion and targets with extreme proportions. These issues significantly impact the overall ability to detect defective targets. Furthermore, YOLO is difficult to train. Due to the complexity of the loss function and its dependence on hyperparameters, improper model design can lead to vanishing or exploding gradients during training, resulting in a significant drop in detection accuracy. Summary of the Invention

[0005] The purpose of this invention is to provide a method and system for detecting surface defects in steel based on an improved YOLO detection model, in order to solve the problems mentioned in the background art.

[0006] This invention is implemented as follows: a method for detecting surface defects in steel based on an improved YOLO detection model, comprising the following steps: An improved YOLO11n model is constructed, comprising an improved convolutional module, an improved feature extraction module, and an improved detection head. The improved convolutional module replaces the standard convolutions of the backbone and neck network of the YOLO11n model with a ghost-swapped convolutional module. The improved feature extraction module integrates a multi-scale dilated attention convolutional module. The improved detection head uses grouped convolutions, regression branches, and classification branches to simplify bounding box regression and class prediction. Obtain a dataset of surface defects in steel and preprocess it to obtain preprocessed data; The preprocessed data is divided into training and testing sets according to a preset ratio; The training set is input into the improved YOLO detection model for training to obtain a surface defect detection model. Based on the surface defect detection model, surface defects of the steel to be inspected are predicted, and the predicted surface defect category, prediction box, and confidence level are output.

[0007] Furthermore, the ghost shuffling convolution module performs a small amount of convolution on the input feature map to generate a feature map X1 with half the number of output channels; then, it performs a linear operation on feature map X1 to generate a highly similar redundant feature map X2, which is then concatenated with feature map X1; finally, it generates the output feature map X through shuffling. out .

[0008] Furthermore, the workflow of the ghost-washing convolution module is represented as follows: ; ; ; In the formula, This is represented as a 1×1 convolution operation, which halves the number of output channels; This is represented as a 5×5 convolution operation generating redundant feature maps; This is a stitching operation used to stitch two feature maps X1 and X2 together along the channel dimension. This is a shuffling operation used to uniformly exchange local feature information from different channels, thereby enhancing feature fusion.

[0009] Furthermore, the improved feature extraction module is a C3k2-MAC module, which is constructed by integrating a multi-scale dilated attention convolution module into the C3k2 module. It is used to enhance the deep feature representation capability through the synergistic effect of multi-scale dilated convolution and lightweight linear attention mechanism.

[0010] Furthermore, the workflow of the C3k2-MAC module is as follows: For the input feature map Perform a 1×1 convolution operation, then split the data along the channel dimension to enter two branches for processing: ; In the formula, This represents the input feature map for the first branch; This represents the input feature map for the second branch; This represents a 1×1 convolution operation; This indicates that the input feature map F is segmented along the channel dimension; C is the number of channels; H is the height; W is the width; The first branch is the residual branch, which directly preserves the original feature information of the input feature map in order to maintain the basic semantics and stable gradient propagation; In the second branch, deep feature extraction is performed using two C3K-MAC modules: ; In the formula, This represents the output feature map of the second branch; This indicates the operation of the C3K-MAC module; The two branches are concatenated along the channel dimension and then integrated and compressed using a 1×1 convolutional layer to construct output features with enhanced information. : .

[0011] In the formula, This is for splicing operations.

[0012] Furthermore, the C3K-MAC module has a dual-branch architecture, including a shallow extraction branch and a deep enhancement branch, and its workflow is as follows: In the shallow feature extraction branch, a 1×1 convolutional layer is used to achieve shallow feature extraction: ; In the formula, This represents the output feature map of the shallow extraction branch; The deep augmentation branch consists of a 1×1 convolutional layer and two multi-scale dilated attention convolutional modules to complete the deep augmentation features: ; In the formula, The output feature map represents the deep enhancement branch; M represents the operation of the multi-scale dilated attention convolution module. The two branches are concatenated along the channel dimension and then integrated and compressed using a 1×1 convolutional layer to construct output features with enhanced information. : .

[0013] Furthermore, the workflow of the multi-scale dilated attention convolution module is as follows: For a given input feature map First, a 1×1 convolution is used to perform channel mapping and expansion on the input features to generate an intermediate feature map X. Then, the intermediate feature map X is uniformly divided into four branch feature maps along the channel dimension: ; ; The first branch feature map X0 directly maps to the branch and retains the original feature information. The second branch feature map X1 is enhanced locally using depthwise convolution with a fixed kernel (DBS1); the fixed convolution kernel k1 of DBS1 is expressed as: ; In the formula, N represents the total number of convolutional kernels, i is the row coordinate of the convolutional kernel, and j is the ordinate of the convolutional kernel; DBS1 uses center-surround distribution depthwise convolutional kernels to enhance local features, and its output Y1 is expressed as: ; In the formula, This represents a depthwise convolution with a fixed kernel of k1. Indicates the SiLU activation function; The third branch feature map X2 further integrates the output of the previous branch to enhance information interaction between different scales and reduce dependence on learning parameters. Its output Y2 is represented as follows: ; In the formula, This represents a depthwise convolution with a fixed kernel of k2; The fourth branch feature map X3 is enhanced based on contextual information. It first fuses the output of the previous branch, and then uses depthwise convolution and dilated convolution to extract local and global language information. Two fixed convolutional kernels k3 and k4 are designed respectively, as follows: ; ; In the formula, k represents the size of the convolution kernel, and the output Y5 of the fourth branch is expressed as: ; ; ; ; In the formula, This represents a depthwise convolution with a fixed kernel of k3; This represents a dilated convolution with a fixed kernel of k4 and a dilation rate of d=2. This indicates a batch normalization operation; Y3 and Y4 are both intermediate outputs. The outputs of the four branches are concatenated along the channel dimension, and multi-scale features are further fused using 3×3 convolutions. A lightweight linear attention module is then introduced to produce the final output. It can be represented as: ; In the formula, This indicates a lightweight linear attention module operation.

[0014] Furthermore, the workflow of the lightweight linear attention module is as follows: First, global average pooling is performed on the input feature X(i,j) to obtain feature X. b Then, a 1×1 convolution is used for channel mapping to obtain the channel enhancement feature Z1: ; ; ; In the formula, This represents the Sigmoid activation function; Indicates element-wise multiplication; X c For intermediate enhancement features; In the linear spatial attention part, local spatial relationships are extracted using depthwise convolution, and spatial information is aggregated through 1×1 point convolution to finally obtain the spatial information enhancement feature Z4: ; ; ; In the formula, This is represented as a 3×3 depthwise separable convolution operation; This is represented as a 1×1 point convolution operation; Then, residual connections are introduced, activated by the SiLU function. Obtain the final output of the module : .

[0015] Another objective of this invention is to provide a steel surface defect detection system based on an improved YOLO detection model, for implementing the aforementioned steel surface defect detection method based on an improved YOLO detection model, specifically including: The model building unit is used to improve the YOLO11n model and build an improved YOLO detection model. The improved YOLO detection model includes an improved convolutional module, an improved feature extraction module, and an improved detection head. The improved convolutional module uses a ghost-swapped convolutional module to replace the standard convolutions of the backbone and neck network of the YOLO11n model. The improved feature extraction module integrates a multi-scale dilated attention convolutional module. The improved detection head uses grouped convolution, regression branches, and classification branches to simplify bounding box regression and class prediction. The data acquisition and preprocessing unit is used to acquire a dataset of surface defects in steel and perform preprocessing to obtain preprocessed data. The data partitioning unit is used to divide the preprocessed data into training and testing sets according to a preset ratio. The model training unit is used to input the training set into the improved YOLO detection model for training, thereby obtaining a surface defect detection model. The prediction output unit is used to predict the surface defects of the steel to be inspected based on the surface defect detection model, and output the predicted surface defect category, prediction box and confidence level.

[0016] This invention provides a steel surface defect detection method based on an improved YOLO detection model. This method achieves a comprehensive improvement in detection performance for small targets and low-contrast defects with lower computational cost, solving problems such as low accuracy, high false positive rate, and high false negative rate in steel surface defect detection. Specifically, this invention introduces a ghost-swap convolution module to replace the standard convolutions in the backbone and neck networks, reducing the generation of redundant information, computational costs, and the number of model parameters, while enhancing the model's nonlinear expressive ability. Furthermore, this invention designs a multi-scale dilated attention convolution module to enhance feature extraction capabilities and constructs a C3k2-MAC module to improve the network's perception of features at different scales. This effectively integrates multi-scale contextual information and key region enhancement capabilities, thereby improving the network's modeling ability for complex scenes, multi-scale targets, and fine-grained texture features. The C3k2-MAC module enhances the overall network performance in steel plate surface defect detection tasks while maintaining a low number of parameters and computational complexity. This invention also simplifies the detection head structure, employs efficient group convolution and simplified prediction branches to achieve bounding box regression and category prediction with fewer parameters and computational consumption, thereby balancing computational efficiency and detection accuracy and meeting the needs of real-time industrial inspection scenarios for efficiency and lightweight deployment. Attached Figure Description

[0017] Figure 1 This is a schematic flowchart of the steel surface defect detection method based on the improved YOLO detection model provided in an embodiment of the present invention. Figure 2A schematic diagram of the structure of the improved YOLO detection model constructed in an embodiment of the present invention; Figure 3 This is a schematic diagram of the C3k2-MAC module. Figure 4 This is a schematic diagram of the MAC module. Figure 5 A schematic diagram of the lightweight linear attention module; Figure 6 Provide dataset examples and labeled visualization results; Figure 7 Enhance parts of the image with data; Figure 8 This is a visual comparison and analysis chart of the detection results of the present invention and different detection models; Figure 9 This is a heatmap comparison of the present invention with different detection models. Detailed Implementation

[0018] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0019] like Figure 1 As shown, in one embodiment of the present invention, a method for detecting surface defects in steel based on an improved YOLO detection model is provided, comprising the following steps: S1. Improve the YOLO11n model and construct an improved YOLO detection model; S2. Obtain the data set of steel surface defects and preprocess it to obtain preprocessed data; S3. Divide the preprocessed data into training set and test set according to a preset ratio; S4. Input the training set into the improved YOLO detection model for training to obtain a surface defect detection model; S5. Based on the surface defect detection model, perform surface defect prediction on the steel to be inspected (or input the test set into the surface defect detection model for prediction), and output the predicted steel plate surface defect category, prediction box, and confidence level.

[0020] Specifically, such as Figure 2As shown, the improved YOLO detection model includes a backbone network, a neck network, and an improved detection head. The backbone network includes an improved convolutional module and an improved feature extraction module; the neck network includes the improved feature extraction module. The input image undergoes multi-scale feature extraction through the backbone network; subsequently, the extracted features are fused into the neck network; finally, the fused features are used by the improved detection head to classify and locate defects on the steel plate surface. Specifically, the improved convolutional module uses the Ghost Wash Convolution (GSConv) module instead of the standard convolutions in the backbone and neck networks of the YOLO11n model to reduce computational cost and the number of model parameters. The improved feature extraction module integrates a multi-scale dilated attention convolution (MAC) module. To simplify the detection head structure, the improved detection head uses grouped convolutions, regression branches, and classification branches to simplify bounding box regression and class prediction.

[0021] In a preferred embodiment of the present invention, the GSConv module is used to perform a small amount of convolution on the input feature map to generate a feature map X1 with half the number of output channels; then, a linear operation is performed on the feature map X1 to generate a redundant feature map X2 with high similarity, and this feature map X2 is concatenated with the feature map X1; finally, the output feature map X is generated by shuffling. out Specifically, the workflow of the GSConv module described above is as follows: ; ; ; In the formula, This is represented as a 1×1 convolution operation, which halves the number of output channels; This is represented as a 5×5 convolution operation generating redundant feature maps; This is a stitching operation used to stitch two feature maps X1 and X2 together along the channel dimension. This is a shuffling operation used to uniformly exchange local feature information from different channels, thereby enhancing feature fusion.

[0022] In this embodiment of the invention, a novel lightweight convolutional module, GSConv, is used to replace standard convolution. Standard convolution generates redundant features with similar characteristics in the feature map, increasing the computational complexity and number of parameters, placing higher demands on hardware computing resources, and making it difficult to meet the real-time requirements of edge devices. The GSConv module combines depthwise convolution and channel shuffling, reducing computational consumption while exchanging local feature information between channels to improve model accuracy. By reducing redundant information through the GSConv module, the number of parameters and computational resource consumption are effectively reduced, while also enhancing the model's nonlinear expressive power.

[0023] like Figure 3As shown, in a preferred embodiment of the present invention, the improved feature extraction module is a C3k2-MAC module, constructed by integrating a MAC module into a C3k2 module. This module enhances deep feature representation capabilities through the synergistic effect of multi-scale dilated convolution and a lightweight linear attention mechanism, improves computational efficiency by fixing the convolution kernel, and enhances the network's ability to perceive features at different scales. The core of the C3k2-MAC module lies in the cascaded stacking of MAC modules, further enhancing deep feature representation capabilities through the synergistic effect of multi-scale dilated convolution and a lightweight linear attention mechanism. While inheriting the lightweight characteristics of the C3k2 structure, this C3k2-MAC module effectively integrates multi-scale contextual information and key region enhancement capabilities, thereby improving the network's ability to model complex scenes, multi-scale targets, and fine-grained texture features.

[0024] Specifically, the workflow of the C3k2-MAC module described above is as follows: For the input feature map A 1×1 convolution operation is performed to expand and reorganize channels, enhancing feature representation and reducing information loss during subsequent feature transfer. Then, the channels are split into two branches for further processing. ; In the formula, This represents the input feature map for the first branch; This represents the input feature map for the second branch; This represents a 1×1 convolution operation; This indicates that the input feature map F is segmented along the channel dimension; C is the number of channels; H is the height; W is the width; The first branch is the residual branch, which directly preserves the original feature information of the input feature map in order to maintain the basic semantics and stable gradient propagation; In the second branch, deep feature extraction is performed using two C3K-MAC modules: ; In the formula, This represents the output feature map of the second branch; This indicates the operation of the C3K-MAC module; The two branches are concatenated along the channel dimension and then integrated and compressed using a 1×1 convolutional layer to construct output features with enhanced information. : ; In the formula, This is for splicing operations.

[0025] In a preferred embodiment of the present invention, the C3K-MAC module is specifically a dual-branch architecture, including a shallow extraction branch and a deep enhancement branch, and its workflow is as follows: In the shallow feature extraction branch, a 1×1 convolutional layer is used to achieve shallow feature extraction: ; In the formula, This represents the output feature map of the shallow extraction branch; The deep augmentation branch consists of a 1×1 convolutional layer and two MAC modules to complete the deep augmentation features: ; In the formula, This represents the output feature map of the deep enhancement branch; M represents the MAC module operation; The two branches are concatenated along the channel dimension and then integrated and compressed using a 1×1 convolutional layer to construct output features with enhanced information. : .

[0026] like Figure 4 As shown, in a preferred embodiment of the present invention, the MAC module is a guided multi-convolutional module that extracts multi-scale information and enhances local perception capabilities by embedding fixed initialization convolutional kernels into depthwise convolutions. This allows the module to achieve collaborative fusion of local texture and global context information while reducing computational complexity. Specifically, the workflow of the MAC module is as follows: For a given input feature map First, a 1×1 convolution is used to perform channel mapping and expansion on the input features to generate an intermediate feature map X. Then, the intermediate feature map X is uniformly divided into four branch feature maps along the channel dimension: ; ; The first branch feature map X0 directly maps to the branch and retains the original feature information. The second branch feature map X1 is enhanced locally using depthwise convolution with a fixed kernel (DBS1); the fixed convolution kernel k1 of DBS1 is expressed as: ; In the formula, N represents the total number of convolutional kernels, i is the row coordinate of the convolutional kernel, and j is the ordinate of the convolutional kernel; DBS1 uses center-surround distribution depthwise convolutional kernels to enhance local features, and its output Y1 is expressed as: ; In the formula, This represents a depthwise convolution with a fixed kernel of k1. Indicates the SiLU activation function; The third branch feature map X2 further integrates the output of the previous branch to enhance information interaction between different scales and reduce dependence on learning parameters. Its output Y2 is represented as follows: ; In the formula, This represents a depthwise convolution with a fixed kernel of k2; The fourth branch feature map X3 is enhanced based on contextual information. It first fuses the output of the previous branch, and then uses depthwise convolution and dilated convolution to extract local and global language information. Two fixed convolutional kernels k3 and k4 are designed respectively, as follows: ; ; In the formula, k represents the size of the convolution kernel, and the output Y5 of the fourth branch is expressed as: ; ; ; ; In the formula, This represents a depthwise convolution with a fixed kernel of k3; This represents a dilated convolution with a fixed kernel of k4 and a dilation rate of d=2. This indicates a batch normalization operation; Y3 and Y4 are both intermediate outputs. The outputs of the four branches are concatenated along the channel dimension, and multi-scale features are further fused using 3×3 convolutions. A lightweight linear attention module is then introduced to produce the final output. It can be represented as: ; In the formula, This indicates a lightweight linear attention module operation.

[0027] like Figure 5 As shown, in a preferred embodiment of the present invention, the lightweight linear attention module combines linear channel attention and linear spatial attention to enhance key semantic information, while utilizing residuals to maintain the integrity of the original features, thereby improving the network's feature extraction capability and training stability. This achieves feature enhancement with low computational complexity, effectively improving the expressive power of contextual information. Specifically, the workflow of the lightweight linear attention module is as follows: First, global average pooling is performed on the input feature X(i,j) to obtain feature X. b Then, a 1×1 convolution is used for channel mapping to obtain the channel enhancement feature Z1: ; ; ; In the formula, This represents the Sigmoid activation function; Indicates element-wise multiplication; X c For intermediate enhancement features; In the linear spatial attention part, local spatial relationships are extracted using depthwise convolution, and spatial information is aggregated through 1×1 point convolution to finally obtain the spatial information enhancement feature Z4: ; ; ; In the formula, This is represented as a 3×3 depthwise separable convolution operation; This is represented as a 1×1 point convolution operation; Then, residual connections are introduced, activated by the SiLU function. Obtain the final output of the module : .

[0028] In surface defect detection tasks on steel materials (such as steel plates), traditional detection heads employ complex convolutional structures to enhance feature representation capabilities. However, this requires significant computational resources and inference latency, limiting the model's application scenarios. Lightweight design of the detection head can retain key feature information while reducing computational complexity, thereby improving model efficiency and flexible deployment.

[0029] In a preferred embodiment of the present invention, the improved detection head is a simplified detection head, which employs grouped convolution with two 3×3 convolutions forming a feature extraction module. This divides the channels into multiple groups for convolution calculation, effectively reducing the number of parameters and computational resource consumption. The bounding box regression and prediction task is divided into two branches: a classification branch performs category prediction through independent 1×1 convolutions, and a regression branch outputs bounding box distribution parameters through 1×1 convolutions. Both branches use single-layer 1×1 convolutions to directly generate prediction results, reducing intermediate redundant feature changes, lowering computational overhead, and shortening the inference path. Simultaneously, a distributed regression mechanism (DFL) is introduced in the bounding box regression branch, transforming continuous coordinate prediction into a discrete probability distribution, improving positioning accuracy.

[0030] In this embodiment of the invention, the simplified detection head employs efficient group convolution and simplified prediction branches, completing bounding box regression and class prediction with fewer parameters and less computational cost. This achieves an effective balance between computational efficiency and detection accuracy, meeting the demands of real-time industrial inspection scenarios for efficiency and lightweight deployment.

[0031] Example 1: The following is an experimental verification of the solution provided by the present invention: 1. Dataset: In this embodiment, the NEU-DET dataset is used to verify the ability of the model of this invention to detect surface defects in steel plates. The NEU-DET dataset contains 1800 original images, mainly including six common surface defects of silicon steel plates: fine cracks (Cr), inclusions (In), patches (Pa), pitting (Ps), iron oxide scale rolling (Rs), and scratches (Sc). Each type of defect has 300 images, with a resolution of 200×200. This dataset demonstrates good research applicability and technical extensibility in terms of scene coverage, defect diversity, and annotation quality. Examples of the dataset and annotation visualization results are shown below. Figure 6 As shown.

[0032] 2. Data preprocessing (enhancement) methods: In order to enhance the generalization ability of the model and alleviate the problem of data scarcity, this embodiment adopts a systematic data augmentation strategy, which enhances the original dataset through various image transformation techniques.

[0033] Data augmentation schemes include morphological changes and photometric changes. Specific morphological changes include (1) horizontal flip: flipping the image left and right; (2) vertical flip: flipping the image up and down; (3) 90° rotation: rotating counterclockwise at 90°, 180°, and 270°; (4) random cropping: randomly selecting cropping areas, filtering and adjusting bounding boxes, and renormalizing coordinates; (5) proportional scaling: scaling the image proportionally while keeping the bounding box coordinates unchanged.

[0034] The luminance changes include: (1) Brightness adjustment: adjusting the overall brightness through the alpha parameter; (2) HSV adjustment: randomly adjusting the hue (H), saturation (S), and brightness (V) channels; (3) Gaussian noise: adding Gaussian distributed noise; (4) Gaussian blur: simulating the defocus effect; (5) Motion blur: simulating the blur caused by a moving camera; (6) Sharpening: enhancing the edges through the difference of Gaussian blur.

[0035] The data augmentation strategies described above are randomly combined to achieve a 5-fold data expansion. The original data distribution characteristics are maintained, increasing the diversity of the dataset. The expanded dataset is divided into training and test sets in an 8:2 ratio. This division ensures that the training set has sufficient samples for model training and learning, while also providing independent data validation for model performance evaluation. Images of the data augmentation are shown below. Figure 7As shown.

[0036] 3. Experimental Setup: The experimental platform in this embodiment is built on a Windows 11 operating system, using PyTorch 2.8.0 as the deep learning framework, CUDA version 12.8, and Python 3.9 as the programming language. The hardware configuration is: CPU: Intel(R) Core(TM) i9-14900K; GPU: NVIDIA GeForce RTX 4090.

[0037] For the training strategy, the input image size was set to 640×640, and the batch size was 32. The initial learning rate was set to 0.01, the momentum factor to 0.937, and the weight decay parameter to 0.0005. The specific hyperparameter configuration of the model is listed in Table 1.

[0038] Table 1 Model training parameters

[0039] 4. Evaluation metrics: This experiment mainly uses relevant evaluation metrics such as precision, recall, average precision, average precision, frames per second, and gigabit floating-point operations per second to comprehensively evaluate the detection capability of the model.

[0040] Among them, precision (P) measures the accuracy of the model in identifying samples that are actually positive when they are judged as positive; recall (R) measures the model's ability to identify real defect samples; average precision (AP) measures the combined performance of precision and recall at different confidence levels; average average precision (mAP) measures the overall detection capability of the model; frames per second (FPS) measures the inference speed of the model, and FPS directly affects the model's real-time detection capability. A high FPS model can smoothly, in real-time, safely, and perfectly complete the defect detection task; gigafloat operations per second (GFLOPs) measures the floating-point operations required by the model for each forward propagation. GFLOPs directly reflect the complexity and weight of the model. A model with lower GFLOPs can be deployed on terminal devices with low computing power, reducing expenses.

[0041] 5. Comparative Experiments: To comprehensively evaluate the improved YOLO detection model constructed in this invention, mainstream target detection models were selected for comparative experiments. All comparative models were trained and tested on the same steel plate surface defect detection dataset, with consistent experimental conditions, including data augmentation strategies, number of training rounds, hardware environment, and other parameter settings. By comparing the performance with these mainstream detection algorithms, the superiority and practicality of the improved YOLO detection model constructed in this invention can be objectively verified. The comparison results are shown in Table 2.

[0042] Table 2 Comparison with other methods on NEU-DET data

[0043] As shown in the table above, the improved YOLO detection model constructed in this invention exhibits superior performance on the NEU-DET dataset, achieving an mAP of 77.6%, representing a 4.4% performance improvement compared to the baseline model YOLO11n. Furthermore, the improved YOLO detection model constructed in this invention has only 1.8M parameters, lower than YOLO11n's 2.9M, and its computational complexity is reduced from 7.6 GFLOPs to 4.3 GFLOPs, representing reductions of approximately 37.9% and 43.4% respectively, demonstrating excellent lightweight characteristics. In terms of detection performance across different categories, the lightweight multi-scale attention-based steel plate surface defect detection method proposed in this invention also demonstrates strong competitiveness. It achieves the highest average accuracy of 59.5% in the Cr category, significantly outperforming other comparative models; it reaches 84.3% in the Ps category, demonstrating good recognition ability for fine-grained surface texture defects; and it achieves the best result of 87.1% in the Sc category. Furthermore, in categories such as In and Pa, the model performance remains comparable to or even slightly improved compared to the baseline, indicating that the proposed method does not introduce significant performance degradation while enhancing key features. This further verifies the model's advantages in detecting defects in complex structures and its good generalization ability in multi-category defect identification tasks. These results demonstrate that the improved YOLO detection model constructed in this invention achieves a good balance between accuracy and efficiency, possesses strong engineering application value, and its efficient structural design makes the model more suitable for resource-constrained industrial scenarios.

[0044] To verify the superior performance of the improved YOLO detection model constructed in this invention in the task of detecting defects on steel plate surfaces, different YOLO framework models were selected and evaluated on NEU-DET test set images. The results are as follows: Figure 8 As shown.

[0045] according to Figure 8The comparative experimental results clearly show that the improved YOLO detection model constructed in this invention exhibits significant advantages in small target defect detection, especially in the detection of In-class defects. Compared with other comparative models, the improved YOLO detection model constructed in this invention can more accurately identify multiple small targets in the image, not only with a more complete number of detections but also with more precise target localization, and higher consistency between the predicted bounding box and the ground truth annotation. This indicates that the improved YOLO detection model constructed in this invention has stronger feature perception capabilities when handling small-scale targets. In the Ps-class defect detection task, the improved YOLO detection model constructed in this invention also demonstrates excellent performance, with the highest degree of matching between its prediction results and the ground truth annotation, and the detection box boundaries more closely conforming to the actual defect area, reflecting strong localization capabilities. In contrast, other detection models suffer from boundary offset or incomplete detection, indicating that they still have shortcomings in the representation of feature details. Furthermore, comparisons of detection results for other types of defects reveal that the improved YOLO detection model constructed in this invention can output prediction results with higher confidence overall, the detection results are more stable, and there are fewer false positives and false negatives, further verifying the superior performance of the model in the task of detecting defects on the surface of steel plates.

[0046] 6. Ablation Experiments: To systematically evaluate the contribution of each innovative module of the improved YOLO detection model constructed in this invention to the model performance, this embodiment designed a series of progressive ablation experiments. Using YOLO11n as the baseline model, the improved modules were gradually introduced through ablation experiments, and the effects of the GSConv model, the C3k2-MAC module, and the improved detection head were examined respectively.

[0047] Table 3 Ablation experiments on NEU-DET data

[0048] In the first phase of the ablation experiment, various improved modules were gradually introduced, and their impact on model performance was systematically evaluated. The results are shown in Table 3. The baseline model YOLO11n achieved a mAP of 73.2% on the NEU-DET dataset. First, after introducing the GsConv module, the mAP increased to 74.6%, indicating that this module can bring a certain accuracy gain while improving feature representation ability. At the same time, GFLOPs decreased from 7.6 to 5.5, the number of parameters decreased to 2.3M, but FPS decreased from 186.37 to 162.57, indicating that it has a certain impact on inference speed while reducing computational complexity. Subsequently, after introducing the C3k2-MAC module, the model mAP further improved to 74.9%, while the recall rate significantly increased from 62.1% to 71.2%, indicating that this module plays an important role in enhancing multi-scale feature modeling ability and reducing false negatives. When the simplified detection head module is introduced, the mAP is 73.1%, slightly lower than the baseline, while the FPS significantly improves to 191.97, reaching the highest value among all configurations. Simultaneously, GFLOPs decrease to 5.1, and the number of parameters is 2.3M. This indicates that this module has significant advantages in optimizing the detection head structure and improving inference efficiency, but it suffers from some shortcomings in accuracy. When all three modules work together, forming the complete improved YOLO detection model, the performance reaches its optimal state: mAP increases to 77.6%, a 4.4% improvement over the baseline, and recall reaches 71.4%. At the same time, GFLOPs decrease to 4.3, and the number of parameters is reduced to 1.9M. Compared to the aforementioned step-by-step stacking process, it can be seen that the modules have a good synergistic effect, not only significantly improving detection accuracy but also effectively reducing model complexity, achieving a comprehensive optimization of performance and efficiency.

[0049] 7. Visualization Experiment: To visually demonstrate the model optimization effect and explore the anomaly detection logic and attention focus area, this embodiment uses the Grad-weighted Class Activation Mapping (Grad-CAM) method to generate feature heatmaps for visualization analysis. The experiment selects the NEU-DET dataset and compares the improved YOLO detection model constructed in this invention with the YOLO series models. The heatmap visualization results are shown below. Figure 9 As shown.

[0050] The visualization results clearly show that the improved YOLO detection model constructed in this invention outperforms other comparative models in terms of target localization accuracy. Specifically, in Figure 9In the defect areas corresponding to the heatmap shown, the improved YOLO detection model constructed in this invention exhibits a more concentrated and intense high-response area (red area), indicating that the model can more effectively capture key defect features and achieve more accurate spatial localization. In contrast, the response areas of YOLO11n, YOLO11s, and other models are relatively dispersed, and background interference responses exist in some samples, indicating that their feature focusing ability is relatively insufficient. This more concentrated and clear response distribution not only improves the consistency between the detection box and the real defect area, but also reflects that the model has a stronger discriminative ability in the feature extraction stage. The color distribution in the heatmap can intuitively reflect the model's attention allocation, where the closer the color is to red, the higher the model's attention level in that area. The improved YOLO detection model constructed in this invention exhibits a deeper and more concentrated red response in the defect area, indicating that it can effectively suppress irrelevant background information and focus attention on the real defect location. In addition, in complex backgrounds and multi-defect scenarios, the improved YOLO detection model constructed in this invention can still maintain a stable and clear response pattern, while other models are prone to response diffusion or shift. This further demonstrates the robustness and reliability of the improved YOLO detection model constructed in this invention in complex industrial environments.

[0051] In another embodiment of the present invention, a steel surface defect detection system based on an improved YOLO detection model is also provided to implement the above-described steel surface defect detection method based on an improved YOLO detection model, specifically including: The model building unit is used to improve the YOLO11n model and build an improved YOLO detection model. The data acquisition and preprocessing unit is used to acquire a dataset of surface defects in steel and perform preprocessing to obtain preprocessed data. The data partitioning unit is used to divide the preprocessed data into training and testing sets according to a preset ratio. The model training unit is used to input the training set into the improved YOLO detection model for training, thereby obtaining a surface defect detection model. The prediction output unit is used to predict surface defects in the steel to be inspected based on the surface defect detection model, and output the predicted surface defect category, prediction box, and confidence level. Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods.

[0052] The above embodiments merely illustrate several implementation methods of the present invention, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these all fall within the protection scope of the present invention. Therefore, the protection scope of this patent should be determined by the appended claims.

Claims

1. A method for detecting surface defects in steel based on an improved YOLO detection model, characterized in that, Includes the following steps: An improved YOLO11n model is constructed, comprising an improved convolutional module, an improved feature extraction module, and an improved detection head. The improved convolutional module replaces the standard convolutions of the backbone and neck networks of the YOLO11n model with a ghost-swapped convolutional module. The improved feature extraction module integrates a multi-scale dilated attention convolutional module. The improved detection head uses grouped convolutions, regression branches, and classification branches to simplify bounding box regression and class prediction. Obtain a dataset of surface defects in steel and preprocess it to obtain preprocessed data; The preprocessed data is divided into training and testing sets according to a preset ratio; The training set is input into the improved YOLO detection model for training to obtain a surface defect detection model. Based on the surface defect detection model, surface defects of the steel to be inspected are predicted, and the predicted surface defect category, prediction box, and confidence level are output.

2. The method for detecting surface defects in steel based on the improved YOLO detection model according to claim 1, characterized in that, The ghost shuffling convolution module performs a small amount of convolution on the input feature map to generate a feature map X1 with half the number of output channels; then, it performs a linear operation on feature map X1 to generate a highly similar redundant feature map X2, which is then concatenated with feature map X1; finally, it generates the output feature map X through shuffling. out .

3. The method for detecting surface defects in steel based on the improved YOLO detection model according to claim 2, characterized in that, The workflow of the ghost-washing convolution module is as follows: ; ; ; In the formula, This is represented as a 1×1 convolution operation, which halves the number of output channels; This is represented as a 5×5 convolution operation generating redundant feature maps; This is a stitching operation used to stitch two feature maps X1 and X2 together along the channel dimension. This is a shuffling operation used to uniformly exchange local feature information from different channels, thereby enhancing feature fusion.

4. The method for detecting surface defects in steel based on the improved YOLO detection model according to claim 1, characterized in that, The improved feature extraction module is the C3k2-MAC module, which is constructed by integrating the multi-scale dilated attention convolution module into the C3k2 module. It is used to enhance the deep feature representation capability through the synergistic effect of multi-scale dilated convolution and lightweight linear attention mechanism.

5. The method for detecting surface defects in steel based on the improved YOLO detection model according to claim 4, characterized in that, The workflow of the C3k2-MAC module is as follows: For the input feature map Perform a 1×1 convolution operation, then split the data along the channel dimension to enter two branches for processing: ; In the formula, This represents the input feature map for the first branch; This represents the input feature map for the second branch; This represents a 1×1 convolution operation; This indicates that the input feature map F is segmented along the channel dimension; C is the number of channels; H is the height; W is the width; The first branch is the residual branch, which directly preserves the original feature information of the input feature map in order to maintain the basic semantics and stable gradient propagation; In the second branch, deep feature extraction is performed using two C3K-MAC modules: ; In the formula, This represents the output feature map of the second branch; This indicates the operation of the C3K-MAC module; The two branches are concatenated along the channel dimension and then integrated and compressed using a 1×1 convolutional layer to construct output features with enhanced information. : ; In the formula, This is for splicing operations.

6. The method for detecting surface defects in steel based on the improved YOLO detection model according to claim 5, characterized in that, The C3K-MAC module has a dual-branch architecture, including a shallow extraction branch and a deep enhancement branch. Its workflow is as follows: In the shallow feature extraction branch, a 1×1 convolutional layer is used to achieve shallow feature extraction: ; In the formula, This represents the output feature map of the shallow extraction branch; The deep augmentation branch consists of a 1×1 convolutional layer and two multi-scale dilated attention convolutional modules to complete the deep augmentation features: ; In the formula, The output feature map represents the deep enhancement branch; M represents the operation of the multi-scale dilated attention convolution module. The two branches are concatenated along the channel dimension and then integrated and compressed using a 1×1 convolutional layer to construct output features with enhanced information. : 。 7. The method for detecting surface defects in steel based on the improved YOLO detection model according to claim 6, characterized in that, The workflow of the multi-scale dilated attention convolution module is as follows: For a given input feature map First, a 1×1 convolution is used to perform channel mapping and expansion on the input features to generate an intermediate feature map X. Then, the intermediate feature map X is uniformly divided into four branch feature maps along the channel dimension: ; ; The first branch feature map X0 directly maps to the branch and retains the original feature information. The second branch feature map X1 is enhanced locally using depthwise convolution with a fixed kernel (DBS1); the fixed convolution kernel k1 of DBS1 is expressed as: ; In the formula, N represents the total number of convolutional kernels, i is the row coordinate of the convolutional kernel, and j is the ordinate of the convolutional kernel; DBS1 uses center-surround distribution depthwise convolutional kernels to enhance local features, and its output Y1 is expressed as: ; In the formula, This represents a depthwise convolution with a fixed kernel of k1. Indicates the SiLU activation function; The third branch feature map X2 further integrates the output of the previous branch to enhance information interaction between different scales and reduce dependence on learning parameters. Its output Y2 is represented as follows: ; In the formula, This represents a depthwise convolution with a fixed kernel of k2; The fourth branch feature map X3 is enhanced based on contextual information. It first fuses the output of the previous branch, and then uses depthwise convolution and dilated convolution to extract local and global language information. Two fixed convolutional kernels k3 and k4 are designed respectively, as follows: ; ; In the formula, k represents the size of the convolution kernel, and the output Y5 of the fourth branch is expressed as: ; ; ; ; In the formula, This represents a depthwise convolution with a fixed kernel of k3; This represents a dilated convolution with a fixed kernel of k4 and a dilation rate of d=2. This indicates a batch normalization operation; Y3 and Y4 are both intermediate outputs. The outputs of the four branches are concatenated along the channel dimension, and multi-scale features are further fused using 3×3 convolutions. A lightweight linear attention module is then introduced to produce the final output. It can be represented as: ; In the formula, This indicates a lightweight linear attention module operation.

8. The method for detecting surface defects in steel based on the improved YOLO detection model according to claim 7, characterized in that, The workflow of the lightweight linear attention module is as follows: First, global average pooling is performed on the input feature X(i,j) to obtain feature X. b Then, a 1×1 convolution is used for channel mapping to obtain the channel enhancement feature Z1: ; ; ; In the formula, This represents the Sigmoid activation function; Indicates element-wise multiplication; X c For intermediate enhancement features; In the linear spatial attention part, local spatial relationships are extracted using depthwise convolution, and spatial information is aggregated through 1×1 point convolution to finally obtain the spatial information enhancement feature Z4: ; ; ; In the formula, This is represented as a 3×3 depthwise separable convolution operation; This is represented as a 1×1 point convolution operation; Then, residual connections are introduced, activated by the SiLU function. Obtain the final output of the module : 。 9. A steel surface defect detection system based on an improved YOLO detection model, used to implement the steel surface defect detection method based on an improved YOLO detection model as described in any one of claims 1-8, characterized in that, include: The model building unit is used to improve the YOLO11n model and build an improved YOLO detection model. The improved YOLO detection model includes an improved convolutional module, an improved feature extraction module, and an improved detection head. The improved convolutional module uses a ghost-swapped convolutional module to replace the standard convolutions of the backbone and neck network of the YOLO11n model. The improved feature extraction module integrates a multi-scale dilated attention convolutional module. The improved detection head uses grouped convolution, regression branches, and classification branches to simplify bounding box regression and class prediction. The data acquisition and preprocessing unit is used to acquire a dataset of surface defects in steel and perform preprocessing to obtain preprocessed data. The data partitioning unit is used to divide the preprocessed data into training and testing sets according to a preset ratio. The model training unit is used to input the training set into the improved YOLO detection model for training, thereby obtaining a surface defect detection model. The prediction output unit is used to predict the surface defects of the steel to be inspected based on the surface defect detection model, and output the predicted surface defect category, prediction box and confidence level of the steel plate.