| Algorithm 1: Algorithm for Segmentation using UNet and Transformers |
|
Input: X as the input image, as the output of the ith convolutional layer in the UNet model, as the ith feature map, as the ith pooling layer, as the ith up-convolutional (transposed convolutional) layer in the U-Net model, as the output of the transformer model, as the multi-head attention mechanism in the transformer model, as the ith dense layer in the transformer model. Output: Segmented Lesion 1. for i in range(N) do: E = sigma(Conv(E-1)) D = sigma(Conv(D-1) S = E + D L_bce = sum(y_i × log(O_i) + (1 − y_i) × log(1 − O_i) for i in range(N)) L_dice = (2 × TP)/((TP + FP) + (TP + FN)) L_jaccard = TP/(TP + FP + FN) end for # Transformer-style segmentation with MultiHeadAttention, Position-wise Feed-forward Network, and Normalization 2. for i in range(N) do: E = MultiHeadAttention_Layer(x) + x D = MultiHeadAttention(Y) + Y + MultiHeadAttention(Encoder_Output) FFN = ReLU(Conv1D(Z, W_1 + b_1)) @ W_2 + b_2 end for |