Printed circuit board (PCB) defect detection is critical for ensuring electronic product quality, yet it remains challenging due to small defect sizes, complex backgrounds, and the need for efficient deployment. This paper proposes a lightweight detection framework based on an improved YOLOv8 architecture to balance accuracy and efficiency. The model integrates RepViTm0.9 as the backbone to enhance small-target feature extraction and replaces the C2f module with RepNCSPELAN4 for more effective multi-scale feature fusion. Additionally, a Layer-Adaptive Magnitude-based Pruning (LAMP) strategy compresses the model by removing redundant channels, while a novel Focaler-MPDIoU loss function improves bounding box regression by focusing on hard samples and minimizing corner-point distances. Experimental results on a public PCB dataset demonstrate that the proposed model achieves 93.9% mAP@0.5 with only 1.27M parameters and 4.28G FLOPs, outperforming baseline YOLOv8n in accuracy while reducing computational cost by 48.9% and model size by 49.2%, offering an effective solution for real-world PCB inspection.
Introduction
This study focuses on improving Printed Circuit Board (PCB) defect detection using a lightweight and enhanced YOLOv8-based deep learning framework. PCB defects such as open circuits, short circuits, spurious copper, burrs, and missing holes can severely impact electronic device reliability. Traditional Automated Optical Inspection (AOI) methods rely on handcrafted image-processing techniques, which struggle with noise, lighting variations, and small or low-contrast defects.
To overcome these limitations, the proposed approach enhances YOLOv8 by introducing several key improvements. The original backbone network is replaced with RepViTm0.9, a lightweight architecture combining convolutional networks and Vision Transformer concepts, improving feature extraction for small and densely distributed defects. The neck network is upgraded with RepNCSPELAN4, which enhances multi-scale feature fusion and preserves fine-grained defect information, leading to better localization and recognition performance.
To reduce computational complexity while maintaining accuracy, the model employs a Layer-Adaptive Magnitude-based Pruning (LAMP) algorithm. This pruning strategy removes less important channels based on weight significance, compressing the model and improving deployment efficiency without major performance loss. Additionally, a new Focaler-MPDIoU loss function is proposed, combining Focaler-IoU and MPDIoU concepts to improve bounding-box regression, reduce false positives and missed detections, and enhance localization of overlapping defects.
Experiments were conducted using the publicly available Peking University PCB defect dataset, containing six defect categories: missing holes, mouse bites, open circuits, short circuits, spurs, and spurious copper. Data augmentation expanded the dataset from 693 to 5,766 images. Training was performed on an NVIDIA RTX 3090 GPU using PyTorch and YOLOv8.
Results demonstrate that the improved YOLOv8 model achieves a better balance between accuracy, robustness, and computational efficiency. The combination of RepViTm0.9, RepNCSPELAN4, LAMP pruning, and Focaler-MPDIoU loss significantly enhances small-defect detection, reduces model size and inference cost, and improves real-time industrial applicability. The proposed framework provides a practical and scalable solution for automated PCB inspection in modern electronics manufacturing.
Conclusion
In this study, a lightweight PCB defect detection framework was developed by enhancing the YOLOv8 architecture with a series of targeted improvements. The proposed model integrates RepViTm0.9 as the backbone to strengthen small-target feature extraction, replaces the original C2f module with RepNCSPELAN4 in the neck to enable more effective multi-scale feature fusion, and introduces the Focaler-MPDIoU loss function to refine bounding box regression by focusing on hard samples and minimizing corner-point distances. Additionally, a Layer-Adaptive Magnitude-based Pruning (LAMP) strategy is applied to remove redundant channels, significantly reducing computational complexity and model size while preserving detection accuracy. Experimental results on a public PCB defect dataset demonstrate that the proposed framework achieves an optimal balance between accuracy and efficiency, making it well suited for real world industrial deployment.
1) The final pruned model attains a mean Average Precision (mAP@0.5) of 93.9%, which is 3.89% higher than the baseline YOLOv8n.
2) Compared to YOLOv8n, the model reduces FLOPs by 48.9%, parameters by 61.2%, and model size by 49.2%, satisfying strict lightweight deployment requirements.
3) The integration of RepViTm0.9 and RepNCSPELAN4 effectively preserves fine grained spatial information, leading to improved detection of small, densely distributed defects.
4) The Focaler-MPDIoU loss reduces missed and false detections by adaptively handling hard regression samples and modeling corner point distances.
5) LAMP pruning removes redundant connections without significantly compromising performance, enabling a compact and efficient model suitable for resource constrained environments.
6) Comparative experiments confirm that the proposed method outperforms several state of the art approaches in terms of both detection accuracy and model compactness.
For future research, we intend to explore adaptive pruning techniques that dynamically adjust compression ratios based on layer sensitivity to further enhance efficiency while maintaining accuracy. Extending the proposed framework to other industrial inspection tasks—such as wafer defect detection, surface quality assessment for electronic components, or automated optical inspection in manufacturing lines—will be a valuable direction. Additionally, we plan to deploy the model on edge devices (e.g., Jetson or FPGA platforms) to evaluate real time performance under practical constraints. Further improvements may also be pursued through the integration of knowledge distillation and post training quantization to achieve even faster inference speeds while preserving detection precision.
References
[1] A. Canal Marques, J.-M. Cabrera, and C. De Fraga Malfatti, ‘Printed circuit boards: A review on the perspective of sustainability’, J. Environ. Manage., vol. 131, pp. 298–306, Dec. 2013, doi: 10.1016/j.jenvman.2013.10.003.
[2] M. T. Tran and S. H. Dau, ‘The optical system design to support defect detection for the automatic inspection system on printed circuit boards on the production line’, Int. J. Interact. Des. Manuf. IJIDeM, Feb. 2026, doi: 10.1007/s12008-026-02528-2.
[3] M. Ronchi, A. Regattieri, M. Gamberi, and C. Cafarella, ‘Multi-criteria selection of image acquisition technologies for automatic optical inspection in assembly lines’, Int. J. Adv. Manuf. Technol., vol. 141, no. 12, pp. 5997–6016, Dec. 2025, doi: 10.1007/s00170-025-17021-5.
[4] Q. Ling and N. A. M. Isa, ‘Printed Circuit Board Defect Detection Methods Based on Image Processing, Machine Learning and Deep Learning: A Survey’, IEEE Access, vol. 11, pp. 15921–15944, 2023, doi: 10.1109/ACCESS.2023.3245093.
[5] Y. Zhou, M. Yuan, J. Zhang, G. Ding, and S. Qin, ‘Review of vision-based defect detection research and its perspectives for printed circuit board’, J. Manuf. Syst., vol. 70, pp. 557–578, Oct. 2023, doi: 10.1016/j.jmsy.2023.08.019.
[6] J. Li, E. Hu, W. Wei, and F. Shi, ‘From Wafers to Electrodes: Transferring Automatic Optical Inspection (AOI) for Multiscale Characterization of Smart Battery Manufacturing’, Adv. Funct. Mater., p. e28142, Mar. 2026, doi: 10.1002/adfm.202528142.
[7] A. Magdy, M. S. Moustafa, H. M. Ebied, and M. F. Tolba, ‘Lightweight faster R-CNN for object detection in optical remote sensing images’, Sci. Rep., vol. 15, no. 1, p. 16163, May 2025, doi: 10.1038/s41598-025-99242-y.
[8] M. Li, Y. Hu, H. Chen, and X. Li, ‘Feature-Enhanced Faster R-CNN for Small Object Detection in Complex Scenes’, IEEE Access, vol. 13, pp. 174297–174315, 2025, doi: 10.1109/ACCESS.2025.3618019.
[9] B. Hu and J. Wang, ‘Detection of PCB Surface Defects With Improved Faster-RCNN and Feature Pyramid Network’, IEEE Access, vol. 8, pp. 108335–108345, 2020, doi: 10.1109/ACCESS.2020.3001349.
[10] X. Liao, S. Lv, D. Li, Y. Luo, Z. Zhu, and C. Jiang, ‘YOLOv4-MN3 for PCB Surface Defect Detection’, Appl. Sci., vol. 11, no. 24, p. 11701, Dec. 2021, doi: 10.3390/app112411701.
[11] V. A. Adibhatla et al., ‘Applying deep learning to defect detection in printed circuit boards via a newest model of you-only-look-once’, Math. Biosci. Eng., vol. 18, no. 4, pp. 4411–4428, 2021, doi: 10.3934/mbe.2021223.
[12] . Yang, Z. Liu, W. Du, and S. Zhang, ‘A PCB Defect Detector Based on Coordinate Feature Refinement’, IEEE Trans. Instrum. Meas., vol. 72, pp. 1–10, 2023, doi: 10.1109/TIM.2023.3322483.
[13] J. Lim, J. Lim, V. M. Baskaran, and X. Wang, ‘A deep context learning based PCB defect detection model with anomalous trend alarming system’, Results Eng., vol. 17, p. 100968, Mar. 2023, doi: 10.1016/j.rineng.2023.100968.
[14] B. Du, F. Wan, G. Lei, L. Xu, C. Xu, and Y. Xiong, ‘YOLO-MBBi: PCB Surface Defect Detection Method Based on Enhanced YOLOv5’, Electronics, vol. 12, no. 13, p. 2821, Jun. 2023, doi: 10.3390/electronics12132821.
[15] S. Alawandi, K. Mallibhat, U. Kudachi, and A. Beedanal, ‘Correction: PCB Defects: a Unified Survey of Trends, Detection Techniques, and Limitations Through Systematic Literature Review’, J. Electron. Test., vol. 41, no. 5–6, pp. 789–789, Dec. 2025, doi: 10.1007/s10836-025-06207-0.
[16] L. Zhu, S. Wang, M. Chen, Y. Zhu, K. Xing, and A. Shen, ‘Subtle Defect Detection Network: More accurately detect subtle defects on the Printed Circuit Board surface’, Eng. Appl. Artif. Intell., vol. 152, p. 110765, Jul. 2025, doi: 10.1016/j.engappai.2025.110765.
[17] S. Luo et al., ‘YOLO-DAFS: A Composite-Enhanced Underwater Object Detection Algorithm’, J. Mar. Sci. Eng., vol. 13, no. 5, p. 947, May 2025, doi: 10.3390/jmse13050947.
[18] D. Bai et al., ‘Surface defect detection methods for industrial products with imbalanced samples: A review of progress in the 2020s’, Eng. Appl. Artif. Intell., vol. 130, p. 107697, Apr. 2024, doi: 10.1016/j.engappai.2023.107697.
[19] M. Nikouei et al., ‘Small object detection: A comprehensive survey on challenges, techniques and real-world applications’, Intell. Syst. Appl., vol. 27, p. 200561, Sep. 2025, doi: 10.1016/j.iswa.2025.200561.
[20] K. C. Fung, K.-W. Xue, C.-M. Lai, K.-H. Lin, and K.-M. Lam, ‘Improving PCB defect detection using selective feature attention and pixel shuffle pyramid’, Results Eng., vol. 21, p. 101992, Mar. 2024, doi: 10.1016/j.rineng.2024.101992.
[21] M. Yuan, Y. Zhou, X. Ren, H. Zhi, J. Zhang, and H. Chen, ‘YOLO-HMC: An Improved Method for PCB Surface Defect Detection’, IEEE Trans. Instrum. Meas., vol. 73, pp. 1–11, 2024, doi: 10.1109/TIM.2024.3351241.
[22] T. Zhang, J. Zhang, P. Pan, and X. Zhang, ‘YOLO-RRL: A Lightweight Algorithm for PCB Surface Defect Detection’, Appl. Sci., vol. 14, no. 17, p. 7460, Aug. 2024, doi: 10.3390/app14177460.
[23] H. Zhang, Y. Li, D. M. Sharid Kayes, Z. Song, and Y. Wang, ‘Research on PCB defect detection algorithm based on LPCB-YOLO’, Front. Phys., vol. 12, p. 1472584, Jan. 2025, doi: 10.3389/fphy.2024.1472584.
[24] J. Wang, X. Xie, G. Liu, and L. Wu, ‘A Lightweight PCB Defect Detection Algorithm Based on Improved YOLOv8-PCB’, Symmetry, vol. 17, no. 2, p. 309, Feb. 2025, doi: 10.3390/sym17020309.
[25] S. Yu, F. Pan, X. Zhang, L. Zhou, L. Zhang, and J. Wang, ‘A lightweight detection algorithm of PCB surface defects based on YOLO’, PLOS One, vol. 20, no. 4, p. e0320344, Apr. 2025, doi: 10.1371/journal.pone.0320344.
[26] [26] Y. Li et al., ‘Lightweight PCB defect detection method based on SCF-YOLO’, PLOS ONE, vol. 20, no. 4, p. e0318033, Apr. 2025, doi: 10.1371/journal.pone.0318033.
[27] Z. Wei, F. Yang, K. Zhong, and L. Yao, ‘PCB-YOLO: Enhancing PCB surface defect detection with coordinate attention and multi-scale feature fusion’, PLOS One, vol. 20, no. 6, p. e0323684, Jun. 2025, doi: 10.1371/journal.pone.0323684.
[28] D. Lang and Z. Lv, ‘SEPDNet: simple and effective PCB surface defect detection method’, Sci. Rep., vol. 15, no. 1, p. 10919, Mar. 2025, doi: 10.1038/s41598-024-84859-2.
[29] S. Lv et al., ‘A dataset for deep learning based detection of printed circuit board surface defect’, Sci. Data, vol. 11, no. 1, p. 811, Jul. 2024, doi: 10.1038/s41597-024-03656-8.
[30] A. J. Rashid, M. A. Ullah, A. Isfara, N. Ahmed, Md. M. Mian, and Md. M. Shalehin, ‘PCB-defect: An annotated dataset for surface defect detection in printed circuit boards’, Data Brief, vol. 64, p. 112296, Feb. 2026, doi: 10.1016/j.dib.2025.112296.
[31] F.-C. Lin, H.-A. Wu, and J.-Y. Lin, ‘A two-stage lightweight network for real-time IC surface defect detection’, Int. J. Adv. Manuf. Technol., vol. 142, no. 7–8, pp. 3933–3946, Feb. 2026, doi: 10.1007/s00170-025-17341-6.
[32] M. Xiao, B. Yang, S. Wang, F. Mo, Y. He, and Y. Gao, ‘GRA-Net: Global receptive attention network for surface defect detection’, Knowl.-Based Syst., vol. 280, p. 111066, Nov. 2023, doi: 10.1016/j.knosys.2023.111066.
[33] N. Zeng, P. Wu, Z. Wang, H. Li, W. Liu, and X. Liu, ‘A Small-Sized Object Detection Oriented Multi-Scale Feature Fusion Approach With Application to Defect Detection’, IEEE Trans. Instrum. Meas., vol. 71, pp. 1–14, 2022, doi: 10.1109/TIM.2022.3153997.