Improved YOLOv8n hot rolled steel surface defect detection method
By introducing global attention module, SPD-Conv convolution and small object detection head in the YOLOv8 model, the missed and missed detection problems of the model in low-resolution images and small object detection are solved, and the detection of steel surface defects is improved Accuracy and efficiency.
Patent Information
- Application Number
- CN202411233147.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-04
- Publication Date
- 2024-12-13
AI Technical Summary
The existing YOLOv8 model cannot effectively extract features in low-resolution images in steel surface defect detection, resulting in high missed detection and error detection rates, and cannot effectively detect small target defects on the steel surface.
By designing a global attention module and introducing SPD-Conv convolution, the model's attention to defect features is enhanced, and a small object detection head is added to form a four-prediction head structure to improve the model's ability to detect low-resolution images and small object.
Significantly reduce the leakage detection rate, enhance the model's low-resolution image detection ability, improve the accuracy of detection of small targets on the steel surface, and improve detection efficiency and accuracy.
Smart Images

Figure CN119130971A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of steel surface defect detection, and in particular to a hot-rolled steel surface defect detection method with improved YOLOv8n. Background Art
[0002] At present, crude steel production is made by pressure processing raw materials into steel with certain shapes and functions. During the processing, under the influence of process, environment, equipment and other factors, inevitable defects such as cracks, inclusions, spots, pitting surfaces, etc. will form on the surface of steel. When defects appear in steel, the compression, tensile and corrosion resistance will be affected to varying degrees, so it is particularly important to improve the accuracy of surface defect detection in steel. Eddy current detection technology and infrared detection technology are two representative traditional detection technologies, but their shortcomings have also been revealed in the detection tasks. Eddy current detection technology can only detect flow-blocking defects on the surface and sub-epidermal layer of steel, and requires large current excitation, which will cause a great waste of energy on the production line. Infrared detection technology is only suitable for applications with low requirements, and there are very few types of defects that can be detected. Traditional detection methods consume a lot of manpower and material resources.
[0003] With the rapid development of artificial intelligence, deep learning-based target detection technology has gradually been applied to the detection industry. The current target detection methods mainly include: one-stage detection and two-stage detection. Among them, the one-stage target detection algorithm is mainly based on the Single Shot MultiBox Detector (SSD) and You Only Look Once (YOLO) series, and the two-stage target detection model is mainly based on Faster R-CNN and Mask R-CNN. The basic principle of the two-stage target detection model is to generate a series of region candidate boxes in the image, and then classify and regress these candidate boxes. The one-stage target detection model does not generate candidate boxes and directly predicts the image. Therefore, the accuracy of the one-stage target detection model is lower than that of the two-stage target detection model, but the speed is much faster than that of the two-stage target detection model. Therefore, the one-stage target detection model is suitable for detection tasks with high real-time performance and limited computer resources.
[0004] Among the one-stage target detection models, the YOLO series of models are particularly popular and have achieved significant success in target detection model tasks. The YOLOv8 model is one of the YOLO series models. Compared with other series, it not only has higher accuracy and faster speed, but also can simultaneously achieve classification, detection, segmentation and pose estimation tasks. In 2020, the introduction of Detection Transformer (DETR) successfully introduced Transformer into the field of computer vision.
[0005] In the task of steel surface defect detection, the YOLOv8 model cannot effectively extract features from the image, which will cause missed detection and false detection of the model, seriously affecting the efficiency of the model and causing certain losses to production activities. Most of the steel image datasets are low-resolution images, which leads to poor model training results and low detection capabilities. The original model cannot well identify and process features in low-resolution images. Finally, the original YOLOv8 model contains three detection layers with different scales. When the input image size is 640×640, the detection layer outputs three scales of 80×80, 40×40, and 20×20. According to the different sizes of the receptive field, large-scale feature maps detect small targets, and small-scale feature maps detect large targets. Although it is suitable for most detection tasks, it is not effective for detection tasks with many overlapping small targets, especially for steel surface defects, which are mostly small targets. Facing these small targets, the prediction head with the smallest detection scale cannot completely solve them.
[0006] Therefore, it is necessary to provide a hot-rolled steel surface defect detection method that improves YOLOv8n. Summary of the invention
[0007] The present invention provides a hot-rolled steel surface defect detection method based on improved YOLOv8n. By designing a global attention module, the Backbone structure in the model can focus on defect features and reduce the missed detection rate. By introducing SPD-Conv convolution, a low-resolution image can be split into sub-feature maps and spliced into intermediate feature maps, thereby extracting key information and enhancing the low-resolution image detection capability of the model. Adding a small target detection head and the original prediction head to form a four-prediction head structure can enhance the model's detection capability for small targets on the steel surface.
[0008] The present invention provides a method for detecting surface defects of hot-rolled steel by improving YOLOv8n, comprising:
[0009] Acquire and process an original hot-rolled steel surface defect image dataset to obtain a target hot-rolled steel surface defect image dataset;
[0010] Get the original YOLOv8n network model, improve it by designing a global attention module, introducing SPD-Conv convolution, and adding a small target prediction head to obtain an improved YOLOv8n network model;
[0011] Train and evaluate the improved YOLOv8n network model to obtain a trained and evaluated improved YOLOv8n network model;
[0012] The trained and evaluated improved YOLOv8n network model is used to perform defect detection on the target hot-rolled steel surface defect image dataset.
[0013] Further, the original hot-rolled steel surface defect image dataset is acquired and processed to obtain the target hot-rolled steel surface defect image dataset, including:
[0014] Based on public big data, obtain the original hot-rolled steel surface defect image dataset;
[0015] The original hot-rolled steel surface defect image dataset is divided into a training dataset, a validation dataset and a test dataset;
[0016] Image data enhancement processing is performed on the training data set, verification data set and test data set to obtain the target hot-rolled steel surface defect image data set.
[0017] Furthermore, the original YOLOv8n network model is improved by designing a global attention module, introducing SPD-Conv convolution, and adding a small target prediction head, including:
[0018] Design a global attention module;
[0019] The proposed global attention module is added to the second layer of the original YOLOv8n network model and after the sixth layer feature fusion module C2f module to extract the features of the hot-rolled steel surface defect image that needs to be identified in the feature map after feature fusion.
[0020] Furthermore, a global attention module is designed, including:
[0021] A parallel design method is adopted to fuse the features processed by spatial attention and channel attention, and then the target features in the feature map are further extracted through convolution operation. Finally, the sigmoid function is used to activate it. Among them, the channel attention is processed by multi-layer perceptron technology, and the spatial attention is processed by channel average pooling and maximum pooling.
[0022] Furthermore, the original YOLOv8n network model is improved by designing a global attention module, introducing SPD-Conv convolution, and adding a small target prediction head, which also includes: introducing SPD-Conv convolution, specifically:
[0023] SPD-Conv is constructed based on space-to-depth layers and non-strided convolution; the space-to-depth layers downsample the feature maps, and non-strided convolution layers are added after each space-to-depth layer to reduce the number of channels by operating the learnable parameters in the non-strided convolution layers.
[0024] Furthermore, the original YOLOv8n network model is improved by designing a global attention module, introducing SPD-Conv convolution, and adding a small target prediction head, which also includes: adding a small target prediction head, specifically: adding a set of small target prediction heads with a size of 160×160 in the Head layer of the original YOLOv8n network model to predict low-level feature maps with few downsampling times and high resolution. The small target prediction head and the prediction head in the original YOLOv8n network model form a four-prediction head structure.
[0025] Furthermore, the network structure of the improved YOLOv8n network model is:
[0026] The 0th and 1st layers of the backbone network are convolutional layers, the 4th and 11th layers are global attention modules, and the 2nd, 6th, 9th and 13th layers are SPD-Conv convolutions. The small target prediction head is used to detect targets based on the features extracted by the C2f modules in the 24th, 27th, 30th and 33rd layers.
[0027] The working steps of the improved YOLOv8n network model are as follows: after the image is input, first, it is convolved in the 0th and 1st layers to expand the channel, reduce the feature map, and extract deep features; then, the SPD-Conv in the second layer will convolute the reduced feature map into 4 sub-feature maps, which are then spliced into an intermediate feature map, and then the information is identified through the C2 filter; the feature map processed by the SPD-Conv convolution is fused with feature maps of different scales in the C2f module, and the global attention module in the 4th layer extracts important features from the feature map after feature fusion; finally, the small target detection head performs target detection on the features extracted by the C2f modules in the 24th, 27th, 30th and 33rd layers to obtain the model output results.
[0028] Furthermore, the improved YOLOv8n network model is trained and evaluated, including:
[0029] Configure training parameters and perform training based on them. The training parameters are: 300 training rounds, 16 batches, 8 workers index, 0.01 learning rate, and other training parameters are the default values of the YOLOv8n network model.
[0030] The average precision is used to measure the accuracy of the improved YOLOv8n network model and evaluate the target detection results. The evaluation of the target detection results includes: conducting a horizontal comparison experiment between the global attention and popular attention mechanisms; conducting ablation experiments to evaluate the impact of performance improvements; and comparing the improved YOLOv8n network model with mainstream popular models.
[0031] Furthermore, the trained and evaluated improved YOLOv8n network model is used to perform defect detection on the target hot-rolled steel surface defect image dataset, including obtaining and analyzing the false detection rate and missed detection rate of defect detection, and obtaining and analyzing the detection accuracy measurement values of different defect types. Based on the analysis results, defect detection is carried out in a targeted manner, specifically:
[0032] According to the acquired historical defect detection results, the accuracy, false detection rate and missed detection rate of different types of defects are obtained;
[0033] Based on the accuracy rate, the false detection rate and the missed detection rate, corresponding weight values are set, and after multiplying the accuracy rate, the false detection rate and the missed detection rate with the corresponding weight values, a first accuracy rate, a first false detection rate and a first missed detection rate are obtained, and the first false detection rate and the first missed detection rate are summed to obtain a first false detection rate; after subtracting the first accuracy rate from the first false detection rate, a detection accuracy measurement value is obtained;
[0034] Based on the detection accuracy measurement value, different types of defect types are marked to obtain defect type annotation data marked with the detection accuracy measurement value;
[0035] Obtain a target hot-rolled steel surface defect image dataset, analyze the defect type distribution in the target hot-rolled steel surface defect image dataset, and obtain distribution data of different types of defects; the distribution data includes the distribution area and the number of distribution areas;
[0036] Setting a first threshold value of the detection accuracy measurement value, an area threshold value of the distribution area area, and a quantity threshold value of the number of distribution areas;
[0037] If the correctness measurement value of the defect type in the target hot-rolled steel surface defect image dataset is greater than the first threshold, and the distribution area is less than the area threshold, and the number of distribution areas is less than the number threshold, the trained and evaluated improved YOLOv8n network model is used for defect detection;
[0038] If the correctness measure value of the defect type in the target hot-rolled steel surface defect image dataset is greater than the first threshold, and the distribution area is greater than the area threshold, and the number of distribution areas is greater than the number threshold, and if the correctness measure value of the defect type in the target hot-rolled steel surface defect image dataset is less than the first threshold, then an alternative detection strategy is used for detection.
[0039] Further, alternative detection strategies are used for detection, including:
[0040] For a defect type in a target hot-rolled steel surface defect image dataset, the correctness measurement value is greater than a first threshold, the distribution area is greater than an area threshold, and the number of distribution areas is greater than a number threshold, obtaining the correctness measurement value, the distribution area, and the number of distribution areas;
[0041] Based on the accuracy measurement value, the area of the distribution area and the number of distribution areas, the probability prediction analysis of the detection accuracy is performed using the set neural network prediction model. When the probability prediction analysis result is greater than the set probability threshold of the detection accuracy, the trained and evaluated improved YOLOv8n network model is used for defect detection. Otherwise, on the basis of defect detection using the trained and evaluated improved YOLOv8n network model, a secondary detection is performed according to the set number of detections.
[0042] When the accuracy measurement value of the defect type in the target hot-rolled steel surface defect image dataset is less than the first threshold, other auxiliary models are used for supplementary detection based on the defect detection using the trained and evaluated improved YOLOv8n network model.
[0043] Compared with the prior art, the present invention has the following advantages and beneficial effects: by designing a global attention module, the Backbone structure in the model can focus on defect features and reduce the missed detection rate; by introducing SPD-Conv convolution, the low-resolution image can be split into sub-feature maps and spliced into intermediate feature maps, thereby extracting key information and enhancing the low-resolution image detection capability of the model; adding a small target detection head and the original prediction head to form a four-prediction head structure can enhance the model's detection capability for small targets on the surface of steel.
[0044] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description and the accompanying drawings.
[0045] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0047] Figure 1 Schematic diagram of the steps to improve YOLOv8n's method for detecting surface defects in hot-rolled steel;
[0048] Figure 2 Schematic diagram of the steps for obtaining a target hot-rolled steel surface defect image dataset;
[0049] Figure 3 This is the structure diagram of the global attention mechanism;
[0050] Figure 4 This is the SPD-Conv convolution structure diagram;
[0051] Figure 5 This is the network structure diagram after adding the small target prediction head;
[0052] Figure 6 This is a comparison chart of the effects of the improved model and the original model. DETAILED DESCRIPTION
[0053] The preferred embodiments of the present invention are described below in conjunction with the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.
[0054] The present invention provides a method for detecting surface defects of hot-rolled steel by improving YOLOv8n, such as Figure 1 As shown, including:
[0055] Acquire and process an original hot-rolled steel surface defect image dataset to obtain a target hot-rolled steel surface defect image dataset;
[0056] Get the original YOLOv8n network model, improve it by designing a global attention module, introducing SPD-Conv convolution, and adding a small target prediction head to obtain an improved YOLOv8n network model;
[0057] Train and evaluate the improved YOLOv8n network model to obtain a trained and evaluated improved YOLOv8n network model;
[0058] The trained and evaluated improved YOLOv8n network model is used to perform defect detection on the target hot-rolled steel surface defect image dataset.
[0059] The working principle of the above technical solution is: in order to realize the hot-rolled steel surface defect detection method of the improved YOLOv8n, the present invention first obtains and processes the original hot-rolled steel surface defect image dataset to obtain the target hot-rolled steel surface defect image dataset; then obtains the original YOLOv8n network model, and improves the original YOLOv8n network model by designing a global attention module, introducing SPD-Conv convolution, and adding a small target prediction head to obtain an improved YOLOv8n network model; then trains and evaluates the improved YOLOv8n network model to obtain a trained and evaluated improved YOLOv8n network model; finally, the trained and evaluated improved YOLOv8n network model is used to perform defect detection on the target hot-rolled steel surface defect image dataset.
[0060] The beneficial effects of the above technical solution are: by adopting the solution provided in this embodiment, by designing a global attention module, the Backbone structure in the model can enhance its attention to defect features and reduce the missed detection rate; by introducing SPD-Conv convolution, the low-resolution image can be split into sub-feature maps and spliced into intermediate feature maps, thereby extracting key information and enhancing the low-resolution image detection capability of the model; adding a small target detection head and the original prediction head to form a four-prediction head structure can enhance the model's detection capability for small targets on the surface of steel.
[0061] In one embodiment, Figure 2 As shown, the original hot-rolled steel surface defect image dataset is acquired and processed to obtain the target hot-rolled steel surface defect image dataset, including:
[0062] Based on public big data, an original hot-rolled steel surface defect image dataset is obtained; a public steel surface defect dataset collected by Northeastern University is selected. The steel surface defect dataset has 1,800 image data, and its defect types are 6 categories, namely cracks, inclusions, plaques, concave surfaces, rolling oxide scales and scratches. The original hot-rolled steel surface defect image dataset is divided into a training dataset, a verification dataset and a test dataset in a ratio of 8:1:1; image data enhancement processing is performed on the training dataset, the verification dataset and the test dataset to obtain the target hot-rolled steel surface defect image dataset.
[0063] The working principle of the above technical solution is: in order to achieve the acquisition of the target hot-rolled steel surface defect image dataset, the present invention first obtains the original hot-rolled steel surface defect image dataset based on public big data; then divides the original hot-rolled steel surface defect image dataset into a training dataset, a verification dataset and a test dataset; finally, image data enhancement processing is performed on the training dataset, the verification dataset and the test dataset to obtain the target hot-rolled steel surface defect image dataset.
[0064] The beneficial effect of the above technical solution is: by adopting the solution provided in this embodiment, a target hot-rolled steel surface defect image dataset is obtained based on the original hot-rolled steel surface defect image dataset, thereby providing a basis and convenience for subsequent defect detection.
[0065] In one embodiment, the original YOLOv8n network model is improved by designing a global attention module, introducing SPD-Conv convolution, and adding a small target prediction head, including:
[0066] Design a global attention module;
[0067] The proposed global attention module is added to the second layer of the original YOLOv8n network model and after the sixth layer feature fusion module C2f module to extract the features of the hot-rolled steel surface defect image that needs to be identified in the feature map after feature fusion.
[0068] The working principle of the above technical solution is to improve the original YOLOv8n network model by designing a global attention module, introducing SPD-Conv convolution, and adding a small target prediction head, including:
[0069] Design a global attention module;
[0070] The proposed global attention module is added to the second layer of the original YOLOv8n network model and after the sixth layer feature fusion module C2f module to extract the features of the hot-rolled steel surface defect image that needs to be identified in the feature map after feature fusion.
[0071] The beneficial effect of the above technical solution is: by adopting the solution provided in this embodiment and designing a global attention module, the Backbone structure in the model can enhance its attention to defect features and reduce the missed detection rate.
[0072] In one embodiment, the global attention module is designed as Figure 3 As shown, including:
[0073] A parallel design method is adopted to fuse the features processed by spatial attention and channel attention, and then the target features in the feature map are further extracted through convolution operation. Finally, the Sigmoid function is used for activation. Among them, the channel attention is processed by multi-layer perceptron technology; the spatial attention is processed by channel average pooling and maximum pooling; in terms of channel attention, the C×H×W feature map is first converted to W×H×C as the input of MLP (Multi layer Perceptron), and two Linear operations are performed in MLP to linearly transform the input feature map and output a specified number of neurons to amplify the cross-dimensional channel-space dependency, reduce information loss and amplify the global interaction representation to improve the performance of the model; the feature map output from the MLP is converted to the original dimension, the Sigmoid activation function is applied, and it is element-by-element multiplied with the input feature map to fuse their information, strengthen important features and reduce noise; in terms of spatial attention, the feature map is subjected to channel average pooling and maximum pooling respectively to retain contextual information and aggregate spatial features. The input size of the image is C×H×W, and after average pooling and maximum pooling, it is 1×H×W. It can be seen from the figure that the feature maps of average pooling and maximum pooling are spliced to increase the depth of the feature map so that the network can learn features of different depths. The number of channels after splicing is 2. After splicing, Batchnorm2d is used for batch normalization to make the input data distribution the same, thereby improving network performance. In addition, the normalized feature map is convolved to restore the number of channels to the number of channels of the original feature map, and finally activated by the Sigmoid activation function and multiplied with the original feature map, fusing the information of the output feature map and the input original feature map.
[0074] The working principle of the above technical solution is: in order to realize the involvement of the global attention module, the present invention first adopts a parallel design method to fuse the features processed by spatial attention and channel attention, and then undergoes a convolution operation to further extract the target features in the feature map, and finally, activates it using the Sigmoid function; among them, the channel attention is processed using multi-layer perceptron technology; the spatial attention is processed using channel average pooling and maximum pooling.
[0075] The beneficial effect of the above technical solution is: by adopting the solution provided in this embodiment and designing a global attention module, the features in the image can be further mined and the accuracy of the model can be improved.
[0076] In one embodiment, the original YOLOv8n network model is improved by designing a global attention module, introducing SPD-Conv convolution, and adding a small target prediction head, and also includes: introducing SPD-Conv convolution, such as Figure 4 As shown, specifically:
[0077] SPD-Conv is constructed based on space-to-depth layers and non-strided convolutions; the space-to-depth layers downsample the feature maps, and non-strided convolution layers are added after each space-to-depth layer to reduce the number of channels by operating the learnable parameters in the non-strided convolution layers.
[0078] The working principle of the above technical solution is: in order to realize the introduction of SPD-Conv convolution, the present invention constructs SPD-Conv based on space-to-depth layer and non-strided convolution; wherein, the space-to-depth layer downsamples the feature map, and adds a non-strided convolution layer after each space-to-depth layer to reduce the number of channels by operating the learnable parameters in the non-strided convolution layer; the working process of SPD-Conv is: dividing the original feature map into a series of sub-feature maps. The original feature map X(S,S,C1) of any size is divided into elements X(scale, scale) as units, and the sub-feature sequence is divided into sub-feature maps; when the image scale is 2, four sub-feature maps can be obtained, and the original feature map is downsampled by 2 times; the sub-feature maps are connected along the channel dimension to obtain a feature map, the spatial dimension of the feature map is reduced by a scale factor, and the channel dimension is increased by a scale factor. After the SPD feature conversion layer, a (s tride=1) convolution-free step layer with a C2 filter is added to realize the intermediate feature map to the final feature map; SPD-Conv splits the low-resolution image of the steel surface defects into sub-feature maps, and then splices them into intermediate feature maps to extract the key information, and then identifies the extracted information through the C2 filter, and finally performs feature fusion through the C2f module.
[0079] The beneficial effect of the above technical solution is: by adopting the solution provided in this embodiment, by constructing SPD-Conv based on space-to-depth layer and non-str ided convolution, the low-resolution image can be split into sub-feature maps and spliced into intermediate feature maps, thereby extracting key information and enhancing the low-resolution image detection capability of the model.
[0080] In one embodiment, the original YOLOv8n network model is improved by designing a global attention module, introducing SPD-Conv convolution, and adding a small target prediction head, and further comprising: adding a small target prediction head, such as Figure 5As shown in the figure, specifically: a set of small target prediction heads with a size of 160×160 is added to the Head layer of the original YOLOv8n network model to predict low-level feature maps with fewer downsampling times and high resolution. The small target prediction heads and the prediction heads in the original YOLOv8n network model form a four-prediction head structure.
[0081] The working principle of the above technical solution is: by designing a global attention module, introducing SPD-Conv convolution, and adding a small target prediction head, the original YOLOv8n network model is improved, and it also includes: adding a small target prediction head, specifically: adding a set of small target prediction heads with a size of 160×160 in the Head layer of the original YOLOv8n network model to predict low-level feature maps with few downsampling times and high resolution. The small target prediction head and the prediction head in the original YOLOv8n network model form a four-prediction head structure.
[0082] The beneficial effect of the above technical solution is: by adopting the solution provided by this embodiment, by adding a small target prediction head, it is possible to predict low-level feature maps with fewer downsampling times and high resolution, thereby improving the quality of prediction.
[0083] In one embodiment, the network structure of the improved YOLOv8n network model is:
[0084] The 0th and 1st layers of the backbone network are convolutional layers, the 4th and 11th layers are global attention modules, and the 2nd, 6th, 9th and 13th layers are SPD-Conv convolutions. The small target prediction head is used to detect targets based on the features extracted by the C2f modules in the 24th, 27th, 30th and 33rd layers.
[0085] The working steps of the improved YOLOv8n network model are as follows: after the image is input, first, it is convolved in the 0th and 1st layers to expand the channel, reduce the feature map, and extract deep features; then, the SPD-Conv in the second layer will convolute the reduced feature map into 4 sub-feature maps, which are then spliced into an intermediate feature map, and then the information is identified through the C2 filter; the feature map processed by the SPD-Conv convolution is fused with feature maps of different scales in the C2f module, and the global attention module in the 4th layer extracts important features from the feature map after feature fusion; finally, the small target detection head performs target detection on the features extracted by the C2f modules in the 24th, 27th, 30th and 33rd layers to obtain the model output results.
[0086] The working principle of the above technical solution is as follows: the network structure of the improved YOLOv8n network model is as follows: the 0th and 1st layers of the backbone network are convolution layers Conv, the 4th and 11th layers are global attention modules, and the 2nd, 6th, 9th and 13th layers are SPD-Conv convolutions; the small target prediction head is used to detect targets based on the features extracted by the C2f modules of the 24th, 27th, 30th and 33rd layers; the working steps of the improved YOLOv8n network model are as follows: after inputting an image, first, after convolution of the 0th and 1st layers, the channels are expanded, the feature maps are reduced, and the image is extracted. Take deep features; then, the SPD-Conv of the second layer will convolute the reduced feature map into 4 sub-feature maps, which are then spliced into an intermediate feature map, and then the C2 filter is used for information identification; the feature map processed by SPD-Conv convolution is fused with feature maps of different scales in the C2f module, and the global attention module of the fourth layer extracts important features from the feature map after feature fusion; finally, the small target detection head performs target detection on the features extracted by the C2f modules of the 24th, 27th, 30th and 33rd layers to obtain the model output results.
[0087] The beneficial effect of the above technical solution is: by adopting the solution provided in this embodiment, the performance improvement of the improved YOLOv8n network model can be guaranteed through the construction of the network structure of the improved YOLOv8n network model.
[0088] In one embodiment, the improved YOLOv8n network model is trained and evaluated, including:
[0089] Configure training parameters and perform training based on them. The training parameters are: 300 training rounds, 16 batches, 8 workers index, 0.01 learning rate, and other training parameters are the default values of the YOLOv8n network model.
[0090] The average precision is used to measure the accuracy of the improved YOLOv8n network model and evaluate the target detection results. The evaluation of the target detection results includes: a horizontal comparison experiment between the global attention and the hot attention mechanism. The comparison experiment results are shown in Table 1 below:
[0091]
[0092] Table 1
[0093] Ablation experiments are conducted to evaluate the impact of performance improvement. The evaluation results are shown in Table 2 below:
[0094]
[0095]
[0096] Table 2
[0097] The improved YOLOv8n network model is compared with the mainstream popular models. The results of the comparison experiment are shown in Table 3 below:
[0098]
[0099] Table 3
[0100] The working principle of the above technical solution is as follows: in order to train and evaluate the improved YOLOv8n network model, the present invention first configures the training parameters and performs training based on the training parameters; wherein the training parameters are: 300 training rounds, 16 batch size, 8 Workers index, 0.01 learning rate, and other training parameters are the default values of the YOLOv8n network model; the average accuracy is then used to measure the accuracy of the improved YOLOv8n network model and evaluate the target detection results; wherein, evaluating the target detection results includes: conducting a horizontal comparison experiment between the global attention and the popular attention mechanism; taking an ablation experiment to evaluate the impact of the performance improvement; conducting a comparison experiment between the improved YOLOv8n network model and the mainstream popular model; the effect comparison diagram of the improved model and the original model in the embodiment of the present invention is shown in FIG. Figure 6 shown.
[0101] The beneficial effect of the above technical solution is: by adopting the solution provided by this embodiment, the use of the improved YOLOv8n network model is facilitated by training and evaluating the improved YOLOv8n network model.
[0102] In one embodiment, the trained and evaluated improved YOLOv8n network model is used to perform defect detection on the target hot-rolled steel surface defect image dataset, and the false detection rate and missed detection rate of the defect detection are obtained and analyzed, and the detection accuracy measurement values of different defect types are obtained and analyzed. Based on the analysis results, defect detection is carried out in a targeted manner, specifically:
[0103] According to the acquired historical defect detection results, the accuracy, false detection rate and missed detection rate of different types of defects are obtained;
[0104] Based on the accuracy rate, the false detection rate and the missed detection rate, corresponding weight values are set, and after multiplying the accuracy rate, the false detection rate and the missed detection rate with the corresponding weight values, a first accuracy rate, a first false detection rate and a first missed detection rate are obtained, and the first false detection rate and the first missed detection rate are summed to obtain a first false detection rate; after subtracting the first accuracy rate from the first false detection rate, a detection accuracy measurement value is obtained;
[0105] Based on the detection accuracy measurement value, different types of defect types are marked to obtain defect type annotation data marked with the detection accuracy measurement value;
[0106] Obtain a target hot-rolled steel surface defect image dataset, analyze the defect type distribution in the target hot-rolled steel surface defect image dataset, and obtain distribution data of different types of defects; the distribution data includes the distribution area and the number of distribution areas;
[0107] Setting a first threshold value of the detection accuracy measurement value, an area threshold value of the distribution area area, and a quantity threshold value of the number of distribution areas;
[0108] If the correctness measurement value of the defect type in the target hot-rolled steel surface defect image dataset is greater than the first threshold, and the distribution area is less than the area threshold, and the number of distribution areas is less than the number threshold, the trained and evaluated improved YOLOv8n network model is used for defect detection;
[0109] If the correctness measure value of the defect type in the target hot-rolled steel surface defect image dataset is greater than the first threshold, and the distribution area is greater than the area threshold, and the number of distribution areas is greater than the number threshold, and if the correctness measure value of the defect type in the target hot-rolled steel surface defect image dataset is less than the first threshold, then an alternative detection strategy is used for detection.
[0110] The working principle of the above technical solution is: in order to realize defect detection on the target hot-rolled steel surface defect image data set, the present invention acquires and analyzes the false detection rate and missed detection rate of defect detection, and acquires and analyzes the detection accuracy measurement values of different defect types, and based on the analysis results, performs defect detection in a targeted manner, specifically: according to the acquired historical defect detection results, the accuracy rate, false detection rate and missed detection rate of different types of defects are acquired; based on the accuracy rate, false detection rate and missed detection rate, corresponding weight values are set, and the accuracy rate, false detection rate and missed detection rate are multiplied by the corresponding weight values to obtain the first accuracy rate, the first false detection rate and the first missed detection rate, and the first false detection rate and the first missed detection rate are summed to obtain the first false detection rate; after subtracting the first accuracy rate from the first false detection rate, the detection accuracy measurement value is obtained; based on the detection accuracy measurement value, different types of defects are marked to obtain defect type annotation data marked with the detection accuracy measurement value; the target hot-rolled steel surface defect image is acquired A data set is provided, wherein the defect type distribution in the target hot-rolled steel surface defect image data set is analyzed to obtain distribution data of different types of defect types; the distribution data includes the distribution area and the number of distribution areas; a first threshold value of the detection accuracy measurement value, an area threshold value of the distribution area area and a number threshold value of the number of distribution areas are set; if the accuracy measurement value of the defect type in the target hot-rolled steel surface defect image data set is greater than the first threshold value, and the distribution area area is less than the area threshold value, and the number of distribution areas is less than the number threshold value, then the defect detection is performed using the improved YOLOv8n network model that has been trained and evaluated; if the accuracy measurement value of the defect type in the target hot-rolled steel surface defect image data set is greater than the first threshold value, and the distribution area area is greater than the area threshold value, and the number of distribution areas is greater than the number threshold value, and if the accuracy measurement value of the defect type in the target hot-rolled steel surface defect image data set is less than the first threshold value, then an alternative detection strategy is used for detection.
[0111] The beneficial effect of the above technical solution is: by adopting the solution provided in this embodiment, the false detection rate and missed detection rate of defect detection are acquired and analyzed, and the detection accuracy measurement values of different defect types are acquired and analyzed. Based on the analysis results, defect detection is carried out in a targeted manner to ensure the accuracy of defect detection.
[0112] In one embodiment, detection is performed using an alternative detection strategy, including:
[0113] For a defect type in a target hot-rolled steel surface defect image dataset, the correctness measurement value is greater than a first threshold, the distribution area is greater than an area threshold, and the number of distribution areas is greater than a number threshold, obtaining the correctness measurement value, the distribution area, and the number of distribution areas;
[0114] Based on the accuracy measurement value, the area of the distribution area and the number of distribution areas, the probability prediction analysis of the detection accuracy is performed using the set neural network prediction model. When the probability prediction analysis result is greater than the set probability threshold of the detection accuracy, the trained and evaluated improved YOLOv8n network model is used for defect detection. Otherwise, on the basis of defect detection using the trained and evaluated improved YOLOv8n network model, a secondary detection is performed according to the set number of detections.
[0115] When the accuracy measurement value of the defect type in the target hot-rolled steel surface defect image dataset is less than the first threshold, other auxiliary models are used for supplementary detection based on the defect detection using the trained and evaluated improved YOLOv8n network model.
[0116] The working principle of the above technical solution is as follows: in order to realize detection using alternative detection strategies, the present invention first obtains the accuracy measurement value, the distribution area area and the number of distribution areas for the case where the accuracy measurement value of the defect type in the target hot-rolled steel surface defect image data set is greater than the first threshold, the distribution area is greater than the area threshold, and the number of distribution areas is greater than the number threshold; then based on the accuracy measurement value, the distribution area and the number of distribution areas, a probability prediction analysis of the detection accuracy is performed using the set neural network prediction model. When the probability prediction analysis result is greater than the set probability threshold of the detection accuracy, the defect detection is performed using the trained and evaluated improved YOLOv8n network model, otherwise, on the basis of the defect detection using the trained and evaluated improved YOLOv8n network model, a secondary detection is performed according to the set number of detections; finally, for the case where the accuracy measurement value of the defect type in the target hot-rolled steel surface defect image data set is less than the first threshold, on the basis of the defect detection using the trained and evaluated improved YOLOv8n network model, other auxiliary models are used for supplementary detection.
[0117] The beneficial effect of the above technical solution is: by adopting the solution provided in this embodiment, different detection strategies are formulated according to the comparison between the accuracy measurement values of different defect types and the first threshold, so as to improve the pertinence and effectiveness of the detection.
[0118] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. Improve the hot-rolled steel surface defect detection method of YOLOv8n, characterized in that: include: Acquire and process an original hot-rolled steel surface defect image dataset to obtain a target hot-rolled steel surface defect image dataset; Get the original YOLOv8n network model, improve it by designing a global attention module, introducing SPD-Conv convolution, and adding a small target prediction head to obtain an improved YOLOv8n network model; Train and evaluate the improved YOLOv8n network model to obtain a trained and evaluated improved YOLOv8n network model; The trained and evaluated improved YOLOv8n network model is used to perform defect detection on the target hot-rolled steel surface defect image dataset.
2. The hot-rolled steel surface defect detection method based on improved YOLOv8n according to claim 1 is characterized in that: Acquire and process the original hot-rolled steel surface defect image dataset to obtain the target hot-rolled steel surface defect image dataset, including: Based on public big data, obtain the original hot-rolled steel surface defect image dataset; The original hot-rolled steel surface defect image dataset is divided into a training dataset, a validation dataset and a test dataset; Image data enhancement processing is performed on the training data set, verification data set and test data set to obtain the target hot-rolled steel surface defect image data set.
3. The hot-rolled steel surface defect detection method based on improved YOLOv8n according to claim 1, characterized in that: The original YOLOv8n network model is improved by designing a global attention module, introducing SPD-Conv convolution, and adding a small target prediction head, including: Design a global attention module; The proposed global attention module is added to the second layer of the original YOLOv8n network model and after the sixth layer feature fusion module C2f module to extract the features of the hot-rolled steel surface defect image that needs to be identified in the feature map after feature fusion.
4. The hot-rolled steel surface defect detection method based on improved YOLOv8n according to claim 3 is characterized in that: Design a global attention module, including: A parallel design method is adopted to fuse the features processed by spatial attention and channel attention, and then the target features in the feature map are further extracted through convolution operation. Finally, the sigmoid function is used to activate it. Among them, the channel attention is processed by multi-layer perceptron technology, and the spatial attention is processed by channel average pooling and maximum pooling.
5. The hot-rolled steel surface defect detection method based on improved YOLOv8n according to claim 1, characterized in that: The original YOLOv8n network model is improved by designing a global attention module, introducing SPD-Conv convolution, and adding a small target prediction head. The method also includes: introducing SPD-Conv convolution, specifically: SPD-Conv is constructed based on space-to-depth layers and non-strided convolution; the space-to-depth layers downsample the feature maps, and non-strided convolution layers are added after each space-to-depth layer to reduce the number of channels by operating the learnable parameters in the non-strided convolution layers.
6. The hot-rolled steel surface defect detection method based on improved YOLOv8n according to claim 1, characterized in that: The original YOLOv8n network model is improved by designing a global attention module, introducing SPD-Conv convolution, and adding a small target prediction head, which also includes: adding a small target prediction head, specifically: adding a set of small target prediction heads with a size of 160×160 in the Head layer of the original YOLOv8n network model to predict low-level feature maps with few downsampling times and high resolution. The small target prediction head and the prediction head in the original YOLOv8n network model form a four-prediction head structure.
7. The hot-rolled steel surface defect detection method based on improved YOLOv8n according to claim 6 is characterized in that: The network structure of the improved YOLOv8n network model is: The 0th and 1st layers of the backbone network are convolutional layers Conv, the 4th and 11th layers are global attention modules, and the 2nd, 6th, 9th and 13th layers are SPD-Conv convolutions; the 24th, 27th, 30th and 33rd layers are equipped with small target prediction heads for target detection based on the features extracted by the C2f module; The working steps of the improved YOLOv8n network model are as follows: after the image is input, first, it is convolved in the 0th and 1st layers to expand the channel, reduce the feature map, and extract deep features; then, the SPD-Conv in the second layer will convolute the reduced feature map into 4 sub-feature maps, which are then spliced into an intermediate feature map, and then the information is identified through the C2 filter; the feature map processed by the SPD-Conv convolution is fused with feature maps of different scales in the C2f module, and the global attention module in the 4th layer extracts important features from the feature map after feature fusion; finally, the small target detection head performs target detection on the features extracted by the C2f modules in the 24th, 27th, 30th and 33rd layers to obtain the model output results.
8. The hot-rolled steel surface defect detection method based on improved YOLOv8n according to claim 6 is characterized in that: Train and evaluate the improved YOLOv8n network model, including: Configure training parameters and perform training based on them. The training parameters are: 300 training rounds, 16 batches, 8 workers index, 0.01 learning rate, and other training parameters are the default values of the YOLOv8n network model. The average precision is used to measure the accuracy of the improved YOLOv8n network model and evaluate the target detection results. The evaluation of the target detection results includes: conducting a horizontal comparison experiment between the global attention and popular attention mechanisms; conducting ablation experiments to evaluate the impact of performance improvements; and comparing the improved YOLOv8n network model with mainstream popular models.
9. The hot-rolled steel surface defect detection method based on improved YOLOv8n according to claim 1, characterized in that: Using the trained and evaluated improved YOLOv8n network model, defect detection is performed on the target hot-rolled steel surface defect image dataset, including acquisition and analysis of the false detection rate and missed detection rate of defect detection, and acquisition and analysis of the detection accuracy measurement values of different defect types. Based on the analysis results, defect detection is carried out in a targeted manner, specifically: According to the acquired historical defect detection results, the accuracy, false detection rate and missed detection rate of different types of defects are obtained; Based on the accuracy rate, the false detection rate and the missed detection rate, corresponding weight values are set, and after multiplying the accuracy rate, the false detection rate and the missed detection rate with the corresponding weight values, a first accuracy rate, a first false detection rate and a first missed detection rate are obtained, and the first false detection rate and the first missed detection rate are summed to obtain a first false detection rate; after subtracting the first accuracy rate from the first false detection rate, a detection accuracy measurement value is obtained; Based on the detection accuracy measurement value, different types of defect types are marked to obtain defect type annotation data marked with the detection accuracy measurement value; Obtain a target hot-rolled steel surface defect image dataset, analyze the defect type distribution in the target hot-rolled steel surface defect image dataset, and obtain distribution data of different types of defects; the distribution data includes the distribution area and the number of distribution areas; Setting a first threshold value of the detection accuracy measurement value, an area threshold value of the distribution area area, and a quantity threshold value of the number of distribution areas; If the correctness measurement value of the defect type in the target hot-rolled steel surface defect image dataset is greater than the first threshold, and the distribution area is less than the area threshold, and the number of distribution areas is less than the number threshold, the trained and evaluated improved YOLOv8n network model is used for defect detection; If the correctness measure value of the defect type in the target hot-rolled steel surface defect image dataset is greater than the first threshold, and the distribution area is greater than the area threshold, and the number of distribution areas is greater than the number threshold, and if the correctness measure value of the defect type in the target hot-rolled steel surface defect image dataset is less than the first threshold, then an alternative detection strategy is used for detection.
10. The hot-rolled steel surface defect detection method based on improved YOLOv8n according to claim 9, characterized in that: Conduct testing using alternative testing strategies, including: For a defect type in a target hot-rolled steel surface defect image dataset, the correctness measurement value is greater than a first threshold, the distribution area is greater than an area threshold, and the number of distribution areas is greater than a number threshold, obtaining the correctness measurement value, the distribution area, and the number of distribution areas; Based on the accuracy measurement value, the area of the distribution area and the number of distribution areas, the probability prediction analysis of the detection accuracy is performed using the set neural network prediction model. When the probability prediction analysis result is greater than the set probability threshold of the detection accuracy, the trained and evaluated improved YOLOv8n network model is used for defect detection. Otherwise, on the basis of defect detection using the trained and evaluated improved YOLOv8n network model, a secondary detection is performed according to the set number of detections. When the accuracy measurement value of the defect type in the target hot-rolled steel surface defect image dataset is less than the first threshold, other auxiliary models are used for supplementary detection based on the defect detection using the trained and evaluated improved YOLOv8n network model.
Citation Information
Patent Citations
Steel surface defect detection method based on YOLOv7-ECD
CN116468716A
Steel plate surface defect detection method based on improved YOLOv8
CN118279272A
Method for improving YOLOv8 network and application of method in strip steel surface defect detection
CN118365599A
