A PCB board defect detection method, system, medium, equipment and terminal
The YOLOv4 algorithm is improved through Bisecting K-means clustering and InceptionV3 and MobileNetV3 networks to solve the problems of low efficiency and high false detection rate in PCB defect detection, achieving efficient and accurate defect detection to meet the real-time and multi-scale requirements of industrial sites. Testing requirements.
Patent Information
- Application Number
- CN202210270622.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-18
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2042-03-18
AI Technical Summary
Existing PCB defect detection methods have problems such as low efficiency, high false detection rate, high cost, and easy damage to PCBs in contact detection. Furthermore, machine vision-based methods such as YOLOv4 have low detection timeliness and low accuracy, making it difficult to meet the requirements of industrial applications.
The Bisecting K-means algorithm is used to perform cluster analysis on the PCB defect data set, and the YOLOv4 algorithm is improved by combining the InceptionV3 and MobileNetV3 networks, adding multiple scale convolution kernels and depth-separable convolutions, improving the feature extraction network, reducing the amount of calculation and improving detection Flexible.
It achieves efficient and accurate PCB defect detection, reduces computer computing power requirements, improves real-time detection and flexibility, can better adapt to multi-scale defect detection, and meets the real-time and accuracy requirements of industrial sites.
Smart Images

Figure CN114596302B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of PCB board defect detection, and in particular relates to a PCB board defect detection method, system, medium, equipment and terminal. Background Art
[0002] At present, PCB is the core component of electronic products, and its quality inspection is the key to meet the growing quality requirements of the electronic manufacturing industry. During the production process, affected by equipment, environment, manual operation, etc., PCB will have defects such as short circuit, open circuit, gap, burr, solder joint leakage, excess copper, etc.
[0003] At present, in the PCB production process, PCB defect detection mainly relies on manual visual inspection and electrical characteristics detection methods. These methods have many disadvantages such as low efficiency, high false detection rate, high cost, and easy damage to PCB during contact detection, which cannot meet the production requirements of PCB with high efficiency, high precision and high performance.
[0004] Machine vision inspection method is a non-contact, non-destructive automated defect detection method with the advantage of high inspection efficiency.
[0005] PCB defect detection methods based on machine vision are divided into reference method, hybrid method and non-reference method. The reference method requires the production of a large number of templates and is easily affected by noise, resulting in low detection versatility and low accuracy. The hybrid method is complex in design and takes a long time to detect, making it difficult to meet industrial application requirements. The non-reference method has better detection flexibility, less impact on noise, and high detection accuracy.
[0006] The no-reference method often uses deep learning methods for PCB defect detection. In deep learning algorithms, the YOLO (You Only Look Once) v4 target detection framework takes the entire image as input and combines neighborhood features for detection during the network propagation stage to avoid background false detection problems, which can better meet the requirements of PCB defect detection.
[0007] Through the above analysis, the problems and defects of the prior art are as follows:
[0008] (1) The existing methods of PCB defect detection that rely on manual visual inspection and electrical characteristics detection methods have many disadvantages, such as low efficiency, high false detection rate, high cost, and easy damage to the PCB during contact detection. They cannot meet the production requirements of PCB with high efficiency, high precision, and high performance.
[0009] (2) Among the existing PCB defect detection methods based on machine vision, the reference method requires the production of a large number of templates, which is easily affected by noise, resulting in low detection versatility and low accuracy; the hybrid method is complex in design and takes a long time to detect, making it difficult to meet industrial application requirements.
[0010] The difficulty of solving the above problems and defects is:
[0011] In order to solve the above problems with the current PCB defect detection method, it is necessary to propose a method that can replace the current PCB defect detection method. The main difficulty in solving this problem is that the method needs to have the performance of high precision, high detection efficiency, low detection cost, and high detection versatility.
[0012] The significance of solving the above problems and defects is:
[0013] By solving the above problems and defects, a PCB defect detection method with high detection efficiency, high precision and non-destructiveness is proposed to achieve high-precision and high-efficiency automated defect detection of PCB boards in industrial production sites, reduce enterprise generation costs, and propose new ideas for PCB defect detection. Summary of the invention
[0014] In view of the problems existing in the prior art, the present invention provides a PCB board defect detection method, system, medium, device and terminal, and more particularly, relates to a PCB board defect detection method, system, medium, device and terminal based on improved YOLOv4, aiming to solve the problems of many types of PCB defects, large defect size span between different types, low detection timeliness and low accuracy of YOLOv4 application.
[0015] The present invention is implemented in this way: a PCB board defect detection method, the PCB board defect detection method comprising the following steps:
[0016] Step 1: Use the Bisecting K-means algorithm to perform cluster analysis on the PCB defect data set, and cluster a total of 9 cluster centers of different sizes;
[0017] Step 2: Input the cluster center value obtained by clustering the PCB defect data set by Bisecting K-means into the YOLOv4 network, and input the relevant information of the data set into the YOLOv4 algorithm;
[0018] Step 3: In each detection head in the YOLOv4 algorithm, add the InceptionV3 network to detect the target by using convolution kernels of multiple scales.
[0019] Step 4: Improve the algorithm of the YOLOv4 feature extraction network after the improved detection network, quote the MobileNetV3 network instead of the YOLOv4 feature extraction network, and improve the YOLOv4 code according to relevant theories;
[0020] Step 5: Modify the improvement ideas in the YOLOv4 code, set relevant parameters for training and conduct experimental verification;
[0021] Step six, use the trained weight file to perform defect detection on the PCB data set test data set and verify the model detection effect.
[0022] Furthermore, in step 1, the Bisecting K-means algorithm is used to implement cluster analysis of the PCB defect data set, and a total of 9 cluster centers of different sizes are clustered, including:
[0023] The Bisecting K-means algorithm is used to implement cluster analysis of the PCB defect data set. Nine cluster centers of different sizes are obtained through cluster analysis as the anchor box values of YOLOv4, including:
[0024] The Bisecting K-means clustering algorithm is used on the public PCB defect dataset. The calibration box data of all calibration datasets are used as input, and all data are regarded as a cluster. The cluster is divided into two clusters using the K-means algorithm, and the error of each cluster is calculated. The cluster that can minimize the cluster loss function IoU is selected and divided into two clusters, and this process is continued until the number of selected clusters reaches the K value given by the user.
[0025] Among them, the error IOU calculation formula is as follows:
[0026]
[0027] In the formula, box i Represents the value of the i-th calibration frame, cen j Represents the value of the jth anchor box; the improved BisectingK-means clustering algorithm is used to cluster the data set, and a total of 9 anchor boxes are clustered.
[0028] Furthermore, in step 2, the cluster center value obtained by clustering the PCB defect data set by Bisecting K-means is input into the YOLOv4 network, and the relevant information of the data set is input into the YOLOv4 algorithm, including:
[0029] The cluster centers obtained by Bisecting K-means algorithm are input into YOLOv4, and the cluster center values obtained by clustering the PCB defect data set using Bisecting K-means algorithm are input into the YOLOv4 model parameters in order from small to large. The defect categories to be detected are set, and the categories to be set are input into the relevant parameters of the YOLOv4 model. The holdout method is used to divide all data sets, and the training data set and the verification data set are set according to the ratio of 9:1. The relevant information of each data set is compiled into a text document and input into the YOLOv4 model.
[0030] Furthermore, in step 3, in each detection head in the YOLOv4 algorithm, an InceptionV3 network is added, and the detection of the target is realized by using convolution kernels of multiple scales, including:
[0031] The Inceptionv3 network is added to the YOLOv4 detection head to detect features using convolution kernels of various scales. The network expands the convolution operations between neural network layers, uses convolution kernels of different sizes (1×1, 3×3, and 5×5) to perform convolutions, and splices them together to fuse features of different scales; the Inceptionv3 structure is added to the algorithm detection layer to increase the network depth without increasing the number of parameters.
[0032] Furthermore, in step 4, the algorithm of the YOLOv4 feature extraction network is improved, the MobileNetV3 network is used instead of the YOLOv4 feature extraction network, and the YOLOv4 code is improved according to relevant theories, including:
[0033] The MobileNetV3 network is used to improve the YOLOv4 feature extraction network; the MobileNetv3 network is the third updated version of the MobileNet network, which uses depthwise separable convolution and introduces two shrinkage hyperparameters: width multiplier and resolution multiplier.
[0034] The standard convolution method combines and calculates all inputs to obtain a new output. The depthwise separable convolution decomposes the standard convolution method into a depthwise convolution and a 1×1 pointwise convolution method. The depthwise separable convolution uses a depthwise convolution method to filter a single input channel with a single filter, and uses a point-by-point convolution method to combine the depthwise convolution outputs to output the final new result. The standard convolution method uses a standard convolution method with a convolution kernel size of Dk×Dk×M×N to perform convolution calculation on the input feature map of input size DF×DF×M, where DF represents the height and width of the input feature map, M represents the number of input channels, DK is the width and height of the convolution kernel, and N represents the number of output channels. The calculation amount of the standard convolution during the calculation process is DF×DF×M×N×Dk×Dk.
[0035] For the depthwise separable convolution method, a depthwise convolution is performed, and a convolution kernel of size Dk×Dk×1 is used to perform a convolution operation on the input image MF×MF×M. The amount of calculation in this process is DF×DF×M×Dk×Dk. The output of the depthwise convolution is linearly combined using a pointwise convolution method to obtain the output. The amount of calculation required for the pointwise convolution method is DF×DF×M×N, and the amount of calculation for the depthwise separable convolution is DF×DF×M×Dk×Dk+DF×DF×M×N. The use of depthwise separable convolution reduces the amount of calculation compared to standard convolution.
[0036] Use α to uniformly thin each layer. When the number of input channels M becomes αM and the number of output channels becomes αN, the amount of calculation for the depthwise separable convolution method becomes Dk×Dk×αM×DF×DF+αM×αN×DF×DF, and the width multiplier α∈(0,1], the depthwise separable convolution method reduces the calculation brightness by α after adding the channel multiplier. 2 The MobileNet network uses the resolution multiplier ρ and applies it to the input image and each layer of expression. After adding the width multiplier and the resolution multiplier, the amount of calculation of the depth-separable convolution becomes Dk×Dk×αM×ρDF×ρDF+αM×αN×ρDF×ρDF.
[0037] The MobileNet algorithm series has evolved to the MobileNetV3 algorithm. The main improvement is the addition of the SE attention module on the basis of MobileNetV2 to reduce the number of channels. The SENet module consists of three main parts: compression, excitation, and weight assignment. The SENet module re-weights the channel responses in a specific layer of the convolutional neural network by modeling the interrelationships between channels in the convolutional features.
[0038] Furthermore, the improvement ideas in step 5 are modified in the YOLOv4 code, and relevant parameters are set for training and experimental verification, including:
[0039] Improve the YOLOv4 algorithm, and implement related code modifications and training; use the MobileNetV3 network to replace the YOLOv4 feature extraction network, modify the corresponding number of channels to modify the code, add the Inceptionv3 network to the YOLOv4 detection head, and modify the corresponding code; use the improved algorithm to implement PCB defect data set training, set relevant parameters, including the number of training iterations epoch, the number of training samples in training batch_size, the training learning rate setting strategy, the training data enhancement method and the training input image size.
[0040] The step 6 of using the trained weight file to perform defect detection on the PCB data set test data set and verifying the model detection effect includes:
[0041] During the training process, a training weight file is obtained for each training, and the weight file is used to detect the PCB defect test data set, thereby achieving efficient and accurate detection of the PCB board and obtaining detection-related performance parameters.
[0042] Another object of the present invention is to provide a PCB board defect detection system using the PCB board defect detection method, the PCB board defect detection system comprising:
[0043] The data set clustering analysis module is used to implement clustering analysis of PCB defect data sets using the Bisecting K-means algorithm, and a total of 9 cluster centers of different sizes are clustered;
[0044] The data input module is used to input the cluster center value obtained by clustering the PCB defect data set by Bisecting K-means into the YOLOv4 network, and input the relevant information of the data set into the YOLOv4 algorithm;
[0045] The target detection module is used to add the InceptionV3 network to each detection head in the YOLOv4 algorithm and detect targets by using convolution kernels of multiple scales.
[0046] Algorithm improvement module, used to improve the algorithm of YOLOv4 feature extraction network, reference MobileNetV3 network to replace YOLOv4 feature extraction network, and improve YOLOv4 code according to relevant theories;
[0047] The experimental verification module is used to modify the improvement ideas in the YOLOv4 code, set relevant parameters for training, and conduct experimental verification;
[0048] The defect detection module is used to perform defect detection on the PCB data set test data set using the trained weight file and verify the model detection effect.
[0049] Another object of the present invention is to provide a computer device, the computer device comprising a memory and a processor, the memory storing a computer program, and when the computer program is executed by the processor, the processor performs the following steps:
[0050] The Bisecting K-means algorithm is used to implement cluster analysis of the PCB defect data set, and a total of 9 cluster centers of different sizes are clustered; the cluster center values obtained by clustering the PCB defect data set by Bisecting K-means are input into the YOLOv4 network, and the relevant information of the data set is input into the YOLOv4 algorithm;
[0051] In each detection head of the YOLOv4 algorithm, the InceptionV3 network is added to detect the target by using convolution kernels of various scales; the algorithm of the YOLOv4 feature extraction network is improved, the MobileNetV3 network is used to replace the YOLOv4 feature extraction network, and the YOLOv4 code is improved according to relevant theories;
[0052] The improvement ideas were modified in the YOLOv4 code, and relevant parameters were set for training and experimental verification. The weight file obtained through training was used to perform defect detection on the PCB data set test data set, and the model detection effect was verified.
[0053] Another object of the present invention is to provide a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor executes the following steps:
[0054] The Bisecting K-means algorithm is used to implement cluster analysis of the PCB defect data set, and a total of 9 cluster centers of different sizes are clustered; the cluster center values obtained by clustering the PCB defect data set by Bisecting K-means are input into the YOLOv4 network, and the relevant information of the data set is input into the YOLOv4 algorithm;
[0055] In each detection head of the YOLOv4 algorithm, the InceptionV3 network is added to detect the target by using convolution kernels of various scales; the algorithm of the YOLOv4 feature extraction network is improved, the MobileNetV3 network is used to replace the YOLOv4 feature extraction network, and the YOLOv4 code is improved according to relevant theories;
[0056] The improvement ideas were modified in the YOLOv4 code, and relevant parameters were set for training and experimental verification. The weight file obtained through training was used to perform defect detection on the PCB data set test data set, and the model detection effect was verified.
[0057] Another object of the present invention is to provide an information data processing terminal, which is used to implement the PCB board defect detection system.
[0058] In combination with all the above technical solutions, the advantages and positive effects of the present invention are as follows: the PCB board defect detection method provided by the present invention specifically relates to a PCB defect detection method combining Inceptionv3 and MobileNetV3 networks to improve YOLOv4, which mainly has the following advantages:
[0059] 1. High real-time detection, reducing the computing power requirements of industrial on-site computers. When using the YOLOv4 algorithm to detect defects on PCBs, its feature extraction network adopts a complex deep-level structure, which requires high computing power of the computer. At the same time, there are many network parameters and the calculation time is longer, which makes it difficult to meet the real-time requirements of industrial detection. Using the MobileNetV3 network instead of the YOLOv4 feature extraction network and using a lightweight feature extraction network can greatly reduce the amount of calculation while ensuring the feature extraction capability, so that the algorithm meets the real-time requirements.
[0060] 2. Stronger detection flexibility. There are many types of PCB board defects. When using YOLOv4 for defect detection, its detection head uses a 3×3 convolution kernel for detection, which may miss target details. The Inceptionv3 network is used to improve the YOLOv4 detection head, and multiple convolution kernels are used for convolution and finally spliced into features of different scales, which can effectively improve detection flexibility.
[0061] 3. Detection can better cope with changes in target size. YOLOv4 uses the K-means algorithm to perform cluster analysis on the data set. During the calculation process, the initial cluster center is first randomly selected, and then the distance to the cluster center is calculated to divide the cluster. This may cause unstable clustering results and fall into local optimality, which is not conducive to the detection of targets with multi-scale changes. It is proposed to use the Bisecting K-means algorithm to improve the K-means algorithm in YOLOv4, overcome the problem of randomly selecting the initial cluster center, and better adapt to the detection of defects of multiple scales. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0063] Figure 1 The figure is a flow chart of a PCB board defect detection method provided by an embodiment of the present invention.
[0064] Figure 2 It is a structural block diagram of a PCB board defect detection system provided by an embodiment of the present invention;
[0065] In the figure: 1. Data set clustering analysis module; 2. Data input module; 3. Algorithm improvement module; 4. Target detection module; 5. Experimental verification module; 6. Defect detection module.
[0066] FIG3 is a schematic diagram of an Inceptionv3 network module provided by an embodiment of the present invention.
[0067] FIG. 3( a ) is a schematic diagram of a module 1 provided in an embodiment of the present invention.
[0068] FIG3( b ) is a schematic diagram of a module 2 provided in an embodiment of the present invention.
[0069] FIG3( c ) is a schematic diagram of module 3 provided in an embodiment of the present invention.
[0070] FIG4 is a schematic diagram of a standard convolution method and a depth-separable convolution method provided by an embodiment of the present invention.
[0071] FIG4( a ) is a schematic diagram of a traditional convolution method provided in an embodiment of the present invention.
[0072] FIG4( b ) is a schematic diagram of a depth convolution method provided in an embodiment of the present invention.
[0073] FIG4( c ) is a schematic diagram of a point convolution method provided in an embodiment of the present invention.
[0074] Figure 5 It is a schematic diagram of the SE channel attention mechanism module provided by an embodiment of the present invention.
[0075] Figure 6 It is a cluster center graph obtained by using an improved Bisecting K-means algorithm on a data set provided by an embodiment of the present invention.
[0076] Figure 7 It is a parameter diagram of the improved MobilNetV3-YOLOv4-Inceptionv3 network structure provided by an embodiment of the present invention.
[0077] Figure 8 It is a mAP graph of the trained model detection provided by an embodiment of the present invention.
[0078] FIG. 9 is a diagram showing actual detection effects of performing defect detection on a PCB using a trained model provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0079] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0080] In view of the problems existing in the prior art, the present invention provides a PCB board defect detection method, system, medium, device and terminal. The present invention is described in detail below with reference to the accompanying drawings.
[0081] like Figure 1 As shown, the PCB board defect detection method provided by the embodiment of the present invention includes the following steps:
[0082] S101, using the Bisecting K-means algorithm to implement cluster analysis of PCB defect data sets, a total of 9 cluster centers of different sizes were clustered;
[0083] S102, inputting the cluster center value obtained by clustering the PCB defect data set by Bisecting K-means into the YOLOv4 network, and inputting the relevant information of the data set into the YOLOv4 algorithm;
[0084] S103, in each detection head of the YOLOv4 algorithm, add the InceptionV3 network to detect the target by using convolution kernels of multiple scales;
[0085] S104, improve the algorithm of the YOLOv4 feature extraction network after the improved detection network, quote the MobileNetV3 network to replace the YOLOv4 feature extraction network, and improve the YOLOv4 code according to relevant theories;
[0086] S105, modify the improvement ideas in the YOLOv4 code, set relevant parameters for training and conduct experimental verification;
[0087] S106, using the trained weight file to perform defect detection on the PCB data set test data set, and verifying the model detection effect.
[0088] like Figure 2 As shown, the PCB board defect detection system provided by the embodiment of the present invention includes:
[0089] Dataset clustering analysis module 1 is used to implement clustering analysis of PCB defect datasets using the Bisecting K-means algorithm, and a total of 9 cluster centers of different sizes are clustered;
[0090] Data input module 2, used to input the cluster center value obtained by clustering the PCB defect data set by Bisecting K-means into the YOLOv4 network, and input the relevant information of the data set into the YOLOv4 algorithm;
[0091] Object detection module 3 is used to add the InceptionV3 network to each detection head in the YOLOv4 algorithm and detect objects by using convolution kernels of multiple scales;
[0092] Algorithm improvement module 4 is used to improve the algorithm of the YOLOv4 feature extraction network, reference the MobileNetV3 network to replace the YOLOv4 feature extraction network, and improve the YOLOv4 code based on relevant theories;
[0093] Experimental verification module 5 is used to modify the improvement ideas in the YOLOv4 code, set relevant parameters for training and conduct experimental verification;
[0094] The defect detection module 6 is used to perform defect detection on the PCB data set test data set using the trained weight file and verify the model detection effect.
[0095] The technical solution of the present invention is further described below in conjunction with specific embodiments.
[0096] 1. Purpose of the invention:
[0097] The purpose of the present invention is to detect defects on PCB. In view of the problems that there are many types of PCB defects, the size span of defects between different types is large, and the application of YOLOv4 has low detection timeliness and low accuracy, a PCB defect detection method combining Inceptionv3 and MobileNetV3 networks to improve YOLOv4 is proposed. The technical solution adopted by this method is:
[0098] The PCB defect detection method provided by the embodiment of the present invention combines the Inceptionv3 and MobileNetV3 networks to improve the YOLOv4, and the steps included are as follows:
[0099] (1) The Bisecting K-means algorithm is used to implement cluster analysis of the PCB defect data set, and a total of 9 cluster centers of different sizes are clustered;
[0100] (2) The cluster center values obtained by clustering the PCB defect data set by Bisecting K-means are input into the YOLOv4 network, and the data set and other related information are input into the YOLOv4 algorithm.
[0101] (3) In each detection head of the YOLOv4 algorithm, an InceptionV3 network is added to detect targets by using convolution kernels of various scales, thereby improving detection accuracy.
[0102] (4) Improve the algorithm of the improved YOLOv4 feature extraction network, quote the MobileNetV3 network instead of the YOLOv4 feature extraction network, and improve the YOLOv4 code based on relevant theories.
[0103] (5) Modify the improvement ideas in the YOLOv4 code, set relevant parameters for training, and conduct experimental verification.
[0104] (6) Use the trained weight file to perform defect detection on the PCB dataset and test dataset, and verify the model detection effect. 2. Summary of the invention:
[0106] According to the requirements of step (1), the Bisecting K-means algorithm is mainly used to implement cluster analysis of the PCB defect data set. Nine cluster centers of different sizes are obtained through cluster analysis as the anchor box values of YOLOv4. The specific process is to use the public PCB defect data set to perform the Bisecting K-means clustering algorithm. The main process is to use the calibration box data of all calibration data sets as input, all data as a cluster cluster, and then divide the cluster into two clusters using the K-means algorithm, and calculate the error of each cluster. Select the cluster that can minimize the clustering loss function, i.e., IoU, and divide it into two clusters. Continue in this way until the number of selected clusters reaches the K value given by the user. Among them, the error IOU calculation formula is as follows:
[0107]
[0108] Where box i Represents the value of the i-th calibration frame, cen j Represents the value of the jth anchor box. The improved Bisecting K-means clustering algorithm is used to cluster the data set, and a total of 9 anchor boxes are clustered.
[0109] According to the requirements of step (2), it is necessary to input the cluster center obtained by using the Bisecting K-means algorithm into YOLOv4, and use the Bisecting K-means algorithm to cluster the PCB defect data set to obtain the cluster center value, and input these values into the YOLOv4 model parameters in order from small to large. Then set the defect category to be detected, and input the category to be set into the relevant parameters of the YOLOv4 model. Use the retention method to divide all data sets, set the training data set and the verification data set according to the ratio of 9:1, and compile the relevant information of each data set into a text document and input it into the YOLOv4 model.
[0110] According to the requirements of step (3), the Inceptionv3 network is mainly added to the YOLOv4 detection head to realize the detection of features with convolution kernels of various scales. The Inceptionv3 network has the high performance characteristics of dense matrices while maintaining a sparse structure. The network expands the convolution operation between neural network layers, uses convolution kernels of different sizes (1×1, 3×3, 5×5) for convolution, and finally splices them together to fuse features of different scales, thereby reducing the amount of calculation and improving the recognition ability of the model. Therefore, in order to meet the requirements of multi-category defect detection in PCB, the Inceptionv3 structure is added to the algorithm detection layer to increase the network depth without increasing the number of parameters, thereby improving the detection performance.
[0111] The Inceptionv3 model mainly follows four optimization methods and principles: (1) appropriately reducing bottlenecks to prevent information loss; (2) higher-dimensional feature representation, sparser and more coupled, specifically implemented by module 1 in Figure 3 (a); (3) spatial aggregation embedded into smaller dimensions, reducing the number of parameters without reducing the network representation ability, specifically implemented by module 2 in Figure 3 (b); (4) balancing network width and depth, specifically implemented by module 3 in Figure 3 (c).
[0112] According to the requirements of step (4), the MobileNetV3 network is mainly used to improve the YOLOv4 feature extraction network. The MobileNetv3 network is the third updated version of the MobileNet network. In 2017, Google proposed the lightweight convolutional neural network MobileNet network. Its biggest feature is the use of depth-separable convolution and the introduction of two shrinkage hyperparameters: width multiplier and resolution multiplier.
[0113] The standard convolution method combines and calculates all inputs to obtain a new output, as shown in Figure 4 (a). The depthwise separable convolution decomposes the standard convolution method into a depthwise convolution and a 1×1 pointwise convolution method, which can effectively reduce the amount of calculation and model size, as shown in Figure 4 (b) and (c). The depthwise separable convolution first uses a depthwise convolution method to filter a single input channel with a single filter, and then uses a pointwise convolution method to combine the depthwise convolution output to output the final new result. The standard convolution method uses a standard convolution method with a convolution kernel size of Dk×Dk×M×N to convolve the input feature map with a feature map of input size DF×DF×M, where DF represents the height and width of the input feature map, M represents the number of input channels, DK is the width and height of the convolution kernel, and N represents the number of output channels. The amount of calculation in the standard convolution process is DF×DF×M×N×Dk×Dk. For the depthwise separable convolution method, first perform depthwise convolution, and use the convolution kernel of size Dk×Dk×1 to perform convolution operation on the input image MF×MF×M. The amount of calculation in this process is DF×DF×M×Dk×Dk. Then, the output of the depthwise convolution is linearly combined using the pointwise convolution method to obtain the output. The amount of calculation required for the pointwise convolution method is DF×DF×M×N. Therefore, the amount of calculation for depthwise separable convolution is DF×DF×M×Dk×Dk+DF×DF×M×N. Therefore, the use of depthwise separable convolution reduces the amount of calculation compared to standard convolution. When the depth convolution kernel size is 3×3, the amount of computation is 8 to 9 times less than that of standard convolution.
[0114] At the same time, the MobileNet network uses a width multiplier α to further reduce the amount of channel calculation, and uses α to uniformly thin each layer, that is, the number of input channels M becomes αM, and the number of output channels becomes αN, so that the amount of calculation of the depth-separable convolution method becomes Dk×Dk×αM×DF×DF+αM×αN×DF×DF, and the width multiplier α∈(0,1], after adding the channel multiplier, the amount of calculation of the depth-separable convolution method is further reduced by about α 2 The MobileNet network also uses the resolution multiplier ρ to reduce the amount of neural network calculations. It is applied to the input image and each layer of expression. After adding the width multiplier and resolution multiplier, the amount of depth-separable convolution calculation becomes Dk×Dk×αM×ρDF×ρDF+αM×αN×ρDF×ρDF.
[0115] In order to further improve the detection accuracy and speed, the MobileNet algorithm series has developed to the MobileNetV3 algorithm. Its main improvement is to add the SE (Squeeze and Exciation) attention module on the basis of MobileNetV2 and reduce the number of channels, such as Figure 5 As shown in Figure 2, the SENet module consists of three main parts: Squeeze, Excitation, and weight assignment. The SENet module re-weights the channel responses in a specific layer of the convolutional neural network by modeling the interrelationships between channels in the convolutional features to enhance the network's extraction of useful information.
[0116] According to the requirements of step (5), the main thing is to improve the YOLOv4 algorithm and implement related code modification and training. Add the Inceptionv3 network to the YOLOv4 detection head, modify the corresponding code, use the MobileNetV3 network to replace the YOLOv4 feature extraction network, modify the corresponding number of channels to modify the code. Use the improved algorithm to implement the training of the PCB defect data set, and set the relevant parameters, mainly including the number of training iterations epoch, the number of training samples batch_size in training, the training learning rate setting strategy, the training data enhancement method, the training input image size and other related parameters.
[0117] According to the requirements of step (6), during the training process, a weight file for each training is obtained, and the weight file is used to detect the PCB defect test data set, realize efficient and accurate detection of PCB boards, and obtain detection-related performance parameters.
[0118] Example 2
[0119] like Figure 2 As shown, the improved YOLOv4-based PCB defect detection algorithm provided by the embodiment of the present invention includes:
[0120] Step 101: Use the Bisecting K-means algorithm to cluster the PCB defect data set to obtain a specified number of cluster centers.
[0121] The Bisecting K-means algorithm is used to cluster the relevant information of the PCB calibration data set. According to the calibration frame length and width information of the calibration data, the Bisecting K-means clustering algorithm is used to obtain 9 cluster center values of different sizes. The specific locations of the cluster centers in the data set are as follows: Figure 6 The cluster center values obtained by clustering the PCB defect dataset using the Bisecting K-means algorithm are: (20, 21), (33, 22), (22, 34), (43, 34), (30, 46), (62, 24), (25, 69), (52, 68), (69, 52).
[0122] Step 102: input the anchor frame information obtained by clustering the data set, the training data set in the data set, the defect type and other related information into the YOLOv4 algorithm network.
[0123] The PCB defect data set is clustered using the Bisecting K-means algorithm. The image size is set to 608 pixels × 608 pixels, and the clustering results are (20, 21), (33, 22), (22, 34), (43, 34), (30, 46), (62, 24), (25, 69), (52, 68), (69, 52). The clustering results are sorted from small to large and input into the anchor information in the model_data in the YOLOv4 algorithm. The train.txt and trainval.txt file information are obtained based on the image information and annotation information of the data set. These text documents store information such as pictures and paths in the training data set and the verification data set. Then the defect category information is input into the classes.txt text document. The defect category information set by the present invention is: missing_hole, mouse_bite, open_circuit, short, spur, spurious_copper. Then the pre-trained weight file is downloaded and input into the model_data folder. At this point, the relevant settings for the data required by the model are completed.
[0124] Step 103: Build the Inceptionv3 network, add the Inceptionv3 network to the YOLOv4 feature detection network, and make corresponding code modifications.
[0125] The Inceptionv3 network has the high performance characteristics of dense matrices while maintaining a sparse structure. The network expands the convolution operations between neural network layers, uses convolution kernels of different sizes (1×1, 3×3, 5×5) for convolution, and finally splices them together to fuse features of different scales, thereby reducing the amount of calculation while improving the recognition ability of the model. It follows four optimization methods and principles: (1) appropriately reduce bottlenecks to prevent information loss; (2) higher-dimensional feature representation, which is sparser and more coupled; (3) spatial aggregation is embedded into smaller dimensions to reduce the number of parameters without reducing the network representation ability; (4) balance the network width and depth. The specific network structure is shown in Table 1. The improved Inceptionv3 network is added to the YOLOv4 feature detection network, and the YOLOv4 network structure of the improved feature extraction network and feature detection network is shown in the following table. Figure 8 As shown, modify the corresponding detection network code and network parameters in YOLOv4.
[0126] Table 1 Network parameters of each layer of Inceptionv3
[0127]
[0128] Step 104: Change the YOLOv4 feature extraction network after the improved detection network, and use MobileNetV3 as the YOLOv4 feature extraction network instead, and modify the code using relevant principles.
[0129] The YOLOv4 detection network uses the CSPDarknet53 network as the feature extraction network, which has the problem of large computational complexity and insufficient ability to extract features for small targets. Therefore, it is proposed to use the lightweight feature extraction network MobileNetV3 network as its feature extraction network. The biggest feature of the MobileNetV3 network is the use of depthwise separable convolution and the introduction of two shrinkage hyperparameters: width multiplier and resolution multiplier. The standard convolution method combines and calculates all inputs to obtain a new output. For the feature map of input size DF×DF×M, the standard convolution method with a convolution kernel size of Dk×Dk×M×N is used to perform convolution calculation on the input feature map, where DF represents the height and width of the input feature map, M represents the number of input channels, DK is the width and height of the convolution kernel, and N represents the number of output channels. The computational complexity of the standard convolution during the calculation process is DF×DF×M×N×Dk×Dk. Depthwise separable convolution decomposes the standard convolution into a depthwise convolution and a 1×1 pointwise convolution. The input image MF×MF×M is convolved with a convolution kernel of size Dk×Dk×1. The amount of computation required in this process is DF×DF×M×Dk×Dk. Then, the output of the depthwise convolution is linearly combined using pointwise convolution to obtain the output. The amount of computation required for the pointwise convolution is DF×DF×M×N. Therefore, the amount of computation required for depthwise separable convolution is DF×DF×M×Dk×Dk+DF×DF×M×N. Therefore, the amount of computation required for depthwise separable convolution is DF×DF×M×Dk×Dk+DF×DF×M×N. Therefore, depthwise separable convolution reduces the amount of computation compared to standard convolution. When the size of the deep convolution kernel used is 3×3, the amount of computation is 8 to 9 times less than that of the standard convolution. The MobileNet network uses the width multiplier α to further reduce the channel calculation amount, and uses α to uniformly thin each layer and the reverse, that is, the number of input channels M becomes αM, and the number of output channels becomes αN, so that the calculation amount of the deep separable convolution method becomes Dk×Dk×αM×DF×DF+αM×αN×DF×DF, and the width multiplier α∈(0,1], after adding the channel multiplier, the calculation amount of the deep separable convolution method is further reduced by about α 2 The MobileNet network also uses the resolution multiplier ρ to reduce the amount of neural network calculations, which is applied to the input image and each layer of expression. After adding the width multiplier and resolution multiplier, the amount of depth-separable convolution calculation becomes Dk×Dk×αM×ρDF×ρDF+αM×αN×ρDF×ρDF. The specific MobileNetV3 network layers and related parameters are shown in Table 2. The MobileNetV3 network is built according to the relevant parameters and applied to the YOLOv4 feature extraction network to modify the relevant parameters.
[0130] Table 2 MobileNetV3 network parameters
[0131]
[0132]
[0133] Step 105: Train the improved YOLOv4 algorithm and set relevant parameters for training in combination with the pre-trained weight file.
[0134] The YOLOv4 algorithm that uses MobileNetV3 to improve the YOLOv4 feature extraction network and add the Inceptionv3 network to YOLOv4 is trained. During the training process, the image input size is set to (608pixels×608pixels) and the number of iterations is set to 300. In these 300 iterations, the first 100 iterations are frozen training, that is, the feature extraction network parameters are not changed, only other parameters are changed, the learning rate is set to 0.001, and the batch_size is set to 16. After 100 epochs, non-frozen training is performed, the learning rate is set to 0.0001, the batch_size is set to 8, and the learning rate optimization method uses the Adam method, and the data enhancement method is not used. After training, a trained network model is obtained. The improved MobilNetV3-YOLOv4-Inceptionv3 network structure parameters are as follows Figure 7 shown.
[0135] Step 106: Use the trained weight file to perform defect detection on the PCB data set test data set to verify the model detection effect.
[0136] Put the defect sample images to be inspected into the sample folder under the dataset, use the obtained weight file and network to detect the defect samples, and obtain the defect category, location and confidence information. The average time to detect an image is: 23.5 milliseconds, and the model's detection mAP is as follows Figure 8 As shown, the obtained detection result is shown in Figure 9. It can be seen from the figure that, through the method of the present invention, the cover glass defect information can be accurately obtained, and the industrial real-time requirements can be met.
[0137] In the description of the present invention, unless otherwise specified, "plurality" means two or more than two; the orientations or positional relationships indicated by the terms "upper", "lower", "left", "right", "inner", "outer", "front end", "rear end", "head", "tail", etc. are based on the orientations or positional relationships shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operate in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", "third", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance.
[0138] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When the use is implemented in whole or in part in the form of a computer program product, the computer program product includes one or more computer instructions. When the computer program instructions are loaded or executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL) or wireless (e.g., infrared, wireless, microwave, etc.) mode) to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0139] The above description is only a specific implementation mode of the present invention, but the protection scope of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by any technician familiar with the technical field within the technical scope disclosed by the present invention and within the spirit and principle of the present invention should be covered by the protection scope of the present invention.
Claims
1. A PCB board defect detection method, It is characterized in that The PCB board defect detection method comprises the following steps: Step 1: Use the Bisecting K-means algorithm to perform cluster analysis on the PCB defect data set and cluster multiple cluster centers of different sizes; Step 2: Input the cluster center value obtained by clustering the PCB defect data set by Bisecting K-means into the YOLOv4 network, and input the relevant information of the data set into the YOLOv4 algorithm; Step 3: In each detection head in the YOLOv4 algorithm, add the InceptionV3 network to detect the target by using convolution kernels of multiple scales. Step 4: Improve the algorithm of the feature extraction network after the improved YOLOv4 algorithm, quote the lightweight network MobileNetV3 network as the YOLOv4 feature extraction network, and improve the YOLOv4 code according to relevant theories; Step 5: Modify the improvement ideas in the YOLOv4 code, set relevant parameters for training and conduct experimental verification; Step 6: Use the trained weight file to perform defect detection on the PCB data set test data set and verify the model detection effect; In step 1, the Bisecting K-means algorithm is used to implement cluster analysis of the PCB defect data set, and a total of 9 cluster centers of different sizes are clustered, including: The Bisecting K-means algorithm is used to implement cluster analysis of the PCB defect data set. Nine cluster centers of different sizes are obtained through cluster analysis as the anchor box values of YOLOv4, including: The Bisecting K-means clustering algorithm is used on the public PCB defect dataset. The calibration box data of all calibration datasets are used as input, and all data are regarded as a cluster. The cluster is divided into two clusters using the K-means algorithm, and the error of each cluster is calculated. The cluster that can minimize the cluster loss function IoU is selected and divided into two clusters, and this process is continued until the number of selected clusters reaches the K value given by the user. Among them, the error IOU calculation formula is as follows: In the formula, box i Represents the value of the i-th calibration frame, cen j Represents the value of the jth anchor box; the improved Bisecting K-means clustering algorithm is used to cluster the data set, and a total of 9 anchor boxes are clustered; In the step 2, the cluster center value obtained by clustering the PCB defect data set by Bisecting K-means is input into the YOLOv4 network, and the relevant information of the data set is input into the YOLOv4 algorithm, including: The cluster centers obtained by using the Bisecting K-means algorithm are input into YOLOv4, and the cluster center values obtained by clustering the PCB defect data set using the Bisecting K-means algorithm are input into the YOLOv4 model parameters in order from small to large; the defect categories to be detected are set, and the categories to be set are input into the relevant parameters of the YOLOv4 model; all data sets are divided into data sets using the holdout method, and the training data set and the verification data set are set according to the ratio of 9:
1. The relevant information of each data set is compiled into a text document and input into the YOLOv4 model; In the step 4, the algorithm of the YOLOv4 feature extraction network is improved, the MobileNetV3 network is used to replace the YOLOv4 feature extraction network, and the YOLOv4 code is improved according to relevant theories, including: The MobileNetV3 network is used to improve the YOLOv4 feature extraction network; the MobileNetv3 network is the third updated version of the MobileNet network, which uses depthwise separable convolution and introduces two shrinkage hyperparameters, namely, width multiplier and resolution multiplier; The standard convolution method combines all inputs and calculates them to get a new output. The depthwise separable convolution decomposes the standard convolution method into a depthwise convolution and a 1×1 pointwise convolution method. The depthwise separable convolution uses a depthwise convolution method to filter a single input channel with a single filter, and uses a pointwise convolution method to combine the depthwise convolution output to output the final new result. The standard convolution method, for input size D F ×D F ×M size feature map, using a convolution kernel size of D k ×D k ×M×N standard convolution method is used to perform convolution calculation on the input feature map, where D F represents the height and width of the input feature map, M represents the number of input channels, and D k is the width and height of the convolution kernel, N represents the number of output channels, and the amount of calculation in the standard convolution process is D F ×D F ×M×N×D k ×D k ; For the depth-separable convolution method, perform depth convolution on the input image M F ×M F ×M images are taken using D k ×D k ×1 size convolution kernel for convolution operation. The amount of calculation in this process is D F ×D F ×M×D k ×D k ; The output of the depth convolution is linearly combined using the point-by-point convolution method to obtain the output. The amount of calculation required for the point-by-point convolution method is D F ×D F ×M×N, the amount of computation required for depthwise separable convolution is D F ×D F ×M×D k ×D k +D F ×DF×M×N; depthwise separable convolution reduces computational complexity compared to standard convolution Use α to uniformly thin each layer, the number of input channels M becomes αM, the number of output channels becomes αN, and the amount of calculation of the depthwise separable convolution method becomes D k ×D k ×αM×D F ×D F +αM×αN×D F ×D F , width multiplier α∈(0,1], after adding channel multiplier, depth separable convolution method is used to calculate brightness and then reduce α 2 times; MobileNet network uses resolution multiplier ρ and applies it to the input image and each layer of expression. After adding width multiplier and resolution multiplier, the amount of depth separable convolution calculation becomes D k ×D k ×αM×ρD F ×ρD F +αM×αN×ρD F ×ρD F ; The MobileNet algorithm series has developed to the MobileNetV3 algorithm. The main improvement is the addition of the SE attention module on the basis of MobileNetV2 to reduce the number of channels; the SENet module contains three main parts: compression, excitation and weight assignment; the SENet module re-weights the channel responses in a specific layer of the convolutional neural network by modeling the relationship between channels in the convolutional features.
2. The PCB board defect detection method as claimed in claim 1, It is characterized in that In step 3, in each detection head in the YOLOv4 algorithm, an InceptionV3 network is added to detect the target by using convolution kernels of multiple scales, including: The Inceptionv3 network is added to the YOLOv4 detection head to realize feature detection using convolution kernels of various scales. The network expands the convolution operations between neural network layers and uses convolution kernels of different sizes (1×1, 3×3, and 5×5) to perform convolution and combine them to fuse features of different scales. The Inceptionv3 structure is added to the algorithm detection layer to increase the network depth without increasing the number of parameters.
3. The PCB board defect detection method as claimed in claim 1, It is characterized in that In step 5, the improvement ideas are modified in the YOLOv4 code, and relevant parameters are set for training and experimental verification, including: Improve the YOLOv4 algorithm, and implement relevant code modification and training; use the MobileNetV3 network to replace the YOLOv4 feature extraction network, modify the corresponding number of channels to modify the code, add the Inceptionv3 network to the YOLOv4 detection head, and modify the corresponding code; use the improved algorithm to implement the training of the PCB defect data set, and set relevant parameters, including the number of training iterations epoch, the number of training samples batch_size in training, the training learning rate setting strategy, the training data enhancement method, and the training input image size; The step 6 uses the trained weight file to perform defect detection on the PCB data set test data set and verifies the model detection effect, including: During the training process, a training weight file is obtained for each training, and the weight file is used to detect the PCB defect test data set, thereby achieving efficient and accurate detection of the PCB board and obtaining detection-related performance parameters.
4. A PCB board defect detection system using the PCB board defect detection method according to any one of claims 1 to 3, It is characterized in that The PCB board defect detection system comprises: The data set clustering analysis module is used to implement clustering analysis of PCB defect data sets using the Bisecting K-means algorithm, and a total of 9 cluster centers of different sizes are clustered; The data input module is used to input the cluster center value obtained by clustering the PCB defect data set by Bisecting K-means into the YOLOv4 network, and input the relevant information of the data set into the YOLOv4 algorithm; The target detection module is used to add the InceptionV3 network to each detection head in the YOLOv4 algorithm and detect targets by using convolution kernels of multiple scales. Algorithm improvement module, used to improve the algorithm of YOLOv4 feature extraction network, reference MobileNetV3 network to replace YOLOv4 feature extraction network, and improve YOLOv4 code according to relevant theories; The experimental verification module is used to modify the improvement ideas in the YOLOv4 code, set relevant parameters for training, and conduct experimental verification; The defect detection module is used to perform defect detection on the PCB data set test data set using the trained weight file and verify the model detection effect.
5. A computer device, It is characterized in that The computer device includes a memory and a processor, the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the PCB board defect detection method according to any one of claims 1 to 3.
6. A computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor executes the steps of the PCB board defect detection method according to any one of claims 1 to 3.
7. An information data processing terminal, It is characterized in that The information data processing terminal is used to implement the PCB board defect detection system as described in claim 4.
