A High-Accuracy PCB Defect Detection Algorithm Based on Improved YOLOv12
Abstract
:1. Introduction
- The GAM is embedded into the A2C2f module, enhancing cross-channel interactions and spatial correlations. This design significantly improve sensitivity to low-contrast defects in PCB images compared to the original A2C2f module.
- The HWD module replaces standard convolutional layers, leveraging multi-scale dilated convolutions to retain high-frequency texture features and effectively mitigate the loss of tiny defect features in PCB detection compared to standard convolutions.
- The BiFPN replaces the original contact structure in the neck network, leveraging a weighted feature fusion mechanism to optimize multi-scale feature contributions. Compared to the contact structure, the BiFPN enhances multi-scale detection capabilities for subtle defects in PCB images.
- The PPA detection head is constructed in the head network, combining local perception and global attention mechanisms to amplify responses in defect regions, reducing the missed detection rate in PCB defect inspection.
- To address the challenge of detecting small PCB defects, the NWD loss function is adopted. Compared to traditional IoU metrics, NWD employs Gaussian distribution modeling to refine localization accuracy for micro-defects.
2. Methods
2.1. YOLOv12 Detection Algorithm
2.1.1. Backbone Network
2.1.2. Neck Network
2.1.3. Head Network
2.2. The Proposed Method
2.2.1. GAM Attention Mechanism
2.2.2. The Haar Wavelet Downsampling
2.2.3. The Bidirectional Feature Pyramid Network
2.2.4. The Parallel Perception Attention Detection Head
2.2.5. The Normalized Wasserstein Distance Loss Function
3. Results
3.1. Dataset
3.2. Experimental Environment and Training Parameters
3.3. Evaluation Metrics
3.4. Experimental Analysis
3.4.1. Comparison with Baseline Model
3.4.2. Comparison of Object Detection Models
3.4.3. Comparison of GAM with Other Attention Mechanisms
3.4.4. Comparison of the HWD with Other Convolutional Modules
3.4.5. Ablation Experiment
4. Discussion
Author Contributions
Funding
Institutional Review Board Statement
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- Zhao, W.; Xu, J.; Fei, W.; Liu, Z.; He, W.; Li, G. The reuse of electronic components from waste printed circuit boards: A critical review. Environ. Sci. Adv. 2023, 2, 196–214. [Google Scholar] [CrossRef]
- Saqib, Q.M.; Mannan, A.; Noman, M.; Chougale, M.Y.; Patil, C.S.; Ko, Y.; Kim, J.; Patil, S.R.; Yousuf, M.; Shaukat, R.A.; et al. Miniaturizing power: Harnessing micro-supercapacitors for advanced micro-electronics. Chem. Eng. J. 2024, 490, 151857. [Google Scholar] [CrossRef]
- Sankar, V.U.; Lakshmi, G.; Sankar, Y.S. A review of various defects in PCB. J. Electron. Test. 2022, 38, 481–491. [Google Scholar] [CrossRef]
- He, X.; Huang, L.; Xiao, M.; Yu, C.; Li, E.; Shao, W. Investigation on the new reliability issues of PCB in 5G millimeter wave application. Microelectron. Int. 2024, 41, 130–141. [Google Scholar] [CrossRef]
- Pham, T.T.A.; Thoi, D.K.T.; Choi, H.; Park, S. Defect detection in printed circuit boards using semi-supervised learning. Sensors 2023, 23, 3246. [Google Scholar] [CrossRef]
- Abd Al Rahman, M.; Mousavi, A. A review and analysis of automatic optical inspection and quality monitoring methods in electronics industry. IEEE Access 2020, 8, 183192–183271. [Google Scholar]
- Chen, X.; Wu, Y.; He, X.; Wu, Y. A comprehensive review of deep learning-based PCB defect detection. IEEE Access 2023, 11, 139017–139038. [Google Scholar] [CrossRef]
- Zhou, Y.; Yuan, M.; Zhang, J.; Ding, G.; Qin, S. Review of vision-based defect detection research and its perspectives for printed circuit board. J. Manuf. Syst. 2023, 70, 557–578. [Google Scholar] [CrossRef]
- Wang, J.; Xie, X.; Liu, G.; Wu, L. A Lightweight PCB Defect Detection Algorithm Based on Improved YOLOv8-PCB. Symmetry 2025, 17, 309. [Google Scholar] [CrossRef]
- Zhou, G.; Yu, L.; Su, Y.; Xu, B.; Zhou, G. Lightweight PCB defect detection algorithm based on MSD-YOLO. Clust. Comput. 2024, 27, 3559–3573. [Google Scholar] [CrossRef]
- Tang, Y.; Liu, R.; Wang, S. YOLO-SUMAS: Improved Printed Circuit Board Defect Detection and Identification Research Based on YOLOv8. Micromachines 2025, 16, 509. [Google Scholar] [CrossRef] [PubMed]
- Yuan, Z.; Tang, X.; Ning, H.; Yang, Z. LW-YOLO: Lightweight Deep Learning Model for Fast and Precise Defect Detection in Printed Circuit Boards. Symmetry 2024, 16, 418. [Google Scholar] [CrossRef]
- Ji, L.; Huang, C.; Li, H.; Han, W.; Yi, L. MS-DETR: A real-time multi-scale detection transformer for PCB defect detection. Signal Image Video Process. 2025, 19, 203. [Google Scholar] [CrossRef]
- 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, 3507014. [Google Scholar] [CrossRef]
- Tian, Y.; Ye, Q.; Doermann, D. Yolov12: Attention-centric real-time object detectors. arXiv 2025, arXiv:2502.12524. [Google Scholar]
- Yan, C.; Zhang, H.; Ye, F.; Xu, W. Performance Analysis of Glass Surface Detection Based on the YOLOs. Curr. Sci. 2025, 5, 1679–1693. [Google Scholar] [CrossRef]
- Alif, M.A.R.; Hussain, M. YOLOv12: A Breakdown of the Key Architectural Features. arXiv 2025, arXiv:2502.14740. [Google Scholar]
- Liu, Y.; Shao, Z.; Hoffmann, N. Global attention mechanism: Retain information to enhance channel-spatial interactions. arXiv 2021, arXiv:2112.05561. [Google Scholar]
- Liu, J.; Kang, B.; Liu, C.; Peng, X.; Bai, Y. YOLO-BFRV: An Efficient Model for Detecting Printed Circuit Board Defects. Sensors 2024, 24, 6055. [Google Scholar] [CrossRef]
- Xu, G.; Liao, W.; Zhang, X.; Li, C.; He, X.; Wu, X. Haar wavelet downsampling: A simple but effective downsampling module for semantic segmentation. Pattern Recognit. 2023, 143, 109819. [Google Scholar] [CrossRef]
- Wang, W.; Li, L.; Qu, Z.; Yang, X. Enhanced damage segmentation in RC components using pyramid Haar wavelet downsampling and attention U-net. Autom. Constr. 2024, 168, 105746. [Google Scholar] [CrossRef]
- Tan, M.; Pang, R.; Le, Q.V. Efficientdet: Scalable and efficient object detection. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Seattle, WA, USA, 13–19 June 2020; pp. 10781–10790. [Google Scholar]
- Shi, P.; He, Q.; Zhu, S.; Li, X.; Fan, X.; Xin, Y. Multi-scale fusion and efficient feature extraction for enhanced sonar image object detection. Expert Syst. Appl. 2024, 256, 124958. [Google Scholar] [CrossRef]
- Tang, G.; Zhao, H.; Claramunt, C.; Zhu, W.; Wang, S.; Wang, Y.; Ding, Y. PPA-Net: Pyramid pooling attention network for multi-scale ship detection in SAR images. Remote Sens. 2023, 15, 2855. [Google Scholar] [CrossRef]
- Wang, J.; Xu, C.; Yang, W.; Yu, L. A normalized Gaussian Wasserstein distance for tiny object detection. arXiv 2021, arXiv:2110.13389. [Google Scholar]
- Xu, C.; Wang, J.; Yang, W.; Yu, H.; Yu, L.; Xia, G. Detecting tiny objects in aerial images: A normalized Wasserstein distance and a new benchmark. ISPRS J. Photogramm. Remote Sens. 2022, 190, 79–93. [Google Scholar] [CrossRef]
- Huang, W.; Wei, P.; Zhang, M.; Liu, H. HRIPCB: A challenging dataset for PCB defects detection and classification. J. Eng. 2020, 13, 303–309. [Google Scholar] [CrossRef]
- Tang, J.; Yang, Y.; Hou, B.; Hao, C. PCB Defect Detection Algorithm Based on YT-YOLO. In Proceedings of the 35th Chinese Control and Decision Conference, Yichang, China, 20–22 May 2023; pp. 976–981. [Google Scholar]
- Khanam, R.; Hussain, M. What is YOLOv5: A deep look into the internal features of the popular object detector. arXiv 2024, arXiv:2407.20892. [Google Scholar]
- Yaseen, M. What is YOLOv8: An in-depth exploration of the internal features of the next-generation object detector. arXiv 2024, arXiv:2408.15857. [Google Scholar]
- Khanam, R.; Hussain, M. Yolov11: An overview of the key architectural enhancements. arXiv 2024, arXiv:2410.17725. [Google Scholar]
- Ren, S.; He, K.; Girshick, R.; Sun, J. Faster R-CNN: Towards real-time object detection with region proposal networks. IEEE Trans. Pattern Anal. Mach. Intell. 2016, 39, 1137–1149. [Google Scholar] [CrossRef]
- Zhao, Y.; Lv, W.; Xu, S.; Wei, J.; Wang, G.; Dang, Q.; Liu, Y.; Chen, J. Detrs beat yolos on real-time object detection. arXiv 2024, arXiv:2304.08069. [Google Scholar]
Platform | Environment Parameters |
---|---|
CPU | 12th Gen Intel Core i5-12500H |
Operating System | Windows 11 64-bit |
Python | 3.11.11 |
PyTorch | 2.6.0 |
CUDA | 12.4 |
RAM | 16G |
GPU | NVIDIA GeForce RTX3060 8G |
Method | Mh | Mb | Oc | Sh | Sp | Sc | P/% | R/% | mAP@50/% | mAP@50:95/% |
---|---|---|---|---|---|---|---|---|---|---|
Faster R-CNN | 48.6 | 43.2 | 31.5 | 34.7 | 29.4 | 32.7 | 39.6 | 32.8 | 36.7 | 18.3 |
RT-DETR-R18 | 93.6 | 77.3 | 79.3 | 97.9 | 93.5 | 89.7 | 89.8 | 84.2 | 88.6 | 44.6 |
YOLOv5s | 49.5 | 64.0 | 73.1 | 86.5 | 79.3 | 71.2 | 80.4 | 62.2 | 70.6 | 33.2 |
YOLOv8s | 52.0 | 68.4 | 78.7 | 95.9 | 88.1 | 87.8 | 87.4 | 70.3 | 78.5 | 37.0 |
YOLOv11n | 99.5 | 79.1 | 76.0 | 87.0 | 84.0 | 73.9 | 91.2 | 75.1 | 83.2 | 40.1 |
YOLOv12n | 98.8 | 88.0 | 77.4 | 84.7 | 79.5 | 79.3 | 93.3 | 76.6 | 84.6 | 43.1 |
OURS | 98.1 | 85.7 | 86.0 | 96.2 | 85.6 | 90.8 | 90.0 | 85.3 | 90.4 | 47.0 |
Model | Parameters/M | FLOPs/G | FPS |
---|---|---|---|
Faster R-CNN | 42.8 | 118.5 | 26.3 |
RT-DETR-R18 | 19.6 | 56.8 | 41.2 |
YOLOv5s | 7.1 | 16.5 | 64.7 |
YOLOv8s | 10.4 | 19.3 | 59.3 |
YOLOv11n | 4.12 | 11.6 | 68.9 |
YOLOv12n | 3.26 | 8.9 | 76.4 |
OURS | 3.87 | 10.5 | 72.8 |
Attention Module | mAP@50/% | Parameters/M | FLOPs/G | FPS |
---|---|---|---|---|
YOLOv12n + SE | 85.4 | 3.73 | 9.7 | 68.9 |
YOLOv12n + CA | 86.2 | 3.68 | 9.5 | 70.5 |
YOLOv12n + ECA | 85.7 | 3.42 | 8.9 | 74.3 |
YOLOv12n + CBAM | 86.5 | 3.86 | 10.4 | 65.1 |
YOLOv12n + GAM | 87.5 | 3.37 | 8.8 | 77.2 |
Convolutional Module | mAP@50/% | Parameters/M | FLOPs/G | FPS |
---|---|---|---|---|
YOLOv12n + AKConv | 85.7 | 4.06 | 12.9 | 62.5 |
YOLOv12n + DWConv | 84.9 | 3.46 | 8.6 | 70.6 |
YOLOv12n + DSConv | 85.2 | 3.57 | 9.3 | 69.7 |
YOLOv12n + HWD | 86.6 | 3.68 | 9.6 | 70.3 |
Experiment | A | B | C | D | E | Mh | Mb | Oc | Sh | Sp | Sc | All |
---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | 98.8 | 88.0 | 77.4 | 84.7 | 79.5 | 79.3 | 84.6 | |||||
2 | ✔ | 98.3 | 86.2 | 83.2 | 90.5 | 82.2 | 84.6 | 87.5 | ||||
3 | ✔ | 97.5 | 84.7 | 82.1 | 88.3 | 81.6 | 85.2 | 86.6 | ||||
4 | ✔ | 98.8 | 87.3 | 83.4 | 86.5 | 82.6 | 84.2 | 87.1 | ||||
5 | ✔ | 98.2 | 82.5 | 84.7 | 84.1 | 84.2 | 87.3 | 86.8 | ||||
6 | ✔ | 98.6 | 86.3 | 79.5 | 85.6 | 81.3 | 83.2 | 85.9 | ||||
7 | ✔ | ✔ | 98.3 | 85.2 | 83.8 | 90.2 | 84.4 | 85.3 | 87.9 | |||
8 | ✔ | ✔ | 98.6 | 86.4 | 83.5 | 89.6 | 83.7 | 84.9 | 87.8 | |||
9 | ✔ | ✔ | 98.5 | 84.9 | 84.6 | 88.4 | 85.2 | 86.8 | 88.1 | |||
10 | ✔ | ✔ | 98.4 | 86.1 | 82.8 | 89.6 | 82.9 | 85.7 | 87.6 | |||
11 | ✔ | ✔ | ✔ | 98.2 | 86.4 | 84.7 | 92.8 | 84.3 | 88.5 | 89.2 | ||
12 | ✔ | ✔ | ✔ | 98.2 | 85.1 | 85.4 | 94.7 | 84.6 | 89.1 | 89.5 | ||
13 | ✔ | ✔ | ✔ | 98.4 | 85.9 | 84.6 | 92.1 | 84.9 | 87.4 | 88.9 | ||
14 | ✔ | ✔ | ✔ | ✔ | 98.2 | 86.3 | 85.3 | 95.7 | 85.3 | 89.6 | 90.1 | |
15 | ✔ | ✔ | ✔ | ✔ | 98.3 | 86.3 | 85.1 | 94.5 | 84.9 | 89.3 | 89.7 | |
16 | ✔ | ✔ | ✔ | ✔ | ✔ | 98.1 | 85.7 | 86.0 | 96.2 | 85.6 | 90.8 | 90.4 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Chen, Z.; Liu, B. A High-Accuracy PCB Defect Detection Algorithm Based on Improved YOLOv12. Symmetry 2025, 17, 978. https://doi.org/10.3390/sym17070978
Chen Z, Liu B. A High-Accuracy PCB Defect Detection Algorithm Based on Improved YOLOv12. Symmetry. 2025; 17(7):978. https://doi.org/10.3390/sym17070978
Chicago/Turabian StyleChen, Zhi, and Bingxiang Liu. 2025. "A High-Accuracy PCB Defect Detection Algorithm Based on Improved YOLOv12" Symmetry 17, no. 7: 978. https://doi.org/10.3390/sym17070978
APA StyleChen, Z., & Liu, B. (2025). A High-Accuracy PCB Defect Detection Algorithm Based on Improved YOLOv12. Symmetry, 17(7), 978. https://doi.org/10.3390/sym17070978