# HS-YOLO: Small Object Detection for Power Operation Scenarios
## 2 Related Works and Methods
### Methods
#### 2.2.4 Object Detection Head  
The Head module serves as the final detection component of the HS-YOLO detection network. The Head consists of three detection branches corresponding to different scale feature maps obtained in the Neck. This structure effectively utilizes the feature information from different scales, enabling accurate detection of objects of various sizes. In the Head, the features from different branches are partitioned into grids of dimensions 80 \(\times\) 80, 40 \(\times\) 40, and 20 \(\times\) 20, respectively. For each grid, the Head undertakes the task of predicting a set of parameters that encompass the bounding box coordinates, the confidence scores related to those boxes, and the probabilities associated with the object classes. These predictions represent the object's position, presence, and category. By processing the grids, efficient and real-time object detection is achieved. During model training, a comprehensive loss function composed of confidence loss Lobj, classification loss Lcls, and bounding box regression loss Lbox is designed to measure the accuracy of the detection head's output. This integrated loss function allows for a comprehensive evaluation of both bounding box prediction and object class prediction accuracy, thereby promoting end-to-end optimization learning of the model. The Lobj plays a pivotal role in evaluating the trustworthiness of predicted boxes. It is computed through the utilization of the cross-entropy loss function, as shown in Equation (3). \[\text{Lobj}=-\sum_{\text{i}=0}^{\text{s}^{2}}\sum_{\text{j}=0}^{\text{B}}\text {I}_{ij}^{\text{obj}}\left[\hat{\text{C}}_{i}^{\text{j}}\text{log}\left( \text{C}_{i}^{\text{j}}\right)+\left(1-\hat{\text{C}}_{i}^{\text{j}}\right) \text{log}\left(1-\text{C}_{i}^{\text{j}}\right)\right]\ -\sum_{\text{i}=0}^{\text{s}^{2}}\sum_{\text{j}=0}^{\text{B}}\text {I}_{ij}^{\text{noobj}}\left[\hat{\text{C}}_{i}^{\text{j}}\text{log}\left( \text{C}_{i}^{\text{j}}\right)+\left(1-\hat{\text{C}}_{i}^{\text{j}}\right) \text{log}\left(1-\text{C}_{i}^{\text{j}}\right)\right] \tag{3}\]  
where s\({}^{2}\) represents the S \(\times\) S grids that the features of different branches are divided into in the Head. B represents the number of anchor boxes assigned to each grid for prediction during the detection process. Iij and Iij indicates whether the j-th anchor box in the i-th grid is a positive or negative sample, where Iij is 1 for a positive sample, while Iij is 1 for a negative sample. \(\hat{\text{C}}_{i}^{\text{j}}\) represents the confidence of the ground truth label for the sample, which can take the values of 0 or 1. \(\hat{\text{C}}_{i}^{\text{j}}\) represents the anticipated confidence score assigned to the sample produced by the detection head module. Figure 4: Sub-pixel convolution implements the upsampling process. The \(\mathrm{L_{cls}}\) calculates the classification error between the ground truth class labels and predicted class probabilities in each grid. \(\mathrm{L_{cls}}\) and \(\mathrm{L_{obj}}\), use the same loss function to calculate, as demonstrated in Equation (4). \[\mathrm{L_{cls}}=\sum_{i=0}^{\mathrm{g^{2}}}\mathrm{I_{ij}^{obj}}\sum_{C\in \mathrm{classes}}\left[\dot{\mathrm{P_{i}^{j}}}\mathrm{log}\left(\mathrm{P_{i}^ {j}}\right)+\left(1-\dot{\mathrm{P_{i}^{j}}}\right)\mathrm{log}(1-\mathrm{P_{ i}^{j}})\right] \tag{4}\]  
where \(\dot{\mathrm{P_{i}^{j}}}\) represents the true class and \(\dot{\mathrm{P_{i}^{j}}}\) represents the class probability value predicted by the model. The \(\mathrm{L_{box}}\) serves the purpose of assessing the positional disparity between the predicted location and the true location. It adopts the CIOU loss function, which combines more factors, such as diagonal distance changes, thus providing a more accurate position estimation. The computation is shown in Equations (5)-(7).