## 3 Methods
### Edge-Aware Feature Aggregation Modules (EFAMs)  
The edge information and fine details are helpful for defect segmentation tasks [24]. Therefore, we propose EFAMs to integrate the edge components extracted by DEFP into the global features obtained from the backbone network, ensuring a comprehensive representation of both structural and detailed information. Figure 3 shows the architecture of EFAM.  
Each EFAM, EFAM\({}_{i}\), takes the backbone network's output \(f_{i}^{d}\) and DEFP's edge feature \(f_{i}^{l}\) at the \(i\)-th level as the inputs, and fuses them through an addition operation to obtain \(f_{i}^{add}\):  
\[f_{i}^{add}=f_{i}^{l}+f_{i}^{d} \tag{8}\]  
The \(f_{i}^{add}\) is then concatenated with the \(f_{i}^{d}\), followed by a convolutional layer. Formally,  
\[f_{i}^{cat}=\text{Conv}\Big{(}\text{Concat}\Big{(}f_{i}^{add},f_{i}^{d}\Big{)} \Big{)} \tag{9}\]  
Then, a spatial attention mechanism is employed to weight the important regions of the aggregated feature \(f_{i}^{cat}\). In particular, a convolutional operation is performed on \(f_{i}^{cat}\), followed by a Sigmoid, to obtain the weight matrix \(a\):  
\[a=\sigma\big{(}\text{Conv}\big{(}f_{i}^{cat}\big{)}\big{)} \tag{10}\]  
where \(\sigma(\cdot)\) is the Sigmoid function. \(a\) is used to weight the \(f_{i}^{cat}\) to obtain the feature with significant representation. Formally,  
\[f_{i}^{att}=a\otimes f_{i}^{cat} \tag{11}\]  
where \(\otimes\) indicates the element-wise multiplication. The feature \(f_{i}^{att}\) is aggregated with the overall feature \(f_{i}^{d}\) obtained from the backbone, obtaining a enhanced feature \(f_{i}^{en}\), and a  
Figure 3: Architectural diagram of EFAMs.  
Convolutional Block Attention Module (CBAM) is applied to \(f_{i}^{cat}\) to further enhance feature representation by focusing on both channel-wise and spatial-wise attention. Formally,  
\[f_{i}^{e}=\text{CBAM}\Big{(}f_{i}^{d}+f_{i}^{att}\Big{)} \tag{12}\]  
The details of CBAM are shown in Figure 3(bottom). CBAM integrates channel attention and spatial attention in a cascaded manner. CBAM first applies channel attention to the input \(f_{i}^{cat}\). Specifically, \(f_{i}^{en}\) undergoes both max pooling as well as average pooling, followed by multilayer perceptrons (MLPs) and an element-wise multiply operation to generate the channel attention feature \(f_{i}^{ca}\).  
\[f_{i}^{a}=\text{MLP}(\text{MaxPool}(f_{i}^{en})\otimes\text{MLP}(\text{AvgPool }(f_{i}^{en}))) \tag{13}\]  
\(f_{i}^{a}\) is activated using the Sigmoid function to obtain channel-wise weights, which are element-wise multiplied with \(f_{i}^{en}\) to produce the weighted feature. Formally,  
\[f_{i}^{ca}=f_{i}^{en}\otimes\sigma(f_{i}^{a}) \tag{14}\]  
Similarly, CBAM applies the spatial attention to the input \(f_{i}^{ca}\). In particular, \(f_{i}^{ca}\) undergoes max pooling and average pooling along the spatial dimension to generate two spatial context descriptors, and concatenates them as \(f_{i}^{cat}\):  
\[f_{i}^{cat}=\text{Concate}(\text{MaxPool}(f_{i}^{ca}),\text{AvgPool}(f_{i}^{ca})) \tag{15}\]  
The spatial weight is obtained by processing \(f_{i}^{cat}\) through a \(7\times 7\) convolution layer followed by a Sigmoid function. Then, this weight is multiplied in elements with \(f_{i}^{ca}\) to generate the refined feature \(f_{i}^{e}\).  
\[f_{i}^{e}=\sigma(\text{Conv}_{7\times 7}(f_{i}^{cat}))\otimes f_{i}^{ca} \tag{16}\]