Defect detection method and device based on PCB (Printed Circuit Board)

Through the target detection network based on knowledge distillation technology and industrial camera real-time image collection, combined with GhostNet and lightweight channel attention module, the existing PCB board defect detection efficiency and low accuracy problems are solved, and high-precision, low-precision detection is achieved. Cost-effective defect detection, adapting to efficient detection results with limited equipment resources.

CN118799272AInactive Publication Date: 2024-10-18HUNAN DINGQIANG ELECTRONIC TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410784384.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-18
Publication Date
2024-10-18
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

Existing PCB board defect detection methods are inefficient and low-precision, making it difficult to detect new defects and high costs, making it difficult to achieve both high efficiency and high precision.

Method used

A target detection network based on knowledge distillation technology is adopted, including a backbone network, a neck network and a target detection head. GhostNet and a lightweight channel attention module are used for feature extraction and fusion. It is combined with an industrial camera to obtain image data in real time. Through the target detection network Perform high-precision detection and continuously optimize the model through manual annotation and data set updates.

Benefits of technology

It achieves high-precision, low-cost PCB board defect detection, can identify new defects in real time, improves the efficiency and accuracy of defect detection, and maintains detection performance even when equipment resources are limited.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118799272A_ABST
    Figure CN118799272A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of defect detection, in particular to a PCB-based defect detection method and device, and the method comprises the steps: S1, building a target detection network; s2, training the target detection network on the data set to obtain a trained target detection model; s3, acquiring a surface image of the PCB in real time through an industrial camera; s4, inputting a PCB image acquired in real time into the trained target detection model; and S5, visualizing a detection result, if a new flaw type is not detected, carrying out manual marking, adding the new flaw type into the training data set, and retraining the target detection network. According to the method and the device, the newly appearing flaws can be conveniently obtained, and can be recorded, stored and trained, so that high-precision detection can be conveniently carried out, more flaws of different types can be conveniently identified in subsequent detection, and the flaw detection accuracy is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of defect detection, and in particular to a method for detecting defects on a printed circuit board (PCB), and a device for detecting defects on a printed circuit board (PCB). Background Art

[0002] PCB is an important part of electronic equipment, and the detection of surface defects is crucial to ensure the quality and reliability of electronic equipment. In fact, most of the defects in PCB only account for a small part of it, which brings great challenges to the detection of PCB defects. By detecting and identifying defects on PCB, defects can be found and repaired in time, ensuring that the quality of the product meets the standard and reducing the defective rate.

[0003] At present, the surface defect detection of PCB boards mainly relies on manual visual inspection, which has obvious problems such as low efficiency, different defect detection standards, high cost, and susceptibility to fatigue and environmental factors. Therefore, PCB board defect detection needs to introduce a method with high efficiency, high precision, low cost and stability. In recent years, some methods based on computer vision technology have also been used for PCB board defect detection. At present, the methods for PCB board defect detection are difficult to take into account both high precision and high efficiency, and cannot detect newly emerging defects. They can only detect recorded defects, and it is difficult to detect different types of defects with high precision. Summary of the invention

[0004] The present invention aims at the deficiencies in the prior art and provides the following technical solutions:

[0005] A PCB defect detection method includes the following steps:

[0006] S1: Build target detection network;

[0007] S2: The target detection network is trained on the data set to obtain a trained target detection model;

[0008] S3: Obtain the surface image of the PCB board in real time through an industrial camera;

[0009] S4: The real-time acquired PCB board image is input into the trained object detection model;

[0010] S5: Visualize the detection results. If new defect types are not detected, they are manually labeled and added to the training data set, and the object detection network is retrained.

[0011] As an improvement of the above technical solution, in step S1, the target detection network includes a backbone network, a neck network and a target detection head; the backbone network uses a lightweight GhostNet to downsample the original input image by 4 times, 8 times, 16 times and 32 times to obtain four feature maps of different sizes; the GhostNet is composed of stacked Ghost Bottleneck modules, and the Ghost Bottleneck module introduces a lightweight channel attention module.

