Steel strip surface defect detection method and device, electronic equipment and storage medium
By improving the YOLO model, combining C2F, SPPF_Res and SE modules, as well as multi-layer feature fusion modules, the problem of low efficiency and accuracy of steel strip surface defect detection is solved, efficient and automated defect identification and classification is achieved, and product quality is improved .
Patent Information
- Application Number
- CN202411273599.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-11
- Publication Date
- 2024-12-17
AI Technical Summary
The existing steel strip surface defect detection methods are inefficient and accurate, have strong subjective manual inspection, high equipment cost, and are greatly affected by the environment and material characteristics.
The improved YOLO model is adopted, and the C3 module is replaced with the C2F module and the SPPF module is SPPF_Res module, and the SE module is added afterwards. A multi-layer feature fusion module is added to the Neck network for steel strip surface defect detection.
It improves the efficiency and accuracy of steel strip surface defect detection, can automatically detect, monitor in real time, reduce labor and equipment costs, adapt to diverse defects, identify complex and micro defects, and improve product quality.
Smart Images

Figure CN119151894A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method, device, electronic equipment and storage medium for detecting surface defects of a steel strip. Background Art
[0002] With the continuous development of science and technology and the continuous improvement of productivity, my country has made great progress in industrial intelligence, industrial digitalization and related fields. Hot-rolled steel strip is an important steel strip product produced by hot rolling process, which is widely used in construction, machinery, automobile and other industries. The production process of hot-rolled steel strip is complex and has extremely high requirements on the surface and internal quality of the product. If defects occur in the production process, it will seriously affect the mechanical properties and processing properties of the hot-rolled steel strip, reduce product quality and increase safety hazards. Therefore, it is of great significance to detect defects on the surface of steel strip.
[0003] The current methods for detecting surface defects of steel strips mainly include manual detection, eddy current detection, magnetic flux leakage detection, and infrared detection. However, manual detection is highly subjective, inefficient, prone to fatigue, has a high rate of missed detection, and poses safety risks; eddy current detection is limited by detection depth, material properties, complex shapes, and complexity of result analysis; magnetic flux leakage detection is only applicable to ferromagnetic materials, and its sensitivity is affected by magnetic permeability, requires good surface conditions, and is susceptible to interference; infrared detection is mainly aimed at surface defects, is greatly affected by the environment, has obvious differences in effects on different materials, and has high equipment costs. Therefore, the current methods for detecting surface defects of steel strips have the problems of low efficiency and low accuracy. Summary of the invention
[0004] In view of the above problems, the embodiments of the present application propose a steel strip surface defect detection method, device, electronic device and storage medium to improve the efficiency and accuracy of steel strip surface defect detection.
[0005] According to one aspect of an embodiment of the present application, a method for detecting surface defects of a steel strip is provided, the method comprising:
[0006] Acquire the surface image of the steel strip to be inspected;
[0007] Inputting the surface image of the steel strip to be detected into a pre-generated steel strip surface defect detection model to obtain steel strip surface defect information output by the steel strip surface defect detection model, wherein the steel strip surface defect information includes defect location and defect type;
[0008] Among them, the steel strip surface defect detection model is obtained by making at least one of the following improvements to the one-view YOLO model: replacing the cross-scale connected composite convolution C3 module with a channel-to-feature conversion C2F module, replacing the fast spatial pyramid pooling SPPF module with a fast spatial pyramid pooling SPPF_Res module with fused residual connection, adding a compression and excitation SE module after the SPPF_Res module, and adding a multi-layer feature fusion module to the neck network.
[0009] According to another aspect of an embodiment of the present application, a device for detecting surface defects of a steel strip is provided, the device comprising:
[0010] An acquisition module, used for acquiring the surface image of the steel strip to be inspected;
[0011] A detection module, used for inputting the surface image of the steel strip to be detected into a pre-generated steel strip surface defect detection model to obtain the steel strip surface defect information output by the steel strip surface defect detection model, wherein the steel strip surface defect information includes the defect position and defect type;
[0012] Among them, the steel strip surface defect detection model is obtained by making at least one of the following improvements to the one-view YOLO model: replacing the cross-scale connected composite convolution C3 module with a channel-to-feature conversion C2F module, replacing the fast spatial pyramid pooling SPPF module with a fast spatial pyramid pooling SPPF_Res module with fused residual connection, adding a compression and excitation SE module after the SPPF_Res module, and adding a multi-layer feature fusion module to the neck network.
[0013] According to another aspect of an embodiment of the present application, an electronic device is provided, comprising a processor and a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium; when the computer program is executed by the processor, the processor executes the steel strip surface defect detection method as described in any one of the above items.
[0014] According to another aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the processor executes the steel strip surface defect detection method as described in any one of the above items.
[0015] In an embodiment of the present application, a steel strip surface defect detection model is used to perform steel strip surface defect detection. The steel strip surface defect detection model is obtained by performing at least one of the following improvements on the YOLO (You Only Look Once) model: replacing the C3 (cross-scale connected composite convolution) module with a C2F (Channel to Feature) module, replacing the SPPF (Spatial Pyramid Pooling Fast) module with an SPPF_Res (Spatial Pyramid Pooling Fast with Residual Connections) module, adding a SE (Squeeze and Excitation) module after the SPPF_Res module, and adding a multi-layer feature fusion module to the Neck network.
[0016] Among them, the C2F module can integrate information from different scales through efficient feature channel processing, and improve the detection accuracy and robustness of the model in complex scenes through multi-scale feature fusion, making the model more efficient; the SPPF_Res module makes the back propagation process more efficient by enhancing the feature extraction ability of the network, and can better capture and express the complex features of the steel strip surface; the SE module significantly improves the distinguishability of features by enhancing the model's learning and expression ability of effective features; the multi-layer feature fusion module can effectively integrate features at different levels and enhance the richness and expression ability of feature representation. Therefore, the efficiency and accuracy of steel strip surface defect detection can be improved by using the steel strip surface defect detection model to detect steel strip surface defects. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solution of the embodiment of the present application, the drawings required for use in the description of the embodiment of the present application will be briefly introduced below. Obviously, the drawings described below are only some drawings of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 is a flow chart of a method for detecting surface defects of a steel strip according to an embodiment of the present application;
[0019] Figure 2 is a schematic diagram of a steel strip surface defect detection model generation process according to an embodiment of the present application;
[0020] Figure 3 is a flow chart of a method for generating a steel strip surface defect detection model according to an embodiment of the present application;
[0021] Figure 4 It is a structural schematic diagram of a steel strip surface defect detection model according to an embodiment of the present application;
[0022] Figure 5 is a schematic diagram of the structure of a C2F module in an embodiment of the present application;
[0023] Figure 6 It is a structural diagram of an SPPF_Res module in an embodiment of the present application;
[0024] Figure 7 It is a structural schematic diagram of a multi-layer feature fusion module in an embodiment of the present application;
[0025] Figure 8 It is a schematic diagram of the architecture of a visual interface of an embodiment of the present application;
[0026] Fig. 9 It is a schematic diagram of a PC terminal interface operation result of an embodiment of the present application;
[0027] Fig.10 It is a structural block diagram of a steel strip surface defect detection device according to an embodiment of the present application;
[0028] Fig.11 is a structural block diagram of an electronic device according to an embodiment of the present application;
[0029] Fig.12 It is a structural block diagram of a computer-readable storage medium in an embodiment of the present application. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0031] In the embodiment of the present application, the steel strip surface defect detection model is used to detect the surface defects of the steel strip, thereby improving the detection accuracy, automating the detection process, realizing real-time detection, reducing costs, adapting to diverse defects, and improving production quality. By learning a large amount of sample data, the steel strip surface defect detection model can accurately identify and classify complex defect characteristics, improve the accuracy and reliability of detection, reduce dependence on manual detection, realize real-time monitoring and feedback on the production line, and promptly discover and deal with problems. It reduces labor and equipment costs, expands the detection range, and can identify various complex and minor defects, thereby improving the quality of steel products, reducing rework and scrap rates, and promoting automation and intelligence in production.
[0032] The steel strip in the embodiment of the present application may be a steel strip obtained by any applicable process, such as a hot-rolled steel strip, etc., and this embodiment does not impose any limitation on this.
[0033] Reference Figure 1 , shows a flow chart of a method for detecting surface defects of a steel strip according to an embodiment of the present application.
[0034] like Figure 1 As shown, the method for detecting surface defects of a steel strip may include the following steps:
[0035] Step 101, obtaining a surface image of a steel strip to be inspected.
[0036] Step 102: input the surface image of the steel strip to be detected into a pre-generated steel strip surface defect detection model to obtain steel strip surface defect information output by the steel strip surface defect detection model.
[0037] The following is a detailed introduction.
[0038] Firstly, a steel strip surface defect detection model is generated.
[0039] Reference Figure 2 , which shows a schematic diagram of a steel strip surface defect detection model generation process according to an embodiment of the present application. Figure 2 As shown in the figure, in the process of generating the steel strip surface defect detection model, the data set is first loaded, then the model is trained, then the model performance is evaluated and optimized, and finally the steel strip surface defect detection model is output.
[0040] Reference Figure 3 , shows a flow chart of a method for generating a steel strip surface defect detection model according to an embodiment of the present application.
[0041] like Figure 3 As shown, the method for generating a steel strip surface defect detection model may include the following steps:
[0042] Step 301, preprocessing and data enhancement operations are performed on the initial data set to obtain a target data set.
[0043] First, collect the initial dataset.
[0044] The initial data set includes a large number of initial steel strip surface images and actual steel strip surface defect information corresponding to the initial steel strip surface images. The actual steel strip surface defect information can be obtained by manual marking or tool marking.
[0045] The actual steel strip surface defect information may include an actual defect position and an actual defect type. The actual defect position may include but is not limited to: the center point position, width, height, etc. of the actual boundary box. The actual defect type may include but is not limited to at least one of the following: crazing, inclusion, patches, pitted-surface, rolled-inscale, scratches, etc.
[0046] The initial data set is divided according to the set ratio to obtain an initial training set, an initial validation set and an initial test set. The specific value of the set ratio can be set according to actual experience and requirements, and this embodiment does not limit this.
[0047] For example, a total of 1,800 steel strip surface images (resolution can be 200×200 pixels, etc.) can be collected as the initial steel strip surface images, and the LabelImg tool (LabelImg is a Python-based graphical interface image annotation tool) can be used to annotate the defect locations and defect types in the initial steel strip surface images. The initial data set is divided into 1,260 initial training sets, 270 initial validation sets, and 270 initial test sets. It should be noted that this is only an example and is not intended to limit the embodiments of the present application.
[0048] Then, the initial dataset is preprocessed and data augmented to obtain the target dataset.
[0049] Preprocess the initial training set, initial validation set, and initial test set in the initial dataset.
[0050] The raw data can be cleaned and enhanced through preprocessing operations to improve the quality and efficiency of the training model. Exemplarily, the preprocessing operations may include, but are not limited to: data cleaning, image cropping, color correction, data enhancement, random image flipping, slicing, brightness transformation, etc.
[0051] For example, the initial steel strip surface images in the initial data set are uniformly adjusted to a size of 640×640 pixels. The standardized processing helps to accelerate the training and testing of the model, facilitates the construction of batches, and improves the stability and consistency of training. At the same time, adaptive size adjustment is performed according to the original ratio of the initial steel strip surface image to ensure that the image content is not distorted. Secondly, the pixel value of the initial steel strip surface image is scaled to between 0 and 1 according to a certain ratio, which not only improves the stability of model training and prediction, but also improves the calculation speed.
[0052] Perform data augmentation operations on the initial training set in the initial data set to effectively expand the diversity of the training set, improve the generalization of the model, and improve the model's ability to identify different defects.
[0053] Exemplarily, a Mosaic data enhancement method may be used to perform data enhancement operations on the initial steel strip surface images in the initial training set.
[0054] The Mosaic data enhancement method mainly randomly fuses four images into one and adjusts the corresponding bounding box coordinates.
[0055] The main steps of Mosaic data enhancement can include:
[0056] (1) Randomly select four initial steel strip surface images img1, img2, img3, and img4 from the initial training set, and obtain the bounding boxes (bboxes) corresponding to img1, img2, img3, and img4 respectively.
[0057] (2) Calculate the height and width of the four initial steel strip surface images respectively. For example, the height and width of img1 are h1 and w1 respectively, the height and width of img2 are h2 and w2 respectively, the height and width of img3 are h3 and w3 respectively, and the height and width of img4 are h4 and w4 respectively.
[0058] (3) A background image (mosaic image) with a size equal to the preprocessed image size (such as 640x640 pixels as mentioned above) and pixel values all being 0 (black) is generated by random initialization.
[0059] (4) Randomly generate the center point coordinates (x, y) and scaling ratios (scales) of the mosaic image.
[0060] (5) Randomly scale and crop the four initial steel strip surface images img1, img2, img3, and img4 according to scales, x, and y.
[0061] (6) Concatenate the four randomly scaled and cropped images into a mosaic image.
[0062] (7) According to the parameters of the four images, adjust the coordinates of the bounding boxes (bboxes) in the mosaic image.
[0063] (8) Perform other common data enhancement operations, such as flipping, color change, etc.
[0064] (9) Return the mosaic image and the adjusted bounding boxes.
[0065] Corresponding to the initial training set, initial validation set and initial test set included in the initial data set, the target data set includes a target training set, a target validation set and a target test set. The target training set is obtained by preprocessing and data enhancement of the initial training set; the target validation set is obtained by preprocessing the initial validation set; and the target test set is obtained by preprocessing the initial test set.
[0066] The target training set, the target verification set and the target test set all include sample steel strip surface images and actual steel strip surface defect information corresponding to the sample steel strip surface images.
[0067] The sample steel strip surface images in the target training set are obtained by preprocessing and data enhancement of the initial steel strip surface images in the initial training set; the sample steel strip surface images in the target validation set are obtained by preprocessing the initial steel strip surface images in the initial validation set; the sample steel strip surface images in the target test set are obtained by preprocessing the initial steel strip surface images in the initial test set. The actual steel strip surface defect information corresponding to the sample steel strip surface images is the same as the actual steel strip surface defect information of the initial steel strip surface images corresponding to the sample steel strip surface images.
[0068] Step 302: Use the target training set to train the steel strip surface defect detection model to be trained, use the target verification set to verify the steel strip surface defect detection model to be trained, and use the target test set to test the steel strip surface defect detection model to be trained. After the training, verification and testing are completed, the steel strip surface defect detection model is obtained.
[0069] By defining the network structure of the steel strip surface defect detection model, selecting the loss function and optimizer to train the model, evaluating the final model, analyzing and optimizing the training process, discovering and solving problems that arise during training, and continuously improving the efficiency and quality of training.
[0070] The steel strip surface defect detection model to be trained refers to a steel strip surface defect detection model that has not been trained.
[0071] In the embodiment of the present application, the steel strip surface defect detection model is obtained by improving the YOLO model by at least one of the following: replacing the C3 module with the C2F module, replacing the SPPF module with the SPPF_Res module, adding the SE module after the SPPF_Res module, and adding a multi-layer feature fusion module to the Neck network. The following is an introduction taking all the above improvements as an example.
[0072] The YOLO model may specifically be a YOLOv5 model, a YOLOv5s model, etc., which is not limited in this embodiment.
[0073] Reference Figure 4 , shows a schematic structural diagram of a steel strip surface defect detection model according to an embodiment of the present application. Figure 4 As shown, the steel strip surface defect detection model is an improvement based on the YOLO model, including a backbone network (Backbone), a neck network (Neck) and a detection head (Head). The C3 module in the YOLO model is replaced by a C2F module, the SPPF module is replaced by an SPPF_Res module, the SE module is added to the back end of the backbone network (that is, the back end of the SPPF_Res module), and a multi-layer feature fusion module is added to the Neck part. For other modules in the steel strip surface defect detection model, they can be processed according to the reference YOLO model, and this embodiment will not be discussed in detail here.
[0074] Among them, the comprehensive extraction layer (Conv BN Si LU) can be composed of three parts: convolution (Convolution, Conv), batch normalization layer (Batch Normalization, BN) and SiLU (Sigmoid-weighted Linear Unit, Sigmoid weighted linear unit) activation function.
[0075] Exemplarily, the C2F module may include but is not limited to: a first convolutional layer, a splitting layer, a bottleneck layer, a first splicing layer, and a second convolutional layer, wherein the bottleneck layer includes at least one bottleneck module connected in series. The input of the C2F module is used as the input of the first convolutional layer, the output of the first convolutional layer is used as the input of the splitting layer, the output of the splitting layer is used as the input of the bottleneck layer, the output of the first convolutional layer and the output of the bottleneck layer are used as the input of the first splicing layer, the output of the splicing layer is used as the input of the second convolutional layer, and the input of the C2F module and the output of the second convolutional layer are multiplied as the output of the C2F module. The output of each bottleneck module in the bottleneck layer can be used as the input of the first splicing layer.
[0076] Reference Figure 5, shows a schematic structural diagram of a C2F module in an embodiment of the present application.
[0077] like Figure 5 As shown, the C2F module includes: a first convolutional layer (Conv), a splitting layer (Split), n (n is a positive integer) bottleneck modules (Bottleneck), a first concatenation layer (Concat) and a second convolutional layer (Conv), and the bottleneck layer includes at least one bottleneck module connected in series.
[0078] like Figure 5 As shown, the bottleneck module may include an adaptive average pooling layer (Adaptive AveragePooling), a first two-dimensional convolution layer (Conv2d), a first activation function (such as ReLU (Rectified Linear Unit, linear rectification) activation function), a second two-dimensional convolution layer (Conv2d), and a second activation function (such as Sigmoid activation function). The input of the bottleneck module is used as the input of the adaptive average pooling layer, the output of the adaptive average pooling layer is used as the input of the first two-dimensional convolution layer, the output of the first two-dimensional convolution layer is used as the input of the first activation function, the output of the first activation function is used as the input of the second two-dimensional convolution layer, the output of the second two-dimensional convolution layer is used as the input of the second activation function, and the input of the bottleneck module and the output of the second activation function are multiplied to obtain the output of the bottleneck module.
[0079] The C2F module is designed to enhance the multi-scale fusion capability while ensuring the lightweight of the model. Through efficient feature channel processing, the C2F module can integrate information from different scales without significantly increasing the computational burden. This feature is particularly important for surface defect detection of steel strips, because the defect features on the surface of steel strips may appear differently at different scales. The C2F module improves the detection accuracy and robustness of the model in complex scenarios through multi-scale feature fusion. For example, when detecting tiny cracks or surface irregularities, the C2F module can effectively capture the details of these features, thereby improving the accuracy of defect detection.
[0080] Exemplarily, the SPPF_Res module may include, but is not limited to: a third convolutional layer, a plurality of branch networks, and a second splicing layer, each of the branch networks comprising at least one maximum pooling layer connected in series, and different branch networks comprising different numbers of the maximum pooling layers. The input of the SPPF_Res module is used as the input of the third convolutional layer, the output of the third convolutional layer is used as the input of each of the branch networks, the output of the third convolutional layer and the output of each of the branch networks are used as the input of the second splicing layer, and the input of the SPPF_Res module and the output of the second splicing layer are added as the output of the SPPF_Res module.
[0081] Reference Figure 6 , shows a schematic diagram of the structure of an SPPF_Res module in an embodiment of the present application. Figure 6 As shown, the SPPF_Res module may include: a third convolutional layer (for example, a two-dimensional convolutional layer Conv2d), three branch networks and a second concatenation layer (Concat), the first branch network includes a maximum pooling layer (Maxpool), the second branch network includes two maximum pooling layers (Maxpool) connected in series, and the third branch network includes three maximum pooling layers (Maxpool) connected in series.
[0082] The SPPF_Res module makes the back propagation process more efficient by enhancing the network's feature extraction capabilities and simplifying the network structure. SPPF_Res introduces the SPP (Spatial Pyramid Pooling) layer, which can effectively capture features of different scales. At the same time, combined with residual connections, it alleviates the gradient vanishing problem, thereby improving training speed and stability. The application of this module enables the network to better capture and express the complex surface features of steel strips, especially when dealing with defects with complex morphology. The SPPF_Res module not only improves the accuracy of feature extraction, but also enhances the generalization ability of the model, making its performance more stable and reliable in different environments and conditions.
[0083] Exemplarily, the SE module includes a global average pooling layer, a first fully connected layer, a first activation function, a second fully connected layer, a second activation function and a channel recalibration layer. The input of the SE module is used as the input of the global average pooling layer, the output of the global average pooling layer is used as the input of the first fully connected layer, the output of the first fully connected layer is used as the input of the first activation function, the output of the first activation function is used as the input of the second fully connected layer, the output of the second fully connected layer is used as the input of the second activation function, the input of the SE module and the output of the second activation function are used as the input of the channel recalibration layer, and the output of the channel recalibration layer is used as the output of the SE module.
[0084] The first activation function may be a ReLU activation function, and the second activation function may be a Sigmoid activation function.
[0085] The SE module obtains attention features through a global average pooling layer, a fully connected layer and activation function, and a channel recalibration layer.
[0086] The formula corresponding to the global average pooling layer is shown in the following formula (1):
[0087]
[0088] Among them, Z c represents the global feature descriptor of the cth channel, H represents the height of the input feature map, W represents the width of the input feature map, X i ,j, c Represents the value of the input feature map at position (i, j, c), where c represents the cth channel.
[0089] The formula corresponding to the fully connected layer and the activation function is shown in the following formula (2):
[0090] S c =σ(W2·ReLU(W1·Z c +b1)+b2) (2)
[0091] Among them, S c represents the weight of the cth channel, W1 represents the weight matrix of the first fully connected layer, W2 represents the weight matrix of the second fully connected layer, b1 represents the bias term of the first fully connected layer, b2 represents the bias term of the second fully connected layer, ReLU represents the operation of the first activation function, and σ represents the operation of the second activation function. The meanings of other parameters refer to the above formula (1).
[0092] The formula corresponding to the channel recalibration layer is shown in the following formula (3):
[0093] Y i,j,c =X i,j,c ·Sc (3)
[0094] Among them, Y i,j,c Output the value of the feature map at position (i, j, c). The meanings of other parameters refer to the above formulas (1) and (2).
[0095] The SE module significantly improves the distinguishability of features by enhancing the model's ability to learn and express effective features. The module adaptively adjusts the weights of each channel, allowing the network to pay more attention to key features and suppress the influence of unimportant features. This feature recalibration mechanism is particularly critical when processing steel strip surface images. It helps the model accurately identify and distinguish various defects and enhances the model's detection capabilities in complex scenarios. The introduction of the SE module not only improves the recognition accuracy of the model, but also enhances the model's ability to capture subtle features, especially when detecting tiny cracks or irregularities on the surface.
[0096] The multi-layer feature fusion module is used to fuse features of multiple levels in the Neck network.
[0097] Reference Figure 7 , shows a schematic diagram of the structure of a multi-layer feature fusion module in an embodiment of the present application. Figure 7 As shown, the multi-layer feature fusion module can concatenate and fuse m (m is a positive integer) features from feature 1 to feature m through a concatenation layer (Concat).
[0098] The formula corresponding to the multi-layer feature fusion module is shown in the following formula (4):
[0099] Z=Concat(F1,F2,…,F m ) (4)
[0100] Among them, Z represents the features after splicing and fusion through the multi-layer feature fusion module, Concat represents the splicing operation, F1, F2, ..., F m Represents m features.
[0101] For example, the input side (i.e. Figure 4 The output of the splicing layer of the input side of the Neck network and the output of the comprehensive extraction layer of the input side of the Neck network are used as the input of the multi-layer feature fusion module, and the output of the multi-layer feature fusion module is used as the output side of the Neck network (i.e. Figure 4 The input of the concatenation layer on the output side of the Neck network.
[0102] Exemplarily, the multi-layer feature fusion module includes a first comprehensive extraction layer, a third splicing layer and a C3 module. The output of the splicing layer on the input side of the Neck network is used as the input of the first comprehensive extraction layer, the output of the first comprehensive extraction layer and the output of the comprehensive extraction layer on the input side of the Neck network are used as the input of the third splicing layer, the output of the third splicing layer is used as the input of the C3 module, and the output of the C3 module is used as the input of the splicing layer on the output side of the Neck network.
[0103] The multi-layer feature fusion module plays a key role in the model. By further fusing features, making full use of the features of each level extracted by the Neck network, and splicing and fusing with the previous convolution, this structure can effectively integrate features at different levels and enhance the richness and expressiveness of feature representation. When dealing with complex surface defects of steel strips, the multi-layer feature fusion module can improve the model's ability to capture subtle differences and further improve detection accuracy. This structure not only enhances the overall performance of the model, but also improves the stability and reliability of the model in practical applications. Through the effective fusion of multi-layer features, the model can better adapt to different defect detection tasks and provide more accurate and reliable detection results.
[0104] The target training set is used to train the model, that is, to let the model learn how to predict the output (target) based on the input data (features). During the training process, the model will continuously adjust its internal parameters (such as weights and biases) to minimize the difference between the predicted output and the actual output (i.e., the loss function). Through the target training set, the model can learn the inherent laws and characteristics of the data, so that it has the ability to predict new data.
[0105] Exemplarily, the process of training the steel strip surface defect detection model to be trained using the target training set may include: taking the sample steel strip surface image as the input of the steel strip surface defect detection model to be trained, and obtaining the output of the steel strip surface defect detection model to be trained, wherein the output is the predicted steel strip surface defect information corresponding to the sample steel strip surface image; calculating the classification loss function, the positioning loss function and the confidence loss function based on the actual steel strip surface defect information and the predicted steel strip surface defect information, and calculating the comprehensive loss function based on the classification loss function, the positioning loss function and the confidence loss function; and determining that the training is completed when the comprehensive loss function meets the preset conditions.
[0106] The predicted steel strip surface defect information includes a predicted defect position and a predicted defect type. The predicted defect position may include but is not limited to: a center point position, width, height, etc. of a predicted boundary box.
[0107] The calculation formula of the confidence loss function can be shown as follows:
[0108]
[0109] Among them, L1 represents the confidence loss function, o i ∈[0,1] represents the intersection-over-union ratio of the predicted bounding box and the actual bounding box of the i-th sample steel strip surface image, is the prediction confidence of the predicted bounding box of the i-th sample steel strip surface image obtained by an activation function (such as sigmoid), N is the number of sample steel strip surface images in the target training set, i represents the index of the sample steel strip surface image, and the value of i ranges from 1 to N.
[0110] The calculation formula of the classification loss function can be shown as follows:
[0111]
[0112] Among them, L2 represents the confidence loss function, O ij ∈[0,1] indicates whether there is the jth defect type in the predicted bounding box of the i-th sample steel strip surface image. N represents the probability of the jth defect type existing in the predicted bounding box of the i-th sample steel strip surface image obtained by the activation function (such as sigmoid), pos represents the number of positive samples in the target training set, i represents the index of the sample steel strip surface image, j represents the index of the defect type, and the value of j ranges from 1 to the total number of defect types.
[0113] The calculation formula of the positioning loss function can be shown as follows:
[0114]
[0115] Where L3 represents the positioning loss function, IoU represents the intersection-over-union ratio between the predicted bounding box and the actual bounding box of the sample steel strip surface image, d is the distance between the center points of the predicted bounding box and the actual bounding box, c is the diagonal length of the minimum circumscribed rectangle that can enclose the predicted bounding box and the actual bounding box, and w is the distance between the predicted bounding box and the actual bounding box. gt Indicates the width of the actual bounding box, h gt represents the height of the actual bounding box, w represents the width of the predicted bounding box, h represents the height of the predicted bounding box, and α and v represent the parameters used for intermediate conversion.
[0116] The calculation formula of the comprehensive loss function can be shown as follows:
[0117] L=λ1L1+λ2L2+λ3L3 (10)
[0118] Among them, L represents the comprehensive loss function, λ1 represents the weight of the confidence loss function, λ2 represents the weight of the classification loss function, and λ3 represents the weight of the positioning loss function.
[0119] The above-mentioned preset conditions can be set according to actual needs, and this embodiment does not limit this. For example, the preset condition can be that the comprehensive loss function is less than a preset threshold, or the comprehensive loss function converges, and so on.
[0120] The target validation set is used to adjust the model's hyperparameters (such as learning rate, number of network layers, number of hidden layer nodes, etc.) during model training. It can help us understand the performance of the model under different hyperparameter settings, so as to select the optimal hyperparameter combination. In addition, the target validation set can also be used for model selection, that is, to compare the pros and cons of different model architectures. The existence of the target validation set can prevent the model from overfitting on the training set, while ensuring that the selected model has good generalization ability. It is a bridge connecting the training set and the test set, and is used to guide the optimization of the model during the training process.
[0121] The target test set is used to evaluate the performance of the final trained model. After the model training is completed, the target test set is also used to test the model's prediction ability to obtain the model's performance on unknown data. The target test set can help understand the performance of the model in actual applications and find possible problems. Through the target test set, it can be determined whether the model has truly learned useful knowledge, rather than just memorizing the data of the target training set.
[0122] In the embodiment of the present application, an optimizer such as Adam can be used to update and optimize network parameters. The Adam optimizer can automatically adjust the learning rate, converge quickly and find a relatively optimal solution.
[0123] In the embodiment of the present application, after the training is completed, the model with the best effect in the training is stored as the steel strip surface defect detection model for subsequent steel strip surface defect detection.
[0124] For example, the storage instruction can be used to store the model with the best training effect during training and output the size. For example, the torch.hub instruction is used to load the trained steel strip surface defect detection model, automatically adapt the computer's GPU (Graphics Processing Unit), and print out the GPU model.
[0125] For example, in the test, the target test set was tested three times using different improved models, and the test results were compared with the basic YOLOv5s model to select the optimal model as the steel strip surface defect detection model.
[0126] The model test results are shown in Table 1 below:
[0127] Table 1
[0128] Model map@0.5 YOLOv5s 0.740 New-YOLOv5s-1 0.775 New-YOLOv5s-2 0.778 New-YOLOv5s-3 0.783
[0129] Among them, New-YOLOv5s-1 is a model with the C2F module added; New-YOLOv5s-2 is a model with the SPPF_Res and SE modules added; New-YOLOv5s-3 is a model with the multi-layer feature fusion module added.
[0130] As can be seen from Table 1, New-YOLOv5s-3 achieved the highest score in the map@0.5 indicator, indicating that the model has the best balance and accuracy in detecting surface defects of steel strips, is suitable for complex environments that require high detection accuracy, and has excellent performance and stability in the task of detecting surface defects of steel strips. Among them, map@0.5 refers to the map value (mean average precision) when the IoU (Intersection over Union) threshold is set to 0.5.
[0131] The map@0.5 comparison results of the model and its corresponding 6 defect types are shown in the table:
[0132] Table 2
[0133]
[0134] As can be seen from Table 2, the models New-YOLOv5s-1, New-YOLOv5s-2, and New-YOLOv5s-3 have significantly improved compared to YOLOv5s in multiple defect categories, especially in detecting plaques, pitted surfaces, and scratches, showing higher accuracy. Performance optimization: With the improvement of the model, from New-YOLOv5s-1 to New-YOLOv5s-3, the detection accuracy gradually increases, especially in the detection of Pitted-surface and Scratches, which has a significant advantage. Among the six defect types, all new models show high accuracy in detecting plaques and scratches, especially New-YOLOv5s-2 and New-YOLOv5s-3, which shows that these models are more effective in dealing with surface defects.
[0135] Experimental results show that the method proposed in the embodiment of the present application achieves a higher defect recognition rate. Compared with the traditional method, it not only improves the recognition performance, but also eliminates the tedious parameter setting process, making it more convenient to use.
[0136] In the embodiment of the present application, a visualization interface may also be constructed, and the steel strip surface defect detection model may be loaded on the visualization interface.
[0137] Exemplarily, PyQt5 can be used to deploy the PC (Personal Computer) side, and Gradio can be used to deploy the Web (webpage) side.
[0138] The process of deploying a PC-side visualization interface using PyQt5 can include:
[0139] (1) Install PyQt5 and the environment required for network operation.
[0140] (2) Design interface layout: Use QTdesigner in PyQt5 to design the layout of the interface.
[0141] (3) Add interactive components: Use buttons, input boxes, labels, image views and other components in PyQt5 to achieve human-computer interaction and result display.
[0142] (4) Loading the network model inference code: Loading the steel strip surface defect detection model is used to input the surface image of the steel strip to be detected and obtain the prediction result.
[0143] (5) Connecting the interaction logic: Use the signal and slot mechanism in PyQt5 to connect various interface components to implement interaction logic and information transmission.
[0144] The process of deploying a web-based visualization interface using Gradio may include:
[0145] (1) Install gradio and the network environment required for operation.
[0146] (2) Loading network model inference code: Loading the network model is used to input images and obtain prediction results.
[0147] (3) Create a gradio app: Use gradio.Interface() to create a gradio app to receive input images and return output results. You can choose image input (upload_file) or camera capture (webcam_input).
[0148] (4) Connect the reasoning logic: Use model in the gradio app to connect the input steel strip surface image to be inspected to the steel strip surface defect detection model. The output result is returned as the app output.
[0149] (5) Start the service: Use gradio.serve_model() to start the gradio service
[0150] (6) Access the web page: Access the deployed web service through the service address, upload the input image or start the camera for target detection.
[0151] (7) Cloud access: When running the deployed code, a URL will be generated. Users can access this URL through any mobile device to perform steel defect target detection.
[0152] (8) Add progress bar option: Use gradio.Interface() to add a confidence threshold progress bar, allowing users to adjust the confidence threshold themselves.
[0153] (9) Add example items: Use gradio.Interface() and add examples to make it easier for users to use the deployment program.
[0154] Reference Figure 8 , shows a schematic diagram of the architecture of a visualization interface of an embodiment of the present application. Figure 8 As shown, the input image is processed by the PC side deployed by PyQt5 or the Web side deployed by Gradio to obtain the output result.
[0155] After the steel strip surface defect detection model is generated, the steel strip surface defect detection model is used to perform steel strip surface defect detection.
[0156] First, a surface image of a steel strip to be detected is obtained. Then, the surface image of the steel strip to be detected is input into a pre-generated steel strip surface defect detection model to obtain steel strip surface defect information output by the steel strip surface defect detection model.
[0157] The surface defect information of the steel strip includes defect location and defect type. The defect location may include but is not limited to: the center point location, width, height, etc. of the boundary box. The defect type may include but is not limited to at least one of the following: crazing, inclusion, patches, pitted-surface, rolled-inscale, scratches, etc.
[0158] In the embodiment of the present application, the surface image of the steel strip to be detected may also be preprocessed, and the preprocessing process is the same as the preprocessing process of the initial steel strip surface image.
[0159] For example, use a steel strip surface image to be inspected, resize it to 640×640 pixels, and input it into the trained steel strip surface defect detection model for forward propagation. Finally, the steel strip surface defect detection model can output three scale feature matrices of 80*80*33, 40*40*33, 20*20*33, and 33 (3*11) because each grid cell generates three anchors (bounding boxes), each anchor (bounding box) corresponds to a prediction box, and each prediction box has 5 parameters, which are the center point position (x, y) of the prediction box, width w, height h, and confidence. Each grid cell will have 6 parameters, which are the confidence-based probabilities of 6 defect categories. The output prediction box is filtered by confidence and non-maximum suppression is performed to obtain the final output result.
[0160] Exemplarily, after constructing a visualization interface and loading the steel strip surface defect detection model on the visualization interface, the surface image of the steel strip to be detected can be input into the steel strip surface defect detection model through the visualization interface to obtain the steel strip surface defect information output by the steel strip surface defect detection model, and the steel strip surface defect information can be output through the visualization interface.
[0161] Reference Fig. 9 , which shows a schematic diagram of the PC terminal interface operation result of an embodiment of the present application. Fig. 9 As shown, after the prediction of the steel strip surface defect detection model, a plurality of defect type boundary boxes of patches can be output.
[0162] In the embodiment of the present application, the C2F module can integrate information from different scales through efficient feature channel processing, and improve the detection accuracy and robustness of the model in complex scenes through multi-scale feature fusion, making the model more efficient; the SPPF_Res module makes the back propagation process more efficient by enhancing the feature extraction ability of the network, and can better capture and express the complex features of the steel strip surface; the SE module significantly improves the distinguishability of features by enhancing the model's learning and expression ability of effective features; the multi-layer feature fusion module can effectively integrate features at different levels, and enhance the richness and expression ability of feature representation. Therefore, the efficiency and accuracy of steel strip surface defect detection can be improved by using the steel strip surface defect detection model to detect steel strip surface defects.
[0163] Reference Fig.10 , shows a structural block diagram of a steel strip surface defect detection device according to an embodiment of the present application.
[0164] like Fig.10As shown, the steel strip surface defect detection device may include the following modules:
[0165] An acquisition module 1001 is used to acquire a surface image of a steel strip to be inspected;
[0166] The detection module 1002 is used to input the surface image of the steel strip to be detected into a pre-generated steel strip surface defect detection model to obtain the steel strip surface defect information output by the steel strip surface defect detection model, wherein the steel strip surface defect information includes the defect position and defect type;
[0167] Among them, the steel strip surface defect detection model is obtained by making at least one of the following improvements to the one-view YOLO model: replacing the cross-scale connected composite convolution C3 module with a channel-to-feature conversion C2F module, replacing the fast spatial pyramid pooling SPPF module with a fast spatial pyramid pooling SPPF_Res module with fused residual connection, adding a compression and excitation SE module after the SPPF_Res module, and adding a multi-layer feature fusion module to the neck network.
[0168] Optionally, the C2F module includes: a first convolutional layer, a splitting layer, a bottleneck layer, a first splicing layer and a second convolutional layer, the bottleneck layer includes at least one bottleneck module connected in series; the input of the C2F module is used as the input of the first convolutional layer, the output of the first convolutional layer is used as the input of the splitting layer, the output of the splitting layer is used as the input of the bottleneck layer, the output of the first convolutional layer and the output of the bottleneck layer are used as the input of the first splicing layer, the output of the splicing layer is used as the input of the second convolutional layer, and the input of the C2F module and the output of the second convolutional layer are multiplied as the output of the C2F module.
[0169] Optionally, the SPPF_Res module includes a third convolutional layer, multiple branch networks and a second splicing layer, each of the branch networks contains at least one maximum pooling layer connected in series, and different branch networks contain different numbers of the maximum pooling layers; the input of the SPPF_Res module is used as the input of the third convolutional layer, the output of the third convolutional layer is used as the input of each branch network, the output of the third convolutional layer and the output of each branch network are used as the input of the second splicing layer, and the input of the SPPF_Res module and the output of the second splicing layer are added as the output of the SPPF_Res module.
[0170] Optionally, the SE module includes a global average pooling layer, a first fully connected layer, a first activation function, a second fully connected layer, a second activation function and a channel recalibration layer; the input of the SE module is used as the input of the global average pooling layer, the output of the global average pooling layer is used as the input of the first fully connected layer, the output of the first fully connected layer is used as the input of the first activation function, the output of the first activation function is used as the input of the second fully connected layer, the output of the second fully connected layer is used as the input of the second activation function, the input of the SE module and the output of the second activation function are used as the input of the channel recalibration layer, and the output of the channel recalibration layer is used as the output of the SE module.
[0171] Optionally, the multi-layer feature fusion module includes a first comprehensive extraction layer, a third splicing layer and a C3 module; the output of the splicing layer on the input side of the Neck network is used as the input of the first comprehensive extraction layer, the output of the first comprehensive extraction layer and the output of the comprehensive extraction layer on the input side of the Neck network are used as the input of the third splicing layer, the output of the third splicing layer is used as the input of the C3 module, and the output of the C3 module is used as the input of the splicing layer on the output side of the Neck network.
[0172] Optionally, the steel strip surface defect detection model is generated by the following modules:
[0173] A processing module is used to perform preprocessing and data enhancement operations on the initial data set to obtain a target data set; the target data set includes a target training set, a target verification set, and a target test set;
[0174] A generation module is used to train the steel strip surface defect detection model to be trained using the target training set, verify the steel strip surface defect detection model to be trained using the target verification set, and test the steel strip surface defect detection model to be trained using the target test set. After the training, verification and testing are completed, the steel strip surface defect detection model is obtained.
[0175] Optionally, the generation module includes: a training unit, used to take the sample steel strip surface image as the input of the steel strip surface defect detection model to be trained, and obtain the output of the steel strip surface defect detection model to be trained, wherein the output is the predicted steel strip surface defect information corresponding to the sample steel strip surface image; calculate a classification loss function, a positioning loss function and a confidence loss function based on the actual steel strip surface defect information and the predicted steel strip surface defect information, and calculate a comprehensive loss function based on the classification loss function, the positioning loss function and the confidence loss function; when the comprehensive loss function meets a preset condition, determine that the training is completed.
[0176] Optionally, the device further comprises: a construction module, configured to construct a visualization interface and load the steel strip surface defect detection model on the visualization interface.
[0177] In the embodiment of the present application, the C2F module can integrate information from different scales through efficient feature channel processing, and improve the detection accuracy and robustness of the model in complex scenes through multi-scale feature fusion, making the model more efficient; the SPPF_Res module makes the back propagation process more efficient by enhancing the feature extraction ability of the network, and can better capture and express the complex features of the steel strip surface; the SE module significantly improves the distinguishability of features by enhancing the model's learning and expression ability of effective features; the multi-layer feature fusion module can effectively integrate features at different levels, and enhance the richness and expression ability of feature representation. Therefore, the efficiency and accuracy of steel strip surface defect detection can be improved by using the steel strip surface defect detection model to detect steel strip surface defects.
[0178] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0179] In an embodiment of the present application, an electronic device is also provided. The electronic device may include a processor and a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium; when the computer program is executed by the processor, the processor executes the steel strip surface defect detection method of any of the above embodiments.
[0180] Reference Fig.11 , shows a structural block diagram of an electronic device according to an embodiment of the present application. Fig.11 As shown, the electronic device 110 includes a processor 1101 and a computer-readable storage medium 1102 , on which a computer program 11021 is stored.
[0181] The processor 1101 is used to execute the computer program 11021 stored on the computer-readable storage medium 1102. When executing the computer program 11021, the processor 1101 implements the steel strip surface defect detection method of any of the above-mentioned embodiments and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0182] The processor 1101 mentioned above may include but is not limited to: a central processing unit (CPU), a network processor (NP), a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0183] The computer-readable storage medium 1102 mentioned above may include but is not limited to: read-only memory (ROM), random access memory (RAM), compact disc read-only memory (CD-ROM), electronic erasable programmable read-only memory (EEPROM), hard disk, floppy disk, flash memory, etc.
[0184] In an embodiment of the present application, a computer-readable storage medium is further provided, on which a computer program is stored. The computer program can be executed by a processor of an electronic device. When the computer program is executed by the processor, the processor executes the steel strip surface defect detection method described in any of the above embodiments.
[0185] Reference Fig.12 , shows a block diagram of a computer-readable storage medium according to an embodiment of the present application. Fig.12 As shown, a computer program 1201 is stored on the computer-readable storage medium 120. When the computer program 1201 is executed by the processor, the processor executes the steel strip surface defect detection method described in any of the above embodiments and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0186] The various embodiments in this specification are interrelated, and each embodiment is described in a progressive manner. Each embodiment focuses on the differences from other embodiments, and the same or similar parts between the various embodiments can be referenced to each other.
[0187] It should be noted that all actions of acquiring signals, information or data in this application are carried out in compliance with the relevant data protection laws and policies of the country where they are located and with the authorization given by the owner of the corresponding device.
[0188] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0189] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application.
[0190] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
[0191] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in the present application can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0192] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0193] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0194] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0195] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0196] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. In summary, the content of this specification should not be understood as limiting the present application.
Claims
1. A method for detecting surface defects of a steel strip, characterized in that: The method comprises: Acquire the surface image of the steel strip to be inspected; Inputting the surface image of the steel strip to be detected into a pre-generated steel strip surface defect detection model to obtain steel strip surface defect information output by the steel strip surface defect detection model, wherein the steel strip surface defect information includes defect location and defect type; Among them, the steel strip surface defect detection model is obtained by making at least one of the following improvements to the one-view YOLO model: replacing the cross-scale connected composite convolution C3 module with a channel-to-feature conversion C2F module, replacing the fast spatial pyramid pooling SPPF module with a fast spatial pyramid pooling SPPF_Res module with fused residual connection, adding a compression and excitation SE module after the SPPF_Res module, and adding a multi-layer feature fusion module to the neck network.
2. The method according to claim 1, characterized in that The C2F module includes: a first convolutional layer, a splitting layer, a bottleneck layer, a first concatenation layer, and a second convolutional layer, wherein the bottleneck layer includes at least one bottleneck module connected in series; The input of the C2F module is used as the input of the first convolutional layer, the output of the first convolutional layer is used as the input of the splitting layer, the output of the splitting layer is used as the input of the bottleneck layer, the output of the first convolutional layer and the output of the bottleneck layer are used as the input of the first splicing layer, the output of the splicing layer is used as the input of the second convolutional layer, and the input of the C2F module and the output of the second convolutional layer are multiplied as the output of the C2F module.
3. The method according to claim 1, characterized in that The SPPF_Res module includes a third convolutional layer, a plurality of branch networks and a second concatenation layer, each of the branch networks includes at least one maximum pooling layer connected in series, and different branch networks include different numbers of the maximum pooling layers; The input of the SPPF_Res module is used as the input of the third convolutional layer, the output of the third convolutional layer is used as the input of each of the branch networks, the output of the third convolutional layer and the output of each of the branch networks are used as the input of the second splicing layer, and the input of the SPPF_Res module and the output of the second splicing layer are added as the output of the SPPF_Res module.
4. The method according to claim 1, characterized in that: The SE module includes a global average pooling layer, a first fully connected layer, a first activation function, a second fully connected layer, a second activation function and a channel recalibration layer; The input of the SE module is used as the input of the global average pooling layer, the output of the global average pooling layer is used as the input of the first fully connected layer, the output of the first fully connected layer is used as the input of the first activation function, the output of the first activation function is used as the input of the second fully connected layer, the output of the second fully connected layer is used as the input of the second activation function, the input of the SE module and the output of the second activation function are used as the input of the channel recalibration layer, and the output of the channel recalibration layer is used as the output of the SE module.
5. The method according to claim 1, characterized in that The multi-layer feature fusion module includes a first comprehensive extraction layer, a third splicing layer and a C3 module; The output of the splicing layer on the input side of the Neck network is used as the input of the first comprehensive extraction layer, the output of the first comprehensive extraction layer and the output of the comprehensive extraction layer on the input side of the Neck network are used as the input of the third splicing layer, the output of the third splicing layer is used as the input of the C3 module, and the output of the C3 module is used as the input of the splicing layer on the output side of the Neck network.
6. The method according to claim 1, characterized in that The steel strip surface defect detection model is generated in the following way: Performing preprocessing and data enhancement operations on the initial data set to obtain a target data set; the target data set includes a target training set, a target verification set, and a target test set; The target training set is used to train the steel strip surface defect detection model to be trained, the target verification set is used to verify the steel strip surface defect detection model to be trained, and the target test set is used to test the steel strip surface defect detection model to be trained. After the training, verification and testing are completed, the steel strip surface defect detection model is obtained.
7. The method according to claim 6, characterized in that The target training set includes a sample steel strip surface image and actual steel strip surface defect information corresponding to the sample steel strip surface image; The step of training the steel strip surface defect detection model to be trained by using the target training set includes: Using the sample steel strip surface image as the input of the steel strip surface defect detection model to be trained, and obtaining the output of the steel strip surface defect detection model to be trained, wherein the output is the predicted steel strip surface defect information corresponding to the sample steel strip surface image; Calculating a classification loss function, a positioning loss function and a confidence loss function based on the actual steel strip surface defect information and the predicted steel strip surface defect information, and calculating a comprehensive loss function based on the classification loss function, the positioning loss function and the confidence loss function; When the comprehensive loss function meets the preset conditions, it is determined that the training is completed.
8. The method according to claim 1, characterized in that: Before acquiring the surface image of the steel strip to be detected, the method further includes: A visualization interface is constructed, and the steel strip surface defect detection model is loaded on the visualization interface.
9. A steel strip surface defect detection device, characterized in that: The device comprises: An acquisition module, used for acquiring the surface image of the steel strip to be detected; A detection module, used for inputting the surface image of the steel strip to be detected into a pre-generated steel strip surface defect detection model to obtain the steel strip surface defect information output by the steel strip surface defect detection model, wherein the steel strip surface defect information includes the defect position and defect type; Among them, the steel strip surface defect detection model is obtained by making at least one of the following improvements to the one-view YOLO model: replacing the cross-scale connected composite convolution C3 module with a channel-to-feature conversion C2F module, replacing the fast spatial pyramid pooling SPPF module with a fast spatial pyramid pooling SPPF_Res module with fused residual connection, adding a compression and excitation SE module after the SPPF_Res module, and adding a multi-layer feature fusion module to the neck network.
10. An electronic device, characterized in that: The electronic device comprises a processor and a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program; When the computer program is executed by the processor, the processor executes the steel strip surface defect detection method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor executes the steel strip surface defect detection method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Marine ship detection method based on improved YOLOv3 algorithm
CN113743322A
Small transparent plastic product defect detection method based on YOLOv5
CN115147380A
Steel surface defect detection algorithm based on deep learning
CN116664478A
Frozen dumpling surface defect real-time detection method based on LightYOLOCBAM network model
CN117218648A
Improved Yolov5-crowps northeast crop disease identification method
CN117437541A
