# Laboratory Flame Smoke Detection Based on an Improved YOLOX Algorithm
## 2 Materials and Methods
### Swin Transformer  
The original YOLOX model's early-fire targets are little flames, making the model easy to overlook. The improved YOLOX model makes up for the original YOLOX network's lack of long-distance modeling and its inability to obtain global information by using Swin  
Figure 1: Overall structure of YOLOX algorithm. Figure 2: Improved YOLOX network structure. Transformer as its backbone network to enhance its ability to extract feature information of flame targets. This also improves the model's detection effect on little flames. Convolutional neural network-based deep learning methods now in use offer the advantages of high accuracy, low costs, and fast speeds, but they fall short of Transformer in terms of processing the link between visual elements and objects [12; 13; 14]. Transformer is a deep neural network that was initially used in the field of natural language processing and is based on a self-attentive mechanism (NLP). Researchers have recently suggested numerous approaches to employ the Transformer to conduct computer vision tasks with good results, even outperforming convolutional neural networks, as a result of its potent performance. By breaking up photos into many image blocks for processing, Vision Transformer (Vit) proved, for the first time, that the Transformer design can also be directly applied to images [15]. Transformer was successfully used for the target detection problem by DETR as the first method [16]. DETR utilizes the set matching loss function and adds a Transformer encoder and decoder to a common CNN model (As ResNet-50/101). A sliding window attention mechanism is proposed by [PERSON] to compute self-attention within a window region without overlap, modeling only local relationships at each layer, while being able to continuously reduce the feature map width and height, and expand the perceptual field [17]. Swin Transformer introduces the hierarchical construction method typically used in CNN to build hierarchical transformers. Compared to ViT, the computational complexity of Swin Transformer is substantially reduced. The use of Transformer in computer vision has two fundamental difficulties. First, the visual target is constantly changing, and the performance of the visual Transformer may not be very effective in various circumstances. Second, Transformer's calculation based on global self-attentiveness will require a significant amount of processing if the image quality is high and there are numerous pixel points. Swin Transformer suggests a strategy to create the Transformer in a hierarchical approach by incorporating sliding window operations in order to address these two problems. By limiting the attentional computation to a window, the sliding window operation can introduce local awareness of CNN convolutional procedures while also reducing computing cost. The network's computing effort is drastically reduced by Swin Transformer's method of maintaining the computational region in windowed units, which reduces complexity to a linear scale of image size. Swin Transformer consists of the following main components: MLP (Multi-layer Perceptron), W-MAS (Window Multi-head Self Attention), SWMSA (Shifted Window based Multi-head Selfattention), and LN (Layer Normal-ization). Its backbone network is shown in Figure 3.  
Figure 3: Backbone network of Swin Transformer. The input features to the Swin Transformer backbone network are shown in Figure 3 to first pass through the normalization layer for normalization, the windowed multi-headed self-attentive layer for feature learning, the residuals are computed, the multilayer perceptron through the normalization layer, and, finally, another residual operation to obtain the output features of this layer. The construction of the sliding window multi-head self-attentive layer is comparable to that of the window multi-head self-attentive layer, with the exception that the sliding window action is necessary for the sliding window multi-head self-attentive layer's computational feature portion.