| Printed Circuit Board(PCB),as one of the most important parts of electronic products,is known as the "mother of electronic products".PCB is widely used in various fields such as automotive electronics,aerospace,computers,medical equipment,and so on.During the production process,PCB may generate various defects.The circulation of defective PCBs can affect the use of all electronic products,and even cause safety hazards.Therefore,it is necessary to conduct defect detection on PCB.The traditional inspection methods mainly include manual inspection and automatic optical inspection.However,these two methods not only have the disadvantages of low detection efficiency and accuracy but are also prone to false positives and missed detections.The development of deep learning has provided a new approach to PCB defect detection.Applying deep learning theory to the task of PCB defect detection has received increasing attention and research.The detection object of this article is a single-layer bare PCB board,and the defects detected include missing holes,mouse bite,open circuit,short,spur,and spurious copper.To improve the training,this paper first augmented the PCB dataset using traditional data augmentation methods,resulting in a dataset containing 8000 images,which solved the problem of insufficient samples in the dataset.Then,the following improvements were made to the yolov5 algorithm: optimization of the loss function,modify the predictive output module,the addition of the ECA attention mechanism,etc.The improved model is called yolov5-ours,which achieves high-precision detection for small target PCB defect tasks.The high-precision model yolov5-ours has improved the accuracy,recall,and average precision of the original yolov5 model by 2.5%,2.8%,and 2.5%,respectively.However,its detection speed has dropped to 39 frames per second.Although the yolov5-ours model achieved improvements in detection accuracy,its efficiency was affected due to its large parameter size and slow detection speed.Therefore,based on the yolov5 algorithm,two lightweight models,Mobilenetv3 and Shufflenetv2,were introduced in this paper to reduce model parameters and improve detection speed.Furthermore,improvements were made to the lightweight models,including converting single-scale output,removing the SPP module,optimizing the use of SE attention mechanism,and reducing the number of model channels,among others.The improved model is called Shufflenetv2-1-yolov5.Compared to yolov5-ours,although the accuracy,recall,and average precision of the lightweight model have decreased by 1.7%,4.2%,and2.5%,respectively,the parameter count of the model is only 2.1% of that of yolov5-ours,and the computation is only 4.2% of that of yolov5-ours.The detection speed has also increased by 46% to 57 FPS.In this paper,build a PCB data set to verify the generalization ability of the improved model.Experiments proved that the yolov5-ours and Shufflenetv2-1-yolov5 models have good robustness and generalization. |