# MAS-YOLO: A Lightweight Detection Algorithm for PCB Defect Detection Based on Improved YOLOv12
## 1 Introduction  
With the widespread adoption of electronic devices, printed circuit boards, as the core components of electronic products [1, 2], have a direct impact on overall product performance and reliability. Nonetheless, defects like Short circuits, Open circuits, and missing solder joints are common occurrences during the manufacturing process. These defects may result in functional failures or even pose safety risks. Therefore, rapid and accurate PCB defect detection is crucial for improving production efficiency and ensuring product quality. Currently, methods for detecting PCB defects are generally divided into two types: manual inspection and automated detection approaches [3, 4, 5, 6]. Manual inspection depends heavily on the experience and skill level of human operators. However, with increasingly complex circuit designs and growing production scales, manual methods have become inefficient and are susceptible to human subjectivity, making them inadequate for meeting industrial-level demands. Within automated methods, machine vision-based automated optical inspection (AOI) is commonly utilized [7, 8, 9]. AOI systems use cameras to scan PCBs and rely on optical principles, frequency domain transformations, and statistical analysis to detect defects [10, 11]. Despite their effectiveness, traditional AOI systems often require complex setups involving lighting, mechanical transport, and image acquisition modules, which occupy significant space on the production line and incur high deployment costs. Moreover, these systems typically require professional engineers to pre-program detection logic for different types of PCBs. As a result, detection accuracy is highly dependent on programming quality, making the system difficult to use and poorly generalizable. In scenarios where PCB models change frequently and production batches are small, the programming workload increases significantly, reducing classification efficiency. Additionally, conventional AOI systems often generate a high number of false positives during defect identification. In recent years, deep learning technologies have achieved remarkable progress in the field of object detection [12; 13; 14; 15; 16]. [PERSON] et al. [17] employed image processing techniques to pre-classify PCB defects, significantly improving the accuracy of both bare and assembled PCB defect detection. However, the overall workflow remained insufficiently automated and relatively complex. [PERSON] et al. [18] proposed a lightweight neural network for PCB defect detection, though the study also pointed out that the model exhibited limited generalization capability when dealing with defects of varying types and sizes. [PERSON] et al. [19] introduced a cost-sensitive residual convolutional neural network for visual PCB defect detection, showing potential in enhancing accuracy. Nevertheless, the model required large-scale training data, leading to high computational costs and long training times. Similarly, recent transformer-based detectors and NAS-optimized models have shown great potential in various detection tasks. For instance, the transformer-based detector for object detection has achieved high accuracy in scenarios involving sequential multi-frame images by identifying patterns across frames. However, its applicability to industrial defect detection, especially in managing the intricate and varied defect patterns commonly found in PCBs, has yet to be established. Additionally, although the transformer-based NAS predictor with a self-evolution framework represents a significant step forward in model optimization, its feasibility and effectiveness in real-time industrial environments remain to be fully explored. These limitations indicate the necessity for further research to tailor and enhance these advanced architectures for specialized industrial applications such as PCB defect detection. The YOLO series of algorithms has emerged as a prominent research focus due to its real-time performance and computational efficiency [20; 21; 22; 23; 24; 25].