Lightweight real-time strip steel surface defect detection method based on improved YOLOv5s model

By improving the YOLOV5S model, design the CGH module, MCFF module, and BIFPN structure, and use the carAFE sampler to build the SDD-YOLO target detection model, solve the problem of poor detection accuracy and efficiency in existing technologies, and achieve high precision, and achieve high precision, and achieve high precision. High -efficiency and lightweight steel surface defect detection effect.

CN118505658BActive Publication Date: 2025-01-28BEIJING SHUTONG MAGIC CUBE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410673378.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-28
Publication Date
2025-01-28
Estimated Expiration
2044-05-28

AI Technical Summary

Technical Problem

The existing metal surface defect detection model has not yet reached a good balance in detection accuracy and detection efficiency, and cannot effectively overcome the challenges in practical applications such as light reflection, light intensity and material interference.

Method used

By improving the YOLOV5S model, design the CGH module, MCFF module, and BIFPN structure, and use the carAFE sampler to build the SDD-YOLO target detection model to enhance the ability and characteristic extraction ability of different scale targets.

Benefits of technology

While maintaining the lightweight network, the accuracy and efficiency of the surface defect detection with steel surface is improved, and the detection effect of high -precision, high efficiency and lightweightness is achieved. Essence

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118505658B_ABST
    Figure CN118505658B_ABST
Patent Text Reader

Abstract

The invention discloses a lightweight real-time strip steel surface defect detection method based on an improved YOLOv5s model, comprising: step S1, obtaining a NEU-DET data set and preprocessing it; step S2, optimizing the network structure based on the existing YOLOv5s algorithm, and obtaining an SDD-YOLO target detection model after optimization; step S3, training the SDD-YOLO target detection model based on the preprocessed data set; step S4, detecting a video or a picture using the SDD-YOLO target detection model, and outputting the detected video or picture. The invention improves the production quality and efficiency of strip steel.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a lightweight real-time strip steel surface defect detection method based on an improved YOLOv5s model. Background Art

[0002] As an important core product of the metal industry, strip steel plays an indispensable role in the fields of construction, automobiles, machinery manufacturing, aerospace, etc. With the vigorous development of high-end industries such as precision metal manufacturing, the metal industry has increasingly stringent requirements for the quality of strip steel products. In the production and manufacturing process of steel, various types of defects such as cracks, holes, scratches, etc. will appear on the surface of the product due to the influence of various factors such as raw material quality, manufacturing equipment and production environment. These defects not only cause huge economic losses to the metal manufacturing industry, but also bring serious safety hazards to society. In recent years, the field of metal surface defect detection has received more and more attention, and the effect and efficiency of detection technology have also been significantly improved. However, the detection of metal surface defects is easily affected by various interference factors such as light reflection, light intensity and material itself in the production process, which increases the difficulty of metal surface defect detection. Therefore, improving the ability to detect strip surface defects is of great significance to improving product quality and manufacturing efficiency.

[0003] With the continuous development of artificial intelligence technology and the improvement of GPU performance, deep learning technology has shown unique application potential in metal surface defect detection. Convolutional neural network (CNN) is highly praised for its powerful feature extraction ability. At present, many scholars have applied deep learning technology to metal surface defect detection research.

[0004] For example, Lin et al. proposed a multi-model cascade CNN based on MobileNet, which is dedicated to reducing false positives for industrial optical defect detection without considering the detection speed. Li et al. developed an integrated framework with complex parameters for industrial railway defect detection, aiming to improve the detection performance of railway defects. Zhou et al. combined the attention mechanism module with the YOLOv5s model to improve the detection performance while reducing the detection efficiency. Zhang et al. combined the lightweight convolutional layer GSConv with YOLOv5s to improve the detection rate of strip surface defect detection at the cost of reducing the detection accuracy. Lv et al. proposed a high-precision strip surface defect detection model based on the improvement of YOLOv7. Li et al. improved on the basis of YOLOv7, maintaining a high surface defect detection capability while slightly reducing the model complexity. Although these studies have made certain contributions to the field of metal surface defect detection, these models have not yet achieved a good balance between detection accuracy and detection efficiency. In addition, since the performance of these detection models is mainly evaluated on data sets in ideal environments, metal surface defect detection in actual applications, especially strip surface defect detection, will be affected by interference factors such as overexposure and uneven brightness. Therefore, the current metal surface defect detection models are unable to overcome these challenges and cannot achieve both detection accuracy and detection speed in actual strip surface defect detection applications. Summary of the invention

