## 2 Materials and Methods
### Improved Deeplabv3+ Network Architecture
#### 2.3.1 CBAM Module  
The CBAM module is an attention mechanism used in feed-forward convolutional neural networks. It combines spatial and channel attention mechanisms and is applied to enhance the understanding of feature information after feature extraction in the Deeplabv3+ network. For the task of tilapia body part segmentation, the experimental results revealed that there is minimal color difference among different parts of the tilapia body, and varying regions exhibit differing levels of significance with regard to morphology. For example, there is more boundary information around the head and tail, while the trunk and fins contain more texture information. By utilizing channel attention and spatial attention, the CBAM module adaptively adjusts the weights of the feature maps, enabling the network to better focus on important morphological features and improve segmentation accuracy. It has been observed that incorporating both channel and spatial attention in the CBAM module yields better results compared to solely focusing on channel attention. The structure of the CBAM module is shown in Figure 7. The CBAM contains two sub-modules, the Channel Attention Module and the Spatial Attention Module, which perform the mapping of attention mechanisms on the channel and the space, respectively.  
Figure 6: Improved Deeplabv3+ network structure diagram.  
The channel attention mechanism compresses the feature maps in the spatial dimension. Specifically, it utilizes two parallel pooling layers, namely max pooling and average pooling, to compress the input feature maps in the spatial dimension, resulting in background descriptors \(F^{c}_{max}\) and \(F^{c}_{avg}\), respectively. These two outputs are then added together using a shared multi-layer perceptron (MLP) module, and the sigmoid activation function is applied to obtain the weights for each channel, generating the channel-wise feature map \(M_{c}\in R^{\text{C}\times 1\times 1}\). The calculation formula is as follows:  
\[M_{c}(F)=\sigma(MLP(AvgPool(F))+MLP(MaxPool(F))) \tag{1}\]  
\[M_{c}(F)=\sigma\Big{(}W_{1}(W_{0}(F^{c}_{max}))+W_{1}\Big{(}W_{0}\Big{(}F^{c}_{ avg}\Big{)}\Big{)}\Big{)} \tag{2}\]  
where \(F\) denotes the input feature map, \(\sigma\) denotes the sigmoid operation, \(W_{0}\in R^{\text{C}\times r/\text{C}}\), \(W_{1}\in R^{\text{C}/r\times\text{C}}\), and \(r\) denotes the reduction rate.  
The spatial attention mechanism is to compress the feature map in the channel dimension. The average pooling and maximum pooling of the channel feature map in the channel dimension are obtained as \(F^{s}_{max}\) and \(F^{s}_{avg}\), respectively, and the two feature maps are combined and reduced to one channel after convolution, and then the feature mapping map \(M_{s}\in R^{1\times W\times H}\) is obtained by the sigmoid activation function, which is calculated as follows:  
\[M_{s}(F)=\sigma\Big{(}f^{7\times 7}([AvgPool(F);MaxPool(F)])\Big{)} \tag{3}\]  
\[M_{s}(F)=\sigma\Big{(}f^{7\times 7}\Big{[}F^{s}_{max};F^{s}_{avg}\Big{]}\Big{)} \tag{4}\]  
where \(f^{7\times 7}\) denotes the convolution kernel of \(7\times 7\) and \(\sigma\) denotes the sigmoid function.