CN116777873A - Strip steel surface defect detection method based on improved YOLOv7 algorithm - Google Patents
Strip steel surface defect detection method based on improved YOLOv7 algorithm Download PDFInfo
- Publication number
- CN116777873A CN116777873A CN202310742405.1A CN202310742405A CN116777873A CN 116777873 A CN116777873 A CN 116777873A CN 202310742405 A CN202310742405 A CN 202310742405A CN 116777873 A CN116777873 A CN 116777873A
- Authority
- CN
- China
- Prior art keywords
- strip steel
- module
- network
- improved
- yolov7
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 229910000831 Steel Inorganic materials 0.000 title claims abstract description 52
- 239000010959 steel Substances 0.000 title claims abstract description 52
- 238000001514 detection method Methods 0.000 title claims abstract description 50
- 230000007547 defect Effects 0.000 title claims abstract description 41
- 238000004422 calculation algorithm Methods 0.000 title claims abstract description 35
- 238000000034 method Methods 0.000 claims abstract description 21
- 230000007246 mechanism Effects 0.000 claims abstract description 18
- 238000004519 manufacturing process Methods 0.000 claims abstract description 7
- 230000002950 deficient Effects 0.000 claims abstract description 3
- 238000012549 training Methods 0.000 claims description 25
- 238000012360 testing method Methods 0.000 claims description 7
- 238000012545 processing Methods 0.000 claims description 6
- 238000012795 verification Methods 0.000 claims description 6
- 239000000284 extract Substances 0.000 claims description 4
- 238000013515 script Methods 0.000 claims description 4
- 238000004513 sizing Methods 0.000 claims 1
- 230000006872 improvement Effects 0.000 abstract description 3
- 230000000694 effects Effects 0.000 description 6
- 230000006870 function Effects 0.000 description 6
- 238000013527 convolutional neural network Methods 0.000 description 5
- 238000010586 diagram Methods 0.000 description 5
- 238000000605 extraction Methods 0.000 description 4
- 238000013135 deep learning Methods 0.000 description 3
- 230000004913 activation Effects 0.000 description 2
- 238000013459 approach Methods 0.000 description 2
- 238000005336 cracking Methods 0.000 description 2
- 238000003064 k means clustering Methods 0.000 description 2
- 230000004075 alteration Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 230000018109 developmental process Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000005286 illumination Methods 0.000 description 1
- 238000003384 imaging method Methods 0.000 description 1
- 238000009776 industrial production Methods 0.000 description 1
- 238000011423 initialization method Methods 0.000 description 1
- 238000011176 pooling Methods 0.000 description 1
- 238000007781 pre-processing Methods 0.000 description 1
- 230000008569 process Effects 0.000 description 1
- 230000011218 segmentation Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/0002—Inspection of images, e.g. flaw detection
- G06T7/0004—Industrial image inspection
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/0464—Convolutional networks [CNN, ConvNet]
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/70—Arrangements for image or video recognition or understanding using pattern recognition or machine learning
- G06V10/762—Arrangements for image or video recognition or understanding using pattern recognition or machine learning using clustering, e.g. of similar faces in social networks
- G06V10/763—Non-hierarchical techniques, e.g. based on statistics of modelling distributions
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/70—Arrangements for image or video recognition or understanding using pattern recognition or machine learning
- G06V10/764—Arrangements for image or video recognition or understanding using pattern recognition or machine learning using classification, e.g. of video objects
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/70—Arrangements for image or video recognition or understanding using pattern recognition or machine learning
- G06V10/77—Processing image or video features in feature spaces; using data integration or data reduction, e.g. principal component analysis [PCA] or independent component analysis [ICA] or self-organising maps [SOM]; Blind source separation
- G06V10/774—Generating sets of training patterns; Bootstrap methods, e.g. bagging or boosting
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/70—Arrangements for image or video recognition or understanding using pattern recognition or machine learning
- G06V10/82—Arrangements for image or video recognition or understanding using pattern recognition or machine learning using neural networks
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/20—Special algorithmic details
- G06T2207/20081—Training; Learning
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/20—Special algorithmic details
- G06T2207/20084—Artificial neural networks [ANN]
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/30—Subject of image; Context of image processing
- G06T2207/30108—Industrial image inspection
- G06T2207/30136—Metal
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Software Systems (AREA)
- Evolutionary Computation (AREA)
- General Physics & Mathematics (AREA)
- Artificial Intelligence (AREA)
- Health & Medical Sciences (AREA)
- Computing Systems (AREA)
- General Health & Medical Sciences (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Multimedia (AREA)
- Medical Informatics (AREA)
- Databases & Information Systems (AREA)
- Biophysics (AREA)
- Life Sciences & Earth Sciences (AREA)
- Biomedical Technology (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Molecular Biology (AREA)
- General Engineering & Computer Science (AREA)
- Mathematical Physics (AREA)
- Probability & Statistics with Applications (AREA)
- Quality & Reliability (AREA)
- Image Analysis (AREA)
Abstract
The invention discloses a strip steel surface defect detection method based on an improved YOLOv7 algorithm, wherein the network improvement mode comprises the following steps: the method comprises the steps of calculating target frame parameters more suitable for the model by using a k-means++ clustering algorithm, replacing partial convolution of a backbone network with PConv, changing a loss function CIOU of an original model into SIOU, and adding a SE attention mechanism at the output position of each feature layer. By improving the network, the detection precision of the model is improved from 0.626 to 0.792, the recall rate is improved from 0.611 to 0.653, and the mAP value is improved from 0.65 to 0.709. Compared with the original network, the strip steel surface defect detection method based on the improved YOLOv7 algorithm has higher detection precision while ensuring the detection speed, reduces the weight file size from the original 74.9Mb to 66.3Mb, plays an important role in the strip steel production process, realizes automatic detection and rapid identification of defect areas, and improves the production efficiency and the product quality. In the later stage of strip steel production, the improved YOLOv7 algorithm is used for detecting surface defects of the finished strip steel, so that the quality of products can be ensured, defective products are prevented from flowing into the market, and the reputation of enterprises is prevented from being influenced.
Description
Technical Field
The invention belongs to the field of target detection, and relates to a strip steel surface defect detection method based on an improved YOLOv7 algorithm.
Background
The early strip steel surface defect detection method mainly comprises a manual detection method, an eddy current detection method, an infrared detection method, a magnetic leakage detection method, a laser scanning detection method and the like. In actual industrial production, the detection objects have large differences in terms of shape, size, texture, color, background, layout, imaging illumination and the like, so that the detection and classification of defects in a complex environment become a difficult task. Under the background of deep learning, convolutional neural networks are widely used for surface defect detection due to strong end-to-end automatic feature extraction capability, and can be classified into classification networks, target detection and instance segmentation according to different detection tasks. With the development of target detection technology, a detection method based on deep learning can be used for detecting the surface defects of the strip steel, and the reliability, the practicability and the high efficiency of the detection method are far superior to those of the method for early identifying the surface defects of the strip steel.
The current target detection algorithm based on deep learning mainly comprises two types: the first type is a two-stage detection algorithm, namely a target detection algorithm based on region extraction, wherein the algorithm extracts a plurality of candidate regions in an image by using a sliding window and other modes, and then classifies and carries out bounding box regression on each candidate region to finally obtain a target detection result. Such algorithms include R-CNN, fastR-CNN, fasterR-CNN, maskR-CNN, and the like. The second class is a single-stage object detection algorithm: such algorithms do not require explicit candidate region extraction, but rather classify and bounding box regression directly on the image, thereby achieving target detection. Such algorithms include YOLO, SSD, retinaNet, etc. The two algorithms have advantages and disadvantages, and the accuracy of the algorithm based on region extraction is higher, but the speed is slower; and the single-stage target detection algorithm is fast, but the accuracy is relatively low.
Disclosure of Invention
In order to overcome the defects in the prior art, the invention provides a strip steel surface defect detection method based on an improved YOLOv7 algorithm, which can improve the detection accuracy on the premise of ensuring higher detection speed.
A strip steel surface defect detection method based on an improved YOLOv7 algorithm comprises the following steps:
(1) Preparing a data set;
(2) Processing the data set;
(3) Improving the network;
(4) Training a network;
(5) The network is tested.
Further said step (1) comprises the steps of:
a dataset of hot rolled strip surface defects at university of northeast is downloaded over a network. 1800 pictures of the six steel strip Surface defects are selected in the downloaded data set, wherein the six steel strip Surface defects comprise inclusions (Inclusion), scratches (scratch), pressed oxide Scale (roll-in-Scale), cracks (cracking), pits (Pitted-Surface) and Patches, and the pictures are preprocessed.
Further said step (2) comprises the steps of:
the method comprises the steps of processing a data set, dividing the data set into a training set test set and a verification set, storing xml files of a marked data set in an animation folder in a ratio of 8:1:1, converting a file with an xml format marked by a marking result into a file with a txt format, storing the file with the txt format in a Labels folder, storing picture names contained in the training set test set and the verification set divided by the data set in an imageset folder by using the script, and placing a picture path under a data directory.
Further said step (3) comprises the steps of:
(3-1) calculating the size of an anchor box applicable to the data set by using a k-means++ clustering method, and replacing the original anchor box parameters with new anchor box parameters in a yaml file.
(3-2) replacing the partial convolution with a lighter and faster PConv convolution module, the principle of which is to convolve only the pixels outside the occlusion region in the convolution operation, while the pixels inside the occlusion region are treated as missing values. The core of PConv is a partial convolution operation that convolves only pixels of the non-occluded region in the input feature map, while pixels within the occluded region are ignored or considered to be 0. The partial convolution operation then combines the pixels of the non-occluded region with the mask of the occluded region to calculate corresponding pixel values in the output feature map. This approach can effectively utilize the context information of surrounding pixels to better recover the missing portions of the image.
And replacing part of convolution in the ELAN module in the network with PConv, and renaming the CBS module after the replaced convolution as a PBS module, wherein the new ELAN module is named as ELANP.
(3-3) adding an SE attention mechanism at the place of the feature layer output in the network, adding the attention mechanism to the network for convenience, adding the attention mechanism to the final convolution layer of the ELAN module for convenience, and naming the last CBS module as CBS-Att, and the new ELAN module as ELANP-Att. In order to better extract the information of the feature map, the ELAN module before all concat splicing is replaced by an ELANP-Att module added with an attention mechanism. The attention mechanism is added to the SPPCSPC module, named SPPCSPC-Att, and the only one SPPCSPC module in the network is replaced with the SPPCSPC-Att module.
And (3-4) replacing the original CIOU loss function in the network with the SIOU loss function, wherein the SIOU introduces vector angle between the real frame and the predicted frame, and the convergence speed is increased.
(1) Loss of angle:
wherein c h The difference between the heights of the center points of the real frame and the predicted frame is shown, and sigma is the distance between the center points of the real frame and the predicted frame.
(2) Distance loss:
wherein c w And c h The width and height of the smallest bounding rectangle for the real and predicted frames,for the center coordinates of the real frame, < >>Is the predicted frame center coordinates.
(3) Shape loss: Ω= (1-e) -Ww ) θ +(1-e -Wh ) θ
Wherein (w, h) and (w gt ,h gt ) The width and height of the prediction and real frames, respectively. Theta controls the attention degree of the shape loss, and the value interval is [2,6]。
Further said step (4) comprises the steps of:
creating a new yaml file, named YOLOv 7-immediate. Yaml, replacing an ELAN module and an SPPCSPC module of the original network with improved modules, changing the cfg file path in the train. Py file into the path of the YOLOv 7-immediate. Yaml file, and running the train. Py file to train the model. After training, recording training results, including precision, recall rate and mAP values, and storing the generated weight file.
Further said step (5) comprises the steps of:
changing the path of the weight file in the detect file into the path of the weight file generated after the improved model training, importing the picture data set of the strip steel to be detected into the model, operating the detect file, storing the detection result of the picture, changing the path of the weight file in the detect file into the weight file generated after the original network training for comparing the difference of the object detection effect before and after the improvement of the model, identifying the picture data set of the same batch, storing the detection result of the picture, and comparing the detection results of the two times. The comparison is shown in fig. 4-6.
Drawings
FIG. 1 is a flowchart of a method for detecting surface defects of a strip steel based on an improved YOLOv7 algorithm
FIG. 2 is a schematic diagram of a network frame of a method for detecting surface defects of a strip steel based on an improved YOLOv7 algorithm
FIG. 3 is a diagram showing the effect of original network identification on defects of a strip steel
FIG. 4 is a graph showing the effect of improved network identification on defects in a strip steel
FIG. 5 is a diagram showing the effect of original network identification on defects in strip steel
FIG. 6 is a second diagram showing the effect of improved network identification on defects in a strip steel
Detailed Description
In order to make the technical scheme of the invention clearer, the invention is further described below with reference to the attached drawings.
Referring to fig. 1-6, the present invention is implemented in the following specific steps:
in the first step, a dataset of hot rolled strip steel from university of northeast is downloaded.
The method comprises the steps of downloading a data set of strip steel defects on a website, selecting 1800 pictures in the downloaded data set, wherein the 1800 pictures are divided into six types of strip steel Surface defects, including Inclusion (Inclusion), scratch (scratch), pressed-in-Scale (roll-in-Scale), crack (cracking), pit (Pitted-Surface) and plaque (Patches), and preprocessing the pictures.
And a second step of processing the data set prepared in the first step.
The method comprises the steps of processing a data set, dividing the data set into a training set test set and a verification set, storing xml files of a marked data set in an animation folder in a ratio of 8:1:1, converting a file with an xml format marked by a marking result into a file with a txt format, storing the file with the txt format in a Labels folder, storing picture names contained in the training set test set and the verification set divided by the data set in an imageset folder by using the script, and placing a picture path under a data directory.
And thirdly, improving the original network model.
(3-1) calculating the size of an anchor box applicable to the data set by using a k-means++ clustering method, and replacing the parameters of the original anchor box with the parameters of the new anchor box in a yaml file.
The k-means++ algorithm is an improved k-means clustering algorithm which is simple and fast, is particularly suitable for use on conventional data sets, and is a method for avoiding weaker clustering sometimes occurring when the k-means algorithm is used. The method improves the accuracy of the clustering result through an intelligent initialization method. The steps of the k-means++ algorithm are as follows:
(1) A sample point is randomly selected from the input dataset as the first cluster center.
(2) For each sample point remaining, calculate its shortest distance to each cluster center that has been selected.
(3) A new cluster center is selected such that its probability of being selected is proportional to the square of its shortest distance to the selected cluster center.
(4) Steps 2 and 3 are repeated until k cluster centers are selected.
(5) The standard k-means clustering algorithm is run with the selected k cluster centers.
The method can enable the algorithm to avoid the local optimal solution more easily, thereby improving the accuracy of the clustering result.
(3-2) replacing the partial convolution with a lighter and faster PConv convolution module, the principle of which is to convolve only the pixels outside the occlusion region in the convolution operation, while the pixels inside the occlusion region are treated as missing values. The core of PConv is a partial convolution operation that convolves only pixels of the non-occluded region in the input feature map, while pixels within the occluded region are ignored or considered to be 0. The partial convolution operation then combines the pixels of the non-occluded region with the mask of the occluded region to calculate corresponding pixel values in the output feature map. This approach can effectively utilize the context information of surrounding pixels to better recover the missing portions of the image.
And replacing part of convolution in the ELAN module in the network with PConv, and renaming the CBS module after the replaced convolution as a PBS module, wherein the new ELAN module is named as ELANP.
(3-3) adding an SE attention mechanism at the place of the feature layer output in the network, adding the attention mechanism to the network for convenience, adding the attention mechanism to the final convolution layer of the ELAN module for convenience, and naming the last CBS module as CBS-Att, and the new ELAN module as ELANP-Att. In order to better extract the information of the feature map, the ELAN module before all concat splicing is replaced by an ELANP-Att module added with an attention mechanism. The attention mechanism is added to the SPPCSPC module, named SPPCSPC-Att, and the only one SPPCSPC module in the network is replaced with the SPPCSPC-Att module. The SE attention mechanism mainly comprises three steps:
(1) Squeeze: global average pooling is carried out on the feature map, and the size of the feature map is converted from h, w and c to 1, 1 and c.
(2) The specification: and generating a weight value for each characteristic channel, and constructing the correlation between the channels through two full connection layers.
s=σ(W 2 δ(W 1 z))
W 1 ,W 2 And (3) for the two full-connection layers, processing the vector z obtained in the previous step to obtain a channel weight value s, wherein the activation function of the first full-connection layer is ReLU, and the activation function of the second full-connection layer is Sigmoid.
Scale: performing weight assignment on the feature map U by the weight file s generated in the step (2) to obtain a required feature map
And (3-4) replacing the original CIOU loss function in the network with the SIOU loss function, wherein the SIOU introduces vector angle between the real frame and the predicted frame, and the convergence speed is increased.
(1) Loss of angle:
wherein c h The difference between the heights of the center points of the real frame and the predicted frame is shown, and sigma is the distance between the center points of the real frame and the predicted frame.
(2) Distance loss:
wherein c w And c h The width and height of the smallest bounding rectangle for the real and predicted frames,for the center coordinates of the real frame, < >>For predicting framesAnd (5) center coordinates.
(3) Shape loss: Ω= (1-e) -Ww ) θ +(1-e -Wh ) θ
Wherein (w, h) and (w gt ,h gt ) The width and height of the prediction and real frames, respectively. Theta controls the attention degree of the shape loss, and the value interval is [2,6]。
And fourthly, training the improved network model.
Creating a new yaml file, named YOLOv 7-immediate. Yaml, replacing an ELAN module and an SPPCSPC module of the original network with improved modules, changing the cfg file path in the train. Py file into the path of the YOLOv 7-immediate. Yaml file, and running the train. Py file to train the model. After training, recording training results, including precision, recall rate and mAP values, and storing the generated weight file. After training, the detection accuracy of the model is improved from 0.626 to 0.792, the recall rate is improved from 0.611 to 0.653, and the mAP value is improved from 0.65 to 0.709 by comparing the training result with the training result of the original model.
And fifthly, testing the improved model.
Changing the path of the weight file in the detect file into the path of the weight file generated after the improved model training, importing the picture data set of the strip steel to be detected into the model, operating the detect file, storing the detection result of the picture, changing the path of the weight file in the detect file into the weight file generated after the original network training for comparing the difference of the object detection effect before and after the improvement of the model, identifying the picture data set of the same batch, storing the detection result of the picture, and comparing the detection results of the two times.
Sixth, application in strip steel production:
in the process of strip steel production, it is very important to detect whether defects exist in strip steel, and the detection of the defects can ensure that the quality of strip steel products meets the standards and customer requirements, and any defects existing in the products can be found and removed, so that the quality and reliability of the products are improved. The product with problems can cause faults and accidents in use, and bring danger to users and surrounding environments, so that the detection of whether the strip steel is defective can also eliminate a plurality of potential safety hazards.
When the quality of a strip steel product is checked, the strip steel required to be detected on a conveyor belt is shot by using a fixed camera, the shot video is imported to a computer which is configured with an improved YOLOv7 model and can be operated, and the shot video is detected by using the improved model.
After the original model and the improved model are used for identifying the shot video of the produced strip steel in the strip steel production process, the improved YOLOv7 model is found to have higher precision and anti-interference capability for identifying the strip steel, and the comparison diagrams of the original network and the improved network for identifying the strip steel are shown in fig. 3-6. When the method is used, the improved YOLOv7 model is reserved, video data of the strip steel shot by the machine can be transmitted to a computer, defects of the strip steel are identified on the computer on which the improved model is deployed, and the model can output detection results of the defects of the strip steel.
While the foregoing is directed to embodiments, aspects and advantages of the present invention, other and further details of the invention may be had by the foregoing description, it will be understood that the foregoing embodiments are merely exemplary of the invention, and that any changes, substitutions, alterations, etc. which may be made herein without departing from the spirit and principles of the invention.
Claims (6)
1. The strip steel surface defect detection method based on the improved YOLOv7 algorithm is characterized by comprising the following steps of:
step 1, preparing a data set, and downloading Guan Daigang defective data sets on a network;
step 2, processing the data set to obtain a data set capable of training;
step 3, improving the network, calculating a target frame parameter more suitable for the model by using a k-means++ clustering algorithm, replacing partial convolution of the main network with PConv, changing a loss function CIOU of the original model into SIOU, and adding an SE attention mechanism at the output position of each feature layer;
and 4, training the network, training the improved network in the step 3, storing the training result, and deploying the trained model on a computer to identify the defects of the strip steel in the production process.
2. The method for detecting Surface defects of strip steel based on the modified YOLOv7 algorithm according to claim 1, wherein in step 1, a data set of strip steel defects is downloaded on a website, 1800 pictures of the downloaded data set are selected, wherein the six types of strip steel Surface defects are classified into Inclusion (including), scratch (scratch), pressed-in Scale (roll-in-Scale), crack (sizing), pitting (Pitted-Surface) and plaque (Patches), and the pictures are preprocessed.
3. The strip steel surface defect detection method based on the improved YOLOv7 algorithm according to claim 1, wherein in step 2, the data set is processed, the data set is divided into a training set test set and a verification set, the ratio is 8:1:1, xml files marked with the data set are stored in an analysis folder, files marked with the xml format are converted into files with txt format by using scripts and are stored in a Labels folder, picture names contained in the training set test set and the verification set divided by the data set are stored in an imageset folder by using scripts, and a picture path is placed under a data directory.
4. The method for detecting surface defects of a strip steel based on the modified YOLOv7 algorithm according to claim 1, wherein in step 3, the modified network comprises:
(1) Calculating the size of an anchor box applicable to the data set by using a k-means++ clustering method, and replacing the original anchor box parameters with new anchor box parameters in yaml files;
(2) The principle of replacing partial convolution with a lighter and faster PConv convolution module is to convolve only pixels outside the occlusion region in the convolution operation, while pixels inside the occlusion region are considered as missing values. The core of PConv is a partial convolution operation that only convolves pixels of the non-occluded region in the input feature map, while pixels in the occluded region are ignored or considered as 0, and then the partial convolution operation combines the pixels of the non-occluded region with the mask of the occluded region to calculate the corresponding pixel values in the output feature map. This method can effectively utilize the context information of surrounding pixels, thereby better recovering the missing part of the image,
replacing partial convolution in an ELAN module in the network with PConv, and renaming a CBS module after the replaced convolution as a PBS module, wherein the new ELAN module is named as ELANP;
(3) And adding an SE attention mechanism at the output position of the feature layer in the network, adding the attention mechanism into the network for convenience, adding the attention mechanism into the final convolution layer of the ELAN module for convenience, and naming the last CBS module as CBS-Att and the new ELAN module as ELANP-Att. In order to better extract the information of the feature map, the ELAN module before all concat splicing is replaced by an ELANP-Att module added with an attention mechanism. Adding an attention mechanism into the SPPCSPC module, named SPPCSPC-Att, and replacing the only SPPCSPC module in the network with the SPPCSPC-Att module;
(4) The original CIOU loss function in the network is replaced by the SIOU loss function, the SIOU introduces vector angle between the real frame and the predicted frame, accelerates the convergence speed,
(1) Loss of angle:
wherein c h Is the difference between the heights of the center points of the real frame and the predicted frame, sigma is the distance between the center points of the real frame and the predicted frame,
(2) Distance loss:
γ=2-Λ
wherein c w And c h The width and height of the smallest bounding rectangle for the real and predicted frames,as the center coordinates of the real frame,in order to predict the coordinates of the center of the frame,
(3) Shape loss: Ω= (1-e) -Ww ) θ +(1-e -Wh ) θ
Wherein (w, h) and (w gt ,h gt ) The width and the height of the prediction frame and the real frame are respectively, the theta controls the attention degree of the shape loss, and the value interval is [2,6 ]],
5. The method for detecting surface defects of strip steel based on the modified YOLOv7 algorithm according to claim 1, wherein in step 4, the method comprises the following steps: creating a new yaml file, named YOLOv 7-immediate. Yaml, replacing an ELAN module and an SPPCSPC module of the original network with improved modules, changing the cfg file path in the train. Py file into the path of the YOLOv 7-immediate. Yaml file, running the train. Py file to train the model, recording the training results after training, including the precision, recall rate and mAP value, and storing the generated weight file.
6. The method for detecting surface defects of a strip steel based on an improved YOLOv7 algorithm according to claim 1, wherein in a workshop for producing the strip steel, the strip steel to be detected on a conveyor belt is shot by using a fixed camera, the shot video is led into a computer which is provided with an improved YOLOv7 model capable of running, the shot video is detected by using the improved model, and the model outputs a detection result of defects existing in the strip steel.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310742405.1A CN116777873A (en) | 2023-06-21 | 2023-06-21 | Strip steel surface defect detection method based on improved YOLOv7 algorithm |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310742405.1A CN116777873A (en) | 2023-06-21 | 2023-06-21 | Strip steel surface defect detection method based on improved YOLOv7 algorithm |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116777873A true CN116777873A (en) | 2023-09-19 |
Family
ID=87990863
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310742405.1A Pending CN116777873A (en) | 2023-06-21 | 2023-06-21 | Strip steel surface defect detection method based on improved YOLOv7 algorithm |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116777873A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117218329A (en) * | 2023-11-09 | 2023-12-12 | 四川泓宝润业工程技术有限公司 | Wellhead valve detection method and device, storage medium and electronic equipment |
-
2023
- 2023-06-21 CN CN202310742405.1A patent/CN116777873A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117218329A (en) * | 2023-11-09 | 2023-12-12 | 四川泓宝润业工程技术有限公司 | Wellhead valve detection method and device, storage medium and electronic equipment |
CN117218329B (en) * | 2023-11-09 | 2024-01-26 | 四川泓宝润业工程技术有限公司 | Wellhead valve detection method and device, storage medium and electronic equipment |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109829914B (en) | Method and device for detecting product defects | |
CN111862064B (en) | Silver wire surface flaw identification method based on deep learning | |
Yuan et al. | A deep convolutional neural network for detection of rail surface defect | |
CN109002824B (en) | OpenCV-based building drawing label information detection method | |
KR20200013148A (en) | Method, system and computer program for providing defect analysis service of concrete structure | |
CN110490842B (en) | Strip steel surface defect detection method based on deep learning | |
CN111681240A (en) | Bridge surface crack detection method based on YOLO v3 and attention mechanism | |
CN111415329A (en) | Workpiece surface defect detection method based on deep learning | |
CN108921120B (en) | Cigarette identification method suitable for wide retail scene | |
CN113920107A (en) | Insulator damage detection method based on improved yolov5 algorithm | |
CN112037219A (en) | Metal surface defect detection method based on two-stage convolution neural network | |
CN106355579A (en) | Defect detecting method of cigarette carton surface wrinkles | |
US20230222645A1 (en) | Inspection apparatus, unit selection apparatus, inspection method, and computer-readable storage medium storing an inspection program | |
US20190272627A1 (en) | Automatically generating image datasets for use in image recognition and detection | |
CN116777873A (en) | Strip steel surface defect detection method based on improved YOLOv7 algorithm | |
TW202127371A (en) | Image-based defect detection method and computer readable medium thereof | |
CN113256601A (en) | Pavement disease detection method and system | |
CN110660049A (en) | Tire defect detection method based on deep learning | |
CN114359235A (en) | Wood surface defect detection method based on improved YOLOv5l network | |
CN115294033A (en) | Tire belt layer difference level and misalignment defect detection method based on semantic segmentation network | |
CN116071315A (en) | Product visual defect detection method and system based on machine vision | |
CN113989585B (en) | Medium-thickness plate surface defect detection method based on multi-feature fusion semantic segmentation | |
CN114782410A (en) | Insulator defect detection method and system based on lightweight model | |
CN114662605A (en) | Flame detection method based on improved YOLOv5 model | |
Katsamenis et al. | A Few-Shot Attention Recurrent Residual U-Net for Crack Segmentation |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |