# Intelligent Monitoring of Tunnel Fire Smoke Based on Improved YOLOX and Edge Computing
## 2 Feature Processing for Tunnel Flame Smoke Image
### Fuzzy Loss  
Throughout our experiments, a significant challenge emerged because the majority of our test data originated from network images, some of which included mosaic and other unclear regions. Consequently, the detection model frequently misidentified these indistinct areas as smoke regions, resulting in the false detection scenario illustrated in Figure 1. These blurred sections of the image typically contain low-frequency information. In the early stages of smoke formation, the observed characteristic in the image is that the smoke partially obscures the blurred portion. Recognizing this distinct feature, we have introduced an additional component in the form of a fuzzy loss to complement the original loss function. In the realm of target detection, it is crucial to calculate regression and classification losses for both the predicted bounding box and the object category within that box. For classification loss, a widely used function is the Focal Loss, which was introduced by [PERSON] to address the issue of model performance being affected by data imbalances in image-related tasks [34]. The core concept behind the Focal Loss is to emphasize the significance of challenging classification samples. Traditional cross-entropy loss functions can be influenced by an unequal distribution of sample categories, causing the model to favor categories with more training samples during the training process. The Focal Loss addresses this by introducing an adjustable factor that modifies the weight of difficult samples in the loss function. The magnitude of this factor is linked to the prediction probability of the sample: easier-to-classify samples have smaller factors, while harder ones receive larger factors. This adjustment compels the model to pay more attention to challenging samples, thereby enhancing classification accuracy. The specific formulation of the Focal Loss is as follows:  
Figure 1: Error detection image. \[FL(p_{t})=-(1-p_{t})^{\gamma}\text{log}(p_{t}) \tag{2}\]  
The proximity of the \(p_{t}\) determines the response to the real label (Ground Truth); that is, regarding the real category \(y\), the larger the \(p_{t}\), the more accurate the classification is. \(\gamma>0\) is a regulatory factor. In the context of regression problems within target detection, the preferred loss function is the Intersection over Union (IOU) Loss, and it has various derivatives such as DIOU, CIOU, and GIOU, among others [35; 36; 37; 38]. The IOU measures the degree of overlap between the predicted bounding box and the actual bounding box. Given that blurred image edges often exhibit smoothness, resulting in low calculated blur values, while regular object edges typically have distinct boundaries, leading to higher blur values, we have introduced a blur loss in addition to the IOU loss in this study. The approach is outlined as follows:  
During the calculation of the IOU loss, we utilize the Laplace operator [39], as indicated in Equation (3), to process the two-dimensional image, resulting in the following:  
\[\bigtriangledown^{2}f=f(x+1,y)+f(x-1,y)+f(x,y+1)+f(x,y-1)-4f(x,y) \tag{3}\]  
\(f(x+1,y)\) represents the value on the image coordinate \((x+1,y)\), and the corresponding calculation matrix is as follows:  
\[m= \begin{bmatrix}0&1&0\\ 1&-4&1\\ 0&1&0\end{bmatrix}  \tag{4}\]  
\[v=(\frac{|pred_{box}\times m|}{s})\cdot avg() \tag{5}\]  
In this context, \(k\subset\{0,1\}\) represents the coefficient of the fuzzy value, which is determined through human control and set to 0.5. The variable \(v\subset\{0,1\}\) corresponds to the computed fuzzy value, while \(L_{blur}\) denotes the fuzzy loss. In a different scenario involving flame detection, where the flame in the target frame typically exhibits similar color and texture characteristics, the computed blur value tends to be close to 0. Consequently, the blur loss has a minimal impact on flame detection.