## 3 Methods
### Object Detection
#### 3.2.2 Heatmap Loss  
Heatmap loss includes response value prediction loss and prediction distance difference loss, prediction loss is defined as the error between the predicted response value and the true response value, due to the problem of imbalance in the ratio of positive and negative samples and difficult samples for centroid detection, in order to reduce the effect of sample inhomogeneity, the loss function follows the Focal Loss [35] function in CenterNet, which is expressed as follows:  
\[L_{p}=-\frac{1}{N}\sum_{xy}\left\{ \begin{array}{c}\left(1-\hat{M}_{xy} \right)^{\alpha}\ln\left(\hat{M}_{xy}\right),\ M_{xy}{=1}\\ \left(1-M_{xy}\right)^{\beta}\hat{M}_{xy}{}^{\alpha}\ln\left(1-\hat{M}_{xy} \right),other\end{array} \right., \tag{2}\]  
where \(N\) is the number of objects, \(\hat{M}_{xy}\) is the predicted response value of the heatmap at \((x,y)\), \(M_{xy}\) is the GT response value, and the preset parameters \(\alpha,\beta\) for Focal Loss are \(\alpha=2,\beta=4\). The detection deviation loss is defined as the deviation of the distance from the predicted position to the corresponding GT position. Considering that a heatmap detects the object location by predicting the response value, it is not necessary to guarantee the correspondence between the predicted location and the GT object, so the principle of proximity is used to select the corresponding GT object for each predicted location to calculate the loss. For each high response position \(\left(\hat{e}_{x}^{i},\hat{e}_{y}^{i}\right)\) of the predicted heatmap, the nearest GT position (the coordinate position with a response value of 1) is selected and the distance between the two coordinates is calculated as the loss. Here, the distance is the 2D coordinate point spacing, so \(L_{2}\) distance is chosen as the loss. A response threshold of \(\lambda=0.5\) is set to filter high response values to ensure effective constraints on detection deviations, and the loss calculation is defined as follows:  
\[L_{d}=\frac{1}{M}\sum_{i=1}^{M}\min\left(\left\|\left(\hat{e}_{x}^{i},\hat{e}_ {y}^{i}\right)-C\right\|_{2}\right), \tag{3}\]  
where \(M\) is the number of predicted response values greater than \(\lambda\), \(\left(\hat{e}_{x}^{i},\hat{e}_{y}^{i}\right)\) is the predicted object location, \(C=\left\{\left(\hat{e}_{x}^{j},\hat{e}_{y}^{j}\right),j\in\left[1,N\right]\right\}\) is the set of GT position coordinates. At the same time, considering that the detection deviation loss is a constraint on the deviation of high response value positions around the object centroid, it is a constraint adjustment based on the better response value prediction results. Therefore, the training of the heatmap should focus on response value prediction, and the detection deviation constraint should be performed when the heatmap response value prediction is better. However, the prediction heatmap is poor at the early training stage, and the detection deviation loss is a distance loss, which is larger than the response value prediction loss, so the constraint at this time will cause the \(L_{p}\) fail to converge quickly and affect the training effect of response value prediction. In the later stage of training, when the response value prediction achieves better results, a stronger detection deviation constraint is needed to correct the predicted positions. Therefore, similar to multi-task training, the losses of the heatmap need to be adjusted to meet the training requirements instead of being directly summed. In order to adjust the loss, this paper adds a linear enhancement factor \(e^{-L_{p}}\) to the deviation loss and adjusts the detection deviation loss by the change in the value of the response value prediction loss \(L_{p}\) convergence process to ensure that the constraint is gradually increased when a better detection effect is achieved. The parameter, \(\mu\), is then set to adjust the deviation loss to be of the same order of magnitude as the predicted loss, which can be chosen according to the value of the loss, and \(\mu\) = 0.1 is taken in the experiment.