# MAS-YOLO: A Lightweight Detection Algorithm for PCB Defect Detection Based on Improved YOLOv12
## 3 Experiment and Analysis
### Experimental Process
#### 3.3.5 Comprehensive Ablation Experiment  
To validate the overall performance of the improved algorithm in PCB defect detection, based on the original YOLOv12 model, the MECS module, AHFIN, and Slide Alignment Loss were added separately. The two datasets were merged to conduct a comprehensive ablation experiment analysis of the contributions of each module. The experimental results are shown in Table 9.  
When the MECS or AHFIN modules were added individually, the model showed improvements in detection accuracy, precision, and recall. When both modules were integrated together, the performance further improved, indicating that the two modules work synergistically in feature extraction and fusion. Additionally, the final model, MAS-YOLO, which incorporates the MECS module, AHFIN module, and SAL function, showed improvements of 7.8%, 8.0%, and 9.7% in detection accuracy, precision, and recall, respectively, compared to the original model. Furthermore, the detection speed FPS also increased by 2.7 percentage points, demonstrating the best performance. This improvement is attributed to the three pooling layers in the MECS module, which preprocess and suppress image noise in the Backbone section, filtering out important features for attention. Moreover, the \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Loss Function** & **mAP/\%** & **Precision/\%** & **Recall/\%** \\ \hline CIoU & 85.4 & 85.6 & 78.5 \\ DIoU & 79.3 & 80.8 & 75.4 \\ GIoU & 85.9 & 86.2 & 78.6 \\ SAL & 88.4 & 89.8 & 82.1 \\ \hline \hline \end{tabular}
\end{table} 
Table 8: Performance comparison of models trained with different loss functions. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Model** & **mAP/\%** & **Precision/\%** & **Recall/\%** & **FPS** \\ \hline YOLOv12 & 85.4 & 85.6 & 78.5 & 47.0 \\ +MECS & 92.1 & 92.3 & 85.1 & 47.1 \\ +AHFIN & 89.6 & 90.2 & 86.3 & 47.8 \\ +MECS + AHFIN & 92.9 & 93.0 & 87.2 & 49.4 \\ +MECS + AHFIN + SAL (MAS-YOLO) & 93.2 & 93.6 & 88.2 & 49.7 \\ \hline \hline \end{tabular}
\end{table} 
Table 9: Model detection performance before and after improvement. use of convolutional kernels of different scales helps capture information in different scales and orientations in the feature map, greatly enhancing the spatial processing efficiency of the subsequent Deformable Convolution in the Neck layer. After noise removal, the workload of the gradient compression module was also reduced, optimizing both detection accuracy and speed. Additionally, the introduction of the SAL function further fine-tunes the model's ability to classify features of varying scales and shapes, leading to further improvements in detection performance. To assess the detection performance of the improved model in practical scenarios, the receptive field of PCB defect images was visualized, as depicted in Figure 5. Figure 5a illustrates the receptive field of the original YOLOv12 model, while Figure 5b shows that of the enhanced MAS-YOLO model. It is evident that the improved model, with optimized multi-scale convolutional kernels and reduced noise interference, significantly broadens the effective receptive field for feature extraction. A larger receptive field enables the model to capture more visual details, further validating the enhanced feature extraction capability of the proposed MAS-YOLO. Figure 6 presents a comparative analysis of the detection performance of the original YOLOv12 and the enhanced MAS-YOLO models across six common PCB defect categories: Missing hole, Mouse bite, Open circuit, Short, Spur, and Spurious copper (subfigures (a) to (f), respectively). Each subfigure juxtaposes the detection outcomes of the two models, with the left side illustrating the original YOLOv12 results and the right side showcasing the MAS-YOLO results. A detailed examination reveals that the original YOLOv12 model suffers from missed detections and imprecise boundary localization, particularly when confronted with small target defects or intricate backgrounds.