With China’s step towards becoming a modern country and a modern power,the demand for high-end manufacturing in China is increasing day by day.Printed circuit board(PCB)is a very important basic component in the field of high-end electronic manufacturing.The aerospace,medical,automotive,home appliances,chips and other fields all need PCBs as key components,so the yield of PCBs is particularly important.In the production process of PCB,its appearance and wiring connection will be defective due to processing errors.These defects will directly affect the quality of downstream products.Therefore,the research on PCB defect detection has very important industrial significance.Traditional PCB defect detection methods have many problems,such as high miss rate,slow detection speed,poor robustness and weak generalization ability.Therefore,a set of PCB defect detection algorithm based on deep learning is proposed,and the algorithm is packaged into a detection software.The specific contents of the study are as follows:In order to solve the problem of PCB defect detection,YOLOv5 is taken as the basic framework for research.Combined with the fact that the proportion of defective target pixels in the PCB to the whole image is very small,it is easy to be missed and wrong detected in the detection.The ATCSP-YOLOv5 algorithm based on multi-head self-attention mechanism is proposed.The algorithm combines the idea of cross-stage local network(CSPNet)and TiV,takes the multi-head self-attention mechanism in Transformer as the core of defect target feature enhancement,and inputs the feature layer of specific depth into the ATCSP module,which enhances the detection ability of the model for small target defects.At the same time,the feature pyramid is fused to generate a target detection layer with smaller receptive field,which is used for small target defect detection in PCB.The target detection head with the largest receptive field in the model is removed,and the calculation amount of the model is reduced.The experiment shows that the ATCSP-YOLOv5 algorithm is relative to the original YOLOv5 algorithm mAP@0.5 It increased by 3.06%,while the detection speed did not decrease significantly.The ability to detect small and medium-sized target defects in PCB is significantly enhanced.In order to further improve the defect detection capability of ATCSPYOLOv5,the algorithm also preprocesses PCB data to expand the data set.Among them,the super-resolution confr-ontation generation network(SRGAN)is used to enhance PCB data,refine the detailed features of PCB images,and enrich the context information around small target defects.Then the effective data enhancement method is used to expand the data set,improve the robustness of the data set,and reduce the risk of training overfitting.After the completion of model training,we tried to compress the model without reducing the accuracy of the model.After replacing PANet with the feature pyramid(FPN),fine-tuning training was carried out to obtain ATCSP-YOLOv5_Pruned model.The experiment shows that under the same pretreatment conditions,ATCSP-YOLOv5_Pruned not only did not reduce the model accuracy,but also compared with ATCSP-YOLOv5,mAP@0.5 By 0.18%,it not only improves the accuracy of the model,but also reduces the calculation amount of the model,and improves the realtime performance slightly.In order to realize the practical application of the model,ATCSPYOLOv5 with the best training results_Pruned model,packaged into a PCB defect detection system.The software uses PyQt5 to develop the UI interface.Then,select PCB pictures with different angles and different lighting conditions to test the system detection stability,and further verify the effectiveness and robustness of the system.Finally,in order to improve the detection accuracy of PCB defects,ATCSP-YOLOv5 algorithm and ATCSP-YOLOv5 after model compression are proposed Pruned model provides an effective data preprocessing scheme.The experimental results show that the algorithm model proposed in the study is superior to the existing PCB target detection algorithm,and has improved detection accuracy,and retains the high realtime performance of YOLOv5.The detection system made can be applied to actual PCB defect detection through practice. |