# YOLOv4-MN3 for PCB Surface Defect Detection
## 4 Experiment
### Comparison of Different Detectors  
The detection accuracy, speed and model complexity of YOLOv4-MN3 were tested and compared with the other five SOTA detectors, Faster RCNN, RetinaNet, SSD, YOLOv3, and original YOLOv4. The experimental results of the different indicators are illustrated in Figure 11. It can be seen that the proposed YOLOv4-MN3 achieve the highest detection accuracy, with a 98.64% _mAP_ value, which is 5.69%, 4.58%, 3.28%, 1.14% and 2.15% superior to Faster-RCNN, RetinaNet, SSD, YOLOv3 and YOLOv4, respectively. Meanwhile, YOLOv4-MN3 outperformed the other five compared models in \(F_{1}\), at 20.66%, 14.00%, 10.66%, 2.33% and 2.66% higher than Faster-RCNN, RetinaNet, SSD, YOLOv3 and YOLOv4 respectively. In terms of model complexity, YOLOv4-MN3 greatly reduced its parameters and _Madds_. The number of _Params_ needed by YOLOv4-MN3 reduced by 28.94%, 64.32% and 61.90% those of Faster RCNN, YOLOv3 and YOLOv4, respectively, and the _Madds_ of YOLOv4-MN3 was 90.45 G, 39.29 G and 33.60 G lower than of Faster RCNN, YOLOv3 and YOLOv4, respectively. The reason for this is that MobileNetV3 uses depthwise separable convolution, replacing the standard convolution, allowing the convolution weights and operations to be reduced greatly. In addition, RetinaNet and SSD had small numbers of parameters but large _Madds_. The reason for this is that the number of parameters indicates the space complexity or storage consumption, and _Madds_ is the metric of time complexity. Detectors with small _Params_ cannot ensure lower _Madds_ or higher detection speed, and vice versa. For example, the activation function and pooling operations increased _Madds_ while _Params_ remained unchanged. Meanwhile, we can see that the _Madds_ of YOLOv4-MN3 is 43.72 G and 90.26 G lower than RetinaNet and SSD, although with a slight increase in parameters. YOLOv4-MN3 also had significant advantage in detection speed, and its _FPS_ value was greater by 10.60, 3.01, 1.98, 11.49 and 5.34 than those of Faster RCNN, RetinaNet, SSD, YOLOv3 and YOLOv4. Based on the comparison of SOTA detectors, the YOLOv4-MN3 model delivered significant advantage in terms of detection accuracy, model parameters, operations and detection speed.  
\begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline \multirow{2}{*}{**Activation**} & \multicolumn{8}{c}{_AP (\%)_} \\ \cline{2-9}  & **Bumpy or** & & & **Clutter** & **Scatch** & **Line Repair** & **Hole Loss** & **Over** & **Off-Filling** & **\(mAP\) (\%)** & **\(F_{1}\) (\%)** \\ \cline{2-9}  & **Broken Line** & & & **Damage** & & **Oil-Filling** & & & \\ \hline Sigmoid & 98.12 & 96.80 & 87.18 & 97.44 & 95.64 & 98.95 & 95.69 & 94.50 \\ Tanh & 98.56 & 95.94 & 88.33 & 98.43 & 99.15 & 99.32 & 96.62 & 95.67 \\ ReLU & 98.89 & 99.41 & 88.53 & 96.35 & 98.95 & 99.99 & 97.02 & 95.75 \\ Leaky ReLU & 99.10 & 98.98 & 90.92 & 95.73 & 99.51 & 99.32 & 97.26 & 95.83 \\ Swish & 99.66 & 98.41 & 86.80 & 98.87 & 99.91 & 100.00 & 97.28 & 96.33 \\
**Mish** & **100.00** & **98.69** & **94.20** & **99.36** & **99.61** & **100.00** & **98.64** & **97.83** \\ \hline \hline \end{tabular}
\end{table}
Table 4: Performance of different activation functions on YOLOv4-MN3.  
Figure 12 gives some detection instances obtained by YOLOv4-MN3 and the compared detectors. The detection instances given in Figure 12a,b show that Faster RCNN and RetinaNet only detected a part of the defect with low confidence. SSD and YOLOv3 defect the whole defect but also with low confidence, as shown in Figure 12c,d. Figure 12e,f indicates that both YOLOv4 and YOLOv4-MN3 could detect the whole defect. However, YOLOv4-MN3 achieved the highest confidence 0.98, while the confidence of YOLOv4 was only 0.87, in this instance.  
Figure 11: Performance of different SOTA models.  
Figure 12: Detection instance obtained by different detectors.