# Position Detection of Doors and Windows Based on DSPP-YOLO
## 2 The Algorithm Principle of Yolov3  
The YOLOV3 network architecture is shown in Figure 1. It is divided into a feature extraction part and a target detection part. In the feature extraction part, it continues and deepens the YOLOV2 backbone network Darknet19. The convolution layer and the batch normalization layer (batch normalization, BN) and the Leaky ReLU activation function layer [21] are connected to the basic unit of the network, CBL. Many 1 \(\times\) 1 and size 3 \(\times\) 3 CBL units are alternately connected to form Darknet53, and a skipping connection structure is adopted to ensure that the gradient explosion and the training convergence cannot occur while deepening the network. And in the target detection network part, the idea of the feature pyramid network (Feature Pyramid Network, FPN [22]) is used for reference, and the feature maps with sizes of 13 \(\times\) 13, 26 \(\times\) 26, 52 \(\times\) 52 are passed on. After sampling, it is fused with the upper-layer feature map of the corresponding size to achieve multi-scale output. The output feature map with the size of 13 \(\times\) 13 has a larger receptive field and is suitable for larger targets, whereas the output feature map with the size of 52 \(\times\) 52 is suitable for the detection of small targets. The basic idea of YOLOV3 algorithm is to divide the input image into \(S\times S\) grid, when there is a target center point in the grid, the center point is responsible for predicting the class position of the target. In order to help predict the size of priori boxes, three sizes of anchor boxes are set up by K-means algorithm. The detection frames are filtered according to the threshold of the intersection over union (IOU), and the detection frames with the highest confidence are output as the final detection results by non-maximum suppression (NMS). In YOLOV3 algorithm, multi-label training is realized by using a logistic classifier, and binary cross entropy is used to describe the classification loss function. The smaller the binary cross entropy is, the smaller the value of the loss function is, and the more the learning result of the network model is close to the actual result. The expressions of the loss function are given in (1). Figure 1: YOLOV3 network model. \[Loss=\lambda_{coord}\sum\limits_{i=0}^{S^{2}}\sum\limits_{j=0}^{B}l_{ij}^{obj} \left[\left(x_{i}-\hat{x}_{i}^{j}\right)^{2}+\left(y_{i}-\hat{y}_{i}^{j}\right)^ {2}\right]+\] \[\lambda_{coord}\sum\limits_{i=0}^{S^{2}}\sum\limits_{j=0}^{B}l_{ij }^{obj}\left[\left(\sqrt{w_{i}^{j}}-\sqrt{\hat{w}_{i}^{j}}\right)^{2}+\left( \sqrt{h_{i}^{j}}-\sqrt{h_{i}^{j}}\right)^{2}\right]-\] \[\sum\limits_{i=0}^{S^{2}}\sum\limits_{j=0}^{B}l_{ij}^{obj}\left[ \hat{C}_{i}^{j}log\left(\hat{C}_{i}^{j}\right)+\left(1-\hat{C}_{i}^{j}\right) log\left(1-C_{i}^{j}\right)\right]- \tag{1}\] \[\lambda_{noob}\sum\limits_{i=0}^{S^{2}}\sum\limits_{j=0}^{B}l_{ij }^{noobj}\left[\hat{C}_{i}^{j}log\left(C_{i}^{j}\right)+\left(1-\hat{C}_{i}^{ j}\right)log\left(1-C_{i}^{j}\right)\right]-\] \[\sum\limits_{i=0}^{S^{2}}l_{ij}^{obj}\sum\limits_{ccclasses} \left[\hat{P}_{i}^{j}log\left(p_{i}^{j}\right)+\left(1-\hat{P}_{i}^{j}\right) log\left(1-P_{i}^{j}\right)\right]\]  
where, the first line is the error term of center coordinates; The second line is the coordinate error term of the height and width of the border; The third line is the bounding box confidence loss of the existing object. The fourth line is the bounding box confidence loss of non-existent objects. The fifth line is the classification loss of the cell in which the object resides. \(S^{2}\) is the number of cells, \(B\) is the number of bounding boxes predicted by each grid.