[0005] The purpose of the present invention is to overcome the existing defects and provide a lightweight real-time strip steel surface defect detection method based on an improved YOLOv5s model, thereby improving the quality and efficiency of strip steel production.

[0006] The technical solution to achieve the above purpose is:

[0007] A lightweight real-time strip surface defect detection method based on an improved YOLOv5s model includes:

[0008] Step S1, obtain the NEU-DET dataset and preprocess it;

[0009] Step S2, optimizing the network structure based on the existing YOLOv5s algorithm, and obtaining the SDD-YO LO target detection model after optimization;

[0010] Step S3, training the SDD-YOLO target detection model based on the preprocessed data set;

[0011] Step S4, using the SDD-YOLO target detection model to detect the video or image, and output the detected video or image.

[0012] Preferably, in step S1, the NEU-DET data set includes six defect types: cracks, inclusions, patches, uneven surfaces, curled oxides, and scratches;

[0013] Each defect type contains 300 images with a resolution of 200 × 200 pixels, and a total of 1800 grayscale images;

[0014] The 1800 grayscale images are divided into the NEU-DET dataset into training set, validation set and test set according to the ratio of 80%, 10% and 10%.

[0015] Preferably, in step S1, the preprocessing includes performing data enhancement and normalization processing on the data set, wherein the data enhancement method includes increasing brightness, reducing brightness and adding Gaussian noise.

[0016] Preferably, in step S2, the YOLOv5s algorithm includes: an Input module, a BackBone module, a Neck module and a Head module.

[0017] The Input module includes: inputting image data enhancement and splicing, setting three initialization anchors, and adaptively scaling the image size;

[0018] BackBone module includes: CBS module, C3 module and SPPF module. CBS module consists of Conv, BatchNorm and SiLU, which is used to extract local spatial information in the image and give it nonlinear transformation; C3 module consists of three standard convolutional layers and a bottleneck layer, which is used to improve the computational efficiency of the algorithm. Each C3 module is connected by Concat operation; SPPF module is used to extract feature maps of different sizes from the input image;

[0019] The Neck module, which consists of FPN and PAN, is used to skillfully integrate the extracted semantic features with the position features. At the same time, it organically integrates the backbone network layer with the detection layer to enhance the features extracted by different network layers.

[0020] The Head module is used to predict targets of different sizes on the feature map. The Head module of the YOLOv5s algorithm uses three detection heads to detect target objects and predict their categories and positions. The three detection heads correspond to feature maps of 20x20, 40x40, and 80x80, and accurately output targets of different sizes.

[0021] Preferably, in step S2, optimizing the network structure of the existing YOLOv5s algorithm includes:

[0022] In the BackBone module, a CGH module is added based on the C3 module, and the standard convolutional layer and bottleneck layer in the C3 module are replaced with GhostConv, and the Concat operation is replaced by the residual connection;

[0023] Then, the formula for calculating the residual connection is as follows:

[0024] Output=F(Input,{W i})+Input;

[0025] The input and output of the first layer are defined as Input and Output respectively, and the nonlinear change is defined as F(Input,{W i}), including non-linear activation functions;

[0026] In the BackBone module, the SPPF (spatial pyramid pooling) module is replaced with a multi-convolution feature fusion block, namely MCFF, M in Represents the input of the multi-convolution feature fusion block, through M in ∈R C×H×W The 3×3, 5×5 and 7×7 convolution kernels are used to extract M1, M2 and M3. Block uses global average pooling to extract features from M2 and M3 of different resolutions. One-dimensional convolution is used for adaptive feature extraction. After Sigmoid transformation, the channel attention S2∈R is obtained. 1×1×C and S3∈R 1×1ωC , and use the function CBR to fuse M1, S2 and S3 to obtain the final output feature M out ∈R C×H×W , the process is as follows:

