Skip to main content
PLOS One logoLink to PLOS One
. 2025 Sep 25;20(9):e0331175. doi: 10.1371/journal.pone.0331175

Vision transformer and Mamba-attention fusion for high-precision PCB defect detection

Asim Niaz 1, Muhammad Umraiz 1, Shafiullah Soomro 2, Kwang Nam Choi 1,*
Editor: Azim Uddin3
PMCID: PMC12463262  PMID: 40997120

Abstract

Defects in printed circuit boards (PCBs) are being detected using computer vision-based techniques. Defect-free PCBs are essential for the reliability of consumer electronics. However, deep learning-based methods often struggle with imbalanced defect distributions and limited generalization. To address these challenges, we propose ViT-Mamba, a hybrid framework that combines Vision Transformers with a Mamba-inspired attention mechanism for global feature extraction and precise defect segmentation. We further introduce an artificial defect generation module that systematically creates six types of PCB defects to improve robustness. A multiscale hierarchical refinement strategy is employed to enhance feature representation for accurate segmentation. Experiments on a public PCB defect dataset show that ViT-Mamba outperforms existing methods, achieving a mean Average Precision (mAP) of 99.69%.

Introduction

Defects are unexpected patterns that may emerge across various data modalities, including tabular, visual, textual, and time-series data. They may occur at any time and in any domain, often requiring automated detection for security, access control, or quality assurance. Automated systems are designed to flag such deviations, enabling timely intervention and response [1]. PCB defect detection is vital for maintaining the quality and reliability of consumer electronics, as even minor defects can lead to significant functional failures and economic losses [20]. In 2024, PCBs had an estimated market value of approximately $80 billion. Conventional manual inspection techniques are highly susceptible to environmental factors, leading to decreased defect detection accuracy. Recent advancements in computer vision and deep learning have significantly improved anomaly detection across various domains, including image aesthetics assessment [2], network anomaly detection [3,4], and 3D reconstruction [5]. Transformer-based architectures, such as PIPformers for image inpainting [6] and EAPT for image processing [7], have demonstrated superior feature extraction capabilities, enabling precise identification of complex patterns [8,9]. In medical imaging, models like Ecsu-Net [10] have been effective in segmentation and classification, showcasing the potential of deep learning for intricate defect detection tasks. Similarly, multimodal cascaded CNNs have been successfully applied to waste classification [11], highlighting the versatility of convolutional and transformer-based models for anomaly detection.

Detecting small PCB defects is challenging due to their subtle visual characteristics, often leading to visual strain and misclassification. To overcome these issues, researchers have increasingly adopted machine learning techniques, which have significantly advanced PCB defect detection in recent years. Despite the development of various computer vision-based automated methods, accurately identifying defects remains complex and continues to evolve [12,13]. Wang et al. [14] developed an automated algorithm capable of identifying 2 mm pinhole defects within ten seconds. Yuk et al. [15] combined accelerated robust features with a random forest algorithm to enhance defect detection by focusing on feature density in defect-prone areas. Gaidhane et al. [16] employed similarity metrics to detect PCB surface defects, demonstrating effectiveness in identifying and localizing anomalies even in complex component layouts. While other machine learning-based approaches [17,18] have been proposed, they often lack real-time processing capabilities and rely on manual feature extraction, limiting their adaptability to diverse defect types.

Fully supervised detection methods [1921] are widely used for detecting small targets, leveraging well-established networks such as YOLO [22,23] and TDD-Net [24]. While these approaches achieve high accuracy, their ability to generalize remains limited, making it difficult for the model to recognize PCB defect types not included in the training data. Additionally, training such models demands large-scale annotated datasets, which involve significant labor costs. The imbalanced distribution of defects in real-world PCB datasets further hampers the performance of fully supervised models.

Despite significant advancements in PCB defect detection, existing methods often struggle with limited generalization, computational inefficiency, and imbalanced defect distributions. Fully supervised approaches require extensive labeled datasets, making them costly and labor-intensive, while unsupervised methods frequently lack precision in anomaly localization. Additionally, CNN-based models, though effective in extracting spatial features, often fail to capture global dependencies, which are crucial for complex defect patterns.

To address these challenges, we propose ViT-Mamba, a hybrid framework that combines ViT-based feature extraction with a Mamba-inspired attention mechanism for precise segmentation and anomaly detection. Unlike traditional CNN-based architectures, our method effectively captures long-range dependencies, enhancing its ability to detect subtle and irregular PCB defects. Moreover, our artificial defect creation module systematically augments training data, improving robustness against real-world variations. The multi-scale hierarchical refinement in our decoder further refines feature representations, ensuring accurate anomaly segmentation while maintaining computational efficiency. The key contributions of this work are as follows:

  • Artificial Defect Creation Module: Systematically generates diverse PCB defects, mitigating data imbalance issues, and ensuring diverse and realistic training data.

  • ViT-Mamba Hybrid Architecture: Combines Vision Transformers for global feature extraction with a Mamba-inspired decoder to improve segmentation precision.

  • Multi-Scale Hierarchical Refinement: Utilizes multi-level convolutional features and Mamba attention gates to refine spatial representations, ensuring precise and computationally efficient anomaly segmentation.

The subsequent sections of this paper are organized as follows: the proposed method is first introduced, followed by the experiments and results. Next, the limitations and potential directions for future research are discussed, and finally, the study is concluded.

Related work

PCB defect detection methods generally fall into two main categories: traditional machine vision techniques and deep learning-based approaches.

Traditional methods typically involve image preprocessing, segmentation, feature extraction, and classification. Moganti et al. [25] surveyed early inspection algorithms that relied on techniques such as image subtraction and template matching. These approaches use handcrafted features—shape, texture, color—to detect issues like missing holes, open circuits, and shorts. For example, Raihan and Ce [26] applied image subtraction using OpenCV, while Raj and Sajeena [27] utilized general-purpose image processing techniques for defect detection. However, such methods are limited by low adaptability to complex defect types and varying conditions, and they require extensive manual feature engineering [28]

Deep learning has significantly improved defect detection by enabling end-to-end learning from data. Convolutional Neural Networks (CNNs), in particular, have shown strong performance. Chen et al. [28] reviewed CNN-based models like AlexNet, VGG, and ResNet, highlighting their high accuracy. Li and Guo [29] implemented Faster R-CNN with a VGG-16 backbone and data augmentation. Hu and Wang [30] enhanced Faster R-CNN using a Feature Pyramid Network (FPN) and generative adversarial region proposals, improving small defect detection.

Single-stage detectors such as YOLO and SSD offer fast inference, making them suitable for real-time inspection. Xin et al. [31] optimized YOLOv4 with mosaic augmentation and Mish activation. Zhang et al. [32] proposed a lightweight detector using dual attention and a path-aggregation FPN, and Wu et al. [33] introduced GSC YOLOv5 with Ghost Convolution and attention modules to enhance speed and accuracy.

Transformer-based models have recently gained attention for their ability to capture long-range dependencies. An et al. [34] proposed LPViT using label smoothing and patch correlation. Chen et al. [35] replaced CNNs with a Swin Transformer in a YOLO-like architecture. Yang et al. [36] integrated SwinV2TDD into YOLOv7, combining local and global features for improved performance.

Despite progress, challenges remain. Deep models often require large datasets, significant computational resources, and lack interpretability. Traditional methods, while lightweight, fail to generalize across diverse defect types. Recent trends involve hybrid models combining CNNs and Transformers [37], with future directions including GAN-based data augmentation, transfer learning for small datasets, and explainable AI solutions [28].

In summary, the evolution from traditional to deep learning approaches has advanced PCB defect detection. CNNs offer a balance between speed and accuracy, while Transformers improve performance in complex scenarios. Building on this, our proposed method combines mathematically generated artificial defects with a ViT-Mamba architecture. By simulating six realistic defect types, we address data imbalance, and through Vision Transformers and Mamba-inspired attention mechanisms, we enable accurate segmentation and localization—providing a robust, efficient solution for diverse PCB defect detection tasks.

Proposed method

    The proposed method consists of two main modules: artificial defects creation and ViT-Mamba. The overall pipeline of the proposed PCB anomaly detection framework is illustrated in Fig 1.

Fig 1. Pipeline of the ViT-Mamba.

Fig 1

A defect-free PCB undergoes artificial anomaly creation to generate synthetic defects for training. The ViT-Mamba architecture processes these images using a ViT encoder for feature extraction, multi-scale convolutional layers for hierarchical representation, and a Mamba-inspired decoder with attention gates.

Artificial defects creation

Defect detection in PCBs is inherently challenging due to the limited availability of labeled data for rare defect types and the imbalance in defect categories. To address these challenges, we propose a structured framework for artificially generating six distinct PCB defect types: Missing Hole, Mouse Bite, Open Circuit, Short, Spur, and Spurious Copper. The artificial creation of these defects is governed by mathematically formulated rules to ensure realism, alignment with real-world manufacturing anomalies, and compatibility with diverse PCB designs. Additionally, defects are induced into the dataset using a randomization strategy to enhance variability and robustness.

