CN116468663A - Method for detecting surface micro defects based on improved YOLOv5 - Google Patents
Method for detecting surface micro defects based on improved YOLOv5 Download PDFInfo
- Publication number
- CN116468663A CN116468663A CN202310240939.4A CN202310240939A CN116468663A CN 116468663 A CN116468663 A CN 116468663A CN 202310240939 A CN202310240939 A CN 202310240939A CN 116468663 A CN116468663 A CN 116468663A
- Authority
- CN
- China
- Prior art keywords
- image
- detection
- network
- defect
- training
- 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
- 230000007547 defect Effects 0.000 title claims abstract description 90
- 238000000034 method Methods 0.000 title claims abstract description 47
- 238000001514 detection method Methods 0.000 claims abstract description 80
- 238000012549 training Methods 0.000 claims abstract description 29
- 230000007246 mechanism Effects 0.000 claims abstract description 11
- 238000004519 manufacturing process Methods 0.000 claims abstract description 7
- 230000000694 effects Effects 0.000 claims abstract description 5
- 230000001965 increasing effect Effects 0.000 claims description 14
- 238000010586 diagram Methods 0.000 claims description 11
- 238000005520 cutting process Methods 0.000 claims description 9
- 238000012360 testing method Methods 0.000 claims description 7
- 238000013527 convolutional neural network Methods 0.000 claims description 5
- 230000006872 improvement Effects 0.000 claims description 4
- 230000008569 process Effects 0.000 claims description 4
- 210000000988 bone and bone Anatomy 0.000 claims description 3
- 238000012545 processing Methods 0.000 claims description 3
- 238000012795 verification Methods 0.000 claims description 3
- 238000013461 design Methods 0.000 claims description 2
- 230000002708 enhancing effect Effects 0.000 claims description 2
- 230000004927 fusion Effects 0.000 claims description 2
- 238000005070 sampling Methods 0.000 claims description 2
- 238000007689 inspection Methods 0.000 abstract description 4
- 239000000523 sample Substances 0.000 description 9
- 238000013135 deep learning Methods 0.000 description 7
- 238000011176 pooling Methods 0.000 description 7
- 230000006870 function Effects 0.000 description 5
- 230000004913 activation Effects 0.000 description 4
- 230000004807 localization Effects 0.000 description 3
- 230000005540 biological transmission Effects 0.000 description 2
- 238000004364 calculation method Methods 0.000 description 2
- 238000006243 chemical reaction Methods 0.000 description 2
- 238000011161 development Methods 0.000 description 2
- 230000018109 developmental process Effects 0.000 description 2
- HPTJABJPZMULFH-UHFFFAOYSA-N 12-[(Cyclohexylcarbamoyl)amino]dodecanoic acid Chemical group OC(=O)CCCCCCCCCCCNC(=O)NC1CCCCC1 HPTJABJPZMULFH-UHFFFAOYSA-N 0.000 description 1
- 208000027418 Wounds and injury Diseases 0.000 description 1
- 230000001133 acceleration Effects 0.000 description 1
- 238000013459 approach Methods 0.000 description 1
- 230000009286 beneficial effect Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 230000006378 damage Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000002474 experimental method Methods 0.000 description 1
- 238000003709 image segmentation Methods 0.000 description 1
- 208000014674 injury Diseases 0.000 description 1
- 238000013507 mapping Methods 0.000 description 1
- 239000000463 material Substances 0.000 description 1
- 239000011159 matrix material Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000002360 preparation method 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
-
- 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/40—Extraction of image or video features
- G06V10/42—Global feature extraction by analysis of the whole pattern, e.g. using frequency domain transformations or autocorrelation
-
- 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/80—Fusion, i.e. combining data from various sources at the sensor level, preprocessing level, feature extraction level or classification level
- G06V10/806—Fusion, i.e. combining data from various sources at the sensor level, preprocessing level, feature extraction level or classification level of extracted features
-
- 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]
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02P—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
- Y02P90/00—Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
- Y02P90/30—Computing systems specially adapted for manufacturing
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Computer Vision & Pattern Recognition (AREA)
- General Physics & Mathematics (AREA)
- Multimedia (AREA)
- Health & Medical Sciences (AREA)
- Software Systems (AREA)
- Artificial Intelligence (AREA)
- Computing Systems (AREA)
- General Health & Medical Sciences (AREA)
- Evolutionary Computation (AREA)
- Data Mining & Analysis (AREA)
- Computational Linguistics (AREA)
- Biophysics (AREA)
- Molecular Biology (AREA)
- Biomedical Technology (AREA)
- General Engineering & Computer Science (AREA)
- Mathematical Physics (AREA)
- Life Sciences & Earth Sciences (AREA)
- Databases & Information Systems (AREA)
- Medical Informatics (AREA)
- Quality & Reliability (AREA)
- Image Analysis (AREA)
Abstract
The invention relates to a method for detecting surface micro defects based on improved YOLOv5, belonging to the field of target detection. The method comprises the following steps: s1, data set manufacturing, namely dividing the data set; s2, improving YOLOv5, and adding a CBAM attention mechanism into a Backbone; s3, on the basis of the three detection scales of Neck, adding a small target detection scale; s4, improving network precision by adopting a decoupled Head in the Head; s5, training a model, importing a data set, combining pre-training weights, setting parameters, training, and verifying effects by using the data set; s6, defect detection is carried out, and defect information after the two graphs are integrated is output. The invention identifies the surface defects of the typical objects such as bright surface, dark surface, smooth surface, frosted surface, texture surface and the like, identifies common defects of large size, medium size, small size and micro size, and can meet the real-time requirement of quality inspection.
Description
Technical Field
The invention belongs to the field of target detection, and relates to a method for detecting surface micro defects based on improved YOLOv 5.
Background
At present, in most production factories, manual detection is still a main quality inspection method in the production process. Because the manual detection has the problems of human fatigue, low detection speed, non-uniform standard, large interference of human subjective factors and the like, the manual detection has low efficiency and poor accuracy. However, the machine vision technology has the advantages of non-contact, safety, reliability, no fatigue and the like which are incomparable with manual detection, so that the secondary injury caused by manual work can be reduced, the detection cost can be reduced, and the production efficiency and the product quality can be improved. The application of machine vision to product surface defect detection would be an essential direction of future quality inspection development.
In terms of the technical development time of the whole machine vision, with 2012 as a boundary, the existing industrial defect detection method is divided into two stages of a traditional method and a deep learning method. The conventional industrial defect detection method mainly comprises a product surface defect detection method based on texture features (such as histogram statistics, gray level co-occurrence matrix, fourier transform, gabor filter, etc.), color features (such as color histogram, color moment, color, correlation right amount), and shape features (such as Hough transform, fourier shape descriptor, etc.). The industrial defect detection in the subsequent deep learning comprises a supervision method, an unsupervised method and a weak supervision method. In the supervision method, alexNet, VGGNet, googLeNet is a typical representative of a classification network, fasterR-CNN, YOLO, SSD is a typical representative of a detection network, and FCN and MaskRCNN are representative of an image segmentation network. In the unsupervised approach, the self-encoder (AE), the generation of the countermeasure network (GAN), and the Deep Belief Network (DBN) are representative networks of comparison. Weak supervision is typically a combination of supervised and unsupervised. There are many practical cases of machine vision industrial defect detection.
Products containing minor defects are one of the most difficult defects to detect. This is mainly related to the defect morphology on the surface of the product, since the defects of the product are relatively small and there are many types of different defects in the production process, such as scratches, stains, bumps, dents and other defects of unknown origin, etc., which behave differently in the image. Meanwhile, the materials of the product shells are special, and defects can be identified only under certain light and proper angles. Therefore, in the aspect of detecting the minor defects of the shell of the product, the related actual landing cases are relatively lacking.
Disclosure of Invention
Therefore, the invention aims to provide the method for detecting the surface micro defects based on the improved YOLOv5, which can realize the identification of the defects of large, medium, small and micro sizes on the appearance of the product, can remarkably improve the detection efficiency and accuracy compared with the original network of the YOLOv5, and simultaneously can meet the requirements of actual industrial quality inspection on real-time performance.
In order to achieve the above purpose, the present invention provides the following technical solutions:
a method for improved YOLOv 5-based surface micro defect detection, the method comprising the steps of:
s1: the method comprises the steps of data set manufacturing, wherein an image to be detected generates a difference map to highlight defects by using a difference method, the image is cut, defect position and category information are marked, a sample is expanded by rotation, blurring and scaling, and finally the data set is divided;
s2: to YOLOv5 improvement, add CBAM attention mechanism at the backbond;
s3: on the basis of the three detection scales of Neck, small target detection scales are increased;
s4: the improvement of the decoupled Head is adopted in the Head to improve the network precision;
s5: model training, importing a data set, training after combining pre-training weights and setting parameters, and verifying effects by using the data set;
s6: and (3) defect detection, namely generating a differential graph by the image to be detected, cutting the differential graph and the image to be detected into small graphs, inputting improved YOLOv5 network detection, and outputting defect information after integrating the two graphs.
Optionally, the step S1 includes the following steps:
s101: obtaining an image of an object to be detected with surface defects, outputting a differential image after differential by utilizing a differential method together with an intact sample image, and simultaneously retaining an original color image and the differential image;
s102: cutting the original image and the differential image into multiple parts according to the size of the image, and increasing the size proportion of the defects in the image;
s103: marking the type and position information of the defect on the cut image by using marking software;
s104: expanding the marked data set by a method of rotating, zooming, overturning and increasing ambiguity random combination;
s105: the expanded data set is divided into a training set, a verification set and a test set according to the corresponding proportion.
Optionally, the step S2 includes the following steps:
s201: selecting a YOLOv5 convolutional neural network basic frame, and constructing a network model for defect detection, wherein the model is divided into four parts, namely Input, backbone, neck and Head;
s202: adding a CBAM attention mechanism in a Backbone part; specifically, a CBAM attention mechanism is added after the last convolution layer of the back bone, and key features can be extracted through the two attention weights on the channel attention module CAM and the spatial attention module SAM.
Optionally, in the step S3, a small target detection layer is added to the negk part; in the network structure of the YOLOv5, only three detection layers are originally provided, so that the detection rate of the network to a small target is improved; enhancing the characteristics at the second layer of the backbone network, increasing up-sampling after 18 layers, expanding the characteristic diagram, carrying out characteristic fusion on the characteristic diagram of 19 layers and the characteristic diagram of the second layer of the backbone network, and detecting a defect target with the size of 4 multiplied by 4 pixels by an increased 160 multiplied by 160 detection layer; the design of the four detection layers enables the network to predict small, medium and large target objects.
Optionally, in the step S4, the code of the head module of the YOLOv5 network model is improved by using a decomplexad head; after YOLOv5 is combined with DecoupledHead, category information and positioning information are respectively realized, so that the branches are used for processing the information respectively and are integrated during prediction.
Optionally, in S5, training the network model includes the following steps:
s501: importing a to-be-detected object shell defect data set into an S2, S3 and S4 improved YOLOv5 network for training, selecting a pre-training weight, and setting parameters of detection types, training iteration times, training sample numbers and input image sizes;
s502: and continuously debugging parameters in the training process to obtain an optimal solution, selecting a trained weight file, and evaluating the performance of the model by using a test set to obtain corresponding network performance key information.
Optionally, in S6, the defect detection includes the following steps: firstly, outputting a differential image by a differential method together with a color surface image of an object to be detected and a defect-free sample image, secondly, cutting the differential image and the color image together into small images, then introducing the small images into an improved YOLOv5 network, outputting the number and the types of defects contained in the small images through Input, backbone, neck and Head of the network in sequence, and finally integrating the defect information of the small images into an original large image to finish final defect judgment.
The invention has the beneficial effects that:
1. aiming at the problems of unobvious appearance detection characteristics and large background interference of common products, the invention provides a defect identification method combining the traditional difference method and deep learning, thereby effectively improving the identification precision of a network and reducing the false detection rate.
2. Aiming at the problem of the tiny defects of the product, the invention improves the detection capability of the network on the tiny defects by adding the small target detection layer.
3. The invention aims at the problems of complex texture of the shell of the product and large defect size range and easy false identification. The method combines a CBAM attention mechanism and a decoupling head on the basis of YOLOv5, so that a network can be more effectively focused on detection of a defect target, and the efficiency of network information transmission is improved. Missing identification and false identification of the product surface defect image are avoided to a certain extent.
4. Compared with the traditional target detection and mainstream deep learning target detection models, the detection method provided by the invention has more comprehensive excellent performances such as FasterR-CNN, SSD, YOLOv, yolox and the like.
Additional advantages, objects, and features of the invention will be set forth in part in the description which follows and in part will become apparent to those having ordinary skill in the art upon examination of the following or may be learned from practice of the invention. The objects and other advantages of the invention may be realized and obtained by means of the instrumentalities and combinations particularly pointed out in the specification.
Drawings
For the purpose of making the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in the following preferred detail with reference to the accompanying drawings, in which:
FIG. 1 is a schematic flow chart of a micro defect detection method based on improved YOLOv5 according to the present invention;
FIG. 2 is a diagram of a network architecture based on an improved YOLOv5 of the present invention;
FIG. 3 is a block diagram of a CBAM attention mechanism module of the present invention;
FIG. 4 is a diagram of a small target defect detection scale of the present invention;
fig. 5 is a diagram of a network structure of a coupled-Head decoupling Head according to the present invention.
Detailed Description
Other advantages and effects of the present invention will become apparent to those skilled in the art from the following disclosure, which describes the embodiments of the present invention with reference to specific examples. The invention may be practiced or carried out in other embodiments that depart from the specific details, and the details of the present description may be modified or varied from the spirit and scope of the present invention. It should be noted that the illustrations provided in the following embodiments merely illustrate the basic idea of the present invention by way of illustration, and the following embodiments and features in the embodiments may be combined with each other without conflict.
Wherein the drawings are for illustrative purposes only and are shown in schematic, non-physical, and not intended to limit the invention; for the purpose of better illustrating embodiments of the invention, certain elements of the drawings may be omitted, enlarged or reduced and do not represent the size of the actual product; it will be appreciated by those skilled in the art that certain well-known structures in the drawings and descriptions thereof may be omitted.
The same or similar reference numbers in the drawings of embodiments of the invention correspond to the same or similar components; in the description of the present invention, it should be understood that, if there are terms such as "upper", "lower", "left", "right", "front", "rear", etc., that indicate an azimuth or a positional relationship based on the azimuth or the positional relationship shown in the drawings, it is only for convenience of describing the present invention and simplifying the description, but not for indicating or suggesting that the referred device or element must have a specific azimuth, be constructed and operated in a specific azimuth, so that the terms describing the positional relationship in the drawings are merely for exemplary illustration and should not be construed as limiting the present invention, and that the specific meaning of the above terms may be understood by those of ordinary skill in the art according to the specific circumstances.
Referring to fig. 1 to 5, the present invention is a flowchart of a method for detecting surface micro defects based on improved YOLOv5, comprising the following specific steps:
s101: firstly, a vision acquisition platform is built, an image is acquired by using a camera, and an image of an object to be detected with surface defects is acquired. Collecting an original image with defects and a sample image without defects, outputting a differential image after differential by using a differential method, and simultaneously retaining an original color image and the differential image;
the purpose of the difference is to avoid the problems of interference of background noise of the picture and inconspicuous defects, and the defects of the picture after the difference can be more prominent.
The difference method is also called as a difference shadow method, and reflects the change between two images, mainly uses the subtraction operation of the images, specifically refers to the point-to-point subtraction of two input images to obtain an output image, and the mathematical expression is as follows:
C(x,y)=A(x,y)-B(x,y)
a (x, y) and B (x, y) of the formula are input images; c (x, y) is the output image.
S102: by the processing of S101, an original image with defects and a differential image obtained by differential are obtained, and since the input image has defects of small size and the size of the defects of small size is relatively small in the whole image, the size ratio of the defects in the image is increased by cutting the original image and the differential image into a plurality of parts on average.
S103: marking the type and the position information of the defect on the cut image by using an image marking tool lableIMage, marking the position information by using a rectangular frame, and generating an xml file after marking, wherein the xml file mainly comprises the name of the picture, the position information, the size information and the type information of an object in the picture.
S104: the marked data set is expanded by a method of random combination of rotation, scaling, overturning, increasing ambiguity and the like, so that a defect sample is increased, overfitting is prevented, and the robustness of the network is improved.
S105: the expanded data set is divided into a training set, a verification set and a test set according to the corresponding proportion.
S201: a YOLOv5 convolutional neural network basic framework is selected, a network model for detecting the defects of the shell is built, the model is mainly divided into four parts, namely Input, backbone, neck, head, and the improved network structure is shown in figure 2.
S202: a CBAM attention mechanism is added to the Backbone section. Specifically, a CBAM attention mechanism is added after the last convolution layer of the back bone, key features can be better extracted through the double attention weights on the channel attention module (ChannelAttentionModule, CAM) and the space attention module (SpatialAttentionModule, SAM), the connection of each feature on the channel and the space is improved, computer resources are improved while key feature information is integrated, and information transmission efficiency is improved, as shown in the structural principle of the CBAM in fig. 3.
Wherein, channel attention acquisition: the input feature map is subjected to global average pooling and Global Maximum Pooling (GMP) in each channel, a full connection layer is replaced by 1×1 convolution, the number of parameters is reduced, the two convolutions are respectively responsible for reducing the dimension and restoring the dimension, and the weight of the attention of the channel is output after the input feature map passes through a multi-layer perceptron (MLP). The Sigmoid activation function is then used to calculate the weight coefficient for each channel. Finally, combining the initial feature map with the original channels to divide the importance degree of different information on the number of the channels of the initial feature map. The calculation formula is as follows:
wherein: w is the first layer of the multi-layer perceptron, W1 is the second layer of the multi-layer perceptron, sigma is denoted as a sigmoid activation function,representing maximum pooling feature,/->Representing the average pooling feature.
The function of the spatial attention module is to improve the expression capability of key areas in the feature map, enhance the target areas of interest in the feature map and weaken the expression of irrelevant areas. Spatial attention acquisition: an input image or feature map is first compressed to a pixel size of 1 x 1 by a pooling layer according to the pixel size. The compressed feature map is then passed through a 7 x 7 convolution kernel and a ReLU activation function in sequence, and then up-sampled and matched to the pixel size of the next layer input. And finally integrating the characteristic diagram obtained by the channel and the spatial attention module, and carrying out second division on the key information. The calculation formula is as follows:
wherein f 7×7 For convolution operations with a filter size of 7 x 7,and->The average pooling feature and the maximum pooling feature under two-dimensional mapping, respectively, and σ is expressed as a sigmoid activation function.
S3: a small target detection layer is added to the neg part of YOLOv 5. Since small object detection relies on high level detail information and low level semantic information, and YOLOv5 backbone network loses more detail through several downsampling. It is more advantageous for target recognition by adding multiscale receptive fields and local features.
Only three detection scales exist in the original network structure of the YOLOv5, and the targets are detected by using feature maps of 8 times downsampling, 16 times downsampling and 32 times downsampling respectively. To increase the detection rate of the network for small targets, a detection layer is added, which can identify smaller defects. The specific operation is that the enhancement feature is started at the second layer of the backhaul, the upsampling is added after 18 layers, the feature map is enlarged, the feature map of 160×160 of 19 layers and the feature map of the second layer of the Backbone network are fused, and the added 160×160 detection layer can detect the defect target with the size of 4×4 pixels, as shown in fig. 4, which is the detection principle of the small target layer.
Wherein, four detection layers are respectively: four sizes of 20×20, 40×40, 80×80, 160×160, therefore, four detection layers correspond to four different detection scales, respectively, targets of 4×4,8×8, 16×16, 32×32 pixels or more, and can predict small, medium, and large defects.
S4: the code of the Head module of the YOLOv5 network model is improved by means of a decoupling Head (decomplexad). In target detection, the conflict problem between classification and regression tasks compares the effect, so the decoupling heads for classification and localization tasks are applied more in most one-stage and two-stage target detection algorithms. However, the probes of the YOLOv5 algorithm are coupled, i.e., the tasks of classification and regression are not separated.
The decoupling head has two branches, as shown in fig. 5, where n anchor For the number of anchors, the two parallel 3×3 convolution layers are passed through after 1×1 convolution. One for classification tasks only and the other for localization and confidence detection tasks, the latter again being subjected to two parallel 1 x 1 convolutions, classification, localization and confidence detection using different detection layers. After Yolov5 is combined with decoupledHead, category information and positioning information are respectively realized, so that each branch can independently process the respective information, and the prediction is performedThe method is integrated, so that the convergence speed of the model can be increased, and the detection precision can be improved.
S5, training a network model comprises the following steps:
s501: defect dataset importation was trained in YOLOv5 networks modified with S2, S3, S4. Firstly, corresponding software and hardware preparation are required to be completed, a deep learning environment is built, and data set format conversion is completed. The detection category, the training iteration number and the training sample number are set, and the size of the input image is 640 multiplied by 640.
The hardware and software devices are as follows: the operating system is WIN10, the deep learning framework is PyTorch (1.7.0), the CPU is InterCorei7-10700 (2.9 GHz), the GPU is GeForceGTX3060 (8G), the acceleration module is CUDA/CUDNN (9.0.176/7.6.5), and the compiler is Python (3.7.0).
The conversion of the data set needs to prepare labels first, and convert the data set format into yolo_txt format, that is, extract bbox information from each xml label into txt format, each image corresponds to a txt file, and each row of the file represents information of a target, including class, x_center and y_ center, width, height.
S502: the training process continuously debugs parameters and evaluates the performance of the model by using the test set. In studying and analyzing the results of the shell defect detection experiments, the average precision mean (meanAveragePrecision, mAP) was used herein to evaluate the detection performance based on deep learning. Some other key information is included: recall (P), accuracy (R), FPS, etc. And obtaining an optimal solution after debugging parameters for multiple times, and selecting a corresponding training weight file as a final version. And evaluating the performance of the model by using the test set to obtain the corresponding network performance key information.
S6: the defect detection comprises the following steps: firstly, outputting a differential image by a differential method together with a color surface image of an object to be detected and a defect-free sample image, secondly, respectively cutting the differential image and the color image into 9 parts, then introducing the 9 parts into an improved YOLOv5 network after cutting the 9 parts into small images, sequentially outputting the number and the types of all defects contained in the small images by the Input, backbone, neck, head of the network, finally, collecting defect information in the differential image and the small images of an original image, and removing repeated defect information to be used for representing final image defect judgment.
Finally, it is noted that the above embodiments are only for illustrating the technical solution of the present invention and not for limiting the same, and although the present invention has been described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that modifications and equivalents may be made thereto without departing from the spirit and scope of the present invention, which is intended to be covered by the claims of the present invention.
Claims (7)
1. A method for detecting surface micro defects based on improved YOLOv5, which is characterized by comprising the following steps: the method comprises the following steps:
s1: the method comprises the steps of data set manufacturing, wherein an image to be detected generates a difference map to highlight defects by using a difference method, the image is cut, defect position and category information are marked, a sample is expanded by rotation, blurring and scaling, and finally the data set is divided;
s2: to YOLOv5 improvement, add CBAM attention mechanism at the backbond;
s3: on the basis of the three detection scales of Neck, small target detection scales are increased;
s4: the improvement of the decoupled Head is adopted in the Head to improve the network precision;
s5: model training, importing a data set, training after combining pre-training weights and setting parameters, and verifying effects by using the data set;
s6: and (3) defect detection, namely generating a differential graph by the image to be detected, cutting the differential graph and the image to be detected into small graphs, inputting improved YOLOv5 network detection, and outputting defect information after integrating the two graphs.
2. A method for improved YOLOv 5-based surface micro defect detection according to claim 1, wherein: the step S1 comprises the following steps:
s101: obtaining an image of an object to be detected with surface defects, outputting a differential image after differential by utilizing a differential method together with an intact sample image, and simultaneously retaining an original color image and the differential image;
s102: cutting the original image and the differential image into multiple parts according to the size of the image, and increasing the size proportion of the defects in the image;
s103: marking the type and position information of the defect on the cut image by using marking software;
s104: expanding the marked data set by a method of rotating, zooming, overturning and increasing ambiguity random combination;
s105: the expanded data set is divided into a training set, a verification set and a test set according to the corresponding proportion.
3. A method for improved YOLOv 5-based surface micro defect detection according to claim 2, wherein: the step S2 comprises the following steps:
s201: selecting a YOLOv5 convolutional neural network basic frame, and constructing a network model for defect detection, wherein the model is divided into four parts, namely Input, backbone, neck and Head;
s202: adding a CBAM attention mechanism in a Backbone part; specifically, a CBAM attention mechanism is added after the last convolution layer of the back bone, and key features can be extracted through the two attention weights on the channel attention module CAM and the spatial attention module SAM.
4. A method for improved YOLOv 5-based surface micro defect detection according to claim 3, wherein: in the step S3, a small target detection layer is added to the Neck part; in the network structure of the YOLOv5, only three detection layers are originally provided, so that the detection rate of the network to a small target is improved; enhancing the characteristics at the second layer of the backbone network, increasing up-sampling after 18 layers, expanding the characteristic diagram, carrying out characteristic fusion on the characteristic diagram of 19 layers and the characteristic diagram of the second layer of the backbone network, and detecting a defect target with the size of 4 multiplied by 4 pixels by an increased 160 multiplied by 160 detection layer; the design of the four detection layers enables the network to predict small, medium and large target objects.
5. The method for improved YOLOv 5-based surface micro defect detection of claim 4, wherein: in the step S4, the code of the head module of the Yolov5 network model is improved by using a decomplexad decoupling head; after YOLOv5 is combined with DecoupledHead, category information and positioning information are respectively realized, so that the branches are used for processing the information respectively and are integrated during prediction.
6. The method for improved YOLOv 5-based surface micro-defect detection of claim 5, wherein: in the step S5, training the network model includes the following steps:
s501: importing a to-be-detected object shell defect data set into an S2, S3 and S4 improved YOLOv5 network for training, selecting a pre-training weight, and setting parameters of detection types, training iteration times, training sample numbers and input image sizes;
s502: and continuously debugging parameters in the training process to obtain an optimal solution, selecting a trained weight file, and evaluating the performance of the model by using a test set to obtain corresponding network performance key information.
7. The method for improved YOLOv 5-based surface micro defect detection of claim 6, wherein: in S6, the defect detection includes the following steps: firstly, outputting a differential image by a differential method together with a color surface image of an object to be detected and a defect-free sample image, secondly, cutting the differential image and the color image together into small images, then introducing the small images into an improved YOLOv5 network, outputting the number and the types of defects contained in the small images through Input, backbone, neck and Head of the network in sequence, and finally integrating the defect information of the small images into an original large image to finish final defect judgment.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310240939.4A CN116468663A (en) | 2023-03-14 | 2023-03-14 | Method for detecting surface micro defects based on improved YOLOv5 |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310240939.4A CN116468663A (en) | 2023-03-14 | 2023-03-14 | Method for detecting surface micro defects based on improved YOLOv5 |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116468663A true CN116468663A (en) | 2023-07-21 |
Family
ID=87177823
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310240939.4A Pending CN116468663A (en) | 2023-03-14 | 2023-03-14 | Method for detecting surface micro defects based on improved YOLOv5 |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116468663A (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117152746A (en) * | 2023-10-27 | 2023-12-01 | 南方医科大学 | Method for acquiring cervical cell classification parameters based on YOLOV5 network |
CN117197787A (en) * | 2023-08-09 | 2023-12-08 | 海南大学 | Intelligent security inspection method, device, equipment and medium based on improved YOLOv5 |
CN117788472A (en) * | 2024-02-27 | 2024-03-29 | 南京航空航天大学 | Method for judging corrosion degree of rivet on surface of aircraft skin based on DBSCAN algorithm |
-
2023
- 2023-03-14 CN CN202310240939.4A patent/CN116468663A/en active Pending
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117197787A (en) * | 2023-08-09 | 2023-12-08 | 海南大学 | Intelligent security inspection method, device, equipment and medium based on improved YOLOv5 |
CN117152746A (en) * | 2023-10-27 | 2023-12-01 | 南方医科大学 | Method for acquiring cervical cell classification parameters based on YOLOV5 network |
CN117152746B (en) * | 2023-10-27 | 2024-03-26 | 南方医科大学 | Method for acquiring cervical cell classification parameters based on YOLOV5 network |
CN117788472A (en) * | 2024-02-27 | 2024-03-29 | 南京航空航天大学 | Method for judging corrosion degree of rivet on surface of aircraft skin based on DBSCAN algorithm |
CN117788472B (en) * | 2024-02-27 | 2024-05-14 | 南京航空航天大学 | Method for judging corrosion degree of rivet on surface of aircraft skin based on DBSCAN algorithm |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112966684B (en) | Cooperative learning character recognition method under attention mechanism | |
CN116468663A (en) | Method for detecting surface micro defects based on improved YOLOv5 | |
CN110060237A (en) | A kind of fault detection method, device, equipment and system | |
Rahmon et al. | Motion U-Net: Multi-cue encoder-decoder network for motion segmentation | |
CN111680755B (en) | Medical image recognition model construction and medical image recognition method, device, medium and terminal | |
CN113609896A (en) | Object-level remote sensing change detection method and system based on dual-correlation attention | |
CN112465759A (en) | Convolutional neural network-based aeroengine blade defect detection method | |
CN111382785A (en) | GAN network model and method for realizing automatic cleaning and auxiliary marking of sample | |
CN111415353A (en) | Detection structure and detection method for fastener burr defects based on ResNet58 network | |
CN116012291A (en) | Industrial part image defect detection method and system, electronic equipment and storage medium | |
CN114581456B (en) | Multi-image segmentation model construction method, image detection method and device | |
CN112861915A (en) | Anchor-frame-free non-cooperative target detection method based on high-level semantic features | |
Avola et al. | Real-time deep learning method for automated detection and localization of structural defects in manufactured products | |
CN111639697B (en) | Hyperspectral image classification method based on non-repeated sampling and prototype network | |
CN114332473A (en) | Object detection method, object detection device, computer equipment, storage medium and program product | |
CN115775236A (en) | Surface tiny defect visual detection method and system based on multi-scale feature fusion | |
CN117011274A (en) | Automatic glass bottle detection system and method thereof | |
CN117274662A (en) | Lightweight multi-mode medical image classification method for improving ResNeXt neural network | |
CN114119621A (en) | SAR remote sensing image water area segmentation method based on depth coding and decoding fusion network | |
CN115527072A (en) | Chip surface defect detection method based on sparse space perception and meta-learning | |
Fan et al. | Application of YOLOv5 neural network based on improved attention mechanism in recognition of Thangka image defects | |
CN116168240A (en) | Arbitrary-direction dense ship target detection method based on attention enhancement | |
CN117152601A (en) | Underwater target detection method and system based on dynamic perception area routing | |
CN113313678A (en) | Automatic sperm morphology analysis method based on multi-scale feature fusion | |
CN117292117A (en) | Small target detection method based on attention mechanism |
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 |