[0027]

[0028] Among them, CBR represents the combination of three layers: the same mode 3×3 convolution layer, BatchNorm layer and nonlinear activation function ReLU, represents element-by-element multiplication, σ represents the ReLU layer, Conv 3×3 It is a 3×3 convolutional layer of the same mode, which is used to fuse feature maps of different resolutions and channel attention. BatchNorm is a normalization method used to solve the problem of inconsistent input data distribution.

[0029] Preferably, in step S2,

[0030] The FPN in the Neck module is replaced with a BiFPN (bidirectional feature pyramid network) network, which is built on the PAN. The upsampling in the BiFPN network is replaced by the CARAFE (content-aware feature recombination) upsampler to improve the algorithm's receptive field and the resolution of the feature map and directly fuse the features in the feature extraction network with the features of relative size in the bottom-up path.

[0031] Preferably, in step S2, represents the intermediate feature information of the top-down transmission path of the i-th layer, represents the output characteristic information of the bottom-up transmission path of the i-th layer, then the calculation formula is as follows:

[0032]

[0033]

[0034] in, Represents the input sample feature information of the i-th layer node, Conv represents the convolution operation, resize represents upsampling or downsampling operation, ω1 represents the weight of the input node of the first layer, ω2 represents the weight of the input node of the second layer, ω1' represents the weight of the output node of the first layer, ω'2 represents the weight of the output node of the second layer, ω3' represents the weight of the output node of the third layer, and ε is generally set to 0.0001 to avoid numerical instability;

[0035] The calculation formula for the final output value O is as follows:

[0036]

[0037] Among them, I i represents the input value of the node, j represents the sum of all input nodes, ω i Represents the weight of the input node. In order to satisfy the weight ω of each input node i ≥0 is established, and the RELU activation function is used for each ω i Perform calculation operations.

[0038] Preferably, in step S3, the training parameters of the SDD-YOLO target detection model are: batch size is 8, initial learning rate is set to 0.01, final learning rate is 0.0001, momentum parameter is set to 0.941, weight decay is 0.0005, input images are uniformly converted to a size of 640x640, and a stochastic gradient descent optimizer is used.

[0039] The beneficial effects of the present invention are as follows: the present invention designs a CGH module and an MCFF module, and adopts a BiFPN structure, so as to fuse features of different scales to enhance the adaptability of the detector to targets of different scales. At the same time, a CARAFE upsampler is used to replace the bilinear interpolation upsampling in the BiFPN structure, and the receptive field of the upsampling is increased, so as to extract more image features and improve the model performance, thereby constructing an SDD-YOLO target detection model, which solves the problem of low accuracy in strip surface defect detection while keeping the network lightweight, and has the characteristics of high precision, high efficiency and light weight, and is suitable for being deployed in equipment in an actual production environment to carry out real-time strip surface defect positioning and detection, thereby improving strip production efficiency and quality. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 It is a flow chart of a lightweight real-time strip steel surface defect detection method based on an improved YOLOv5s model of the present invention;

[0041] Figure 2 is a sample schematic diagram of six typical surface defects in the NEU-DET data set of the present invention;

[0042] Figure 3 This is a schematic diagram of the network architecture of the traditional YOLOv5s algorithm;

[0043] Figure 4 It is a schematic diagram of the structure of the CGH module in the present invention;

[0044] Figure 5 It is a schematic diagram of the structure of GhostConv in the present invention;

[0045] Figure 6 It is a schematic diagram of the structure of the multi-convolution feature fusion block in the present invention;

[0046] Figure 7 It is a schematic diagram of the structure of the CARAFE upsampler in the present invention;

[0047] Figure 8 Schematic diagram of the network architecture of the SDD-YOLO target detection model of the present invention;

[0048] Fig. 9 It is a schematic diagram comparing the defect detection results of YOLOv5s and SDD-YOLO on the NEU-DET dataset of the present invention;

[0049] Fig.10 is a schematic diagram of performance comparison between the present invention and other different detection algorithms;

[0050] Fig.11 Schematic diagram of AP performance comparison between the present invention and the classical target detection method. DETAILED DESCRIPTION

[0051] The technical solution of the present invention will be described clearly and completely below in conjunction with the accompanying drawings. In the description of the present invention, it should be noted that the terms "center", "up", "down", "left", "right", "vertical", "horizontal", "inside", "outside" and the like indicate directions or positional relationships based on the directions or positional relationships shown in the accompanying drawings, which are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific direction, be constructed and operated in a specific direction, and therefore cannot be understood as a limitation on the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance.

[0052] The present invention will be further described below in conjunction with the accompanying drawings.

[0053] like Figure 1 As shown, a lightweight real-time strip steel surface defect detection method based on an improved YOLOv5s model includes:

[0054] Step S1, obtain the NEU-DET dataset and preprocess it.

[0055] In the embodiment, the NEU-DET dataset includes six defect types: cracks (Cr), inclusions (I n), patches (Pa), bumpy surfaces (Ps), curled oxides (Rs) and scratches (Sc); each defect type contains 300 images with a resolution of 200×200 pixels, and a total of 1800 grayscale images; the 1800 grayscale images are divided into a training set, a validation set and a test set according to the ratio of 80%, 10% and 10%; the training set is used to optimize the network parameters to minimize the loss function, the validation set is used to verify the performance of the model during the training process, and the test set is used to evaluate the accuracy of the trained network in surface defect recognition. Figure 2 Samples of six typical surface defects in the NEU-DET dataset are shown.

[0056] In an embodiment, the preprocessing includes performing data enhancement and normalization processing on the data set, wherein the data enhancement method includes increasing brightness, reducing brightness, and adding Gaussian noise.

[0057] Step S2, optimizing the network structure based on the existing YOLOv5s algorithm, and obtaining the SDD-YO LO target detection model after optimization.

[0058] In the embodiment, YOLOv5s is a lightweight target detection neural network with relatively low cost in inference calculation and training speed. The YOLOv5s algorithm includes: Input module, BackBone module, Neck module and Head module. The Input module includes: input image data enhancement splicing, setting three initialization anchors and adaptive image size scaling; BackBone module includes: CBS module, C3 module and SPPF module. The CBS module consists of Conv, BatchNorm and Si LU is composed of three layers, which are used to extract local spatial information in the image and give it nonlinear transformation; the C3 module consists of three standard convolutional layers and a bottleneck layer, which is used to improve the computational efficiency of the algorithm, among which each C3 module is connected by the Concat operation; the SPPF module is used to extract feature maps of different sizes from the input image; the Neck module, composed of FPN and PAN, is used to cleverly integrate the extracted semantic features with the position features, and at the same time, organically integrate the backbone network layer with the detection layer to enhance the features extracted by different network layers; the Head module is used to predict targets of different sizes on the feature map, among which, the Head module of the YOLOv5s algorithm uses three detection heads, which are responsible for detecting target objects and predicting their categories and positions. The three detection heads correspond to feature maps of 20x20, 40x40 and 80x80, and accurately output targets of different sizes. The network architecture diagram of the YOLOv5 algorithm is shown as follows Figure 3 shown.

[0059] The optimization of the existing YOLOv5s algorithm network structure includes:

[0060] In the embodiment, although the C3 module adopts the CSP (Cross Stage Partial Network) structure to reduce the amount of calculation, its computational complexity is still higher than that of the traditional single convolution structure, which may increase the time cost of training and reasoning. In order to solve this problem, this study proposes a CGH module. In the BackBone module, a CGH module is added on the basis of the C3 module. The structure diagram of the CGH module is as follows: Figure 4 As shown in Figure 2, the standard convolutional layer and bottleneck layer in the C3 module are replaced with GhostConv. The structure diagram of GhostConv is as follows: Figure 5 As shown in the figure, the computational complexity is effectively reduced, and the Concat operation is replaced by residual connection, which solves the problems of overfitting, gradient disappearance and gradient explosion that may be caused by deep networks, and significantly improves the stability of the network. That is, it combines the low-cost feature map generation of GhostConv and the characteristics of residual connection to reduce memory consumption and improve feature extraction efficiency.

