# MAS-YOLO: A Lightweight Detection Algorithm for PCB Defect Detection Based on Improved YOLOv12
## 3 Experiment and Analysis
### Experimental Process  
#### 3.3.1 Comparison of Detection Performance Across Different Basic Models  
In a carefully controlled and unified experimental environment, a comprehensive and systematic comparative analysis was performed to evaluate the performance of several of the most recent and widely recognized object detection algorithms on two distinct datasets: the Kaggle PCBA Defects dataset and the Peking University PCB Defects dataset. The selected algorithms include SSD, CNN, Mask R-CNN, RetinaNet, EfficientDet, YOLOv8, and YOLOv12. SSD (Single Shot Multibox Detector) is a real-time object detection algorithm that predicts object classes and locations directly from fixed-size input images. It uses a series of convolutional layers to produce predictions, making it efficient for real-time applications. CNN (convolutional neural network) forms the Backbone of many object detection models, using convolutional layers to extract features from images. It is characterized by its depth and the use of multiple layers to learn hierarchical features. Mask R-CNN extends Faster R-CNN to predict instance masks in addition to bounding boxes and classes, making it suitable for instance segmentation tasks. It introduces a branch for predicting object masks, thus enabling precise localization. RetinaNet addresses the class imbalance problem in object detection with a focal loss function, improving performance on small objects. It uses a ResNet Backbone and a feature pyramid network to handle objects at different scales. EfficientDet balances efficiency and accuracy through a balanced architecture and compound scaling method. It scales the network in a balanced way to achieve optimal performance across different resource constraints. For a fair comparison, all models were trained under the same experimental conditions. Specifically, the learning rate was set to 0.01, and training was conducted for 300 epochs with a batch size of 16. The optimizer used was Stochastic Gradient Descent (SGD) due to its simplicity and effectiveness. Table 1 details the performance metrics of each algorithm on the Kaggle PCBA Defects dataset, while Table 2 presents the results for the Peking University PCB Defects dataset. This analysis offers valuable insights into the relative efficiency and applicability of these methods, helping to identify the most suitable algorithms for PCB defect detection tasks. \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Model** & **mAP/\%** & **Precision/\%** & **Recall/\%** & **Parameters/MB** & **GFLOPs** & **FPS** \\ \hline SSD & 79.0 & 79.9 & 74.3 & 8.9 & 28.3 & 47.1 \\ CNN & 79.8 & 81.2 & 73.2 & 19.6 & 48.0 & 9.3 \\ Mask R-CNN & 84.2 & 83.4 & 82.6 & 14.8 & 34.2 & 10.9 \\ RetinaNet & 80.7 & 79.2 & 81.9 & 9.0 & 16.8 & 45.1 \\ EfficientDet & 83.1 & 83.8 & 79.9 & 11.1 & 19.1 & 38.3 \\ YOLOv8 & 83.2 & 83.5 & 80.3 & 12.6 & 20.0 & 46.7 \\ YOLOv12 & 85.3 & 82.7 & 85.6 & 12.8 & 22.4 & 47.2 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Different model detection performance (Kaggle PCBA Defects dataset). The experimental results demonstrate that YOLOv12 exhibits significant advantages across multiple key metrics on both datasets. For the Kaggle PCBA Defects dataset, YOLOv12 achieved a mean average precision of 85.3%, ranking highest among all compared models. Although its model size of 12.8 MB is slightly larger than that of SSD and RetinaNet, this is acceptable given the substantial improvement in accuracy. In terms of computational complexity, YOLOv12 reaches 22.4 GFLOPs--higher than EfficientDet's 19.1 and RetinaNet's 16.8--but its detection frame rate hits 47.2 frames per second, the fastest among all algorithms. For the Peking University PCB Defects dataset, YOLOv12 also attained the highest mAP at 84.2%. Its FPS reached 48.0, second only to RetinaNet, indicating excellent detection speed. While YOLOv12's model size is 12.4 MB, slightly larger than SSD and RetinaNet, the balance it strikes between accuracy and speed makes it more favorable for real-time applications.