# LightSeg: Local Spatial Perception Convolution for Real-Time Semantic Segmentation
## 3 Methods
### Local Spatial Perception Block  
A new network block named LSPBlock was designed based on LSPConv. Figure 3(b) illustrates the difference between LSPBlock and DBlock [10]. LSPBlock maintains the same number of input and output channels. First, LSPBlock applies a \(5\times 5\) standard convolution to extract features from the input. Then, the input with \(w\) channels is split into two groups, each group including \(w/2\) channels. A standard convolution is applied to one group while the other group undergoes spatial separable convolution. Next, LSPBlock concatenates the outputs of the two groups and finally applies a pointwise convolution to fuse different channel features. Notably, the LSPBlock module was not used in the early stages of the network, and other modules were adopted instead. Additionally, similar to the convolutions with the parameter \(g\) shown in LightSeg, group convolutions were also used to reduce the number of parameters and computational complexity. Figure 4: Comparison of LightSeg’s LSP block and ResSeg D block. The symbol \(g\) denotes the size of the group convolution, while the symbols \(d1\) and \(d2\) represent the dilation rates of the dilated convolutions. Figure 3: Illustration of the LSPConv module. The input feature map is split into two channel parts, \(f_{a}\) and \(f_{b}\), which are processed separately using different convolutional layers. The output feature maps \(f_{a}^{out}\) and \(f_{b}^{out}\) are then concatenated and passed through a nonlinear activation function to obtain the final output feature map \(f^{out}\). Assuming the input feature \(X\) has \(C\) channels and the configuration of spatially separable convolution size is \(m\), the number of parameters \(P\) in the LSP block can be calculated as follows when the stride is 1:  
\[ \begin{split} P_{5\times 5}&=5^{2}\times C\\ P_{Sparable\ Conv}&=3^{2}\frac{C}{2}+2m\frac{C}{2}\\ P_{1\times 1}&=C\times C\\ &\Downarrow\\ P=P_{5\times 5}&+P_{Sparable\ Conv}+P_{1\times 1}\end{split}  \tag{2}\]  
where \(P_{5\times 5}\) represents the number of parameters in a \(5\times 5\) convolutional layer, \(P_{Sparable\ Conv}\) represents the number of parameters in a spatially separable convolutional layer with kernel size \(m\), \(P_{1\times 1}\) represents the number of parameters in a \(1\times 1\) convolutional layer, and \(P\) represents the total number of parameters in the LSP block. A typical LightSeg Encoder is shown in Table 1. \begin{table}
\begin{tabular}{c c c c c} \hline
**Stage** & **Output Size** & **LightSeg-Base** & **LightSeg-Large** \\ \hline
1 & \(\frac{H}{4}\times\frac{W}{4}\) & \(C_{1}\) 48 & \(\begin{bmatrix}3\times 3,48\\ 3\times 3,48\\ 1\times 1,48\end{bmatrix}\) & \(C_{1}=64\) & \(\begin{bmatrix}3\times 3,64\\ 3\times 3,64\\ 1\times 1,64\end{bmatrix}\) \\ \hline
2 & \(\frac{H}{8}\times\frac{W}{8}\) & \(C_{2}\) 128 & \(\begin{bmatrix}3\times 3,128\\ 3\times 3,128\\ 1\times 1,128\end{bmatrix}\) & \(C_{2}=128\) & \(\begin{bmatrix}3\times 3,128\\ 3\times 3,128\\ 3\times 3,128\\ 1\times 1,128\end{bmatrix}\) \\ \hline
2 & \(\frac{H}{8}\times\frac{W}{8}\) & \(C_{2}\) 128 & \(\begin{bmatrix}3\times 3,128\\ 3\times 3,128\\ 1\times 3,128\\ 1\times 1,128\end{bmatrix}\times 2\) & \(C_{2}=128\) & \(\begin{bmatrix}3\times 3,128\\ 3\times 3,128\\ 3\times 3,128\\ 1\times 3,128\\ 1\times 1,128\end{bmatrix}\times 2\) \\ \hline
3 & \(\frac{H}{16}\times\frac{W}{16}\) & \(C_{3}\) 256 & \(\begin{bmatrix}3\times 3,256\\ 3\times 3,128\\ 1\times 1,128\\ 1\times 1,256\\ 1\times 1,256\end{bmatrix}\times 4\) & \(C_{3}=256\) & \(\begin{bmatrix}3\times 3,256\\ 3\times 3,256&7\times 1,128\\ 1\times 1,128\\ 1\times 1,256\end{bmatrix}\times 6\) \\ \hline
3 & \(\frac{3}{3}\times 3,320\) & \(11\times 1,160\) & \(1\times 11,160\) \\ \(\frac{(LSPBlock)}{1\times 1,320}\) & \(\begin{bmatrix}3\times 3,256\\ 3\times 3,256&11\times 1,128\\ 1\times 1,256\\ 1\times 1,256\end{bmatrix}\) \\ \hline \end{tabular}
\end{table}