[0061] Then, the formula for calculating the residual connection is as follows:

[0062] Output=F(Input,{W i})+Input;

[0063] The input and output of the first layer are defined as Input and Output respectively, and the nonlinear change is defined as F(Input,{W i}), including non-linear activation functions.

[0064] Deep neural networks usually generate many similar redundant feature maps when extracting features, which consumes a lot of computing resources; although these feature maps are crucial for the network to understand data features, their generation process is very expensive; inspired by GhostNet, GhostNet is a neural architecture designed to verify the effectiveness of GhostConv; in order to reduce memory consumption in the process of feature space expansion, the present invention introduces GhostConv technology, which generates more feature maps in a lower cost manner, thereby reducing memory consumption in the intermediate expansion process; at the same time, in order to ensure the effective extraction of feature information and enhance the stability of the network, the present invention introduces residual connections.

[0065] In the BackBone module, the SPPF module is replaced by a multi-convolution feature fusion block, namely MCFF, whose structure is shown in the following figure. Figure 6 As shown; then we can get, M in Represents the input of the multi-convolution feature fusion block, through M in ∈R C×H×W The 3×3, 5×5 and 7×7 convolution kernels are used to extract M1, M2 and M3. Block uses global average pooling to extract features from M2 and M3 of different resolutions. One-dimensional convolution is used for adaptive feature extraction. After Sigmo id transformation, the channel attention S2∈R is obtained. 1×1×C and S3∈R 1×1×C , and use the function CBR to fuse M1, S2 and S3 to obtain the final output feature M out ∈R C×H×W , the process is as follows:

[0066]

[0067] Among them, CBR represents the combination of three layers: the same mode 3×3 convolution layer, BatchNorm layer and nonlinear activation function ReLU, represents element-by-element multiplication, σ represents the ReLU layer, Conv 3×3It is a 3×3 convolutional layer of the same mode, which is used to fuse feature maps of different resolutions and channel attention. BatchNorm is a normalization method used to solve the problem of inconsistent input data distribution.

[0068] In the embodiment, the introduction of MCFF can effectively improve the feature expression ability and robustness of the model, which means that the model can better capture various scales and forms of metal surface defects, thereby improving the accuracy and comprehensiveness of defect detection; secondly, the introduction of MCFF helps to avoid the gradient vanishing problem and accelerates the training process of the model. The metal surface defect detection task often requires the processing of a large amount of data and complex features, and MCFF optimizes the feature extraction process, so that the neural network can learn and adapt to different surface defect patterns more efficiently, thereby improving the convergence speed and training efficiency of the model; most importantly, MCFF ensures that the neural network can complete more complex strip surface defect detection tasks; defects on the metal surface may have different shapes, sizes and textures, so the model needs to have strong feature expression and generalization capabilities; the introduction of MCFF enables the model to better understand and distinguish different types of defects, thereby improving the robustness and reliability of the detection system.

[0069] In the embodiment, the FPN in the Neck module is replaced with a BiFPN network, and is constructed on the basis of PAN.

[0070] In the embodiment, BiFPN is built on the basis of PAN. Compared with the original neck structure, BiFPN removes nodes that do not contribute to feature fusion to save resources; it introduces new channels between input and output nodes at the same level to more fully integrate feature information; at the same time, a cross-scale connection method is proposed, and additional edges are added to directly fuse the features in the feature extraction network with the features of relative size in the bottom-up path to retain more surface semantic information while minimizing the loss of deep semantic information; the introduction of BiFPN enables SDD-YOLO to combine more feature information while saving computational complexity, thereby enhancing the network's information extraction capability; it combines the underlying position information with the high-level semantic information, further improving the network's performance in target detection tasks.

[0071] In the embodiment, the upsampling in the BiFPN network is replaced by the CARAFE upsampler to improve the receptive field of the algorithm and the resolution of the feature map and directly merge the features in the feature extraction network with the features of relative size in the bottom-up path. The structure diagram of the CARAFE upsampler is shown in FIG. Figure 7 shown.

