## 2 Methodology
### Key Technical Innovations
#### 2.2.4 Neck Network Architecture  
To solve the loss of details in PCB by traditional FPN, a new Neck network architecture is formed by utilizing a multi-level feature fusion module (SDI) paired with the classical weighted bidirectional feature pyramid network ASF-YOLO, where the SDI module enhances semantic and detail information in the image by integrating the hierarchical feature maps generated by the encoder. The model improves the accuracy and speed of processing images by combining spatial and scale features.  
ASF-YOLO (AttentionalScaleSequenceFusionbasedYOLO) [32] is a new instance segmentation model based on the YOLO framework, which aims to improve the accuracy and speed of image segmentation by fusing spatial and scale features. The model introduces the following two key modules based on the YOLO segmentation framework.  
1. Triple Feature Encoder (TFE) module  
It increases the detailed information of small objects by fusing feature maps of different scales, as shown in Figure 4, where C represents the number of channels and S represents the feature map size. Each triple feature encoder module uses three feature maps of different sizes as input.  
2. Channel and Position Attention Mechanism (CPAM)  
The feature information of SFFF and TFE modules is integrated to focus on the channel and spatial location related to small objects, thereby improving the detection and segmentation performance, as shown in Figure 5, which contains channel and location attention networks; w and h denote width and height respectively, \(\otimes\) denotes the run of Hadamard product.  
Computational formula:  
\[C=\psi(k)=2^{(\gamma\times k-b)} \tag{21}\]  
\[k=\psi(C)=\left|\frac{log_{2}(C)+b}{\gamma}\right|_{odd} \tag{22}\]  
Here, \(\gamma\) and \(b\) are scaling parameters that control the ratio of the convolution kernel size \(k\) to the channel dimension \(C\).  
Multi-level feature fusion module SDI is discussed in [33]. U-Net v2 is a modified U-Net architecture that aims to enhance the performance of image segmentation by redesigning skip connections. The proposed model improves the quality of feature maps by injecting semantic information and detailed information into the multi-level feature maps generated by the encoder, as shown in Figure 6.  
Figure 4: Structure of TFE module.  
Figure 5: The structure of the CPAM module.  
1. Spatial and channel attention mechanism  
Enhance the ability of feature maps to integrate local spatial information and global channel information.  
\[f_{i}^{1}=\phi_{i}^{c}\left(\varphi_{i}^{s}\left(f_{i}^{0}\right)\right) \tag{23}\]  
Here, \(f_{i}^{1}\) is the original feature map at level \(i\); \(\varphi_{i}^{s}\) and \(\phi_{i}^{c}\) represent the parameters of the spatial and channel attention mechanism, respectively.
2. Semantic and detail injection SDI module  
High-level features (semantic information) and low-level features (detail information) are fused into each level feature map by Hadamard product. Feature map adjustment and fusion:  
\[f_{ij}^{3}\begin{cases}D\left(f_{j}^{2}\left(H_{i},W_{i}\right)\right)\ if\ j<i,\\ I\left(f_{j}^{2}\right)\quad if\ j=i,\\ U\left(f_{j}^{2}\left(H_{i},W_{i}\right)\right)\ if\ j>i,\end{cases} \tag{24}\]  
Here, \(D\), \(I\), and \(U\) represent adaptive average pooling, identity mapping, and bilinear interpolation, respectively.
3. Smooth convolution Smooth the adjusted feature map by 3 \(\times\) 3 convolution: \[f_{ij}^{4}=\theta_{ij}\left(f_{ij}^{3}\right)\] (25) Here, \(\theta^{ij}\) represents the parameters of the smoothed convolution.