Automatic PCB defect detection method based on deep learning
By constructing a small defect detection network based on deep learning methods, combined with feature pyramid transformation, the problems of low efficiency and low accuracy in PCB defect detection are solved, efficient automatic detection and identification are achieved, and the reliability and efficiency of detection are significantly improved. .
Patent Information
- Application Number
- CN202010675846.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-14
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2040-07-14
AI Technical Summary
The existing technology has problems of low efficiency and low accuracy in PCB defect detection, especially due to the complexity of different PCBs and the diversity of defect types, which makes traditional methods incompatible and data imbalanced, resulting in high false detection and missed detection rates. .
Using a method based on deep learning, through preprocessing and data enhancement, a small defect detection network is constructed, and a model that can automatically detect and identify PCB defects is trained by combining deep learning algorithms and feature pyramid transformation, including using ResNet-101 as the backbone convolution. network, extract features and associate upper and lower feature maps through feature pyramid transformation, optimizing the model to improve detection accuracy.
Automatic detection and identification of PCB defects is realized, saving labor costs, and the fault detection rate reaches more than 95%, which greatly improves the efficiency and reliability of detection.
Smart Images

Figure CN111862025B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of printed circuit board defect detection and small target recognition, and specifically relates to a PCB defect automatic detection method based on deep learning. Background Art
[0002] A printed circuit board (PCB) is essentially a board of electronic components that are mechanically supported and electrically connected. It is a fundamental component in the design process of all electronic products and has evolved over the years to become a very complex component. PCBs are widely used in all but the simplest electronic products, and the 2019 Global Single-Sided Printed Circuit Board Market Analysis Report estimates that the printed circuit board market will reach $85 billion by 2025. However, currently, visual defect detection to ensure the quality of PCB products is often the largest cost of PCB manufacturing. In recent years, automated optical inspection (AOI) systems have replaced most manual inspections and improved inspection accuracy, but their false detection and missed detection rates are still too high.
[0003] There are three main problems in PCB defect detection. First, there are various PCBs in electronic products. Different PCBs have wiring design rules of different complexity, which makes it difficult for general algorithms to be compatible with various PCBs. Therefore, traditional PCB defect detection methods may be unstable. Second, the types and characteristics of PCB defects are usually different. Third, it is very difficult to collect a large number of PCB defect samples in industry, which leads to data imbalance in some traditional methods. PCB defects can be divided into two categories: functional defects and appearance defects. Functional defects can seriously affect the performance of PCBs and lead to abnormal use of PCBs. These defects are the most serious defects. Appearance defects mainly affect the appearance of PCBs, but in the long run, they will also damage the performance of PCBs due to abnormal heat dissipation and current distribution. Among these two types of defects, six types of defects are often seen in industrial production, including missing holes, rat bites, open circuits, short circuits, bone spurs and excess copper. At present, industrial production defect detection widely relies on automatic optical detection and manual detection. Both detection accuracy and manual errors may have great consequences. Realizing automatic recognition and detection of PCB defects has a far-reaching impact on saving labor costs and reducing detection error rates. Summary of the invention
[0004] The purpose of the present invention is to provide a PCB defect automatic detection method based on deep learning, to solve the problems of low efficiency and low precision in PCB defect detection, to realize automatic detection and target recognition of six major defects, to save labor costs and greatly improve the efficiency and reliability of defect detection.
[0005] The technical solution to achieve the purpose of the present invention is: a method for automatic detection of PCB defects based on deep learning, the steps are as follows:
[0006] (1) Preprocess the raw data, convert the data format and size, and complete the data set division;
[0007] (2) Perform data enhancement on the preprocessed image;
[0008] (3) Input the enhanced data into the micro-defect detection network to train a defect detection model;
[0009] (4) Evaluate the performance of the trained model;
[0010] (5) Combined with the evaluation results of step (4), the model is further optimized.
[0011] Compared with the prior art, the present invention has the following significant advantages: (1) The present invention proposes a new micro-defect detection network, which can better learn the characteristics of micro-defect detection and solve some problems existing in traditional detection methods; (2) The present invention combines the deep learning algorithm with the feature pyramid transformation to solve the PCB defect detection problem and associates the upper and lower feature maps; (3) The present invention realizes automatic detection and identification of PCB defects and saves labor costs; (4) The present invention has a high fault detection rate, which can reach more than 95%, greatly improving the reliability and efficiency of traditional methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Figure 1 This is a flow chart of the automatic PCB defect detection method based on deep learning of the present invention. DETAILED DESCRIPTION
[0013] like Figure 1 As shown, a method for automatic PCB defect detection based on deep learning, the steps are as follows:
[0014] (1) Preprocess the raw data, convert the data format and size, and complete the data set division;
[0015] (2) Perform data enhancement on the preprocessed image;
[0016] (3) Input the enhanced data into the micro-defect detection network to train a defect detection model;
[0017] (4) Evaluate the performance of the trained model;
[0018] (5) Refer to the evaluation results of step (4) to further optimize the model.
[0019] The preprocessing converts the data set format into a unified data input format for the TensorFlow interface, and the PCB image size is 600 × 600. The data set is divided into two parts: a training data set of 8250 images and a test data set of 2102 images.
[0020] Six classic data enhancement methods are used, including Gaussian noise addition, illumination change, image rotation, flipping, random cropping and shifting, and threshold filtering is performed on the results produced by the image rotation, flipping, random cropping and shifting methods.
[0021] The step (3) constructs a new micro-defect detection network and conducts deep learning model training, specifically:
[0022] (3.1) Based on the characteristics of common PCB defects, the standard k-means algorithm with distance metric is used to set the scale of the framed area to {15 2 , 25 2 , 40 2 , 60 2}, the aspect ratio is set to {2:1, 3:1, 4:1, 5:1};
[0023] (3.2) Use ResNet-101 as the backbone convolutional network to extract features. Pre-train the ResNet-101 model on the ImageNet classification set and fine-tune it on the PCB defect dataset;
[0024] (3.3) Using the structural information of the high-resolution feature map, the low-level feature map is connected with the high-level feature map to create a top-down feature map.
[0025] Drawing on the idea of transfer learning, the backbone convolutional network ResNet-101 is pre-trained in the ImageNet classification set, and only the parameters need to be fine-tuned when carrying out defect detection work in the later stage.
[0026] Combine deep learning methods with feature pyramid transformation to increase the connection between upper and lower feature layers.
[0027] In step (4), the evaluation of the model is mainly divided into two aspects: defect area positioning and defect classification. For defect area positioning, the intersection over union (IoU) is calculated as the evaluation index; for defect classification, the mean average precision (mAP) is used as the evaluation index.
[0028] In the step (5), when the evaluation result fails to meet the detection requirements, the parameters such as the intersection threshold, learning rate and momentum can be fine-tuned while increasing the diversity and quantity of training samples.
[0029] The automatic defect detection process can be easily extended to detect tiny defects in other fields.
[0030] The specific embodiments of the present invention are further described in detail below with reference to the accompanying drawings.
[0031] Example
[0032] like Figure 1 As shown in the figure, a method for automatic PCB fault detection based on deep learning is shown in the figure. The steps are as follows:
[0033] (1) Preprocess the raw data, convert the data format and size, and complete the data set division;
[0034] First, the PCB image is cropped into 600×600 sub-images, and then the dataset format is converted to a unified data input format for the TensorFlow interface, and then the dataset is divided into two parts: training and reasoning. Among them, the training dataset contains 8250 images and the test dataset contains 2102 images.
[0035] (2) Perform data enhancement on the preprocessed image;
[0036] Data augmentation purpose:
[0037] 1) Expand the training samples to reduce the risk of overfitting of neural network parameters;
[0038] 2) Reduce collection costs, the number of defective PCBs is small, and the collection cycle is long;
[0039] The present invention adopts six traditional data enhancement techniques, including Gaussian noise addition, illumination change, image rotation, flipping, random cropping and shifting. Among them, simple operations such as Gaussian noise addition or illumination change do not require changing the value of the bounding box. When rotating, shearing and moving the image, the corresponding value of the bounding box has been changed, and the method is used to further adjust it. The key problem of the six data enhancement methods is the defective truncation in the random cropping stage, setting a threshold and discarding these abnormal bounding boxes.
[0040] (3) Input the enhanced data into a new micro-defect detection network to train a defect detection model;
[0041] (3.1) PCB defect images are different from the common images in open source datasets. PCB images collected by industrial cameras usually have a large resolution, such as 2777×2138, while the defects in the image only occupy a small part of the entire image area. Therefore, it is necessary to design a reasonable anchor point size. K-means clustering is used on the bounding box of the PCB training set to automatically find a reasonable anchor point size. Using the standard k-means algorithm with a distance metric, the scale of the framed area is set to {152 , 25 2 , 40 2 , 60 2}, and the aspect ratio is set to {2:1, 3:1, 4:1, 5:1}.
[0042] (3.2) Use ResNet-101 as the backbone convolutional network to extract features. First, the ResNet-101 model was pre-trained in the ImageNet classification set, and then the training was transferred to the PCB defect dataset, and the parameters were fine-tuned. Among them, four residual blocks {conv2_x, conv3_x, conv4_x, conv5_x} are set in the ResNets model, and the output of the last residual block is used as the feature map reference set. The outputs of the residual blocks conv2, conv3, conv4 and conv5 are represented as C2, C3, C4 and C5 respectively. Relative to the input image, the sliding stride is set to {4, 8, 16, 32} respectively.
[0043] (3.3) Connect the feature maps of the lower and higher layers. First, in order to reduce the channel size, a 1×1 convolution operation is performed on each corresponding feature map from bottom to top, and then the upsampled map is connected to the corresponding bottom-up map by element-by-element addition. The process is as follows: the last output feature map {C5} of the last layer is passed through a 1×1 convolution layer to produce the coarsest resolution map, and then this feature map is upsampled by 2 times, and finally the upsampled feature map is merged with the low-level feature map. After the map connection is completed, a 3×3 convolution layer is attached to each merged feature map to generate the final feature map. The final set of feature maps corresponding to {C2, C3, C4, C5} is represented as {P2, P3, P4, P5}, and the spatial size of the two remains unchanged.
[0044] (4) Evaluate the performance of the trained model;
[0045] The evaluation of the model mainly considers two aspects: defect area localization and defect classification. For defect area localization, the intersection over union (IoU) is calculated as the evaluation metric. By default, the IoU threshold is set to 0.5 to determine the true positive value on the PCB defect dataset.
[0046]
[0047] Where GT represents the basic truth and DR represents the detection result. For defect classification, the mean average precision (mAP) is used as the evaluation metric. Usually, the IoU with a threshold of 0.5 is used as the evaluation metric of mAP.
[0048] During the evaluation process, in order to complete the PCB defect detection process based on TensorFlow, the input image was cropped into 600×600 sub-images, and the pre-trained ResNet-101 model was used to conduct experiments on 1 GPU. Each image contained 512 regions of interest, and the learning rate and momentum were set to 0.0001 and 0.9 respectively. The experimental results proved the effectiveness of the network, as well as the importance of reasonable anchor size design and multi-scale feature fusion.
[0049] (5) Refer to the evaluation results of step (4) to further optimize the model.
[0050] When the evaluation results meet the requirements, the model inference can be directly performed on the collected PCB images to complete the detection and identification of the six major defect targets on the board; when the evaluation results fail to meet the detection requirements, the intersection threshold, learning rate, momentum and other parameters can be fine-tuned while increasing the diversity and number of training samples.
Claims
1. A PCB defect automatic detection method based on deep learning, characterized in that: Here are the steps: (1) Preprocess the raw data, convert the data format and size, and complete the data set division; (2) Perform data enhancement on the preprocessed image; (3) Input the enhanced data into the micro-defect detection network to train the defect detection model, specifically: (3.1) Using the standard k-means algorithm with distance metric, the scale of the framed area is set to {15 2 , 25 2 , 40 2 , 60 2 }, the aspect ratio is set to {2:1, 3:1, 4:1, 5:1}; (3.2) Use ResNet-101 as the backbone convolutional network to extract features; Pre-train the ResNet-101 model on the ImageNet classification set and fine-tune it on the PCB defect dataset; (3.3) Using the structural information of the high-resolution feature map, the low-level feature map is connected with the high-level feature map to create a top-down feature map. The specific method is as follows: from bottom to top, a 1×1 convolution operation is performed on each corresponding feature map, and the upsampled map is connected with the corresponding bottom-up map by element-by-element addition; after the map connection is completed, a 3×3 convolution layer is attached to each merged feature map to generate the final feature map; (4) Evaluate the performance of the model obtained after training; the evaluation of the model is mainly divided into two aspects: defect area positioning and defect classification; for defect area positioning, the intersection combination is calculated as the evaluation index; For defect classification, the average computational accuracy is used as the evaluation metric; For defect area localization, the intersection union is calculated as the evaluation metric, and the IoU threshold is set to 0.5 to determine the true positive values on the PCB defect dataset; For defect classification, the average calculation accuracy is used as the evaluation index, and the IoU with a threshold of 0.5 is used as the evaluation index of mAP; (5) Based on the evaluation results of step (4), the model is further optimized; when the evaluation results fail to meet the detection requirements, the intersection threshold, learning rate and momentum are adjusted while increasing the diversity and number of training samples.
2. The method for automatic PCB defect detection based on deep learning according to claim 1 is characterized in that: The preprocessing is to convert the data set format into a unified data input format for the TensorFlow interface, and the PCB image size is 600×600; the data set is divided into two parts: a training data set of 8250 images and a test data set of 2102 images.
3. The method for automatic PCB defect detection based on deep learning according to claim 1, characterized in that: Six data enhancement methods are used: Gaussian noise addition, illumination change, image rotation, flipping, random cropping and shifting, and threshold filtering is performed on the results produced by the image rotation, flipping, random cropping and shifting methods.