[0072] In an embodiment, the CARAFE upsampler can utilize the underlying content information at each position to predict the reassembled kernel and reassemble features within a predefined neighborhood; compared with traditional methods, the CARAFE upsampler can achieve significant progress with only a small amount of additional parameters and computational work; because the CARAFE upsampler can flexibly adjust and optimize the reassembled kernel according to the content information at different positions, it outperforms mainstream upsampling operators such as interpolation or deconvolution in performance.

[0073] In the embodiment, represents the intermediate feature information of the top-down transmission path of the i-th layer, represents the output characteristic information of the bottom-up transmission path of the i-th layer, then the calculation formula is as follows:

[0074]

[0075]

[0076] in, Represents the input sample feature information of the i-th layer node, Conv represents the convolution operation, resize represents upsampling or downsampling operation, ω1 represents the weight of the input node of the first layer, ω2 represents the weight of the input node of the second layer, ω1' represents the weight of the output node of the first layer, ω'2 represents the weight of the output node of the second layer, ω3' represents the weight of the output node of the third layer, and ε is generally set to 0.0001 to avoid numerical instability;

[0077] The calculation formula for the final output value O is as follows:

[0078]

[0079] Among them, I i represents the input value of the node, j represents the sum of all input nodes, ω i Represents the weight of the input node. In order to satisfy the weight ω of each input node i ≥0 is established, and the RELU activation function is used for each ω i Perform calculation operations.

[0080] Step S3, based on the preprocessed data set, train the SDD-YOLO target detection model, the framework diagram of which is as follows Figure 8 shown.

[0081] In the embodiment, the training parameters of the SDD-YOLO target detection model are as follows: the batch size is 8, the initial learning rate is set to 0.01, the final learning rate is 0.0001, the momentum parameter is set to 0.941, the weight decay is 0.0005, the input image is uniformly converted to a size of 640x640, and a stochastic gradient descent optimizer is used. The specific training parameter settings are shown in Table 1.

[0082]

[0083] Table 1

[0084] This study comprehensively evaluates the network proposed in this study by using indicators such as accuracy (AP), mean average accuracy (mAP), precision (Preci s ion), recall (Reca ll), floating point operations (FLOPs), number of parameters (Params) and frames per second (FPS). In the task of strip surface defect detection, this study uses the intersection over union (IOU) to determine whether the detection result is a real defect. If the value exceeds the set threshold, it is considered a positive sample; otherwise, it is a negative sample. In the target detection task, accuracy and recall are important indicators for evaluating the recognition effect of the network.

[0085] Precision (P) refers to the ratio of the number of correctly classified positive samples to the number of samples determined as positive samples by the classifier.

[0086]

[0087] Recall (Recall, denoted as R) refers to the ratio of the number of correctly classified positive samples to the number of true positive samples.

[0088]

[0089] Among them, TP refers to the number of samples correctly predicted by the model as positive examples, FP refers to the number of samples incorrectly predicted by the model as positive examples, and FN refers to the number of samples incorrectly predicted by the model as negative examples.

[0090] but

[0091]

[0092]

[0093] Among them, mAP is the area approximately enclosed by the Precision-Recall curve.

[0094] FLOPs is usually used to measure the complexity of a model. The smaller the value, the faster the model runs. The corresponding formula is as follows:

[0095] FLOPs(Conv)=(2×C in ×K 2 -1)×W out ×H out ×C out .

[0096] FLOPs(Conv)=(2×C in -1)×C out .

[0097] Among them, C in and C out Represents input channel and output channel respectively, K, H out and W out They are respectively represented as the convolution kernel size, the height and width of the output feature map.

[0098] The present invention uses the NEU-DET dataset to verify the SDD-YOLO model. The experimental results are shown in Table 2. The proposed SDD-YOLO model improves accuracy, recall, mAP50 and mAP50:95 by 4.93%, 3.28%, 6.3% and 4.3% respectively, while reducing the number of parameters by 51.4%.

[0099]

[0100] Table 2

