# AspectNet: Aspect-Aware Anchor-Free Detector for Autonomous Driving
## 3 Proposed Method
### Loss Function  
The loss function of the proposed method can be divided into three parts that correspond to three heads: the classification part, regression part, and aspect-aware part. The  
Figure 5: Aspect-aware Gaussian kernel. Different distances from the center point have different influence on the definition and selection of positive samples. The Gaussian kernel is sensitive to the width and height of the bounding box. classification loss function is aspect-aware logistic regression based on the focal loss. As shown in the proposed sample definition method, \(Y_{xyc}\) is an aspect-aware Gaussian kernel, indicating the aspect ratio of the bounding box. The heatmap is a pixel-wise decrease from the center point of the bounding box to the surrounding region, and the decreasing speed is related to the aspect ratio. The classification loss function is defined as  
\[\mathcal{L}_{cls}=\frac{-1}{N_{Pos+Neg}}\sum_{x,y,c}\left\{ \begin{array}{c} \left(Y_{xyc}-\hat{Y}_{xyc}\right)^{\alpha}\log\left(\hat{Y}_{xyc}\right),\ \ if\ Y_{xyc}\geq\tau_{1}\\ 0,\ if\ \tau_{2}<Y_{xyc}<\tau_{1}\\ \left(1-Y_{xyc}\right)^{\beta}\left(\hat{Y}_{xyc}\right)^{\alpha}\log\left(Y_{ xyc}-\hat{Y}_{xyc}\right),\ \ if\ Y_{xyc}\leq\tau_{2}\end{array} \right., \tag{4}\]  
where \(\alpha\) and \(\beta\) are the hyperparameters of the focal loss, and \(N\) is the sum of the number of positive and negative samples. As shown in Figure 6, the value of the center point of the image is equal to the maximum value 1. The positive samples are set according to the focal loss when \(Y_{xyc}\geq\tau_{1}\). The ignored area is defined as \(\tau_{2}<Y_{xyc}<\tau_{1}\). The model does not calculate the loss for this area and does not perform backpropagation to make the model not pay too much attention to the edge of the bounding box. For negative samples, controllable variable \(\left(1-Y_{xyc}\right)^{\beta}\) is added. For the negative sample point near the center point, the penalty is relatively large, and the weight of loss \(\left(1-Y_{xyc}\right)^{\beta}\) is relatively small, which indicates that the distinction between positive and negative at this position is more blurred. The bounding boxes use CIoU [23] to regress the spatial coordinates. As illustrated in Figure 7, the regression objectives \(\hat{l}\), \(\hat{t}\), \(\hat{r}\), and \(\hat{b}\) are computed for each location on all feature  
Figure 6: Aspect-aware Gaussian kernel in the traffic object. The value of the center point of the image is equal to the maximum value of 1.  
levels. Therefore, the predicted coordinates of the upper left and lower right corner points are represented as \((\vec{x}_{1},\vec{y}_{1})\), \((\vec{x}_{2},\vec{y}_{2})\), where \(\vec{x}_{1}=\vec{p}_{x}-\hat{l}\), \(\vec{y}_{1}=\vec{p}_{y}-\hat{t}\), \(\vec{x}_{2}=\vec{p}_{x}+\tilde{\tau}\), \(\vec{y}_{2}=\vec{p}_{y}+\tilde{b}\). The CIoU resolves the issue of no overlap between the bounding box and ground truth, which results in more stable bounding box regression because it considers the bounding box distance, overlap rate, scale, and penalty terms. Additionally, this may help to avoid divergence throughout the training phase. The CIoU loss function includes an impact term \(\beta v\) based on the DIoU [23], which takes the length-to-width ratio of the predicted and ground truth boxes into account:  
\[\mathcal{L}_{reg}=\frac{1}{N_{Pos}}\sum_{i\in Pos}^{N}1-IoU_{i}+\frac{\rho^{2} \Big{(}b_{i},b_{i}^{gt}\Big{)}}{c_{i}^{2}}+\beta v \tag{5}\]  
\[\beta=\frac{v}{(1-IoU_{i})+v} \tag{6}\]  
\[v=\frac{4}{\pi^{2}}\Bigg{(}\left(arctan\frac{w_{i}^{gt}}{h_{i}^{gt}}\right)- arctan\frac{w_{i}}{h_{i}}\Bigg{)}^{2}, \tag{7}\]  
where \(\beta\) is a trade-off parameter and \(v\) is a parameter used to determine the aspect ratio consistency. Additionally, \(\rho()\) denotes the distance between the center points of the bounding box and ground truth, and \(c\) denotes the diagonal length of the smallest enclosing box that encompasses both boxes. The binary cross-entropy loss is adopted for the aspect-aware head loss.