With the rapid development of electronic industry technology,the demand for electronic products is increasing,Printed circuit board(PCB)as the information carrier of integrated electronic components,which is widely used in the electronic field.In the industrial production process of PCB,automatic defect detection is an essential process.In recent years,although great progress has been made in PCB defect detection,there are still various problems in the traditional defect detection methods.For example,manual inspection has the problem of missed inspection and low efficiency,there are some problems in template matching method,such as overreliance on "perfect" template,difficult to achieve precise image registration,optical detection methods are susceptible to the influence of light,noise and reflectivity.Based on the problems of the above traditional methods,this topic focuses on PCB appearance defect detection,and builds a network framework based on deep learning methods,and proposes two PCB defect detection algorithms: 1)The defect detection algorithm based on yolov5 has high detection accuracy and is mainly used for PC with high computing power,as an on-line detection of defects in the production process;2)Defect detection algorithm based on Mobile Net-Yolo-Fast.This algorithm is a lightweight PCB defect detection algorithm with fast detection speed and strong real-time performance.It is mainly used in mobile terminal,As a review of defects in the production process.PCB defect detection algorithm based on yolov5:(1)Input: 1)Mosaic data enhancement is adopted to splice and combine four pictures to enrich the background information of defects;2)Using adaptive anchor box calculation,design a more reasonable anchor box to speed up the convergence;3)Adaptive image scaling is adopted to scale the input image to a unified standard size,reduce redundant information and speed up reasoning.(2)Feature extraction network: 1)Using the Focus module,the Focus module slices the input image to obtain four feature maps to improve the receptive field and avoid information loss during downsampling;The structure of cross stage partial(CSP)is introduced into the backbone network for feature extraction,the position and size of the target are dissociated,and only the center point of the target is detected,which strengthens the detection ability of small targets.(3)Neck: Using feature pyramid network(FPN)and pyramid attention with simple network(PAN),which strengthens the dissemination of information,strengthens the ability to retain spatial information,and helps to locate pixels to form a mask.(4)Loss function: Generalized Intersection over Union(GIoU)loss function is adopted to solve some problems existing in the traditional Intersection over Union(Io U)loss function.PCB defect detection algorithm based on Mobile Net-Yolo-Fast:(1)Feature extraction network: Deep neural network Mobile Net V2 is used as the backbone network for feature extraction.The use of depthwise separable convolution instead of ordinary convolution greatly reduces the amount of calculation and parameters of the network;the inverted residual structure first expands and then compresses the channel,enhances gradient propagation,reduces the memory occupation during reasoning,and strengthens the ability of feature extraction.(2)Feature pyramid pooling structure: After Mobilenetv2,the spatial pyramid pooling structure is inserted to replace the original pooling layer,which increases the receptive field,extracts more feature information by using the feature maps of different scales,enhances the scale invariance of the image and improves the detection accuracy of the network.(3)Feature fusion structure: Based on the FPN to build a strengthened feature extraction network for multi-scale feature fusion,fully integrate deep feature information and shallow feature information,and trade-off between speed and accuracy to obtain more robust feature information.(4)Loss function: The Complete Intersection over Union(CIoU)is used to optimize the loss function.Based on the Intersection over Union(Io U),the center distance between the prediction box and the real box,the diagonal distance of the smallest closed rectangle containing the prediction box and the real box,the aspect ratio of the prediction box and the real box are all taken into consideration,which solves the problem of Io U when the prediction box and the real box have no intersection,and makes the prediction box more consistent with the real box.The algorithm proposed in this topic is verified and evaluated on its own dataset.The generalization ability of the network model is verified by dividing different proportion of datasets and cross validation.The experimental results show that the two algorithms proposed in this paper: the defect detection algorithm based on Yolo5 has high accuracy,Mean Average Precision(m AP)has reached 99.18%,and performs well on the PC side,meet the online inspection requirements for defects;The defect detection algorithm based on Mobile Net-Yolo-Fast has small complexity,high accuracy,fast speed,and strong real-time performance.At the same time,the algorithm is transplanted to k210 development board,which can meet the requirements of real-time detection,and the frame rate can also reach 12 fps / s,meet the requirements for review and inspection of defects. |