1. Missing hole.

Condition: Missing holes occur when predefined vias or mounting holes are not drilled properly during manufacturing. These defects disrupt the electrical connections between PCB layers or impede mechanical assembly.

Mathematical Formulation:

Dhole(x,y)={1if (x,y)H, where H is the set of predefined hole centers,0otherwise. (1)

Constraint:

(xhx)2+(yhy)2<r2,where r is the radius of the hole. (2)

Explanation: The predefined hole positions are derived from PCB design files, such as Gerber drill files, which specify the coordinates of critical vias, mounting holes, or component connections. The defect is simulated by applying a circular mask to remove specific hole regions, ensuring the defect aligns with realistic manufacturing errors. Missing hole defects are introduced randomly into selected hole positions.

2. Mouse bite.

Condition: Mouse bite defects are irregular notches along conductive traces caused by incomplete etching or mechanical stress. These defects can weaken the trace and lead to electrical instability.

Mathematical Formulation:

Dmouse(x,y)={1if dist((x,y),T)<ϵ and R(x,y)=1,0otherwise. (3)

Here, T is the set of conductive trace points, ε is the max notch distance, and R(x,y) defines the notch shape.

Explanation: Mouse bite defects are applied by introducing notches along the conductive traces of the PCB. The trace points T are randomly selected, and the size, shape, and orientation of the notches are varied to simulate real-world imperfections. These defects mimic failures in the etching process and mechanical handling errors.

3. Open circuit.

Condition: Open circuit defects occur when breaks along conductive traces interrupt the electrical continuity of a circuit, often due to incomplete etching or mechanical damage.

Mathematical Formulation:

Dopen(x,y)={0if (x,y)Tbreak,1if (x,y)TTbreak,0otherwise. (4)

Here, T is all trace points, Tbreak is the broken subset, and Length(Tbreak)<Lmax limits break length.

Explanation: Open circuit defects are simulated by removing segments of conductive traces. The location and length of the break are randomized to replicate diverse failure scenarios. These defects disrupt the continuity of the circuit, providing an effective training dataset for detecting trace interruptions.

4. Short.

Condition: Short circuit defects are unintended connections between two conductive elements, often caused by excess solder, copper residues, or manufacturing errors.

Mathematical Formulation:

Dshort(x,y)={1if (x,y)S, where S=C1C2,0otherwise. (5)

Here:

  • C1,C2: Sets of points for the two conductive elements being shorted.

  • dist(C1,C2)<δ: threshold for short placement.

Explanation: Short circuits are introduced by artificially connecting two nearby conductive elements. The placement and geometry of the short are randomized to reflect realistic manufacturing or assembly errors. This defect simulates unintended bridging, a critical anomaly in PCB functionality.

5. Spur.

Condition: Spur defects are thin, unintended protrusions extending from conductive traces, often caused by over-etching or material deposition errors.

Mathematical Formulation:

Dspur(x,y)={1if (x,y)T and (x,y)P,0otherwise. (6)

Here:

  • T: Set of trace points.

  • P: Protrusion points defined as:
    P={(x,y):dist((x,y),T)w and Length(P)l}. (7)
  • w,l: Maximum width and length of the spur.

Explanation: Spur defects are applied as protrusions along the traces, varying in size and shape. The placement of these defects is controlled to ensure alignment with real-world patterns observed in faulty PCBs.

6. Spurious copper.

Condition: Spurious copper defects occur as random copper patches left on the PCB due to incomplete etching or material deposition.

Mathematical Formulation:

Dspurious(x,y)={1if (x,y)C,0otherwise. (8)

Here:

  • C: Set of randomly placed copper patch points.

  • C={(x,y):R(x,y)=1},whereR(x,y) is a random binary mask.

Explanation: Spurious copper defects are simulated by randomly placing irregular copper patches across the PCB. The randomness ensures variation in patch size, shape, and placement, making the dataset more comprehensive.

General context constraints.

  1. Avoid Overlapping Defects:
    Di(x,y)Dj(x,y)=ij (9)

    Ensures that defects do not overlap unless explicitly intended.

  2. Region-Specific Constraints:
    D(x,y)EmptyRegion=,D(x,y)CriticalRegion (10)

    Ensures defects are placed in logical regions of the PCB and avoid unused areas.

Random induction of defects.

A randomization strategy introduces defects into defect-free PCB images by generating binary masks that define the size, location, and orientation of each defect. The artificially defective PCB image, denoted as Ia, is generated by combining the original defect-free image I, the defect-only image M, and the binary mask Ma. The generation formula is defined as follows:

Ia=not(Ma)I+M, (11)

where not(Ma) represents the inverse of the binary mask, marking the non-defective regions, denotes element-wise multiplication. This ensures seamless integration of defects while preserving the intact areas of the PCB.

To further enhance variability, the defects and their corresponding masks undergo a series of random transformations, including rotation, translation, and scaling. Rotation applies a random angle to the defects and masks, translation shifts them randomly along the x- and y-axes, and scaling adjusts their size using a random factor. This diversifies the dataset, improving model robustness for anomaly detection and segmentation. Figs 2 and 3 illustrate the defect creation pipeline and generated synthetic masks.

Fig 2. Artificial defect creation pipeline: A defect-free PCB undergoes mathematically defined defect generation and random transformations to produce defected samples.

Fig 2

Fig 3. Illustration of various masks generated using the artificial defects creation module.

Fig 3

ViT-Mamba

This section presents ViT-Mamba, a novel architecture for image anomaly detection and segmentation. The proposed method integrates the global feature extraction capabilities of ViTs in the encoder with a Mamba-inspired decoder that utilizes attention mechanisms for precise segmentation and anomaly localization. The framework is designed to address challenges in industrial and medical imaging, where accurate anomaly detection and pixel-level segmentation are crucial.

Encoder: Vision transformer-based feature extraction.

The encoder leverages the Vision Transformer (ViT) to capture global dependencies and contextual information by processing images as non-overlapping patches. The input image 𝐗H×W×C is divided into patches of size P×P, forming a sequence of flattened patches 𝐗pN×(P2·C), where N=H·WP2 is the number of patches. The embeddings of these patches are then processed through a multi-layer transformer.

The transformer computes self-attention as follows:

Attention(𝐐,𝐊,𝐕)=Softmax(QKdk)𝐕, (12)

where 𝐐, 𝐊, and 𝐕 are the query, key, and value matrices, respectively, and dk is the dimensionality of the keys.

To adapt the ViT for segmentation tasks, the encoded feature maps are passed through lightweight convolutional layers to generate hierarchical feature representations at multiple scales. These feature maps are denoted as {b1,b2,b3,b4,b5}, where b1 corresponds to shallow features and b5 contains the most semantic information. The multi-scale features are then forwarded to the decoder.

Decoder: Mamba-inspired attention-gated design.

The decoder employs a Mamba-inspired design that incorporates attention gates and efficient upsampling mechanisms to produce high-resolution segmentation maps. The decoder comprises three key components:

Mamba attention gates.

Mamba Attention gates refine the skip connections from the encoder by suppressing irrelevant features and enhancing the most relevant ones. Given the decoder’s intermediate features 𝐠 and the encoder’s skip connection 𝐱, the attention gate outputs a refined feature map 𝐱:

𝐱=𝐱·ψ(ReLU(𝐖g𝐠+𝐖x𝐱)), (13)

where 𝐖g and 𝐖x are learnable weight matrices, and ψ is a sigmoid activation function. This mechanism improves the focus on anomalous regions. The Mamba Attention Gate mechanism is illustrated in Fig 4.

Fig 4. Mamba attention gate workflow.

Fig 4

Encoder (𝐱) and decoder (𝐠) features are weighted, combined, and passed through ReLU and sigmoid activations to compute attention weights (ψ). These weights refine 𝐱, producing the final feature map (𝐱) for improved segmentation.

Efficient upsampling.

The decoder progressively upsamples the feature maps using bilinear interpolation followed by convolutional layers. Each upsampling stage integrates refined skip connections from the encoder to recover fine-grained details.

Multi-scale refinement.

The decoder processes the hierarchical features b1,b2,b3,b4,b5 starting from the deepest map b5. At each stage, the upsampled feature is concatenated with the corresponding skip connection and passed through a decoding block:

𝐟out=Conv([𝐟up,𝐱]), (14)

where 𝐟up is the upsampled feature, 𝐱 is the refined skip connection, and [·] denotes concatenation.

Table 1 summarizes the ViT-Mamba architecture, detailing the encoder, Mamba-based decoder, layer types, output shapes, and key design components for anomaly detection and segmentation.

Table 1. Network architecture of the ViT-Mamba framework. The table provides a detailed overview of the components, layer types, output shapes, and additional details.
Component Layer Type Output Shape Details
Input Input Image 256×256×3 RGB Input
Encoder ViT Patch Embeddings 16×16×768 Patch Size: 16×16, Embedding Dim: 768
Vision Transformer 16×16×768 12 Layers, 8 Heads, MLP Ratio: 4.0
Convolution Conv1 16×16×128 1×1 Convolution
Conv2 16×16×256 1×1 Convolution
Conv3 16×16×512 1×1 Convolution
Conv4 16×16×1024 1×1 Convolution
Conv5 16×16×1024 1×1 Convolution
Encoder Skip Connections Feature Maps: b1,b2,b3,b4,b5
Decoder Mamba Attention Gate 1 Refines Features: b5 and b4
Upsampling Block 1 16×16×102432×32×1024 Bilinear + Conv
Decoding Block 1 32×32×1024 Conv-BatchNorm-ReLU
Mamba Attention Gate 2 Refines Features: b4 and Decoder Output
Upsampling Block 2 32×32×102464×64×512 Bilinear + Conv
v Decoding Block 2 64×64×512 Conv-BatchNorm-ReLU
Mamba Attention Gate 3 Refines Features: b3 and Decoder Output
Upsampling Block 3 64×64×512128×128×256 Bilinear + Conv
Decoding Block 3 128×128×256 Conv-BatchNorm-ReLU
Mamba Attention Gate 4 Refines Features: b2 and Decoder Output
Final Upsampling 128×128×256256×256×128 Bilinear + Conv
Final Decoding Block 256×256×128 Conv-BatchNorm-ReLU
Output Layer 256×256×3 1×1 Conv for Final Segmentation

Loss calculation.

The proposed ViT-Mamba framework optimizes a hybrid loss function designed to address both segmentation accuracy and anomaly detection performance. The total loss, , combines pixel-wise segmentation loss, anomaly detection loss, and focal loss to handle challenges such as class imbalance and hard-to-detect anomalies. The loss is defined as:

=λ1seg+λ2anomaly+λ3focal, (15)

where λ1, λ2, and λ3 are weighting factors that balance the contribution of each loss component.

The segmentation loss, seg, ensures accurate pixel-wise predictions for both normal and anomalous regions. This loss penalizes the difference between the predicted segmentation mask 𝐘^ and the ground truth 𝐘. Common choices for seg include the Dice loss or binary cross-entropy (BCE) loss, defined as:

seg=1Ni=1N[yilog(y^i)+(1yi)log(1y^i)], (16)

where N is the total number of pixels, and yi and y^i represent the ground truth and predicted probabilities, respectively, for pixel i.

The anomaly detection loss, anomaly, guides the model to distinguish anomalous regions from normal regions. This loss emphasizes the detection of rare and subtle anomalies, penalizing false positives and false negatives. For binary anomaly detection, anomaly can also be formulated using BCE loss.

To address class imbalance and improve the detection of hard-to-classify regions, focal loss, focal, is incorporated into the total loss. Focal loss dynamically reduces the weight of well-classified examples, allowing the model to focus on harder examples. It is defined as:

focal=α(1pt)γlog(pt), (17)

where pt is the predicted probability for the true class, α[0,1] is a balancing factor, and γ0 is the focusing parameter. For multi-class segmentation, this loss can be extended by summing over all classes.

The weighting factors λ1, λ2, and λ3 allow fine-tuning of the relative importance of segmentation accuracy, anomaly detection performance, and hard example emphasis. These weights are determined empirically based on the specific characteristics of the dataset and the task requirements.

The hybrid loss function ensures that the model effectively learns to segment and localize anomalies while addressing challenges like class imbalance and subtle anomaly patterns, making the ViT-Mamba framework robust and efficient for anomaly detection tasks.

The ViT-Mamba framework integrates a Vision Transformer encoder for global context awareness, enhancing robustness to anomalies of varying sizes. Attention gates in the decoder refine skip connections for precise segmentation, while efficient upsampling and multi-scale refinement ensure computational efficiency. Hierarchical features enable accurate anomaly localization, making ViT-Mamba a powerful and scalable solution for image anomaly detection and segmentation. Algorithm 1 outlines the framework’s detailed steps.

Algorithm 1. ViT-Mamba framework for PCB defect detection.

1: Input: Image IH×W×C, ViT parameters ΘViT, Decoder parameters ΘDec, Loss weights λ1,λ2,λ3

2: Output: Predicted segmentation mask Y^

3: 1. Preprocessing & Data Augmentation

4: Introduce artificial defects (e.g., missing hole, spur) and generate binary masks Ma

5: 2. Feature Extraction via ViT

6: Divide I into P×P patches, obtain embeddings Xp, and extract hierarchical features {b1,,b5} via ViT

7: 3. Decoding via Mamba-Attention

8: for each feature bi{b5,,b1} do

9:   Refine skip connection with attention gates:

10:   x=x·ψ(ReLU(Wgg+Wxx))

11:   Upsample, concatenate, and pass through decoding blocks

12: end for

13: 4. Segmentation Output

14: Apply 1×1 convolution to obtain Y^

15: 5. Loss Calculation

16: Compute loss: L=λ1Lseg+λ2Lanomaly+λ3Lfocal

17: 6. Optimization

18: Update ΘViT,ΘDec via backpropagation

    return Predicted segmentation mask Y^

Experiments and results

Dataset and implementation details

We utilize the publicly available PCB defect dataset[38] released by the Open Lab on Human-Robot Interaction at Peking University. This dataset comprises 1,386 images containing six types of PCB defects, namely missing hole, mouse bite, open circuit, short, spur, and spurious copper. These defects are introduced into PCB images, making the dataset suitable for tasks such as defect detection, classification, and registration. Fig 5 presents examples from the PCB defect dataset, illustrating one image per defect category with annotated bounding boxes.

Fig 5. Examples from the PCB defect dataset, showcasing one image per defect category with annotated bounding boxes: missing hole, mouse bite, open circuit, short, spur, and spurious copper.

Fig 5

During the experimental evaluation, the model was trained for 1000 epochs. The batch size was set to 8, and the learning rate was initialized at 0.0001. To address potential overfitting due to the limited size of the training dataset, data augmentation was employed by applying random rotations within the range of −45 to 45 degrees. The proposed network was implemented using PyTorch, and all experiments were conducted on a workstation equipped with an NVIDIA GeForce RTX 3090Ti GPU.

Comparison with state-of-the-art methods

Table 2 presents a comparative analysis of various supervised and unsupervised methods for PCB defect detection, evaluated across six defect types: Missing Hole, Mouse Bite, Open Circuit, Short, Spur, and Spurious Copper. The results are reported in terms of Average Precision (AP) for each defect type, along with the mean Average Precision (mAP) for overall performance comparison.

Table 2. Comparison of different methods for PCB defect detection.

Method AP mAP
Missing Hole Mouse Bite Open Circuit Short Spur Spurious Copper
SVM (Supervised)
Zhang et al. [39] 44.4 27.5 56.9 82.2 44.2 82.1 56.2
Li et al. [40] 46.6 13.0 36.2 48.6 31.2 65.7 40.4
Chaudhary et al. [41] 97.2 84.7 96.0 92.6 82.7 97.2 91.7
Neural Network (Supervised)
Li et al. [42] 97.0 97.9 97.0 97.5 93.7 98.5 97.7
Huang et al. [43] 97.0 97.9 97.0 97.5 93.7 98.5 97.5
Lim et al. [44] - - - - - - 99.17
Hu et al. [45] - - - - - - 98.45
Ding et al. [24] - - - - - - 98.9
Chen et al. [46] - - - - - - 99.17
Unsupervised
Zeng et al. [47] 97.35 97.15 95.46 99.15 99.82 99.05 93.27
Roth et al. [48] 85.14 60.06 80.18 85.32 50.94 81.09 73.77
Changlin et al. [49] 99.91 97.55 98.42 99.97 99.92 99.97 99.29
ViT Mamba 99.93 99.21 99.13 99.96 99.98 99.97 99.69

Among the SVM-based supervised approaches, Chaudhary et al. achieved the highest mAP of 91.7%, significantly outperforming Zhang et al. and Li et al., whose mAP scores were 56.2% and 40.4%, respectively. The Neural Network-based supervised approaches demonstrated higher accuracy, with Li et al. and Huang et al. both achieving an mAP of 97.7% and 97.5%, respectively. Other deep learning-based methods, such as Lim et al. and Chen et al., reported mAP values exceeding 99.0%, indicating strong performance in supervised learning settings.

In contrast, unsupervised methods varied significantly in performance. While Roth et al. achieved a relatively lower mAP of 73.77%, other methods such as Zeng et al. (93.27%) and Changlin et al. (99.29%) showed strong results. The proposed method, ViT-Mamba, outperformed all existing techniques, achieving the highest mAP of 99.69%, with near-perfect AP values across all defect categories. These results highlight the effectiveness of ViT-Mamba in accurately detecting PCB defects without requiring extensive supervised training. The radar chart in Fig 6 illustrates the AP scores of four top-performing PCB defect detection methods (Changlin et al., ViT Mamba, Zeng et al., and Chaudhary et al.) across six defect categories. Each axis represents a different defect type, and the area covered by each method indicates its overall detection capability. ViT Mamba and Changlin et al. exhibit consistently high performance across all defect types, while Zeng et al. shows slightly lower accuracy in detecting open circuits. The chart highlights variations in method effectiveness, offering an intuitive comparison of strengths and weaknesses in PCB defect detection.

Fig 6. Performance comparison of top methods across defect types.

Fig 6

The significant improvement in performance demonstrates the potential of ViT-Mamba as a robust and scalable solution for real-world PCB defect detection. The results indicate that transformer-based architectures, particularly ViT-Mamba, can generalize well to diverse defect types while maintaining superior detection accuracy.

Ablation studies

To assess the contribution of each component in the proposed ViT-Mamba framework, we conducted ablation experiments, as per Table 3, on the PCB defect dataset. The study isolates the impact of three core modules: (1) the Vision Transformer (ViT) encoder, (2) Mamba-inspired attention gates, and (3) the multiscale hierarchical refinement strategy. In each experiment, one component was removed or replaced, while the rest of the model remained unchanged.

Table 3. Performance comparison from ablation experiments. Each component is removed or replaced to assess its contribution to the model. Results are reported as mean Average Precision (mAP).

Configuration mAP (%)
Full ViT-Mamba (Proposed) 99.69
ViT Replaced with ResNet Backbone 90.58
Without Mamba Attention Gates (simple skip) 96.47
Without Multiscale Refinement (single scale) 95.83

The full ViT-Mamba model achieved the highest accuracy. Removing the artificial defect generation module significantly degraded performance, emphasizing its role in addressing data imbalance. Replacing Mamba attention with simple skip connections reduced segmentation precision, and removing multiscale refinement affected the model’s ability to recover fine-grained details. Substituting the ViT encoder with a ResNet backbone also resulted in lower performance, indicating the importance of modeling global dependencies.

These results confirm the effectiveness of each proposed module and validate the overall architecture design of ViT-Mamba for high-precision PCB defect detection.

Discussion

    The ViT-Mamba framework, while highly accurate, could face challenges in computational efficiency and real-time deployment, especially on edge devices. Its reliance on ViTs increases processing demands compared to CNNs, and its generalization to real-world PCB images with diverse lighting, resolutions, and textures remains untested. Industrial variations like noise, reflections, and occlusions could impact robustness, requiring further validation. The artificial defect creation module, though useful, may not fully capture all real-world defect patterns, affecting adaptability.

Future research should focus on optimizing computational efficiency through lightweight transformers, model compression (pruning, quantization), and edge AI implementations. Unsupervised and self-supervised learning can enhance domain generalization, while few-shot and zero-shot learning could improve adaptability to novel defects. Multi-modal imaging (thermal, X-ray) may further refine defect detection, and adversarial training can boost robustness against industrial variations. Lastly, explainable AI (XAI) will improve model transparency and trust, supporting broader adoption in automated PCB quality inspection for consumer electronics manufacturing.

Conclusion

    This study proposed ViT-Mamba, a hybrid Vision Transformer (ViT) and Mamba-inspired framework for PCB defect detection. By integrating global feature extraction with attention-driven segmentation, the model effectively detects subtle and irregular defects while maintaining computational efficiency. The inclusion of an Artificial Defect Creation Module further enhances robustness by diversifying training data. Experimental results show that ViT-Mamba outperforms existing methods, achieving a mean Average Precision (mAP) of 99.69%, demonstrating its effectiveness for real-world PCB inspection. Future work can focus on optimizing computational efficiency and enhancing generalization to unseen defects. ViT-Mamba contributes to advancing deep learning for industrial anomaly detection, offering a scalable and accurate solution for PCB quality inspection.

Data Availability

All relevant data are within the manuscript.

Funding Statement

This work was supported by the Ministry of Science and Information and Communication Technology (ICT) and National IT Industry Promotion Agency (NIPA) through the High Performance Computing (HPC) Support Project. The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript.

References

  • 1.Niaz A, Ul Amin S, Soomro S, Zia H, Nam Choi K. Spatially aware fusion in 3D convolutional autoencoders for video anomaly detection. IEEE Access. 2024;12:104770–84. doi: 10.1109/access.2024.3435144 [DOI] [Google Scholar]
  • 2.Yang B, Zhu C, Li FWB, Wei T, Liang X, Wang Q. IAACS: image aesthetic assessment through color composition and space formation. Virtual Reality & Intelligent Hardware. 2023;5(1):42–56. doi: 10.1016/j.vrih.2022.06.006 [DOI] [Google Scholar]
  • 3.Tian X, Wu Z, Cao J, Chen S, Dong X. ILIDViz: an incremental learning-based visual analysis system for network anomaly detection. Virtual Reality & Intelligent Hardware. 2023;5(6):471–89. doi: 10.1016/j.vrih.2023.06.009 [DOI] [Google Scholar]
  • 4.Wei H, Li Q, Pan J, Chen J, Zhang Y, Qi L, et al. SPSNet: semantic-guided perspective shift network for robust person re-identification in drone imagery. Vis Comput. 2024;41(8):5563–82. doi: 10.1007/s00371-024-03738-z [DOI] [Google Scholar]
  • 5.Zhu X, Yao X, Zhang J, Zhu M, You L, Yang X, et al. TMSDNet: Transformer with multi-scale dense network for single and multi-view 3D reconstruction. Comput Animation Virtual. 2023;35(1). doi: 10.1002/cav.2201 [DOI] [Google Scholar]
  • 6.Lee J, Kang H. PIPformers: Patch based inpainting with vision transformers for generalize paintings. Computer Animation Virtual. 2024;35(3). doi: 10.1002/cav.2270 [DOI] [Google Scholar]
  • 7.Lin X, Sun S, Huang W, Sheng B, Li P, Feng DD. EAPT: Efficient Attention Pyramid Transformer for Image Processing. IEEE Trans Multimedia. 2023;25:50–61. doi: 10.1109/tmm.2021.3120873 [DOI] [Google Scholar]
  • 8.Wang J, Du H, Zeng Y. PDFormer: Efficient Vision Transformer for Photovoltaic Defect Detection. IEEE Trans Consumer Electron. 2025;71(2):6602–11. doi: 10.1109/tce.2025.3536438 [DOI] [Google Scholar]
  • 9.Gao H, Jiang W, Ran Q, Wang Y. Vision-Language Interaction via Contrastive Learning for Surface Anomaly Detection in Consumer Electronics Manufacturing. IEEE Trans Consumer Electron. 2024;70(3):6119–30. doi: 10.1109/tce.2024.3378771 [DOI] [Google Scholar]
  • 10.Nazir A, Cheema MN, Sheng B, Li P, Li H, Xue G, et al. ECSU-Net: An Embedded Clustering Sliced U-Net Coupled With Fusing Strategy for Efficient Intervertebral Disc Segmentation and Classification. IEEE Trans Image Process. 2022;31:880–93. doi: 10.1109/TIP.2021.3136619 [DOI] [PubMed] [Google Scholar]
  • 11.Li J, Chen J, Sheng B, Li P, Yang P, Feng DD, et al. Automatic Detection and Classification System of Domestic Waste via Multimodel Cascaded Convolutional Neural Network. IEEE Trans Ind Inf. 2022;18(1):163–73. doi: 10.1109/tii.2021.3085669 [DOI] [Google Scholar]
  • 12.Tong K, Wu Y, Zhou F. Recent advances in small object detection based on deep learning: A review. Image and Vision Computing. 2020;97:103910. doi: 10.1016/j.imavis.2020.103910 [DOI] [Google Scholar]
  • 13.Fupei Wu, Xianmin Zhang, Yongcong Kuan, Zhenzhen He. An AOI algorithm for PCB based on feature extraction. In: 2008 7th World Congress on Intelligent Control and Automation. 2008. 10.1109/wcica.2008.4592931 [DOI]
  • 14.Wang W-C, Chen S-L, Chen L-B, Chang W-J. A machine vision based automatic optical inspection system for measuring drilling quality of printed circuit boards. IEEE Access. 2017;5:10817–33. doi: 10.1109/access.2016.2631658 [DOI] [Google Scholar]
  • 15.Yuk EH, Park SH, Park C-S, Baek J-G. Feature-Learning-Based Printed Circuit Board Inspection via Speeded-Up Robust Features and Random Forest. Appl Sci. 2018;8(6):932. doi: 10.3390/app8060932 [DOI] [Google Scholar]
  • 16.Gaidhane VH, Hote YV, Singh V. An efficient similarity measure approach for PCB surface defect detection. Pattern Anal Applic. 2017;21(1):277–89. doi: 10.1007/s10044-017-0640-9 [DOI] [Google Scholar]
  • 17.Tsai D, Hsieh Y. Machine Vision-Based Positioning and Inspection Using Expectation–Maximization Technique. IEEE Trans Instrum Meas. 2017;66(11):2858–68. doi: 10.1109/tim.2017.2717284 [DOI] [Google Scholar]
  • 18.Liu Z, Qu B. Machine vision based online detection of PCB defect. Microprocessors Microsystems. 2021;82:103807. doi: 10.1016/j.micpro.2020.103807 [DOI] [Google Scholar]
  • 19.Liu W, Anguelov D, Erhan D, Szegedy C, Reed S, Fu CY. Ssd: Single shot multibox detector. In: Computer Vision–ECCV 2016 : 14th European Conference, Amsterdam, The Netherlands, October 11–14, 2016, Proceedings, Part I. 2016;21–37.
  • 20.Zhang Q, Liu H. Multi-scale defect detection of printed circuit board based on feature pyramid network. In: 2021 IEEE International Conference on Artificial Intelligence and Computer Applications (ICAICA). 2021;911–4. 10.1109/icaica52286.2021.9498174 [DOI]
  • 21.Zhong Z, Ma Z. A Novel Defect Detection Algorithm for Flexible Integrated Circuit Package Substrates. IEEE Trans Ind Electron. 2022;69(2):2117–26. doi: 10.1109/tie.2021.3057026 [DOI] [Google Scholar]
  • 22.Zhang Y, Zhang W, Yu J, He L, Chen J, He Y. Complete and accurate holly fruits counting using YOLOX object detection. Comput Electronics Agriculture. 2022;198:107062. doi: 10.1016/j.compag.2022.107062 [DOI] [Google Scholar]
  • 23.Tong K, Wu Y. I-YOLO: a novel single-stage framework for small object detection. Vis Comput. 2024;40(12):8927–44. doi: 10.1007/s00371-024-03284-8 [DOI] [Google Scholar]
  • 24.Ding R, Dai L, Li G, Liu H. TDD-net: a tiny defect detection network for printed circuit boards. CAAI Trans on Intel Tech. 2019;4(2):110–6. doi: 10.1049/trit.2019.0019 [DOI] [Google Scholar]
  • 25.Moganti M, Ercal F, Dagli CH, Tsunekawa S. Automatic PCB Inspection Algorithms: A Survey. Computer Vision and Image Understanding. 1996;63(2):287–313. doi: 10.1006/cviu.1996.0020 [DOI] [Google Scholar]
  • 26.Raihan F, Ce W. PCB defect detection USING OPENCV with image subtraction method. In: 2017 International Conference on Information Management and Technology (ICIMTech). 2017;204–9. 10.1109/icimtech.2017.8273538 [DOI]
  • 27.Raj A, Sajeena A. Defects detection in PCB using image processing for industrial applications. In: 2018 Second International Conference on Inventive Communication and Computational Technologies (ICICCT). 2018;1077–9.
  • 28.Ling Q, Isa NAM. Printed Circuit Board Defect Detection Methods Based on Image Processing, Machine Learning and Deep Learning: A Survey. IEEE Access. 2023;11:15921–44. doi: 10.1109/access.2023.3245093 [DOI] [Google Scholar]
  • 29.Li YT, Guo JI. A VGG-16 based faster RCNN model for PCB error inspection in industrial AOI applications. In: 2018 IEEE International Conference on Consumer Electronics-Taiwan (ICCE-TW). 2018;1–2.
  • 30.Hu B, Wang J. Detection of PCB Surface Defects With Improved Faster-RCNN and Feature Pyramid Network. IEEE Access. 2020;8:108335–45. doi: 10.1109/access.2020.3001349 [DOI] [Google Scholar]
  • 31.Xin H, Chen Z, Wang B. PCB Electronic Component Defect Detection Method based on Improved YOLOv4 Algorithm. J Phys: Conf Ser. 2021;1827(1):012167. doi: 10.1088/1742-6596/1827/1/012167 [DOI] [Google Scholar]
  • 32.Zhang Y, Xie F, Huang L, Shi J, Yang J, Li Z. A lightweight one-stage defect detection network for small object based on dual attention mechanism and PAFPN. Front Physics. 2021;9:708097. [Google Scholar]
  • 33.Wu L, Zhang L, Zhou Q. Printed Circuit Board Quality Detection Method Integrating Lightweight Network and Dual Attention Mechanism. IEEE Access. 2022;10:87617–29. doi: 10.1109/access.2022.3198994 [DOI] [Google Scholar]
  • 34.An K, Zhang Y. LPViT: A Transformer Based Model for PCB Image Classification and Defect Detection. IEEE Access. 2022;10:42542–53. doi: 10.1109/access.2022.3168861 [DOI] [Google Scholar]
  • 35.Chen W, Huang Z, Mu Q, Sun Y. PCB Defect Detection Method Based on Transformer-YOLO. IEEE Access. 2022;10:129480–9. doi: 10.1109/access.2022.3228206 [DOI] [Google Scholar]
  • 36.Yang Y, Kang H. An Enhanced Detection Method of PCB Defect Based on Improved YOLOv7. Electronics. 2023;12(9):2120. doi: 10.3390/electronics12092120 [DOI] [Google Scholar]
  • 37.Zou Z, Chen K, Shi Z, Guo Y, Ye J. Object Detection in 20 Years: A Survey. Proc IEEE. 2023;111(3):257–76. doi: 10.1109/jproc.2023.3238524 [DOI] [Google Scholar]
  • 38.Huang W, Wei P. A PCB dataset for defects detection and classification. arXiv preprint. 2019. doi: 10.48550/arXiv.1901.08204 [DOI] [Google Scholar]
  • 39.Zhang C, Shi W, Li X, Zhang H, Liu H. Improved bare PCB defect detection approach based on deep feature learning. J Eng. 2018;2018(16):1415–20. doi: 10.1049/joe.2018.8275 [DOI] [Google Scholar]
  • 40.Li Y, Li S. Defect detection of bare printed circuit boards based on gradient direction information entropy and uniform local binary patterns. CW. 2017;43(4):145–51. doi: 10.1108/cw-06-2017-0028 [DOI] [Google Scholar]
  • 41.Chaudhary V, Dave IR, Upla KP. Automatic visual inspection of printed circuit board for defect detection and classification. In: 2017 International Conference on Wireless Communications, Signal Processing and Networking (WiSPNET). 2017;732–7. 10.1109/wispnet.2017.8299858 [DOI]
  • 42.Li M, Yao N, Liu S, Li S, Zhao Y, Kong SG. Multisensor Image Fusion for Automated Detection of Defects in Printed Circuit Boards. IEEE Sensors J. 2021;21(20):23390–9. doi: 10.1109/jsen.2021.3106057 [DOI] [Google Scholar]
  • 43.Huang W, Wei P, Zhang M, Liu H. HRIPCB: a challenging dataset for PCB defects detection and classification. J Eng. 2020;2020(13):303–9. doi: 10.1049/joe.2019.1183 [DOI] [Google Scholar]
  • 44.Lim J, Lim J, Baskaran VM, Wang X. A deep context learning based PCB defect detection model with anomalous trend alarming system. Result Eng. 2023;17:100968. doi: 10.1016/j.rineng.2023.100968 [DOI] [Google Scholar]
  • 45.Hu X, Kong D, Liu X, Zhang J, Zhang D. Printed circuit board (PCB) surface micro defect detection model based on residual network with novel attention mechanism. Comput Materi Cont. 2024;78(1). [Google Scholar]
  • 46.Chen X, Wu Y, He X, Ming W. A comprehensive review of deep learning-based PCB defect detection. IEEE Access. 2023;11:139017–38. doi: 10.1109/access.2023.3339561 [DOI] [Google Scholar]
  • 47.Zeng N, Wu P, Wang Z, Li H, Liu W, Liu X. A Small-Sized Object Detection Oriented Multi-Scale Feature Fusion Approach With Application to Defect Detection. IEEE Trans Instrum Meas. 2022;71:1–14. doi: 10.1109/tim.2022.3153997 [DOI] [Google Scholar]
  • 48.Roth K, Pemula L, Zepeda J, Schölkopf B, Brox T, Gehler P. Towards total recall in industrial anomaly detection. In: Proceedings of the IEEE/CVF conference on computer vision and pattern recognition; 2022. p. 14318–28.
  • 49.Chen C, Wu Q, Zhang J, Xia H, Lin P, Wang Y. Y. U 2 D 2 PCB: uncertainty-aware unsupervised defect detection on PCB images using reconstructive and discriminative models. IEEE Transactions on Instrumentation and Measurement. 2024. [Google Scholar]

Decision Letter 0

Azim Uddin

1 Jul 2025

PONE-D-25-26195Vision Transformer and Mamba-Attention Fusion for High-Precision PCB Defect DetectionPLOS ONE

Dear Dr. Choi,

Thank you for submitting your manuscript to PLOS ONE. After careful consideration, we feel that it has merit but does not fully meet PLOS ONE’s publication criteria as it currently stands. Therefore, we invite you to submit a revised version of the manuscript that addresses the points raised during the review process.

==============================

Please answer the questions of all the reviewers carefully. Please also emphasize on the novelty of your work.

==============================

Please submit your revised manuscript by Aug 15 2025 11:59PM. If you will need more time than this to complete your revisions, please reply to this message or contact the journal office at plosone@plos.org. When you're ready to submit your revision, log on to https://www.editorialmanager.com/pone/ and select the 'Submissions Needing Revision' folder to locate your manuscript file.

Please include the following items when submitting your revised manuscript:

  • A rebuttal letter that responds to each point raised by the academic editor and reviewer(s). You should upload this letter as a separate file labeled 'Response to Reviewers'.

  • A marked-up copy of your manuscript that highlights changes made to the original version. You should upload this as a separate file labeled 'Revised Manuscript with Track Changes'.

  • An unmarked version of your revised paper without tracked changes. You should upload this as a separate file labeled 'Manuscript'.

If you would like to make changes to your financial disclosure, please include your updated statement in your cover letter. Guidelines for resubmitting your figure files are available below the reviewer comments at the end of this letter.

If applicable, we recommend that you deposit your laboratory protocols in protocols.io to enhance the reproducibility of your results. Protocols.io assigns your protocol its own identifier (DOI) so that it can be cited independently in the future. For instructions see: https://journals.plos.org/plosone/s/submission-guidelines#loc-laboratory-protocols. Additionally, PLOS ONE offers an option for publishing peer-reviewed Lab Protocol articles, which describe protocols hosted on protocols.io. Read more information on sharing protocols at https://plos.org/protocols?utm_medium=editorial-email&utm_source=authorletters&utm_campaign=protocols.

We look forward to receiving your revised manuscript.

Kind regards,

Azim Uddin, Ph.D.

Academic Editor

PLOS ONE

Journal Requirements: 

When submitting your revision, we need you to address these additional requirements.

1. Please ensure that your manuscript meets PLOS ONE's style requirements, including those for file naming. The PLOS ONE style templates can be found at

https://journals.plos.org/plosone/s/file?id=wjVg/PLOSOne_formatting_sample_main_body.pdf and

https://journals.plos.org/plosone/s/file?id=ba62/PLOSOne_formatting_sample_title_authors_affiliations.pdf.

2. Please note that PLOS ONE has specific guidelines on code sharing for submissions in which author-generated code underpins the findings in the manuscript. In these cases, we expect all author-generated code to be made available without restrictions upon publication of the work. Please review our guidelines at https://journals.plos.org/plosone/s/materials-and-software-sharing#loc-sharing-code and ensure that your code is shared in a way that follows best practice and facilitates reproducibility and reuse.

3. Thank you for stating the following financial disclosure:

 [This work was supported by the Ministry of Science and Information and Communication Technology (ICT) and National IT Industry Promotion Agency (NIPA) through the High Performance Computing (HPC) Support Project.]. 

Please state what role the funders took in the study.  If the funders had no role, please state: ""The funders had no role in study design, data collection and analysis, decision to publish, or preparation of the manuscript.""

If this statement is not correct you must amend it as needed.

Please include this amended Role of Funder statement in your cover letter; we will change the online submission form on your behalf.

4. Please review your reference list to ensure that it is complete and correct. If you have cited papers that have been retracted, please include the rationale for doing so in the manuscript text, or remove these references and replace them with relevant current references. Any changes to the reference list should be mentioned in the rebuttal letter that accompanies your revised manuscript. If you need to cite a retracted article, indicate the article’s retracted status in the References list and also include a citation and full reference for the retraction notice.

[Note: HTML markup is below. Please do not edit.]

Reviewers' comments:

Reviewer's Responses to Questions

Comments to the Author

1. Is the manuscript technically sound, and do the data support the conclusions?

The manuscript must describe a technically sound piece of scientific research with data that supports the conclusions. Experiments must have been conducted rigorously, with appropriate controls, replication, and sample sizes. The conclusions must be drawn appropriately based on the data presented.

Reviewer #1: Yes

Reviewer #2: Yes

**********

2. Has the statistical analysis been performed appropriately and rigorously?

Reviewer #1: Yes

Reviewer #2: N/A

**********

3. Have the authors made all data underlying the findings in their manuscript fully available?

The PLOS Data policy requires authors to make all data underlying the findings described in their manuscript fully available without restriction, with rare exception (please refer to the Data Availability Statement in the manuscript PDF file). The data should be provided as part of the manuscript or its supporting information, or deposited to a public repository. For example, in addition to summary statistics, the data points behind means, medians and variance measures should be available. If there are restrictions on publicly sharing data—e.g. participant privacy or use of data from a third party—those must be specified.

Reviewer #1: Yes

Reviewer #2: Yes

**********

4. Is the manuscript presented in an intelligible fashion and written in standard English?

PLOS ONE does not copyedit accepted manuscripts, so the language in submitted articles must be clear, correct, and unambiguous. Any typographical or grammatical errors should be corrected at revision, so please note any specific errors here.

Reviewer #1: Yes

Reviewer #2: Yes

**********

5. Review Comments to the Author

Please use the space provided to explain your answers to the questions above. You may also include additional comments for the author, including concerns about dual publication, research ethics, or publication ethics. (Please upload your review as an attachment if it exceeds 20,000 characters)

Reviewer #1: �1�Regarding the dataset used in the experiment, the paper mentioned in the experimental section that the dataset published by Peking University was used, with only individual data being rotated. However, in the "Abstract" and "Artificial Defects Creation" sections, it was mentioned that six types of defects were generated, which is inappropriate. Although the paper provides a formula to represent the generation method, there is no detailed explanation of how the formula is applied in the process of image generation, making it difficult to understand the specific way defect images are generated.

�2�Only data compared with other methods is available, lacking the display of comparison results between the proposed model and other models, which facilitates a more intuitive understanding of the advantages of the proposed method.

�3�During the verification process of the experiment, no ablation experiments were conducted, which cannot prove the effectiveness of the different models used. Please verify the effectiveness of each module through experiments.

�4�There is no relevant work introduction section in the paper.

�5�The contribution summary section of the paper mentions "segmentation precision" and "computationally efficient anomaly segmentation". The direction of the paper is Object Detection, and there is no content related to Object Segmentation in the paper. Is the expression inconsistent?

Reviewer #2: The manuscript presents ViT-Mamba, a hybrid transformer-based architecture for high-precision PCB defect detection. It integrates Vision Transformers (ViT) with a Mamba-inspired decoder enhanced by attention gates, and introduces a novel artificial defect generation strategy. Results show strong performance (mAP 99.69%) on a public PCB dataset, surpassing existing methods. The methodology is clearly described and the model is effective, and relevant to industrial applications.

However, some minor clarifications and elaborations are needed to improve transparency. I list below several questions and suggestions:

• Could the authors clarify how the realism of the synthetic defects was validated? Was any human inspection or comparison to real-world defects conducted?

• Were the synthetic and real defects mixed during training? If so, in what proportion?

• The constraint to avoid overlapping defects (Equation 9) is logical, but was any experimentation done to test whether overlapping defects affect performance?

• The dataset used is from the Open Lab at Peking University. Were any additional, unseen real-world datasets used for validation or generalization tests?

• On page 14, limitations regarding industrial variations like noise and occlusion are acknowledged. Have the authors tried any robustness tests (e.g., noise injection, variable lighting conditions)?

• Could the authors explain the resolution of input images and whether resizing or cropping was applied?

• The paper uses a ViT with a patch size of 16×16 (Table 1). Were other patch sizes tested? How does patch size influence performance?

• The decoder uses "Mamba attention gates" (Figures 4 and 9). Could the authors elaborate how the Mamba gates differ from standard attention gates like those used in U-Net++ or other vision transformers?

• Were any pretrained weights used for ViT, or was it trained from scratch?

• What optimizer was used during training? Were learning rate schedulers (e.g., cosine decay) applied?

• Loss weights (λ1, λ2, λ3) are mentioned in Equation 15. How they were chosen?

• On page 12, augmentation includes rotations of −45 to 45 degrees. Were other augmentations tried (e.g., brightness changes, blur, cutout)?

• In Table 2, multiple recent models are cited without full AP breakdowns. Are those AP values pulled from original papers or re-evaluated using your implementation?

• Can the authors comment on the relative training time and ease of convergence compared to other models like U²-Net, YOLO variants, or TDD-Net?

• Could the authors clarify in Figure 2 whether "Adjust Defects for Constraints" is a manual or automated step?

• Please ensure that all figures (especially Figures 5 and 6) have alt text or descriptive captions to meet accessibility requirements.

• Be consistent with capitalization (e.g., “ViT-Mamba” vs “ViT Mamba”).

• In the abstract, consider avoiding “state-of-the-art mAP of 99.69%” unless you cite direct competitors for context.

• Equation formatting is clear but could be rendered using numbered LaTeX environments (as per journal style).

**********

6. PLOS authors have the option to publish the peer review history of their article (what does this mean?). If published, this will include your full peer review and any attached files.

If you choose “no”, your identity will remain anonymous but your review may still be made public.

Do you want your identity to be public for this peer review? For information about this choice, including consent withdrawal, please see our Privacy Policy.

Reviewer #1: No

Reviewer #2: No

**********

[NOTE: If reviewer comments were submitted as an attachment file, they will be attached to this email and accessible via the submission site. Please log into your account, locate the manuscript record, and check for the action link "View Attachments". If this link does not appear, there are no attachment files.]

While revising your submission, please upload your figure files to the Preflight Analysis and Conversion Engine (PACE) digital diagnostic tool, https://pacev2.apexcovantage.com/. PACE helps ensure that figures meet PLOS requirements. To use PACE, you must first register as a user. Registration is free. Then, login and navigate to the UPLOAD tab, where you will find detailed instructions on how to use the tool. If you encounter any issues or have any questions when using PACE, please email PLOS at figures@plos.org. Please note that Supporting Information files do not need this step.

PLoS One. 2025 Sep 25;20(9):e0331175. doi: 10.1371/journal.pone.0331175.r002

Author response to Decision Letter 1


4 Aug 2025

Reviewer#1, Concern # 1: Regarding the dataset used in the experiment, the paper mentioned in the experimental section that the dataset published by Peking University was used, with only individual data being rotated. However, in the "Abstract" and "Artificial Defects Creation" sections, it was mentioned that six types of defects were generated, which is inappropriate. Although the paper provides a formula to represent the generation method, there is no detailed explanation of how the formula is applied in the process of image generation, making it difficult to understand the specific way defect images are generated.

Author response: We thank Reviewer #1 for this insightful comment. We acknowledge the need to clarify the dataset usage and the defect generation process.

In our study, we employed the publicly available PCB dataset released by the Open Lab on Human-Robot Interaction at Peking University as the base dataset. To address the limitations of data imbalance and enhance generalization, we introduced an Artificial Defect Creation Module, which synthetically generates six types of defects—Missing Hole, Mouse Bite, Open Circuit, Short, Spur, and Spurious Copper—based on defect-free images from the original dataset.

While the abstract and method sections correctly state that synthetic defects were introduced, we realize that the description in the experimental section may have created ambiguity by only emphasizing rotation-based augmentation. To clarify: the synthetic defects were applied to augment the dataset, and image-level augmentations such as random rotations were used in addition to this synthetic generation.

Regarding the formulas, we agree that more implementation details are needed. The mathematically defined rules for each defect type (Equations 1–11) were applied using a controlled procedural generation pipeline. Specifically:

The defect-free regions were first identified.

Masks were created based on the constraints (e.g., region specificity, non-overlapping).

These masks were then applied to the original images using pixel-wise operations to produce defective images.

Random transformations (rotation, scaling, translation) were further applied to the defect masks to improve variability.

This process is visually depicted in Figures 2 and 3, which illustrate the creation pipeline and example masks, respectively.

We will revise the manuscript to include a more explicit step-by-step explanation of the image generation pipeline in the "Artificial Defects Creation" section and ensure consistency across all sections regarding dataset usage and augmentation strategy.

Thank you for helping us improve the clarity of our methodology.

Reviewer#1, Concern # 2: Only data compared with other methods is available, lacking the display of comparison results between the proposed model and other models, which facilitates a more intuitive understanding of the advantages of the proposed method.

Author response: Thank you for the insightful comment. We appreciate your emphasis on the importance of intuitive comparisons. To address this, we included both a detailed tabular comparison

(Table 2) and a visual radar chart (Figure 6) to highlight the performance of our proposed ViT-Mamba framework relative to other state-of-the-art methods across six defect types. These additions help convey the superiority of our model both quantitatively and visually.

Reviewer#1, Concern # 3: During the verification process of the experiment, no ablation experiments were conducted, which cannot prove the effectiveness of the different models used. Please verify the effectiveness of each module through experiments.

Author response: We thank the reviewer for this valuable observation. In response, we have conducted comprehensive ablation experiments to verify the effectiveness of each key module in the ViT-Mamba framework, including the Vision Transformer encoder, Mamba-inspired attention gates, and the multiscale refinement strategy. The results, now presented in the revised manuscript (Section: Ablation Studies, Table 3, clearly demonstrate the performance contribution of each component. These findings confirm that each module plays a critical role in achieving the model’s overall accuracy and robustness in PCB defect detection.

Reviewer#1, Concern # 4 There is no relevant work introduction section in the paper.

Author response: Thank you for pointing this out. While we included a discussion of related work within the Introduction section, we acknowledge that it may not have been clearly delineated as a standalone Related Work section. In response to your feedback, we have now revised the manuscript to include a dedicated Related Work section.

Reviewer#1, Concern # 5: The contribution summary section of the paper mentions "segmentation precision" and "computationally efficient anomaly segmentation". The direction of the paper is Object Detection, and there is no content related to Object Segmentation in the paper. Is the expression inconsistent?

Author response: We thank the reviewer for raising this point. We would like to clarify that our paper does not focus on object detection, nor do we use the terms “object detection” or “object segmentation” anywhere in the manuscript. Instead, the core contribution of our work lies in pixel-level anomaly segmentation for printed circuit boards (PCBs), where the goal is to accurately localize defective regions at a fine-grained level.

The terms “segmentation precision” and “computationally efficient anomaly segmentation” mentioned in the contribution summary are consistent with our methodology and results. Our ViT-Mamba model outputs segmentation masks rather than bounding boxes, and the architecture, loss functions, and evaluation pipeline are designed specifically for semantic segmentation and anomaly localization.

We recognize that our use of mAP (mean Average Precision) for evaluation—commonly associated with object detection—may have contributed to this misunderstanding. However, in our context, mAP is used to measure the performance of segmentation-based anomaly detection across defect types,

as also done in several previous works on PCB inspection.

Reviewer#2, Concern # 1: Could the authors clarify how the realism of the synthetic defects was validated? Was any human inspection or comparison to real-world defects conducted?

Author response: We appreciate the reviewer’s thoughtful question. The realism of the synthetic defects was primarily ensured through two complementary approaches:

The artificial defect generation module was developed based on domain knowledge of PCB manufacturing faults, using mathematically defined rules that mirror the geometric properties and spatial distributions of six common defect types (e.g., missing hole, spur, short). These rules were derived from analysis of real PCB defect patterns documented in existing datasets and literature. For example, the spatial constraints (e.g., placement near vias or along traces) and shape-specific masks (e.g., circular for missing holes, linear for open circuits) were designed to closely replicate actual defect formations seen in manufacturing.

While we did not conduct a formal user study or human labeling task, we performed internal visual inspection of a large subset of the synthetically generated images and masks. These were assessed by the authors and domain researchers to ensure that the artificial defects were visually plausible and consistent with the types and appearances of defects observed in real-world PCB images.

We acknowledge that incorporating formal human evaluation or cross-referencing with annotated real-world defects could further strengthen the validation. We plan to explore such methods in future work to quantitatively assess perceptual realism and model alignment with human judgment.

Thank you for pointing out this important aspect.

Reviewer#2, Concern # 2: Were the synthetic and real defects mixed during training? If so, in what proportion?

Author response: We thank the reviewer for this insightful question. Yes, both real and synthetically generated defect samples were included during the training process. The synthetic defects, created using our Artificial Defect Creation Module, were applied to defect-free images from the original dataset to enrich the training set and address issues such as data imbalance and limited defect diversity.

The real and synthetic samples were strategically mixed to ensure that the model could learn from real-world defect patterns while also benefiting from the variability and completeness offered by synthetic augmentation. This approach helped improve the model's robustness and generalization across different types of defects.

Reviewer#2, Concern # 3: The constraint to avoid overlapping defects (Equation 9) is logical, but was any experimentation done to test whether overlapping defects affect performance?

Author response: We appreciate the reviewer’s observation regarding the constraint in Equation 9, which ensures that synthetic defects do not overlap during generation. This design decision was made to maintain clarity in the defect labels and facilitate unambiguous learning signals during training, especially in a pixel-level segmentation setting.

At this stage, we did not conduct a dedicated experiment to evaluate the impact of overlapping defects on model performance. Our initial objective was to generate clear and distinct defect types to avoid potential confusion in ground truth labeling and ensure effective supervision. However, we agree that exploring scenarios with overlapping or compound defects could provide valuable insights into the model’s capacity to handle more complex real-world conditions.

We appreciate this suggestion and consider it a promising direction for future work, where controlled experiments involving overlapping defects can help assess model robustness and segmentation accuracy under more challenging defect configurations.

Thank you for raising this important point.

Reviewer#2, Concern # 4: The dataset used is from the Open Lab at Peking University. Were any additional, unseen real-world datasets used for validation or generalization tests?

Author response: We thank the reviewer for this important question. In this study, we used the public PCB defect dataset provided by the Open Lab at Peking University as our primary dataset for training, validation, and testing. This dataset includes diverse samples of six common defect types and is widely adopted in PCB defect detection research, making it a strong benchmark for evaluating our proposed method.

However, we acknowledge that testing on additional unseen real-world datasets would provide further evidence of generalization capability. Due to the lack of publicly available, high-quality PCB datasets with compatible annotation formats and defect categories, we did not include cross-dataset evaluation in this work. That said, our synthetic defect generation strategy was specifically designed to improve robustness and generalization by exposing the model to varied defect appearances and locations.

We consider generalization to new domains and real-world settings an important future direction and plan to validate our model on additional datasets or industrial PCB samples as they become accessible.

Thank you for highlighting this valuable consideration.

Reviewer#2, Concern # 5: On page 14, limitations regarding industrial variations like noise and occlusion are acknowledged. Have the authors tried any robustness tests (e.g., noise injection, variable lighting conditions)?

Author response: We thank the reviewer for the insightful question. While we acknowledge the importance of robustness to industrial variations such as noise and occlusion (as noted on page 14), we did not conduct explicit robustness tests (e.g., noise injection or lighting variation) in this study.

However, our synthetic data generation pipeline includes random transformations (rotation, translation, scaling), which introduce some variability.

Reviewer#2, Concern # 6: Could the authors explain the resolution of input images and whether resizing or cropping was applied?

Author response: We thank the reviewer for this question. All input images were resized to 256 × 256 pixels before being fed into the network. This resizing was applied uniformly to ensure compatibility

with the Vision Transformer-based encoder and to maintain consistent input dimensions across the dataset.

No cropping was applied, and care was taken to preserve the aspect ratio and key defect features during resizing. This resolution was selected to balance computational efficiency with sufficient detail for accurate defect segmentation.

Reviewer#2, Concern # 7: The paper uses a ViT with a patch size of 16×16 (Table 1). Were other patch sizes tested? How does patch size influence performance?

Author response: We thank the reviewer for this insightful question. In our experiments, we used a patch size of 16 × 16 for the Vision Transformer, which provided a good balance between capturing global context and maintaining spatial detail.

We conducted preliminary tests with smaller (8 × 8) and larger (32 × 32) patch sizes. However, smaller patches increased computational cost without significant performance gain, while larger patches led to a loss in fine-grained spatial detail, which negatively impacted segmentation precision for small or subtle defects.

Therefore, the 16 × 16 patch size was chosen as an effective compromise.

Reviewer#2, Concern # 8: The decoder uses "Mamba attention gates" (Figures 4 and 9). Could the authors elaborate how the Mamba gates differ from standard attention gates like those used in U-Net++ or other vision transformers?

Author response: We thank the reviewer for this thoughtful question. The Mamba attention gates used in our decoder are inspired by traditional attention gate mechanisms, such as those in U-Net++, but are designed to operate in a more lightweight and efficient manner.

Specifically, while standard attention gates (e.g., in U-Net++) typically rely on concatenation followed by multiple convolutional layers to compute spatial attention maps, our Mamba gates employ a simplified additive fusion of encoder and decoder features followed by ReLU and sigmoid activations to compute attention weights.

This design reduces computational overhead while still effectively suppressing irrelevant background features and enhancing salient regions. The Mamba gates are particularly suited for hierarchical, transformer-based architectures, and were optimized to preserve fine-grained spatial details in the upsampling path.

Reviewer#2, Concern # 9: Were any pretrained weights used for ViT, or was it trained from scratch?

Author response: We thank the reviewer for this question. The Vision Transformer (ViT) encoder in our framework was initialized with pretrained weights from ImageNet. This helped accelerate convergence and improve feature extraction, especially given the limited size of the PCB dataset.

We then fine-tuned the ViT jointly with the rest of the network during training.

Reviewer#2, Concern # 10: What optimizer was used during training? Were learning rate schedulers (e.g., cosine decay) applied?

Author response: We thank the reviewer for the question. We used the Adam optimizer during training with an initial learning rate of 0.0001. A StepLR scheduler was applied to reduce the learning rate by a factor of 0.1 every 300 epochs to ensure stable convergence.

We will include these training details in the revised manuscript for clarity.

Reviewer#1, Concern # 11: Loss weights (λ1, λ2, λ3) are mentioned in Equation 15. How they were chosen?

Author response: We thank the reviewer for pointing this out. The loss weights in Equation 15 were empirically selected based on initial experiments using the validation set. We performed a small grid search to balance segmentation accuracy, anomaly detection, and class imbalance handling. The chosen weights provided stable convergence and optimal mAP performance across all defect types.

Reviewer#2, Concern # 12: On page 12, augmentation includes rotations of −45 to 45 degrees. Were other augmentations tried (e.g., brightness changes, blur, cutout)?

Author response: We appreciate the reviewe

Attachment

Submitted filename: Response-to-Reviewers.pdf

pone.0331175.s001.pdf (206.8KB, pdf)

Decision Letter 1

Azim Uddin

13 Aug 2025

Vision Transformer and Mamba-Attention Fusion for High-Precision PCB Defect Detection

PONE-D-25-26195R1

Dear Dr. Choi,

We’re pleased to inform you that your manuscript has been judged scientifically suitable for publication and will be formally accepted for publication once it meets all outstanding technical requirements.

Within one week, you’ll receive an e-mail detailing the required amendments. When these have been addressed, you’ll receive a formal acceptance letter and your manuscript will be scheduled for publication.

An invoice will be generated when your article is formally accepted. Please note, if your institution has a publishing partnership with PLOS and your article meets the relevant criteria, all or part of your publication costs will be covered. Please make sure your user information is up-to-date by logging into Editorial Manager at Editorial Manager® and clicking the ‘Update My Information' link at the top of the page. For questions related to billing, please contact billing support.

If your institution or institutions have a press office, please notify them about your upcoming paper to help maximize its impact. If they’ll be preparing press materials, please inform our press team as soon as possible -- no later than 48 hours after receiving the formal acceptance. Your manuscript will remain under strict press embargo until 2 pm Eastern Time on the date of publication. For more information, please contact onepress@plos.org.

Kind regards,

Azim Uddin, Ph.D.

Academic Editor

PLOS ONE

Additional Editor Comments (optional):

Reviewers' comments:

Acceptance letter

Azim Uddin

PONE-D-25-26195R1

PLOS ONE

Dear Dr. Choi,

I'm pleased to inform you that your manuscript has been deemed suitable for publication in PLOS ONE. Congratulations! Your manuscript is now being handed over to our production team.

At this stage, our production department will prepare your paper for publication. This includes ensuring the following:

* All references, tables, and figures are properly cited

* All relevant supporting information is included in the manuscript submission,

* There are no issues that prevent the paper from being properly typeset

You will receive further instructions from the production team, including instructions on how to review your proof when it is ready. Please keep in mind that we are working through a large volume of accepted articles, so please give us a few days to review your paper and let you know the next and final steps.

Lastly, if your institution or institutions have a press office, please let them know about your upcoming paper now to help maximize its impact. If they'll be preparing press materials, please inform our press team within the next 48 hours. Your manuscript will remain under strict press embargo until 2 pm Eastern Time on the date of publication. For more information, please contact onepress@plos.org.

You will receive an invoice from PLOS for your publication fee after your manuscript has reached the completed accept phase. If you receive an email requesting payment before acceptance or for any other service, this may be a phishing scheme. Learn how to identify phishing emails and protect your accounts at https://explore.plos.org/phishing.

If we can help with anything else, please email us at customercare@plos.org.

Thank you for submitting your work to PLOS ONE and supporting open access.

Kind regards,

PLOS ONE Editorial Office Staff

on behalf of

Dr. Azim Uddin

Academic Editor

PLOS ONE

Associated Data

    This section collects any data citations, data availability statements, or supplementary materials included in this article.

    Supplementary Materials

    Attachment

    Submitted filename: Response-to-Reviewers.pdf

    pone.0331175.s001.pdf (206.8KB, pdf)

    Data Availability Statement

    All relevant data are within the manuscript.


    Articles from PLOS One are provided here courtesy of PLOS

    RESOURCES