Hot coil defect detection algorithm based on deep learning
By introducing a new convolution module and attention mechanism into the YOLOv8n network model, the detection head reception domain and weight allocation are optimized, and the problem of unbalanced accuracy and efficiency in hot coil defect detection is solved, and efficient and real-time defect detection is achieved.
Patent Information
- Application Number
- CN202411751570.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-03-14
AI Technical Summary
The existing deep learning methods have problems of imbalance in detection accuracy and efficiency in thermal coil defect detection, which is difficult to meet the requirements of industrial real-time monitoring.
A hot coil defect detection algorithm based on deep learning is proposed. Based on the YOLOv8n network model, combined with the new superimposed convolution module, channel and spatial attention mechanism and other deep learning modules, the detection head reception domain is expanded and the channel and spatial weight allocation of small target fuzzy defects is optimized.
The detection accuracy and efficiency are balanced, the parameter quantity is low, the detection frame rate is high, the real-time detection standard is met, and high accuracy is achieved in the detection of hot coil defects.
Smart Images

Figure CN119624923A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the professional field of deep learning, and in particular relates to a hot coil defect detection algorithm based on deep learning. Background Art
[0002] In the field of defect recognition, traditional defect detection mainly relies on manual recognition, but it has the disadvantages of high subjectivity and inability to work continuously at high intensity. Some non-destructive testing methods used in production, such as ultrasonic testing and magnetic flux leakage testing, have effectively avoided some of the shortcomings of manual recognition, but they have the disadvantages of long time consumption, difficulty in describing defect shapes, high difficulty in operation, and high cost. In recent years, machine vision has been used for surface defect detection. However, the feature extraction of machine vision is too dependent on manually designed algorithms, which may lead to poor robustness and generalization of defect detection algorithms. The deep learning method based on convolutional neural network (CNN) has powerful feature extraction and expression capabilities, and has the advantages of fast detection speed, high accuracy, simple operation, and low cost. The effective performance of deep learning methods in the field of defect detection has enabled them to develop rapidly and be widely used. At present, the surface defect detection methods based on deep learning are mainly divided into one-stage methods and two-stage methods. Among them, the one-stage method directly generates the existence probability and position coordinates of the detection object during detection, and the two-stage method first generates region proposals, and then the network classifies the region proposals and obtains prediction information. Compared with the one-stage model, the two-stage model has higher detection accuracy, but slower detection speed. At present, deep learning methods still face problems in industrial actual production defect detection, such as high-precision algorithms have high hardware requirements and industrial production environment leads to unstable detection results. Continuous improvement and development are still needed.
[0003] For the engineering example of defect detection, it is a difficult problem to find an algorithm that balances accuracy and detection speed. Yang et al. improved the convolutional neural network Faster R-CNN and effectively improved the internal defect detection accuracy in infrared thermal images by aggregating the feature maps in the feature extraction network; Zhao et al. introduced variable convolution layers and deformable pooling layers to the Faster R-CNN algorithm to replace the fixed-scale convolution layers and pooling layers, which also effectively improved the detection accuracy. The above networks are all improvements based on the two-stage model. Although they have high recognition accuracy, their recognition efficiency is low and cannot meet the standards of industrial real-time monitoring. For the one-stage model, Li et al. proposed an EFD-YOLOv4 model for enhanced feature detection. The model introduces a convolutional encoder-decoder (ED) module, a feature alignment module (FAM), and a multi-scale module based on hierarchical residual connections, and improves the performance of the model by optimizing the feature processing method. Based on the YOLOv5 network, Zhang et al. added deeper convolutional layers to the backbone and used residual modules BiFPN and weighted feature networks CSWFFN to enhance multi-scale feature fusion, retaining more semantic information and location information. The detection accuracy and speed of the algorithm have been effectively improved. In summary, it can be observed that the improvement of the algorithm is more for the purpose of practical application. While improving the detection accuracy, the algorithm parameters and the requirements for computer hardware are taken into account. These are also the problems faced by the current deep learning real-time defect detection algorithm.
[0004] Based on the deep learning method, the present invention proposes for the first time an anchor-free defect detector for surface defect detection with excellent detection accuracy and efficiency. The detector is based on YOLOv8n, and comprehensively utilizes the new convolution module proposed for the first time, the existing channel and spatial attention mechanism and other deep learning modules or methods to expand the detection head receptive field, so that the algorithm can obtain feature maps of more scales and a larger receptive field, and further optimize the channel and space weight distribution of small target fuzzy defects. This defect detector not only has a significant advantage over other efficient algorithms in terms of model parameter quantity, but also exceeds most algorithms in detection frame rate and reaches the standard of real-time detection, and has achieved high accuracy in defect detection of hot coils, and has a broad application prospect. Summary of the invention
[0005] In view of the above problems, the purpose of the present invention is: to improve the model performance of the hot coil defect detection model, so that the detection efficiency of the detection model is higher, the detection effect is better, and it can better meet the actual detection requirements of production. The present invention proposes a hot coil defect detection algorithm based on deep learning.
[0006] The technical solution of the present invention is: a hot coil defect detection algorithm based on deep learning, characterized in that it includes the following steps: A: Obtain a dataset of hot coil surface defect images and divide the dataset into a training set and a test set; B: Build the YOLOv8n network model; C: In the neck network structure, the proposed new stacked convolution module, attention mechanism and other deep learning modules and methods are added to improve the neck network structure; D: Improve the algorithm header structure and add another decoupling header on the basis of the original number of decoupling headers; E: Optimize the loss function and obtain the optimized loss function; F: Based on the training set and the test set as well as the above-mentioned improvements and adjustments to the deep learning model, the hot coil surface defect detection model is trained and tested in turn to obtain a qualified hot coil surface defect detection model; In step B, a deep learning-based defect detection algorithm is modeled according to relevant parameters through the Pycharm platform; Step C improves the neck structure of the defect detection algorithm model, specifically: C1. In the neck network structure of the YOLOv8n model, the stacked convolution module Con5v is used to replace the original convolution layer Conv. The new convolution module Con5v generates five feature maps per convolution. C2. On this basis, a spatial and channel mixed attention mechanism GAM is added to each feature fusion unit with a convolution module and an upsampling unit with an upsampling layer in the neck to form a new unit feature fusion unit and upsampling unit structure; C3. Increase the network depth, repeat the new upsampling unit once more in the feature pyramid network FPN, and repeat the feature fusion unit once more in the path aggregation network PAN at the neck, and obtain a feature map with a size of 32×32; Due to the improvement in C, step D obtains a new feature map with a size of 32×32. Before the original three decoupling heads (which receive and output feature maps of 64×64, 128×128, and 256×256, respectively), a new decoupling head that receives and outputs a feature map of 32×32 is added.
[0007] The step E optimizes and evaluates the detection effect of the original model by calling and replacing the loss function, and the loss function for the optimal detection effect is a combination of the SIoU loss function and the Focal loss function.
[0008] The beneficial effects of the present invention are as follows: the present invention proposes for the first time an anchor-free defect detector for surface defect detection with superior detection accuracy and efficiency. The detector is based on YOLOv8n, and comprehensively utilizes new convolution modules, channel and spatial attention mechanisms and other deep learning modules or methods to expand the receptive field of the detection head, so that the algorithm can obtain feature maps of more scales and a larger receptive field, and further optimize the channel and spatial weight distribution of small target fuzzy defects. The defect detector not only has a significant advantage over other efficient algorithms in terms of the number of model parameters, but also exceeds most algorithms in terms of detection frame rate and reaches the standard of real-time detection, and has achieved high accuracy in defect detection of hot coils, and has a broad application prospect. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] Figure 1 It is a structural diagram of the stacked convolution module Con5v proposed for the first time in the present invention.
[0010] Figure 2 It is a schematic diagram of the structure of a hot coil defect detection algorithm based on deep learning of the present invention. DETAILED DESCRIPTION
[0011] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0012] like Figure 2 The figure shows a schematic diagram of the structure of a hot coil defect detection algorithm model based on deep learning of the present invention. A hot coil defect detection algorithm based on deep learning is characterized by comprising the following steps: A: Obtain a dataset of hot coil surface defect images and divide the dataset into a training set and a test set; B: Build the YOLOv8n network model; C: In the neck network structure, the proposed new stacked convolution module, attention mechanism and other deep learning modules and methods are added to improve the neck network structure; D: Improve the algorithm head structure and add another decoupling head on the basis of the original number of decoupling heads; E: Optimize the loss function and obtain the optimized loss function; F: Based on the training set and the test set as well as the above-mentioned improvements and adjustments to the deep learning model, the hot coil surface defect detection model is trained and tested in turn to obtain a qualified hot coil surface defect detection model; In step B, a deep learning-based defect detection algorithm is modeled according to relevant parameters through the Pycharm platform; Step C improves the neck structure of the defect detection algorithm model, specifically: C1. In the neck network structure of the YOLOv8n model, the stacked convolution module Con5v is used to replace the original convolution layer Conv. The new convolution module Con5v generates five feature maps per convolution. C2. On this basis, a spatial and channel mixed attention mechanism GAM is added to each feature fusion unit with a convolution module and an upsampling unit with an upsampling layer in the neck to form a new unit feature fusion unit and upsampling unit structure; C3. Increase the network depth, repeat the new upsampling unit once more in the feature pyramid network FPN, and repeat the feature fusion unit once more in the path aggregation network PAN at the neck, and obtain a feature map with a size of 32×32; Due to the improvement in C, step D obtains a new feature map with a size of 32×32. Before the original three decoupling heads (which receive and output feature maps of 64×64, 128×128, and 256×256, respectively), a new decoupling head that receives and outputs a feature map of 32×32 is added.
[0013] The step E optimizes and evaluates the detection effect of the original model by calling and replacing the loss function, and the loss function for the optimal detection effect is a combination of the SIoU loss function and the Focal loss function.
[0014] In the above step B, the hot coil defect detection algorithm of the present invention is taken as an example, and the algorithm model is established by Pycharm according to relevant parameters. The parameter settings of the defect detection algorithm are as follows: the input image scale is 256×256, the number of batch input images is 16, the maximum number of model iterations is 300, and the positive sample selection threshold intersection ratio is 0.5.
[0015] In step C, the convolution layer has the convolution formula: in is the pixel value of the position in the output feature map obtained after the convolution operation, Represents the input image or the output feature map of the previous layer, represents the convolution kernel, is the height of the convolution kernel, is the width of the convolution kernel, is the location of the output feature map, where , , is the height of the output feature map, is the width of the output feature map. After knowing the feature map of the input or previous network output, the output feature map scale of the stacked convolution module can be calculated by the above formula.
[0016] In step E, the optimized loss function is the SIoU loss function combined with the Focal loss function. The SIoU loss function is defined using distance cost, shape cost, and IoU cost, and its definition is: The IoU cost is the normal intersection over union value minus 1. By subtracting the IoU value of 1, the non-overlapping part of the predicted bounding box is emphasized. For the IoU cost, there is:
[0017]
[0018] For the shape cost, we have:
[0019] in , , and are the widths of the predicted box and the true bounding box, respectively. and are the heights of the predicted box and the true bounding box, respectively. and are the relative differences in width and height between the predicted and true bounding boxes, respectively.
[0020] For distance cost, we have: in , , , and are the horizontal coordinates of the real bounding box and the predicted bounding box, respectively. and are the ordinates of the true bounding box and the predicted bounding box, respectively. and are the maximum width difference and maximum height difference between the real bounding box and the predicted bounding box, respectively. is the angle cost, .
[0021] The definition of the Focal loss function is: in is the weight factor, is the regulating factor, It is the true class probability, and the Focal loss function helps solve the problem of cross entropy failure.
[0022] By combining the SIoU loss function and the Focal loss function to replace the original loss function in the algorithm model for optimization, the model obtains better detection results.
[0023] Those skilled in the art will appreciate that the embodiments described herein are intended to help readers understand the principles of the present invention, and should be understood that the protection scope of the present invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific variations and combinations that do not deviate from the essence of the present invention based on the technical revelations disclosed by the present invention, and these variations and combinations are still within the protection scope of the present invention.
Claims
1. A hot coil defect detection algorithm based on deep learning, characterized in that: The following steps are involved: A: Obtain a dataset of hot coil surface defect images and divide the dataset into a training set and a test set; B: Build the YOLOv8n network model; C: In the neck network structure, the proposed new stacked convolution module, attention mechanism and other deep learning modules and methods are added to improve the neck network structure; D: Improve the algorithm head structure and add another decoupling head on the basis of the original number of decoupling heads; E: Optimize the loss function and obtain the optimized loss function; F: Based on the training set and the test set as well as the above-mentioned improvements and adjustments to the deep learning model, the hot coil surface defect detection model is trained and tested in turn to obtain a qualified hot coil surface defect detection model; In step B, a deep learning-based defect detection algorithm is modeled according to relevant parameters through the Pycharm platform; Step C improves the neck structure of the defect detection algorithm model, specifically: C1. In the neck network structure of the YOLOv8n model, the stacked convolution module Con5v is used to replace the original convolution layer Conv. The new convolution module Con5v generates five feature maps per convolution. C2. On this basis, a spatial and channel mixed attention mechanism GAM is added to each feature fusion unit with a convolution module and an upsampling unit with an upsampling layer in the neck to form a new unit feature fusion unit and upsampling unit structure; C3. Increase the network depth, repeat the new upsampling unit once more in the feature pyramid network FPN, and repeat the feature fusion unit once more in the path aggregation network PAN at the neck, and obtain a feature map with a size of 32×32; Due to the improvement in C, step D obtains a new feature map with a size of 32×32. Before the original three decoupling heads (which receive and output feature maps of 64×64, 128×128, and 256×256, respectively), a new decoupling head that receives and outputs a feature map of 32×32 is added.
2. In step E, the detection effect of the original model is optimized and evaluated by calling and replacing the loss function. The loss function for the optimal detection effect is a combination of the SIoU loss function and the Focal loss function.