# Weak Edge Target Segmentation Network Based on Dual Attention Mechanism
## 3 Model Design and Optimization
### Total Network Framework  
WETS-Net is a real-time segmentation network built upon the foundation of U-Net, enhanced by the incorporation of the EAEM and MIFM modules, as illustrated in Figure 2. The EAEM module extracts edge feature information from the first and second low-scale downsampled features at the encoding stage, while the MIFM module focuses on channel information extraction from all downsampled features. These modules are interconnected during the adjacent upsampling process in the decoder, facilitating further information aggregation for feature fusion. WETS-Net is an efficient and accurate image-processing network that demonstrates outstanding performance in terms of real-time capability and precision. From a computational complexity perspective, this network, based on U-Net, introduces only a small number of additional 3 \(\times\) 3 convolutional layers, maximizing GPU resources and reducing computational waste. Moreover, the foundational U-Net model itself is a lightweight multitask network, further decreasing the time overhead during inference. It can be said that WETS-Net maintains performance while balancing computational efficiency and resource utilization. To enhance the network's feature extraction and fusion capabilities, WETS-Net incorporates two key modules: EAEM and MIFM. EAEM not only focuses on target edge features but also reorganizes and optimizes spatial features, enabling the network to better capture structural information about the targets. Meanwhile, MIFM strengthens the fusion and transmission of contextual information by modeling the dependencies between features at different scales. The synergistic action of these two modules allows WETS-Net to explore semantic information from multiple perspectives, leading to higher segmentation accuracy. WETS-Net employs a multi-task joint optimization strategy in its loss function design, incorporating two auxiliary loss terms (EAEM and MIFM outputs) to enhance network training. This approach not only supervises the final output but also emphasizes the learning of intermediate layer features, promoting more effective gradient propagation and consequently improving convergence speed and generalization performance. The comprehensive loss function concept allows for a balanced weighting of the main task and auxiliary tasks, ensuring that the model achieves an optimal equilibrium across various objectives. This sophisticated design enhances the model's expressiveness while deepening feature learning and providing more extensive supervision throughout the network training process. The loss function is formulated as follows:  
\[L_{total}=L_{final}+\alpha\times L_{EAEM}+\beta\times L_{MIFM} \tag{1}\]  
In the equation, \(\alpha\) and \(\beta\) are used as weight parameters to balance the auxiliary loss terms to adjust the influence of the two attention mechanism modules. After simulation experiment verification, it is determined that the two weight parameters of the auxiliary loss terms are both set to 0.5 to achieve a balanced effect on the attention mechanism module. In the formula, \(L_{final}\), \(L_{EAEM}\), and \(L_{MIFM}\) represent the losses of the entire network, EAEM and MIFM, and \(L_{total}\) represents the total loss function. It should be pointed out that these two auxiliary loss terms are only used in the training phase. All of these loss functions are calculated using the cross-entropy loss function, and the calculation method is shown in Equation (2). During the training process, by appropriately adjusting the weight parameters and the structure of the loss function, the model can better learn the data features and improve its performance. This meticulous loss design and weight adjustment is to promote the effective training of the network and the optimization of the final performance.