# STHarDNet: Swin Transformer with HarDNet for MRI Segmentation
## 4 Proposed Method: STHarDNet  
### HarDNet  
HarDNet is a model of U-Net form with an encoder-decoder structure built with the HarDNet block as a backbone. Figure 4 shows the structure of the HarDNet model. The encoder refers to a process of extracting a feature map while reducing the image size through the down-sampling process and the encoder consists of one convolution block, four HarDNet blocks, and four down-sampling blocks. The convolution block consists of a convolution layer where filter = 24, kernel size = 3, and stride = 2, and a convolution layer where filter = 48, kernel size = 3, and stride = 1. A down-sampling block consists of a convolution layer with kernel size = 1 and an AvgPoll2d layer with kernel size = 2 and stride = 2. The transition section (bottleneck) uses a HarDNet block to complete the parameter transfer of the encoder and the decoder. The decoder up-samples the feature map received from the bottleneck into the same size as the input and, at the same time, it finds the disease region in the feature map and displays it in the output image. The decoder outputs the final image of (W, H) size after going through four HarDNet blocks, five up-sampling blocks, and the last convolution layer with kernel size = 1. An up-sampling block consists of an interpolate function that uses the \"bilinear\" mode and a convolution layer with kernel size = 1.  
If an input image is expressed in terms of (W (width), H (height), and C (channels)), the shape of the feature map calculated through the encoder's convolution block is (W/2, H/2, 48). The feature map of (W/32, H/32, 286) is output through four HarDNet blocks and four down-sampling blocks. The decoder receives the feature map of (W/32, H/32, 320) output from the bottleneck as input and then outputs a feature map of (W, H, class) (the class refers to the number of disease categories in the data). Table 1 shows the HarDNet'sdetailed structure and output examples, where the output size column shows examples where a grayscale image with a size of 224 \(\times\) 224 is used as input.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Stage** & **Block Name** & **Details** & **Output Size** \\ \hline Input & & & 224 \(\times\) 224 \(\times\) 1 \\ \hline \multirow{8}{*}{Encoder} & Conv Block & 2 \(\times\) Convolution & 112 \(\times\) 112 \(\times\) 48 \\  & HarDNet Block & 4 \(\times\) Convolution & 112 \(\times\) 112 \(\times\) 48 \\  & Down-sampling Block & 1 \(\times\) Convolution & 56 \(\times\) 56 \(\times\) 64 \\  & HarDNet Block & 4 \(\times\) Convolution & 56 \(\times\) 56 \(\times\) 78 \\  & Down-sampling Block & 1 \(\times\) Convolution & 28 \(\times\) 28 \(\times\) 96 \\  & HarDNet Block & 8 \(\times\) Convolution & 28 \(\times\) 28 \(\times\) 160 \\  & Down-sampling Block & 1 \(\times\) Convolution & 14 \(\times\) 14 \(\times\) 160 \\  & HarDNet Block & 8 \(\times\) Convolution & 14 \(\times\) 14 \(\times\) 214 \\  & Down-sampling Block & 1 \(\times\) Convolution & 7 \(\times\) 7 \(\times\) 286 \\ \hline Bottle Neck & HarDNet Block & 8 \(\times\) Convolution & 7 \(\times\) 7 \(\times\) 320 \\ \hline \multirow{8}{*}{Decoder} & Up-sampling Block & 1 \(\times\) Upsample & - \\  & HarDNet Block & 8 \(\times\) Convolution & 14 \(\times\) 14 \(\times\) 214 \\  & Up-sampling Block & 1 \(\times\) Upsample & - \\  & HarDNet Block & 8 \(\times\) Convolution & 28 \(\times\) 28 \(\times\) 160 \\  & Up-sampling Block & 1 \(\times\) Convolution & 56 \(\times\) 56 \(\times\) 78 \\  & Up-sampling Block & 1 \(\times\) Upsample & - \\  & HarDNet Block & 1 \(\times\) Upsample & - \\  & Up-sampling Block & 1 \(\times\) Convolution & 112 \(\times\) 112 \(\times\) 48 \\  & Up-sampling Block & 1 \(\times\) Upsample & - \\  & Up-sampling Block & 1 \(\times\) Convolution & - \\ \hline Output & Conv Block & 1 \(\times\) Convolution & 224 \(\times\) 224 \(\times\) 2 \\ \hline \hline \end{tabular}
\end{table}
Table 1: HarDNet’s structure and output examples.  
Figure 4: Architecture of HarDNet.