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.
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.
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