[0012] As an improvement of the above technical solution, the lightweight channel attention module obtains a feature map embedded with channel feature responses by global pooling of the feature map obtained by the GhostBottleneck module, and then passes the feature map through two fully connected layers to ensure that the number of channels of the feature map does not change, and then outputs a weight between 0 and 1 through the Sigmod function;

[0013] The calculation formula is as follows:

[0014] F′=w·F

[0015] w=sig(W2(W1(pooling(F))))

[0016] Among them, w represents the weight, F represents the feature map obtained by the lightweight channel attention module for the Ghost Bottleneck module, F' represents the feature map embedded with the channel feature response, pooling() represents the global pooling operation, W1 represents the first fully connected layer, W2 represents the second fully connected layer, and sig() represents the Sigmod function.

[0017] As an improvement of the above technical solution, the neck network is used to realize feature fusion and upsampling operations. The neck network performs multi-scale feature fusion on the four-size feature maps extracted by the backbone network sampling and the four-size features obtained by upsampling to obtain four-size fused features with high-level semantic information and contextual information.

[0018] As an improvement of the above technical solution, the target detection head is used to detect the target. The target detection head further processes the features obtained by the neck network and outputs feature maps of four different sizes to detect targets of different sizes.

[0019] As an improvement of the above technical solution, in step S1, the target detection network trains a teacher model and a student model based on knowledge distillation technology, and then migrates the teacher model to the student model to achieve lightweight model.

[0020] As an improvement of the above technical solution, the target detection network needs to be trained for loss, and the loss function expression of the training is:

[0021] L final =L bb +L cl +L obj

[0022] Among them, L bb represents the bounding box loss, L cl represents the classification loss, L obj represents the target confidence loss.

[0023] As an improvement of the above technical solution, in step S2, the data set includes six defect types, specifically, leak holes, mouse bites, open circuits, short circuits, strays, and miscellaneous copper.

[0024] A PCB defect detection device, comprising a processor, an industrial camera and a memory;

[0025] The processor can execute a PCB board defect detection method, the industrial camera is used to collect image data of the PCB board surface in real time, and the memory is used to store the image data collected by the industrial camera and the program to be executed by the processor.

[0026] Beneficial effects of the present invention:

[0027] By using the knowledge distillation technology based on the target detection network, the teacher model and the student model can be trained, and the teacher model can be transferred to the student model to achieve lightweight model, ensure high-precision detection performance while obtaining high-efficiency detection effect. In addition, the image of the surface of the PCB board can be obtained through the industrial camera to obtain new defects, and the new defects can be recorded, stored and trained for high-precision detection. In subsequent detection, it is easy to identify more different types of defects and improve the accuracy of defect detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 It is a flow chart of the PCB board defect detection method of the present invention;

[0029] Figure 2 It is a schematic diagram of the target detection network based on the knowledge distillation technology of the present invention. DETAILED DESCRIPTION

[0030] 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. 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.

[0031] Please refer to Figure 1-Figure 2As shown, the present invention provides a PCB defect detection method, comprising:

[0032] S1: Building a target detection network

[0033] The target detection network adopts the improved Yolov5 model, including the backbone network, neck network and target detection head.

[0034] The backbone network uses a lightweight GhostNet to obtain a feature map with a gradually decreasing size. The feature map includes four different sizes. Specifically, the backbone network downsamples the original input image by 4 times, 8 times, 16 times, and 32 times to obtain four different sizes of feature maps. Therefore, the backbone network adds a 4-fold downsampling process to the original input image on the basis of the original Yolov5 model feature extraction module. The original image is sent to the neck network after 4 times downsampling to obtain a feature map of a new size. The receptive field of the feature map after 4 times downsampling is small. Among them, the 4-fold downsampling is obtained by convolution operation. The implementation of convolution depends on the convolution kernel. The convolution kernel has different sizes. The receptive field here refers to the relative size of the convolution kernel in the image, and the position information of the 4-fold downsampling is relatively rich, which means the position information of the defect in the whole picture. The position information of the defect in the feature map obtained by 4 times downsampling is richer than that of the defect in the feature map obtained by 8, 16, and 32 times downsampling, which can improve the detection effect of detecting small targets.

