Research on PCB defect detection algorithm based on mixed attention mechanism

Zhenhua Li, Lei Zhang, Yu WangHighlights 2022

Abstract

The production process of Printed Circuit Boards (PCBs) is complex and cumbersome, leading to diverse defects that seriously affect productivity. Timely and effective detection of surface defects is momentous for industrial quality control. This paper presents a novel mixed attention module, C_Efficient Channel Attention (C_ECA), which connects spatial attention with effective channel attention. In the channel attention component, a one-dimensional convolution replaces the standard fully connected layer to reduce overhead. In the spatial attention component, parallel 3x3 and 7x7 convolution kernels are utilized to capture multi-scale regional features. By integrating this module into the YOLOv3 architecture, we demonstrate significant improvements in detection performance on standard PCB datasets, achieving a near-perfect 99.42% mAP while maintaining industrial-grade processing speeds.

Introduction

Printed Circuit Board (PCB) manufacturing is a high-precision process where microscopic defects—such as short circuits, open circuits, or "mouse bites"—can lead to total device failure. Traditional manual inspection is slow and prone to human error. While deep learning models like YOLOv3 have revolutionized object detection, they often struggle with PCB defects due to the small target size of flaws, complex wiring backgrounds, and the stringent real-time requirements of industrial production lines.

Methodology

The C_ECA Mixed Attention Module

The core innovation of this research is the C_Efficient Channel Attention (C_ECA) module. This module is designed as a "plug-and-play" component that combines the strengths of channel and spatial attention to refine feature maps.

Overview of the Mixed Attention Module (C_ECA) showing the sequential application of channel and spatial attention.
  1. Efficient Channel Attention: Unlike traditional Squeeze-and-Excitation (SE) networks that use computationally expensive Fully Connected (FC) layers, C_ECA employs a one-dimensional convolution. The kernel size ($k$) is adaptively determined by the number of channels, allowing the model to learn inter-channel correlations with minimal parameter overhead.
  2. Multi-Scale Spatial Attention: Standard spatial attention typically uses a single large convolution kernel (e.g., 7x7). C_ECA replaces this with a dual-branch approach using 3x3 and 7x7 kernels in parallel. This allows the network to capture defect information at multiple scales simultaneously, which is critical for identifying defects of varying sizes.

Strategic Integration into YOLOv3

To maintain real-time performance, the authors did not modify the Darknet53 backbone. Instead, the C_ECA modules were strategically inserted into the three prediction branches of the YOLOv3 network. This placement ensures that the attention mechanism operates on high-level semantic features where refinement is most impactful for final object localization and classification.

The proposed network architecture, illustrating the placement of C_ECA modules within the YOLOv3 prediction heads.

Experimental Setup and Results

Dataset and Augmentation

The study utilized the PCB dataset from the Intelligent Robot Open Laboratory of Peking University. The original set of 693 high-resolution images covers six defect categories: open circuit, short circuit, spur, mouse bite, spurious copper, and missing hole. To enhance model robustness and prevent overfitting, the dataset was expanded to 10,668 images using random horizontal flips and brightness adjustments.

Performance Evaluation

The C_ECA-enhanced YOLOv3 was compared against several industry-standard models. The results indicate that the proposed method offers a superior balance of accuracy and speed.

Method mAP (%) FPS
Faster R-CNN 71.55 1.02
SSD 91.28 53.39
YOLOv4 97.11 33.49
Proposed (C_ECA + YOLOv3) 99.42 40.38

The proposed model achieved a mean Average Precision (mAP) of 99.42%, significantly outperforming the baseline YOLOv4 and SSD models. While the addition of the attention module introduced a slight reduction in frame rate compared to the base YOLOv3 (from 47.65 to 40.38 FPS), the speed remains well within the requirements for real-time industrial inspection.

Conclusion

This research demonstrates that integrating a mixed attention mechanism—specifically one that leverages efficient 1D convolutions and multi-scale spatial kernels—can dramatically improve the precision of PCB defect detection. The C_ECA module effectively suppresses background noise from complex wiring patterns, allowing the model to focus on critical flaws. Future work will focus on further optimizing the network structure to reclaim processing speed without sacrificing the high level of precision achieved in this study.

Summary updated

BibTeX
@inproceedings{li2022research,
  author = {Zhenhua Li and Lei Zhang and Yu Wang},
  title = {{Research on PCB defect detection algorithm based on mixed attention mechanism}},
  booktitle = {Highlights},
  year = {2022},
  doi = {10.54097/hset.v7i.1026},
}
Figure