A stainless steel foil side turning detection method based on a YOLOv8 model
By improving the YOLOv8 algorithm and data processing technology, the problems of low efficiency and insufficient accuracy in detecting rollover defects in stainless steel strips have been solved, achieving high-precision and high-efficiency rollover detection, thereby improving production efficiency and product quality.
Patent Information
- Application Number
- CN202310898085.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-21
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2043-07-21
AI Technical Summary
Existing technologies for detecting rollover defects in stainless steel strip rolling processes suffer from low efficiency and insufficient accuracy, making it difficult to meet the demands for high precision and high efficiency in production.
An improved YOLOv8 algorithm is adopted. By improving the feature extraction layer and detection layer, and combining K-Means value clustering calculation and FocalLoss loss function, new anchor box values are generated for stainless steel foil side-tipping detection. Images are captured by an industrial camera and data are processed and trained to improve detection accuracy and speed.
It achieves high-precision and high-speed detection of stainless steel foil rollover defects, improves production efficiency and product quality, can promptly detect and handle production problems, and adapts to different production environments.
Abstract
Description
TECHNICAL FIELD
[0001] The present invention relates to the field of stainless steel strip rolling. BACKGROUND
[0002] Stainless steel strip is a kind of metal material with good corrosion resistance, heat resistance, low temperature strength and mechanical properties, commonly used in tableware, cabinet, boiler, automobile parts, medical devices, building materials, food industry and other fields. The rolling deformation resistance of stainless steel is relatively large, and its work hardening degree is also very high, more than twice that of ordinary carbon steel. In order to process and roll this material, high rate and high precision must be used. However, due to the very strict requirements for the surface quality of stainless steel strip, and the surface of stainless steel strip is prone to various defects, so reducing the side turning defect of stainless steel strip is an important problem. YOLOv8 is a single-stage object detection algorithm. There are many ways to improve the feature extraction layer and detection layer based on the original YOLOv8 algorithm. In the YOLOv8 algorithm, Darknet53 is usually used as the feature extraction layer, which is a deep network structure composed of convolutional layers and residual blocks. In order to improve the feature extraction layer, a deeper or wider network structure is introduced, and pre-trained deep network structures such as ResNet and EfficientNet are used instead of Darknet53 to obtain better feature representation capability. Feature pyramid pooling operation is implemented at the end of the network to extract features of different size objects through multi-scale pooling operation. This can better capture the subtle differences and geometric shapes in the steel foil. The attention mechanism is introduced to enhance the attention of the features, such as the SENet (Squeeze-and-Excitation) module, which adjusts the importance of features by learning channel weights to improve the expression ability of key information. The detection layer in YOLOv8 algorithm is a network structure composed of multiple convolutional layers and fully connected layers, whose goal is to generate bounding boxes and corresponding class predictions based on feature maps. Predictions are made in different levels of feature maps to obtain multiple scale target detection results. This can improve the detection ability of different size targets. By increasing the resolution of the feature map, more detailed target information can be captured to improve the accuracy of detection. This can be achieved by using smaller convolution kernels or introducing up-sampling techniques. According to the characteristics of the steel foil, the prior box settings in the original YOLOv8 algorithm are adjusted to make it more suitable for the detection of steel foil side turning defects. This step needs to be optimized in combination with the corresponding data set and actual application scenario. YOLOv8 algorithm uses Mosaic data enhancement, cmBN, SAT self-adversarial training operation and other improvements at the input end to improve the detection accuracy and speed of the algorithm. YOLOv8 algorithm uses multi-scale feature extraction in the feature utilization part, a total of three feature layers, located in the middle layer, lower layer and bottom layer, the shape of the three feature layers is (19, 19, 255), (38, 38, 255) and (76, 76, 255) respectively, which can effectively improve the detection accuracy of the algorithm.The YOLOv8 algorithm adopts Weighted-Residual-Connections (WRC), Crossmini-Batch Normalization (CmBN), Self-adversarial-training (SAT), and other technologies to improve the accuracy of the Convolutional Neural Network (CNN), achieving a perfect balance between speed and accuracy. The YOLOv8 algorithm can be used to detect various defects on precision strip steel in precision strip steel production. By performing target detection on precision strip steel, defects can be detected in a timely manner, improving production efficiency and quality. In summary, the YOLOv8 algorithm has wide application prospects in precision strip steel production and can help production enterprises improve production efficiency and product quality. On the basis of the original YOLOv8 algorithm, the feature extraction layer and the detection layer are improved to improve the detection accuracy and speed of the strip foil side turning defect.
[0003] In summary, to improve the YOLOv8 algorithm to improve the detection accuracy and speed of the strip foil side turning defect, the feature extraction layer and the detection layer can be improved to enhance the model's expression ability and the ability to capture details. These improvement methods can be selected and adjusted according to actual needs and the characteristics of the data set to obtain the best detection effect. SUMMARY
[0004] The purpose of the present application is to overcome the shortcomings of the prior art and provide a stainless steel foil side turning detection method based on an improved YOLOv8 algorithm that can reduce side turning.
[0005] The technical solution adopted by the present application is: a stainless steel foil side turning detection method based on a YOLOv8 model, comprising the following steps
[0006] S1, establish a YOLOv8 model, use an industrial camera to take pictures of a stainless steel foil, and obtain images of the stainless steel foil;
[0007] S2, obtain and process side turning images generated during the production process of the stainless steel foil, and form a stainless steel foil side turning training data set after data processing on the stainless steel foil images and the side turning images;
[0008] S3, perform K-Means value clustering calculation on the stainless steel foil side turning training data set to obtain new anchor box values (anchor box), and replace the data set parameters in the original YOLOv8 model with the new anchor box values;
[0009] S4, training a YOLOv8 model through the stainless steel foil lateral training data set, and replacing the binary cross-entropy loss function in the original YOLOv8 model with a FocalLoss loss function to obtain an improved YOLOv8 model, and using the improved YOLOv8 model to perform lateral target detection on the stainless steel foil image.
[0010] The data processing of the stainless steel foil image and the lateral image in step S2 includes: image cropping, scaling, flipping, shifting, rotating, brightness adjustment and stretching on the stainless steel foil image; and fusing the stainless steel foil image and the lateral image through an image segmentation algorithm, an image enhancement algorithm or an image fusion algorithm to obtain a stainless steel foil lateral training image.
[0011] The data processing of the stainless steel foil image and the lateral image in step S2 further includes: dividing each of the stainless steel foil images into multiple slice images, and displaying each of the slice images at a set resolution to improve the detection accuracy of small target lateral images; and processing the sliced images in a multi-thread process to complete data processing of the slice images in a synchronous manner.
[0012] The data processing of the stainless steel foil image and the lateral image in step S2 further includes: establishing a flip image set to determine whether there is a flip in the stainless steel foil image through the flip image set, and if there is, marking a bounding box in the stainless steel foil image and obtaining the bounding box coordinates of the flip.
[0013] The data processing of the stainless steel foil image and the lateral image in step S2 further includes: calculating the width and height data of the bounding box according to the bounding box coordinates, wherein the height of the bounding box is the difference between the horizontal coordinate of the lower right corner of the bounding box and the horizontal coordinate of the upper left corner of the bounding box, and the width of the bounding box is the difference between the vertical coordinate of the lower right corner of the bounding box and the vertical coordinate of the upper left corner of the bounding box.
[0014] The K-Means value clustering calculation of the stainless steel foil lateral training data set in step S3 includes: initializing all the height values and width values of the lateral flips obtained in the training data set, and randomly selecting multiple height values and width values as the initial values of anchor boxes; calculating the iou value of each bounding box and each anchor box to generate anchor boxes (anchor boxes) with multiple width and height combinations; calculating the error d(n, k) of each bounding box relative to each anchor box, and selecting the one with the smallest error for classification by comparing the error size of each bounding box relative to each anchor box.
[0015] Note: Collect the image dataset of precision strip steel and label it. Perform object detection on new precision strip steel images to identify target objects in the precision strip steel. Based on the detection results, perform corresponding processing and analysis to improve the production efficiency and quality of precision strip steel.
[0016] The present application realizes high-precision and high-speed detection of strip foil side turning defects by utilizing deep learning and machine vision technology, improves production efficiency and product quality. At the same time, through real-time monitoring and detection and adaptive threshold adjustment, problems can be found and handled in time, further improving production efficiency and better adapting to different production environments and states. This not only promotes the modernization and intelligentization of manufacturing industry, but also opens up new possibilities for the application of deep learning and machine vision in other fields. DETAILED DESCRIPTION
[0017] The input of the algorithm includes image flipping, patching, or image pyramid of the entire production process to extract the image features of the parts, which can refer to the trained network; a feature enhancement module is set, which has extracted some relevant shallow features, and this part processes and enhances the low-level features extracted from the data, thereby enhancing the features learned by the model. Set the feature enhancement module, the previous one has extracted some relevant shallow features, and this part processes and enhances the low-level features extracted, so that the features learned by the model are the required features. If you want to get bbox directly, you can connect the conv output result. In target detection, this means using some useful training techniques to train the model, so that the model achieves better accuracy without increasing the complexity of the model, which also does not increase the computational cost of inference. The purpose of data augmentation is to increase the diversity of training samples, so that the detection model has strong robustness. Common data augmentation methods include two aspects: geometric enhancement and color enhancement. Geometric enhancement includes: random flipping (more in the horizontal direction, less in the vertical direction), random cropping, stretching and rotation. Color enhancement includes: contrast enhancement, brightness enhancement, and more importantly, HSV space enhancement. The improvement of YOLOv8 not only increases the above optimization algorithm, but also improves other aspects of the technology. The goal is to use the improved YOLOv8 algorithm to detect the flip defects of the strip foil. A labeled data set is collected, which contains images of normal defects and flip defects of strip aluminum foil. First, prepare the collected image data. This usually includes dividing the data set into training and test sets, and labeling the boundary box and class label of the corresponding flip defect area for each image. Configure the model according to the improved YOLOv8 algorithm architecture. This may involve selecting appropriate feature extraction and detection layers, adjusting the depth and width of the network, and setting regularization and optimizer hyperparameters. Initialize the weights of the model, which can use different initialization methods such as random initialization or use pre-trained weight initialization. Train the model using the prepared training set. In each training iteration, the image data is input into the model, and the predicted result and the corresponding loss are calculated. Then, according to the loss function and optimization algorithm, the parameters are updated, so that the model gradually learns the features of the strip foil side flip defects. Use the test set to verify and evaluate the model obtained during the training process. This can be achieved by calculating the accuracy, precision, recall and other indicators of the model on the test set. If the performance of the model is not satisfactory, it can be improved and optimized by adjusting the architecture of the model, hyperparameters or training strategy. After completing the model training and adjustment, the model can be deployed to the actual production environment. This may include saving the trained model and integrating it into a real-time image processing system to detect strip foil side flip defects. The following will further illustrate the present application combined with specific implementation examples. It needs to be emphasized that these examples are only used to illustrate the present application and are not used to limit the use range of the present application.
[0018] Moreover, all such equivalent ranges and modifications made by those skilled in the art are to be encompassed by the presently claimed application. In view of the teachings of the present application, those skilled in the art will readily recognize methods and materials similar or equivalent to those described herein, which can be used in the practice of the present application. Accordingly, the present application is not intended to be limited to the methods and materials described herein, but instead includes all methods and materials within the scope of the present application, as set forth in the appended claims.
[0019] A stainless steel foil side turning detection method based on a YOLOv8 model, comprising:
[0020] S1, establish a YOLOv8 model, use an industrial camera to shoot a stainless steel foil, and obtain an image of the stainless steel foil;
[0021] S2, obtain and process side turning images generated in the production process of the stainless steel foil, and form a stainless steel foil side turning training data set after data processing on the stainless steel foil image and the side turning image;
[0022] S3, perform K-Means value clustering calculation on the stainless steel foil side turning training data set to obtain new anchor box values, and replace the data set parameters in the original YOLOv8 model with the new anchor box values.
[0023] S4, train the YOLOv8 model through the stainless steel foil side turning training data set, replace the binary cross-entropy loss function in the original YOLOv8 model with a FocalLoss loss function, obtain an improved YOLOv8 model, and use the improved YOLOv8 model to perform side target detection on the stainless steel foil image.
[0024] The data processing of the stainless steel foil image and the side turning image includes image cropping, scaling, flipping, shifting, rotating, brightness adjustment and stretching of the stainless steel foil image; and the stainless steel foil image is fused with the side turning image through an image segmentation algorithm, an image enhancement algorithm or an image fusion algorithm to obtain a stainless steel foil side turning training image. Further, the data processing of the stainless steel foil image and the side turning image further includes: cutting each of the stainless steel foil images into multiple slice images, and displaying each of the slice images at a set resolution to improve the detection accuracy of the small target side turning image; and a multi-thread process is used to process the cut images, so that the slice images complete data processing in a synchronous manner. In actual application, a high-resolution industrial camera is used to capture a moving picture of the stainless steel foil during the detection process, and the picture to be detected is cut into 6 or 4 pictures to be detected. After cutting, the cut pictures are detected by using a multi-thread synchronous processing manner. Since the pictures to be detected are cut into 1 / 6 or 1 / 4 of the original picture size, all the pictures to be detected become the size of the late detection model during the detection process. The pictures to be detected become pictures with a size of 416*416, which is equivalent to magnifying the original picture by 6 or 4 times for detection, thereby increasing the detection accuracy of the small target side light.
[0025] The data processing of the stainless steel foil image and the side turning image further includes: establishing a set of turning images, judging whether there is a turning in the stainless steel foil image through the set of turning images, if there is, marking a frame in the stainless steel foil image and obtaining the frame coordinates of the turning.
[0026] The data processing of the stainless steel foil image and the side turning image further includes: calculating the width and height data of the frame according to the frame coordinates, wherein the height of the frame is the difference between the horizontal coordinate of the lower right corner of the frame and the horizontal coordinate of the upper left corner of the frame, and the width of the frame is the difference between the vertical coordinate of the lower right corner of the frame and the vertical coordinate of the upper left corner of the frame.
[0027] The K-Means value clustering calculation of the stainless steel foil side turning training data set includes: by initializing all the height values and width values of the side turning obtained in the data set, a plurality of height values and width values are randomly selected as the initial values of the anchor box. Calculate the iou value of each bounding box and each anchor box, generate a plurality of anchor boxes with width and height combinations. Calculate the error d(n, k) of each bounding box relative to each anchor box, and select the one with the smallest error for classification by comparing the error size of each bounding box relative to each anchor box. Specifically, after studying the yolov3 detection model widely used in the field of deep learning, the stainless steel foil bounding box frequently occurring and possibly occurring in the actual production process is statistically collected and summarized. The stainless steel foil image is shot by an industrial camera, and the stainless steel foil image data after rolling confirmation is processed, so as to obtain the stainless steel foil rolling training data set. The stainless steel foil rolling detection training data set can be made using the VOC training set format. Since the default anchor box size in the YOLOv8 algorithm is obtained based on the voc data set using the k-means clustering algorithm, the training target and detection target in the data set are completely different from the target size and shape in the VOC data set. Therefore, using the general anchor box size will affect the accuracy of the final training model. At this time, it is necessary to generate the corresponding anchor box size to replace the default value, which provides reliable guarantee for the accurate detection of the stainless steel foil side turning visual detection system.
[0028] In one embodiment, the implementation steps are as follows:
[0029] Step one: the clustering is the boundary (bounding box) of the detected target (side turning), so in the first step, all the side turning boundary (bounding box) coordinates in the data set need to be extracted. There may be one rectangular frame in a picture, or there may be multiple ones, but all pictures need to be extracted without difference. However, all rectangular frames of all pictures need to be extracted and placed together.
[0030] Step 2: Data processing, obtain the width and height data of all bounding boxes in the training data. The training data often gives 4 coordinates of its bounding box, but the subsequent clustering analysis needs the width and height of the bounding box, so the coordinate data needs to be converted into the width and height size of the bounding box. Step 3: Initialize the values of 9 anchor boxes, randomly select 9 values from all the boundary box values obtained from the data set as the initial values of the 9 anchor boxes. Step 4: Calculate the IOU value of each boundary box and each anchor point box. Use the method shown in the figure to introduce the IOU region, and use the k-means clustering algorithm to cluster and analyze all the boundary box values, and generate 9 anchor boxes with width and height combinations. The calculation formula of the IOU region is as follows: IOU = (x*y) / (a*b+c*d -x*y), and the distance parameter D is defined as: D = 1 - IOU.
[0031] Step 5: Classification operation. After the calculation in the previous step, the error d(n,k) of each boundary box to each anchor box can be obtained, by comparing the error size of each boundary box to each anchor box, selecting the anchor box with the smallest error, and classifying this boundary box to it, and performing this operation for each boundary box. Perform this operation for each boundary box, and finally record which anchor box each boundary box belongs to. Step 6: Anchor box update. After the previous step, it is known which boundary boxes belong to each anchor point box, then find the width and height values of these boundary boxes in each anchor point box, and take them as the new size of the anchor point box. Step 7: Repeat steps 4 to 6 until in step 5 it is found that the anchor box class to which all boundary boxes belong is exactly the same as before. In this way, 9 new anchor box classes that meet the stainless steel foil side load sample data set are obtained. In Table 1, the clustering analysis is performed on the stainless steel foil side image data set, and the detection effect before and after the K-means method is used to optimize the anchor point box in an embodiment, and the width and height of the corresponding anchor point box selected after iteration are (2, 7), (6, 19), (8, 28), (16, 19), (17, 24), (34, 98), (38, 167), (132, 154), (156, 246) respectively. Table 1 compares the differences and detection results of AnchorBox on the stainless steel foil side image data set before and after the clustering method is optimized. As can be seen from Table 1, the AnchorBox obtained by using the optimized clustering algorithm has a significant improvement in target detection, and the test environment is: Win10 operating system, CPU model: Intel8700k; GPU model: NVIDIAGTX4080: Compared with the original YOLOv8, the detection speed is improved by 0.6 frames / second, and the average detection accuracy is improved by 2.7 percentage points, reaching 92.1%.
[0032] By using the improved YOLOv8 algorithm, high-precision and high-speed detection of foil-side defects can be achieved, thereby improving production efficiency and product quality. In addition, through real-time monitoring and detection of side defects, problems can be discovered and handled in a timely manner, further improving production efficiency. Finally, through adaptive threshold adjustment, it can better adapt to different production environments and states.
Claims
1. A stainless steel foil side turning detection method based on a YOLOv8 model, characterized in that, The method comprises the following steps: S1, establishing a YOLOv8 model, using an industrial camera to shoot a stainless steel foil, and obtaining a stainless steel foil image; S2, obtaining and processing a side-up image generated in the production process of the stainless steel foil, and forming a stainless steel foil side-up training data set after data processing on the stainless steel foil image and the side-up image; S3, performing K-Means value clustering calculation on the stainless steel foil side-up training data set to obtain new anchor box values, and replacing the data set parameters in the original YOLOv8 model with the new anchor box values; the K-Means value clustering calculation on the stainless steel foil side-up training data set comprises: initializing the height value and the width value of all the side-up bounding boxes obtained in the training data set, and randomly selecting 9 height values and width values as the initial values of the anchor boxes; calculating the iou value of each bounding box and each anchor box, generating 9 anchor boxes with width and height combinations; calculating the error d(n, k) of each bounding box relative to each anchor box, selecting the one with the smallest error for classification by comparing the error size of each bounding box relative to each anchor box; the width and height of the 9 corresponding anchor point boxes selected after iteration using the K-Means clustering algorithm are (2, 7), (6, 19), (8, 28), (16, 19), (17, 24), (34, 98), (38, 167), (132, 154), and (156, 246); S4, training the YOLOv8 model through the stainless steel foil side-up training data set, replacing the binary cross-entropy loss function in the original YOLOv8 model with a FocalLoss loss function, obtaining an improved YOLOv8 model, and using the improved YOLOv8 model to perform side-up target detection on the stainless steel foil image.
2. The stainless steel foil side turning detection method based on the YOLOv8 model according to claim 1, characterized in that: The data processing on the stainless steel foil image and the side-up image in step S2 comprises: image cropping, scaling, flipping, shifting, rotating, brightness adjustment, and stretching on the stainless steel foil image; and fusing the stainless steel foil image and the side-up image through an image segmentation algorithm, an image enhancement algorithm, or an image fusion algorithm to obtain a stainless steel foil side-up training image.
3. The stainless steel foil side-over method based on the YOLOv8 model according to claim 2, characterized in that: The data processing on the stainless steel foil image and the side-up image in step S2 further comprises: dividing each stainless steel foil image into multiple slice images, and displaying each slice image at a set resolution to improve the detection accuracy of small target side-up images; and processing the sliced images through a multi-thread process to complete data processing on the slice images in a synchronous manner.
4. The stainless steel foil side turning detection method based on the YOLOv8 model according to claim 3, characterized in that: The data processing on the stainless steel foil image and the side-up image in step S2 further comprises: establishing a flip image set, judging whether there is a flip in the stainless steel foil image through the flip image set, and if there is, marking a bounding box and obtaining the bounding box coordinates in the stainless steel foil image.
5. The stainless steel foil side-over method based on the YOLOv8 model according to claim 4, characterized in that: The data processing of the stainless steel foil image and the side turning image in step S2 further comprises: calculating the width and height data of the frame according to the frame coordinates, wherein the height of the frame is higher than the difference between the horizontal coordinate of the lower right corner of the frame and the horizontal coordinate of the upper left corner of the frame, and the width of the frame is equal to the difference between the vertical coordinate of the lower right corner of the frame and the vertical coordinate of the upper left corner of the frame.
Citation Information
Patent Citations
Tobacco shred impurity detection method based on Yolo V3 model
CN112883797A