[0035] The GhostNet is composed of stacked Ghost Bottleneck modules. The Ghost Bottleneck module introduces a lightweight channel attention module (SE module). The SE module obtains a feature map (F') embedded with channel feature responses by global pooling of the feature map (F) obtained by the Ghost Bottleneck module, so that the information from the global receptive field of the network can be used by the feature map (F) obtained by the Ghost Bottleneck module. The feature map embedded with channel feature responses is then passed through two fully connected layers, where the number of neurons in the second fully connected layer is the same as the input feature map, ensuring that the number of channels of the feature map will not change. Finally, the Sigmod function is used to output a weight w between 0 and 1, which is then multiplied by the feature map (F) obtained by the original Ghost Bottleneck module to finally obtain a feature map (F') embedded with a channel attention mechanism. The formula is as follows:

[0036] F′=w·F

[0037] The specific expression of weight w is as follows:

[0038] w=sig(W2(W1(pooling(F))))

[0039] Among them, pooling() represents the global pooling operation, W1 represents the first fully connected layer, W2 represents the second fully connected layer, and sig() represents the Sigmod function.

[0040] In PCB defect detection, different types of defects (such as leaks, mouse bites, open circuits, short circuits, strays, and copper debris) are represented differently in feature maps. The SE module can adaptively allocate attention weights so that the features related to these defects are more prominent in the feature maps, thereby helping the detection model to more accurately identify and classify different types of defects.

[0041] The neck network is used to implement feature fusion and upsampling operations, and fuses the position information of shallow features with the semantic information of deep features to obtain features with higher-level semantic information.

[0042] The neck network adopts the FPN-PANet structure. The semantic information flow of small-sized deep features in FPN (feature pyramid module) needs to be passed to large-sized shallow features layer by layer through the backbone network. PANet (path aggregation network) introduces a path from large-sized features to small-sized features based on FPN. The position information flow of large-sized shallow features needs to be able to be passed to small-sized deep features.

[0043] The neck network performs multi-scale feature fusion on the feature maps of four sizes extracted by the backbone network and the features of four sizes obtained by upsampling in combination with PANet, and obtains fused features of four sizes with high-level semantic information and contextual information.

[0044] The target detection head is used to detect targets. The target detection head further processes the features obtained by the neck network and outputs feature maps of four different sizes to detect targets of different sizes. The four detection layers in the target detection head correspond to the four different sizes of feature maps obtained in the neck network. Each grid on the feature map has four anchor frames with different aspect ratios preset. All position information and classification information based on the anchor frames can be saved in the channel dimension of the feature map to predict and regress targets.

[0045] The target detection network uses knowledge distillation technology to achieve lightweight design. The schematic diagram of the method is as follows Figure 2As shown, the target detection network based on knowledge distillation technology trains a teacher model (Yolov5) and a student model (lightweight Yolov5), and then migrates the teacher model (Yolov5) to the student model (lightweight Yolov5) to achieve lightweight model. Therefore, the target detection network based on knowledge distillation technology can adapt to the situation of limited equipment resources while taking into account high precision and high efficiency.

[0046] The target detection network based on knowledge distillation technology mainly includes a teacher model (Yolov5), a student model (lightweight Yolov5), a loss function and training data. The corresponding soft labels will be obtained by training the teacher model (Yolov5). The student model (lightweight Yolov5) is jointly learned by the soft labels and true values ​​obtained through training the teacher model (Yolov5).

[0047] The loss function expression of the target detection network based on knowledge distillation technology that needs to be trained is:

[0048] L final =L bb +L cl +L obj

[0049] Among them, L bb represents the bounding box loss, L cl represents the classification loss, L obj represents the target confidence loss, L bb , L cl , L obj The three losses are composed of detection loss and distillation loss respectively.

[0050] The distillation loss can more accurately transfer the knowledge of the teacher model (Yolov5) to the student model (lightweight Yolov5).

[0051] S2: The target detection network is trained on the data set to obtain a trained target detection model

[0052] The constructed target detection network is trained on a public PCB Defect dataset to obtain a trained target detection model; the public PCB Defect dataset includes a training set, a validation set, and a test set, which contains six defect types, namely, leak holes, rat bites, open circuits, short circuits, stray circuits, and miscellaneous copper.

[0053] S3: Real-time acquisition of PCB surface images through industrial cameras

