# Light-YOLOv5: A Lightweight Algorithm for Improved YOLOv5 in Complex Fire Scenarios
## 3 Methods
### IoU Loss and Activation  
The loss function of Light-YOLOv5 consists of two main components: classification loss and bounding box regression loss. The most classical form of bounding box regression loss is IoU [22] loss, and the most commonly used version in the YOLO series is CIoU [23]. As the research progresses, there are increasingly more variants of IoU, such as DIoU [24], GIoU [25], EIoU [26], and the latest, SIoU [27]. They are defined as follows:  
\[Loss_{IoU}=1-IoU,IoU=\left|\frac{A\cap B}{A\cup B}\right| \tag{10}\]  
\[Loss_{GIoU}=1-IoU+\frac{C-(A\cup B)}{C} \tag{11}\]  
\[Loss_{DIoU}=1-IoU+\frac{\rho_{(b,b^{st})}^{2}}{d^{2}} \tag{12}\]  
\[\begin{array}{l}Loss_{CIoU}=1-IoU+\frac{\rho_{(b,b^{st})}^{2}}{d^{2}}+\alpha v,\\ \alpha=\frac{v}{(1-IoU)+v},\\ v=\frac{4}{\pi^{2}}(arctan\frac{\mu\text{g}^{st}}{b^{st}}-arctan\frac{w}{h} )^{2}\\ Loss_{EIoU}=1-IoU+\frac{\rho_{(b,b^{st})}^{2}}{d^{2}}+\frac{\rho_{(w,a^{st})} ^{2}}{C_{h}^{2}}+\frac{\rho_{(h,b^{st})}^{2}}{C_{h}^{2}}\end{array} \tag{14}\]  
\[\begin{array}{l}Loss_{SIoU}=1-IoU+\frac{\Delta+\Omega}{2},\\ \Delta=\sum\limits_{t=x,y}{(1-e^{-\gamma\rho_{t}})},\\ \rho_{x}=\frac{b_{x}^{st}-b_{x}}{c_{w}},\rho_{y}=\frac{b_{x}^{st}-b_{x}}{c_{ b}},\gamma=2-\Lambda,\\ \Lambda=1-2*\sin^{2}(\arc\arcsin(x)-\frac{\pi}{4}),\\ x=\frac{c_{h}}{\sigma}=\sin(\alpha),\\ \sigma=\sqrt{\left(b_{x}^{st}-b_{x}\right)^{2}+\left(b_{y}^{st}-b_{x}\right)^ {2}},\\ c_{h}=\max(b_{x_{y}}^{st},b_{x_{y}})-\min(b_{x_{y}}^{st},b_{x_{y}}),\\ \Omega=\sum\limits_{t=x,y}{(1-e^{-\alpha_{t}})^{\theta}},\\ \omega_{w}=\frac{\left|w-w^{st}\right|}{\max(w,a^{st})},\omega_{h}=\frac{ \left|h-b^{st}\right|}{\max(h,b^{st})}\end{array} \tag{15}\]  
where the parameters \(A\) and \(B\) represent the areas of the ground-truth and prediction bounding boxes, which are rectangular, to describe the spatial location of objects; \(C\) denotes the minimum enclosing box of the ground-truth and prediction bounding boxes; \(b,b^{st}\)  
Figure 5: The structure of the GAM bottleneck.  
represent the centroids of the prediction and ground-truth bounding boxes, respectively; \(\rho\) represents the Euclidean distance between the two centroids; \(d\) is the diagonal distance of the smallest enclosing region that can contain both the prediction and ground-truth bounding boxes; \(\alpha\) is the weight function; and \(v\) is used to measure the similarity of the aspect ratios.  
The CIoU used by YOLOv5 relies on the aggregation of bounding box regression metrics and does not consider the direction of the mismatch between the desired ground box and predicted \"experimental\" box. This leads to its inferiority to SIoU in terms of training speed and prediction accuracy.  
In lightweight networks, HSwish, Mish, and LeakyReLu are quicker than ReLu regarding training speed. They can be defined as  
\[Hswish(x)=x\cdot\frac{\text{ReLu}6(x+3)}{6} \tag{16}\]  
\[Mish(x)=x\cdot\tanh(\log(1+\text{e}^{x})) \tag{17}\]  
\[\text{LeakyReLu}(x)=\max(ax,x) \tag{18}\]  
We observed in our experiments that the Mish activation function was more accurate than the others, and detailed comparison experiments are presented in Section 4.