# 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
Finally, a linear projection is employed to reduce the channel from \((2C_{gk}+C_{v})\) to \(C\), generating the detail enhancement weight. The last two steps are shown as follows:  
\[F^{e}=\text{Conv}(\text{ReLU}(\text{Conv}(f^{e}))) \tag{9}\]  
where ReLU represents the activation function, and each convolution operation here is followed by a BN operation. The squeeze-enhanced feature map is obtained through the multiplication of the global semantic features \(F^{s}\) extracted from squeeze axial attention and the detail enhancement features \(F^{e}\) derived from the detail enhancement kernel:  
\[F^{se}=\text{Mul}(F^{s},F^{e}) \tag{10}\]  
where Mul means the bit-wise multiplication operation. The SeaFormer layer feeds \(F^{se}\) into the FFN to produce the output \(F^{l}\), enhancing the non-linear modeling capability of the model. To preserve important aspects of the original feature information and facilitate the transfer and fusion of fire feature information, residual connections are employed after the SEA attention and the FFN operations. This connection combines the learned features with the original features, ensuring the incorporation of valuable contextual information. The above operations can be summarized as follows:  
\[F^{l}=\text{Residual}(x,F^{se},\text{FFN}(F^{se})) \tag{11}\]  
where Residual means the residual connection, and FFN represents the feed-forward neural network. **(3) Spatial branch:** The spatial branch is designed to obtain high-resolution spatial information. Similar to the context branch, the spatial branch also operates on the feature map \(x^{s}\). However, early convolutional layers tend to contain abundant spatial information but lack higher-level semantic information. To address this, the fusion block integrates features from the context branch with the spatial branch, combining high-level fire semantic and low-level fire spatial information. As shown in the blue branch of Figure 5, the spatial branch module mainly consists of two fusion blocks. The fusion block is shown in detail in Figure 6b. In the first fusion block, the low-level feature \(x^{s}\) undergoes a \(1\times 1\) convolutional layer and a BN layer to generate a feature to be fused. \[x^{\prime}=\text{Conv}(x^{s}). \tag{12}\]  
Then, the high-level feature map derived from the context branch undergoes a sequence of operations, comprising a \(1\times 1\) convolutional layer, a BN layer, and a sigmoid layer. The processed feature map is upsampled to match the high resolution via bilinear interpolation, producing a semantic weight. \[x^{c}=\text{Up}\Big{[}\text{Sigmoid}\Big{(}\text{Conv}(F^{l})\Big{)}\Big{]} \tag{13}\]  
where Up is the upsampling operation and Sigmoid is the activation function. Finally, the semantic weight from context branch is element-wise multiplied with the feature from the spatial branch to obtain the fire feature that contains rich spatial and semantic information. \[F^{s}=x^{\prime}\cdot x^{c}. \tag{14}\]  
The fusion block enables low-level spatial features to acquire high-level semantic information, thereby improving the accuracy of flame segmentation. **(4) Light segmentation head:** The output feature from the last fusion block is directly fed into the light segmentation head, as illustrated in Figure 6c. To achieve efficient inference, the segmentation head consists of two convolutional layers, each preceded by a BN layer. The feature from the first BN layer undergoes an activation layer. Subsequently, the feature is further processed by another convolutional layer, which maps the feature to the original dimensions of the input image. This process generates a semantically rich flame feature. \[Flame^{s}=\text{Conv}(\text{ReLu}(\text{Conv}(F_{2}^{cs}))) \tag{15}\]  
where \(F_{2}^{cs}\) is the output of the second fusion block. Finally, a fully connected layer is utilized to assign a category label \(\hat{y}_{ij}\) for each pixel. \[(Q^{e},K^{e},V^{e})=(W^{e}_{q},W^{e}_{k},W^{e}_{v})x \tag{7}\]0  
where FC denotes the fully connected operation.