# Multi-Scale Flame Situation Detection Based on Pixel-Level Segmentation of Visual Images
## 3 Method
### The Framework of Flame-SeaFormer
#### 3.2.1 Flame Segmentation Model: SeaFormer  
As shown in Figure 5, SeaFormer consists of four modules: the shared fire feature extractor, context branch, spatial branch, and light segmentation head. Firstly, the shared fire feature extractor is employed to extract low-level fire feature maps. Secondly, both the context branch and spatial branch share the feature maps. The context branch captures global context information through axial attention, modeling features using axial attention mechanisms to obtain long-range semantic information dependencies. The spatial branch fuses low-level spatial information with high-level semantic information through the fusion block to achieve more accurate fire features. Finally, the light segmentation head employs lightweight convolution operations to map the fused features to the pixel-level fire segmentation results. The following sections will provide detailed descriptions of these four modules. \begin{table}
\begin{tabular}{c c c} \hline
**Item** & **SeaFormer** & **Flame-SeaFormer (Ours)** \\ \hline Purpose & Static segmentation & Static flame segmentation & Static flame segmentation \\  & & and dynamic flame \\  & & situation detection \\ \hline  & Focusing on the internal & Focusing on applying the \\  & design of the model to & model to specific real-world \\  & achieve the best trade-off & scenarios and conducting \\  & between segmentation & result analysis to explore \\  & accuracy and latency & potential patterns \\ \hline  & & \\ \end{tabular}
\end{table} 
Table 1: _Cont._  
Figure 5: The framework of multi-scale flame situation detection model Flame-SeaFormer. For input fire images, the SeaFormer model produces pixel-level segmentation results. Based on the segmentation results of fire video sequences, the flame parameter inversion section calculates static and dynamic flame parameters and then analyzes the development trends of the flames. Due to space limitations, only the trends of the flame static parameters of the five combustion processes are shown here. 1. **Shared fire feature extractor:** SeaFormer adopts MobileNetV2 as the feature extraction network, leveraging its high efficiency and accuracy while operating within limited computing resources. The shared fire feature extractor consists of a regular convolution with a step size of 2 and four MobileNet blocks. Given an input image \(I\), the extractor extracts fire features and produces a feature map \(x^{s}\in\mathbb{R}^{\frac{H_{I}}{\tau}\times\frac{W_{I}}{\tau}\times C^{\prime}}\), where \(r\) is the scaling factor of the feature map and \(C^{\prime}\) is the number of channels. The operation of the fire feature extraction process is expressed as \[x^{s}=\text{FE}(I)\] (1) where FE denotes the fire feature extraction operation. 2. **Context branch:** The context branch is designed to capture more global and fine-grained context information from the feature map \(x^{s}\), as shown in the red branch of Figure 5. To achieve a good trade-off between segmentation accuracy and inference speed, the SeaFormer layer is introduced in the last two stages of the context branch. It consists of a squeeze-enhanced axial attention block (SEA attention) and feed-forward network (FFN), as shown in Figure 6a. As depicted in Figure 7, SEA attention employs concise squeeze axial attention for global semantic extraction, while using an efficient detail enhancement kernel based on convolution to supplement local details. Squeeze axial attention and the detail enhancement kernel are described separately. Figure 6: Illustration of the three major modules in SeaFormer. (**a**) SeaFormer layer consists of SEA attention and an FFN. (**b**) Fusion block is utilized to fuse high-resolution fire feature maps in the spatial branch and low-resolution fire feature maps in the context branch. (**c**) Light segmentation head consists of two convolution layers. Figure 7: Schematic illustration of SEA attention. SEA attention includes detail enhancement kernel and squeeze axial attention.