Unsupervised PCB Anomaly Segmentation with Foundational Models

Chih-Hui Ho, SungBal Seo, NaYeon Kim, Pin-Ying Wu, YouSuk Bae, Nuno VasconcelosElectronic Imaging 2024 · OpenReview

Abstract

PCB defect segmentation aims to localize defects in printed circuit boards (PCBs), a task with significant industrial impact but limited public data. Predicting manufacturing defects is challenging, especially given the imbalanced distribution of defect categories in real-world conditions. This paper investigates Unsupervised PCB Anomaly Segmentation (UAS), where no labeled defect data is available during training. We propose PROS (Pcb pROmpt Sam), an efficient prompt tuning method that adapts a pretrained large foundational segmentation model (SAM) to PCB-UAS. By introducing a few learnable adapter layers while keeping the core SAM frozen, and training on synthetic defect images, our method outperforms baselines by 7 points in Mean IoU with 16.6 times fewer learnable parameters.

Introduction

In electronics manufacturing, detecting defects on Printed Circuit Boards (PCBs) is critical for quality assurance. However, automating this process faces two major hurdles: the high cost of manual labeling for rare real-world defects and the extreme data imbalance where certain defects occur far more frequently than others. To address these, we focus on Unsupervised Anomaly Segmentation (UAS), enabling models to identify defects without ever seeing a labeled real defect during training.

Methodology

The PROS Architecture

Instead of building a specialized model from scratch, we leverage the Segment Anything Model (SAM), a foundational model pretrained on over a billion masks. Our framework, PROS, keeps the SAM image encoder and most of the mask decoder frozen to preserve its general structural knowledge. We insert lightweight, fully connected "adapter" layers into the transformer layers of the decoder. Only these adapters are trained, effectively "prompting" the foundational model to identify PCB-specific textures and anomalies.

The PROS framework: (Top) Data synthesis pipeline converting normal images to defective ones. (Bottom) Model architecture showing frozen SAM components and optimized adapter layers.

Training with Synthetic Data

To bypass the need for real labeled data, we generate pseudo-defects programmatically. Using OpenCV, we paste simple geometric shapes—dots, lines, and circles—onto healthy PCB images. By varying transparency and blur, we create synthetic defects that mimic real manufacturing flaws. Because these are generated algorithmically, the ground truth masks are automatically available, transforming the unsupervised task into a supervised training problem.

Visual comparison of normal PCB images, the generated synthetic defects, and the resulting ground truth masks used for training.

Datasets and Evaluation

We introduce a new benchmark dataset of 10,261 images across 10 defect categories. This dataset reflects industrial reality with an imbalance factor of 271, meaning the most common class is 271 times more frequent than the rarest. While training uses only normal and synthetic images, evaluation is performed on real-world labeled defects.

Key Results and Insights

  • Superior Performance: PROS achieved a Mean IoU of 46.02, significantly outperforming standard architectures like UNet (39.52) and Siamese UNet (39.15).
  • Extreme Parameter Efficiency: PROS requires only 0.47 million learnable parameters, making it roughly 91 times more parameter-efficient than the Siamese UNet baseline (42.8M parameters).
  • The Adapter Paradox: Ablation studies revealed that using fewer adapter layers (K=1) performed better than using many (K=12). Excessive learnable parameters caused the model to overfit to the simple synthetic shapes, losing its ability to generalize to complex real-world defects.

Conclusion

PROS demonstrates that foundational models trained on general imagery contain sufficient structural "common sense" to be adapted for highly specialized industrial tasks. By using parameter-efficient adapters and simple synthetic data, we can achieve state-of-the-art results in PCB defect detection without the need for expensive, manually labeled real-world datasets. Future work will explore more complex synthetic defect generation using GANs or Diffusion models to further bridge the gap between synthetic and real-world anomalies.

Summary updated

Abstract

PCB defect segmentation aims to localize the defects in printed circuit boards (PCBs). While this problem has a great industrial impact, few datasets are publicly available. It is also challenging to predict the defects that appear during manufacturing. To address the former challenge, we curate a large dataset with various defective categories of imbalanced distribution, reflecting real-world conditions. The problem of unsupervised PCB anomaly segmentation (UAS), where no labeled defect data is available during training, is then investigated. We propose an efficient prompt tuning method to address PCB-UAS. Specifically, a pretrained large foundational segmentation model (SAM) is adapted to PCB-UAS by the introduction of a few learnable adapter layers. SAM is frozen during training and only the additional adapter parameters are learned. To overcome the lack of labeled defect images for training, we propose to create synthetic defect images that mimic the real ones. Experiments highlight that the proposed method can outperform baselines by 7 points with 16.6 times less learnable parameters.
BibTeX
@inproceedings{ho2024unsupervised,
  author = {Chih-Hui Ho and SungBal Seo and NaYeon Kim and Pin-Ying Wu and YouSuk Bae and Nuno Vasconcelos},
  title = {{Unsupervised PCB Anomaly Segmentation with Foundational Models}},
  booktitle = {Electronic Imaging},
  year = {2024},
  url = {https://openreview.net/forum?id=OzR1r4fs7k},
}
Figure