CM-UNetv2: An Enhanced Semantic Segmentation Model for Precise PCB Defect Detection and Boundary Restoration

Qiaoyun Guo, Yajun Chen, Yirui Zhu, Delin ChenSensors 2025 · DOI

TL;DR

This paper introduces CM-UNetv2, a novel semantic segmentation network designed for precise PCB defect detection and boundary restoration. By integrating novel attention and feature fusion modules, CM-UNetv2 significantly improves the detection of small, irregular defects and enhances boundary accuracy, outperforming existing methods on challenging datasets.

What Problem Does This Paper Address?

The manufacturing of Printed Circuit Boards (PCBs) is crucial for modern electronics, but ensuring product quality hinges on accurate defect detection. Traditional methods struggle with small, irregularly shaped defects that are often embedded in complex textures, leading to missed detections and inaccurate boundary localization. This can result in reduced product quality, increased costs, and potential safety risks. Existing deep learning approaches, while advanced, still face challenges in precisely segmenting these fine-grained defects and accurately restoring their boundaries, especially in complex industrial environments.

Methods

CM-UNetv2 tackles these challenges with a three-pronged architectural approach:

  • Parallelized Patch-Aware Attention (PPA) Encoder: This module enhances multi-scale feature representation by employing a multi-branch attention mechanism. It combines local, global, and serial convolutions to capture context at various scales, producing three outputs for progressive encoding, semantic refinement, and spatial skip connections.
  • Dual-Stream Skip Guidance (DSSG) Module: To better preserve spatial details, DSSG decouples semantic refinement from spatial information preservation. It utilizes two separate skip pathways: one for semantically enriched features (processed by an MSAA module) and another that directly passes original encoder features to the decoder, retaining fine spatial structure.
  • Frequency-domain Guided Context Mamba (FGCMamba) Decoder: This module integrates two key innovations:
  • Spatial Guidance Cross-Attention (SGCA): Aligns semantic features (from the semantic stream) with spatial features (from the spatial stream) to improve boundary and texture reconstruction.
  • Frequency-domain Self-Attention Solver (FSAS): Computes global attention efficiently in the frequency domain, reducing computational overhead and improving boundary restoration.

Datasets

The authors evaluated CM-UNetv2 on two publicly available datasets:

  • MeiweiPCB Dataset: A high-quality dataset for PCB defect detection, containing 926 industrial line-scan images with pixel-level semantic segmentation labels for defects like open circuits, burrs, and missing holes. It presents challenges due to complex background textures, grayscale variations, and noise.
  • KWSD2 Water Body Segmentation Dataset: A benchmark dataset for remote sensing image analysis, focusing on high-precision extraction of surface water bodies. It features high-resolution images with complex backgrounds, blurred boundaries, and varying water body forms, posing challenges for context awareness and edge restoration.

Key Insights and Ideas

  • Decoupling Semantic and Spatial Information: The DSSG module's dual-stream approach is crucial. By keeping a direct spatial stream separate from the semantically processed one, the model avoids losing fine-grained details that are often degraded in traditional fusion methods.
  • Frequency Domain for Efficiency: Using FSAS in the frequency domain for attention computation is a clever way to capture long-range dependencies more efficiently than traditional spatial attention, leading to better global context understanding with reduced computational cost.
  • Hybrid Attention for Robustness: The combination of PPA's multi-scale attention, SGCA's cross-attention, and FSAS's frequency-domain attention creates a powerful system that can handle complex textures, blurred boundaries, and subtle defects.

Key Results

CM-UNetv2 achieved state-of-the-art performance on both datasets:

  • MeiweiPCB Dataset: Achieved an mIoU of 0.8224, outperforming other methods.
  • KWSD2 Dataset: Achieved an mIoU of 0.9516, also surpassing existing benchmarks.

Qualitatively, the model demonstrated superior performance in:

  • Detecting small and low-contrast defects.
  • Accurately restoring boundaries, even in cluttered or textured environments.
  • Maintaining segmentation continuity for elongated structures like rivers and canals.
  • Achieving a good balance between accuracy and computational efficiency.

Limitations and Future Work

The authors acknowledge two main limitations:

  • Computational Overhead of PPA: While PPA significantly boosts accuracy, it introduces non-negligible computational overhead, which might limit real-time deployment in highly resource-constrained scenarios.
  • Generalization to Diverse Defects: While CM-UNetv2 shows strong generalization across the tested datasets, its robustness across a wider variety of industrial defect types still needs validation.

Future work will focus on:

  • Designing a more lightweight version of the PPA module to improve runtime efficiency.
  • Expanding the dataset with more real-world PCB samples to increase diversity.
  • Exploring a multi-modal learning framework that integrates spectral, textural, or temporal cues for even broader applicability.

Summary updated

Abstract

PCBs play a critical role in electronic manufacturing, and accurate defect detection is essential for ensuring product quality and reliability. However, PCB defects are often small, irregularly shaped, and embedded in complex textures, making them difficult to detect using traditional methods. In this paper, we propose CM-UNetv2, a semantic segmentation network designed to address these challenges through three architectural modules incorporating four key innovations. First, a Parallelized Patch-Aware Attention (PPA) module is incorporated into the encoder to enhance multi-scale feature representation through a multi-branch attention mechanism combining local, global, and serial convolutions. Second, we propose a Dual-Stream Skip Guidance (DSSG) module that decouples semantic refinement from spatial information preservation via two separate skip pathways, enabling finer detail retention. Third, we design a decoder module called Frequency-domain Guided Context Mamba (FGCMamba), which integrates two novel mechanisms: a Spatial Guidance Cross-Attention (SGCA) mechanism to enhance the alignment of spatial and semantic features, and a Frequency-domain Self-Attention Solver (FSAS) to compute global attention efficiently in the frequency domain, improving boundary restoration and reducing computational overhead. Experiments on the MeiweiPCB and KWSD2 datasets demonstrate that the CM-UNetv2 achieves state-of-the-art performance in small object detection, boundary accuracy, and overall segmentation robustness.
BibTeX
@inproceedings{guo2025cm,
  author = {Qiaoyun Guo and Yajun Chen and Yirui Zhu and Delin Chen},
  title = {{CM-UNetv2: An Enhanced Semantic Segmentation Model for Precise PCB Defect Detection and Boundary Restoration}},
  booktitle = {Sensors},
  year = {2025},
  doi = {10.3390/s25164919},
}
Figure