Abstract:Printed Circuit board is an indispensable part of electronic products, and its market demand is increasing day by day. Therefore, it is of great significance to manufacture PCB without defects. In the PCB defect detection, the defect targets to be detected are small and most of the detection targets are easily confused with the background, so the improved algorithm introduces the Coordinate Attention mechanism into the backbone network of the native YOLOv5 algorithm. A Transformer Encoder was introduced into the neck network and a high-resolution detection head suitable for small targets was added. The Intersection over Union algorithm of selected anchor frames was changed to a more advanced E-IoU. Compared with the original YOLOv5 algorithm, the performance of the improved algorithm is significantly improved according to the results of Precision, recall and mean Average Precision of the algorithm evaluation index, and the mean Average Precision is 98.46%. It can meet the precision requirement of PCB defect detection in industrial field.