## 3 Methodology
### Double Head Module  
Previous work shows that the fully connected detection head (fc-head) and the convolutional detection head (conv-head) have different functional focus [36]. Therefore, applying different detection heads for different tasks is beneficial for obtaining more accurate classification and regression results. In our double head module, the fc-head is used for the classification task while the conv-head is used for the regression task.  
The structure of the detection head we adopt is shown in Figure 5. The ROI features extracted by ROIAlign is the input of the double head module. The ROI features are fed into two branches for classification and regression. In the classification branch, we follow the design of Faster R-CNN, in which two fully connected layers with 1024 dimension  
Figure 4: The structure of the proposed double pyramid network (DPN). \(\mathrm{C_{i}}/\mathrm{P_{i}}/\mathrm{N_{i}}\) represents features of different scales.  
are shared before the two output layers of classification and regression. In the regression branch, a residual block is used to increase the feature map channel from 256 to 1024, and then two bottleneck blocks are used to extract location information. Each bottleneck block is followed by a non-local attention block for enhancing defective features and suppressing background noise. The introduction of non-local attention block can cope the detection challenge caused by the high similarities between the steel strip defects and the background. Finally, average pooling is used to generate 1024-dimensional feature vectors for class prediction and bounding box regression.  
Notably, classification and regression are performed in both branches. While giving full play to the advantages of the two detection heads, additional supervision information is added, and they complement each other to achieve better performance. It has been reported that stacking more non-local attention blocks can achieve better performance [36]. We stack two non-local attention blocks, which are stacked alternately with bottleneck blocks to balance the accuracy and speed. Other settings are referred to the previous publication [36].  
After the classification and regression tasks are divided and conquered, the loss function also includes two parts, namely fc-head loss, and conv-head loss. Additionally, each detection head includes both classification loss and bounding box regression loss. The mathematical expressions are:  
\[L^{fc}=\lambda^{fc}.L^{fc}_{cls}+\left(1-\lambda^{fc}\right).L^{fc}_{\text{ reg}} \tag{4}\]  
\[L^{conv}=(1-\lambda^{conv}).L^{conv}_{cls}+\lambda^{conv}.L^{conv}_{cls} \tag{5}\]  
where \(L^{fc}\) is the loss of fc-head, and \(L^{conv}\) is the loss of conv-head. \(\lambda^{fc}\) is the weight coefficient for balancing the classification loss and bounding box regression loss in \(L^{fc}\). Similarly, \(\lambda^{conv}\) is the weight coefficient for balancing the classification loss and bounding box regression loss in \(L^{conv}\).  
The total loss function is:  
\[L=\omega^{fc}.L^{fc}+\omega^{conv}.L^{conv}+L^{rpn} \tag{6}\]  
where \(\omega^{fc}\) and \(\omega^{conv}\) are the weight coefficients of \(L^{fc}\) and \(L^{conv}\), respectively. \(L^{rpn}\) is the loss of RPN. In both fc-head and conv-head, the cross-entropy function [38] is used in the classification loss, and the smooth L1 function is used in the bounding box regression loss.  
Figure 5: The structure of the double head module. fc: fully connected layer, conv: convolution layer.  
Different detection heads in the double head can capture different information, and the function of the classifiers of the two detection heads can achieve better defect classification. Mathematical expression is shown as:  
\[S=S^{fc}+S^{conv}.(1-S^{fc})=S^{conv}+S^{fc}.(1-S^{conv}) \tag{7}\]  
where \(S^{fc}\) and \(S^{conv}\) are the classification scores of fc-head and conv-head, respectively.