[0101] The comparison of the detection effects of baseline YOLOv5s and SDD-YOLOv5 on 6 surface defect categories is shown in the figure below. Fig. 9 It is clearly found that the SDD-YOLO proposed in this study can not only process steel strip surface defect images of various types and conditions, but also has a significantly better detection effect than YOLOv5s.

[0102] In order to verify the performance of the SDD-YOLO method proposed in this study for strip surface defect detection, the present invention compares it with classic models, including YOLOv3, YOLOv5s, YOLOv7-tiny and YOLOv8s networks; in addition, this study also replaces the default backbone network of YOLOv5s with lightweight backbone networks ShuffleNetv2, MobileNetv3 and GhostNet. Table 3 and Fig.10 The comprehensive performance of each method on the NEU-DET dataset is shown.

[0103]

[0104]

[0105] Table 3

[0106] Figure 4 This further highlights the comprehensive performance of the SDD-YOLO model proposed in this paper. While maintaining low parameter count and light weight, it achieves the highest average precision (mAP), highlighting the superior performance of the SDD-YOLO model in the task of strip surface defect detection compared to the other eight models.

[0107] In order to verify the performance of the SDD-YOLO method proposed in this study in detecting different defect types, the present invention compares it with multiple other models; Table 4 and Fig.11 The AP comparison of the proposed SDD-YOLO method and other classic methods is shown.

[0108]

[0109] Table 4

[0110] As can be seen from Table 4, the SDD-YOLO model's ability to detect defects in each category is better than all classic algorithms, which proves that the CGH module and MCFF proposed in this paper can effectively and comprehensively improve the model's ability in strip surface defect detection tasks.

[0111] Fig.11 The performance comparison of SDD-YOLO and classic object detection methods is shown. By visualizing the centroid of the AP values ​​of the 9 models, it is obvious that the SDD-YOLO method is far ahead of other methods in comprehensive detection performance. In addition, the AP value of each category highlights the ability of the proposed method in detecting specific surface defect categories, especially in the Cr and Rs categories, the SDD-YOLO method is ahead of all other classic methods.

[0112] Step S4, finally use the trained, tested and verified SDD-YOLO target detection model to detect the video or picture, and output the detected video or picture.

[0113] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that the technical solutions described in the above embodiments may still be modified, or some or all of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A lightweight real-time strip surface defect detection method based on an improved YOLOv5s model, characterized in that: include: Step S1, obtaining the NEU-DET dataset and preprocessing it; Step S2, optimizing the network structure based on the existing YOLOv5s algorithm, and obtaining the SDD-YOLO target detection model after optimization; Step S3, training the SDD-YOLO target detection model based on the preprocessed data set; Step S4, using the SDD-YOLO target detection model to detect the video or picture, and output the detected video or picture; In step S2, the YOLOv5s algorithm includes: an Input module, a BackBone module, a Neck module and a Head module. The Input module includes: input image data enhancement and splicing, setting three initialization anchors and adaptively scaling the image size; BackBone module includes: CBS module, C3 module and SPPF module. CBS module consists of Conv, BatchNorm and SiLU, which is used to extract local spatial information in the image and give it nonlinear transformation; C3 module consists of three standard convolutional layers and a bottleneck layer, which is used to improve the computational efficiency of the algorithm. Each C3 module is connected by Concat operation; SPPF module is used to extract feature maps of different sizes from the input image; The Neck module, which consists of FPN and PAN, is used to skillfully integrate the extracted semantic features with the position features. At the same time, it organically integrates the backbone network layer with the detection layer to enhance the features extracted by different network layers. The Head module is used to predict objects of different sizes on the feature map. The Head module of the YOLOv5s algorithm uses three detection heads to detect the target objects and predict their categories and positions. The three detection heads correspond to feature maps of 20x20, 40x40, and 80x80, and accurately output objects of different sizes. In step S2, optimizing the network structure of the existing YOLOv5s algorithm includes: In the BackBone module, a CGH module is added based on the C3 module, and the standard convolutional layer and bottleneck layer in the C3 module are replaced with GhostConv, and the Concat operation is replaced by the residual connection; Then, the formula for calculating the residual connection is as follows: Output=F(Input,{W i })+Input; The input and output of the first layer are defined as Input and Output respectively, and the nonlinear change is defined as F(Input,{W i }), including nonlinear activation functions, W i is the residual connection; In the BackBone module, the SPPF module is replaced by a multi-convolution feature fusion block, namely MCFF, M in Represents the input of the multi-convolution feature fusion block, through M in ∈R C×H×W The 3×3, 5×5 and 7×7 convolution kernels are used to extract M1, M2 and M3. The block uses global average pooling to extract features from M2 and M3 of different resolutions respectively, and uses one-dimensional convolution for adaptive feature extraction. After Sigmoid transformation, the channel attention S2∈R 1×1×C and S3∈R 1×1×C , and use the function CBR to fuse M1, S2 and S3 to obtain the final output feature M out ∈R C×H×W , M1, M2 and M3 are the inputs of the multi-convolution feature fusion blocks extracted from 3×3, 5×5 and 7×7 convolution kernels, R is the number of convolution kernels, C is the number of channels, H is the height of the convolution kernel, and W is the width of the convolution kernel. The process is as follows: Among them, CBR represents the combination of three layers: the same mode 3×3 convolution layer, BatchNorm layer and nonlinear activation function ReLU, represents element-by-element multiplication, σ represents the ReLU layer, Conv 3×3 It is a 3×3 convolutional layer of the same mode, which is used to fuse feature maps of different resolutions and channel attention. BatchNorm is a normalization method used to solve the problem of inconsistent input data distribution; The FPN in the Neck module is replaced with a BiFPN network, which is built on the PAN. The upsampling in the BiFPN network is replaced by the CARAFE upsampler to improve the algorithm's receptive field and the resolution of the feature map and directly fuse the features in the feature extraction network with the features of relative size in the bottom-up path.

