# A Real-Time Safety Helmet Wearing Detection Approach Based on CSYOLOv3
## 2 Original YOLOv3 Model  
### The Structure of YOLOv3  
YOLOv3 is a single-stage target detection model proposed by [PERSON] et al. [19] in 2018. The network structure of the algorithm is shown in Figure 1. It combines excellent methods such as residual network, feature pyramid and multi-feature fusion network, with high performance of detection speed and accuracy. The first highlight of YOLOv3 is that the novel darknet53 network is applied as the backbone feature extraction, which draws on the experience of residual network in RESNET [13] and has excellent effect. The residual structure of darknet53 includes four steps: First, a \(3\times 3\) convolution with stride 2 is recorded as feature layer \(X\). Afterwards, one \(1\times 1\) convolution is executed to compress the number of channels to half of the original, after which a \(3\times 3\) convolution is performed to enhance feature extraction and expanded to the number of channels to obtain \(F(x)\). Finally, \(X\) and \(F(x)\) are stacked by residual structure. One of the biggest advantages is that the model is capable of enhancing the accuracy by reinforcing its network depth. Meanwhile, the inner residual block employs jump connection, which also alleviates the gradient disappearance puzzle raised by adding its network depth.  
Figure 1: Original YOLOv3 network structure.  
Each convolution layer of DarkNet53 employs a unique structure (darknetconv2d). L2 regularization is used at each convolution operation, batch normalization and leaky ReLU activation function are performed after convolution being executed. Compared with the ordinary ReLU function that sets all negative values to zero, the Leaky ReLU activation function used in DarkNet53 allocates all negative values a non-zero slope, as shown in Equation (1).  
\[f(x)_{j}=\begin{cases}x_{j}&\geq 0\\ \frac{x_{j}}{a_{j}}&<0\end{cases} \tag{1}\]  
The second highlight of YOLOv3 is the use of multi-scale features for prediction, extracting three different feature layers from DarkNet53 with shape size of (52, 52, 256), (26, 26, 512) and (13, 13, 1024). The three feature layers are convoluted for five times. One part of the processed results is utilized to output the prediction corresponding to the feature layer, and the other part is used to fuse with the previous feature layer after de-convolution operation. In addition, the way YOLOv3 predicts the coordinate position of the bounding box inherits the method in YOLOv2 [24], and \(k\)-means clustering is utilized to generate three categories of prior boxes with different sizes. Finally, each prediction border will generate four values, namely, the coordinate position of the upper left corner, along with the width and height of the border. Compared with other target detection models, YOLOv3 has the superiority of swift detection speed and high accuracy, but it still has some disadvantages when directly applied to the SHW detection task in complex scenes. Firstly, although the multi-scale prediction network is adopted in YOLOv3 to make full use of the receptive field, effectively alleviating the lack of scale invariance of convolution neural network, it also increases the amount of calculation, which leads to higher demands of hardware facilities; Secondly, although YOLOv3 improves the detection accuracy of small targets, it has the problem of insufficient shallow feature extraction. Thirdly, YOLOv3 still shows some detection deficiencies in the problems of existing occlusion, dense crowd and small scale targets in complex scenario. Therefore, the CSYOLOv3 model is put forward in this paper aiming to address the above problems.