[0054] The PCB board image is acquired in real time through an industrial camera and input into the trained target detection model to detect whether it contains defects. If there are defects, the location and type of defects are marked.

[0055] S4: The real-time acquired PCB board image is input into the trained object detection model.

[0056] S5: Visualize the detection results. If new defect types are not detected, manually annotate them and add them to the training data set to retrain the object detection network.

[0057] The detection results of PCB boards collected in real time are visualized. If there are defects on the PCB board but they do not belong to the defect types included in the public PCBDefect dataset, the defects on the PCB board will not be detected. The PCB boards that do not belong to the defect types included in the public PCB Defect dataset but have defects will be manually labeled and added to the training set of the public PCB Defect dataset to retrain the target detection network.

[0058] The present invention also provides a PCB board defect detection device, which includes at least one processor, an industrial camera, and at least one memory; the at least one processor can execute a PCB board defect detection method, the industrial camera can collect image data of the PCB board surface in real time, and the at least one memory can store the image data collected by the industrial camera and a program to be executed by the at least one processor.

[0059] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit them.

Claims

1. A PCB defect detection method, characterized in that: The following steps are involved: S1: Build target detection network; S2: The target detection network is trained on the data set to obtain a trained target detection model; S3: Obtain the surface image of the PCB board in real time through an industrial camera; S4: The real-time acquired PCB board image is input into the trained object detection model; S5: Visualize the detection results. If new defect types are not detected, they are manually labeled and added to the training data set, and the object detection network is retrained.

2. A PCB defect detection method according to claim 1, characterized in that: In step S1, the target detection network includes a backbone network, a neck network and a target detection head; The backbone network uses a lightweight GhostNet to downsample the original input image by 4 times, 8 times, 16 times, and 32 times to obtain feature maps of four different sizes; The GhostNet consists of stacked Ghost Bottleneck modules, which introduce a lightweight channel attention module.

3. A PCB defect detection method according to claim 2, characterized in that: The lightweight channel attention module obtains a feature map embedded with channel feature responses by global pooling of the feature map obtained by the Ghost Bottleneck module, and then passes the feature map through two fully connected layers to ensure that the number of channels of the feature map does not change, and then outputs a weight between 0 and 1 through the Sigmod function; The calculation formula is as follows: F′=w·F w=sig(W2(W1(pooling(F)))) Among them, w represents the weight, F represents the feature map obtained by the lightweight channel attention module for the Ghost Bottleneck module, F' represents the feature map embedded with the channel feature response, pooling() represents the global pooling operation, W1 represents the first fully connected layer, W2 represents the second fully connected layer, and sig() represents the Sigmod function.

4. A PCB defect detection method according to claim 2, characterized in that: The neck network is used to realize feature fusion and upsampling operations. The neck network performs multi-scale feature fusion on the four-size feature maps extracted by the backbone network sampling and the four-size features obtained by upsampling, and obtains four-size fused features with high-level semantic information and context information.

5. A PCB defect detection method according to claim 4, characterized in that: The target detection head is used to detect the target. The target detection head further processes the features obtained by the neck network and outputs four feature maps of different sizes to detect targets of different sizes.

6. A PCB defect detection method according to claim 1, characterized in that: In step S1, the target detection network trains a teacher model and a student model based on knowledge distillation technology, and then migrates the teacher model to the student model to achieve lightweight model.

7. A PCB defect detection method according to claim 6, characterized in that: The target detection network needs to be trained with loss, and the loss function expression of the training is: L final =L bb +L cl +L obj Among them, L bb represents the bounding box loss, L cl represents the classification loss, L obj represents the target confidence loss.

8. The PCB defect detection method according to claim 1, characterized in that: In step S2, the data set includes six defect types, specifically, leak hole, rat bite, open circuit, short circuit, stray, and miscellaneous copper.

9. A PCB defect detection device, applying a PCB defect detection method according to any one of claims 1 to 7, characterized in that: Including processors, industrial cameras and memory; The processor can execute a PCB board defect detection method, the industrial camera is used to collect image data of the PCB board surface in real time, and the memory is used to store the image data collected by the industrial camera and the program to be executed by the processor.