2. The lightweight real-time strip steel surface defect detection method based on the improved YOLOv5s model according to claim 1 is characterized in that: In step S1, the NEU-DET data set includes six defect types: cracks, inclusions, patches, uneven surfaces, curled oxides, and scratches; Each defect type contains 300 images with a resolution of 200 × 200 pixels, and a total of 1800 grayscale images; The 1800 grayscale images are divided into the NEU-DET dataset into training set, validation set and test set according to the ratio of 80%, 10% and 10%.

3. The lightweight real-time strip steel surface defect detection method based on the improved YOLOv5s model according to claim 1 is characterized in that: In the step S1, the preprocessing includes performing data enhancement and normalization processing on the data set, wherein the data enhancement method includes increasing brightness, reducing brightness and adding Gaussian noise.

4. The lightweight real-time strip steel surface defect detection method based on the improved YOLOv5s model according to claim 1 is characterized in that: In step S2, P i td represents the intermediate feature information of the top-down transmission path of the i-th layer, P i out represents the output characteristic information of the bottom-up transmission path of the i-th layer, then the calculation formula is as follows: Among them, P i in Represents the input sample feature information of the i-th layer node, Conv represents the convolution operation, resize represents upsampling or downsampling operation, ω1 represents the weight of the input node of the first layer, ω2 represents the weight of the input node of the second layer, ω′1 represents the weight of the output node of the first layer, ω′2 represents the weight of the output node of the second layer, ω′3 represents the weight of the output node of the third layer, and ε is set to 0.0001 to avoid numerical instability; The calculation formula for the final output value O is as follows: Among them, I i represents the input value of the node, j represents the sum of all input nodes, ω i Represents the weight of the input node. In order to satisfy the weight ω of each input node i ≥0 is established, and the RELU activation function is used for each ω i Perform calculation operations.

5. The lightweight real-time strip steel surface defect detection method based on the improved YOLOv5s model according to claim 1 is characterized in that: In step S3, the training parameters of the SDD-YOLO target detection model are as follows: the batch size is 8, the initial learning rate is set to 0.01, the final learning rate is 0.0001, the momentum parameter is set to 0.941, the weight decay is 0.0005, the input image is uniformly converted to a size of 640x640, and a stochastic gradient descent optimizer is used.