Printed circuit boards (PCBs) are a critical component of modern electronic equipment, performing a crucial role in the electronic information industry chain. However, accurate detection of PCB defects can be challenging. To address this problem, this paper proposes an enhanced detection method based on an improved YOLOv7 network. First, the SwinV2_TDD module is proposed, which adds a convolutional layer to extract the local features of the PCB. Then, the Magnification Factor Shuffle Attention (MFSA) mechanism is introduced, which adds a convolutional layer to each branch of the Shuffle Attention (SA) to expand its depth and enhance the adaptability of the attention mechanism. The SwinV2_TDD module and MFSA mechanism are integrated into the YOLOv7 network, replacing some ELAN modules and changing the activation function to Mish. The evaluation indexes used are Precision (P), Recall (R), and mean Average Precision (mAP). Experimental results show that the enhanced method achieves an AP of 98.74%, indicating a significant improvement in PCB defect detection performance.
Printed Circuit Boards (PCBs), as integral components of electronic products, play a crucial role in modern industrial production. However, due to the precision and complexity of PCBs, existing PCB defect detection methods exhibit some issues such as low detection accuracy and limited usability. In order to address these problems, a PCB defect detection method based on D-DenseNet (PCBDD-DDNet) has been proposed. This method capitalizes on the advantages of two deep learning networks, CDBN (Convolutional Deep Belief Networks) and DenseNet (Densely Connected Convolutional Networks), to construct the D-DenseNet (Combination of CDBN and DenseNet) network. Within this network, CDBN focuses on extracting low-level features, while DenseNet is responsible for high-level feature extraction. The outputs from both networks are integrated using a weighted averaging approach. Additionally, the D-DenseNet employs a multi-scale module to extract features from different levels. This is achieved by incorporating filters of sizes 3 × 3, 5 × 5, and 7 × 7 along the three paths of the CDBN network, multi-scale feature extraction network, and DenseNet network, effectively capturing information at various scales. To prevent overfitting and enhance network performance, the Adafactor optimization function and L2 regularization are introduced. Finally, online hard example mining mechanism (OHEM) is incorporated to improve the network’s handling of challenging samples and enhance the accuracy of the PCB defect detection network. The effectiveness of this PCBDD-DDNet method is demonstrated through experiments conducted on publicly available PCB datasets. And the method achieves a mAP (mean Average Precision) of 93.24%, with an accuracy higher than other classical networks. The results affirm the method’s efficacy in PCB defect detection.