# Focus on Point: Parallel Multiscale Feature Aggregation for Lane Key Points Detection
## 3 Methodology
### Global Key Points Detection  
For the global key point detection, the network predicts two sets of heatmaps. The first one models the probability space of all target key points, which expresses the probability of existence for each key point. The second predicts the location offset vectors of these key points. Based on them, we are able to locate the exact location of the key points to ensure the geometric accuracy of the final output lane curve. The size of each set of heatmaps is \(H\times W\), but the number of channels is different. In the training data, each lane curve is annotated as an ordered key points set \(l_{m}=\{k_{i}|i=1,2,\cdots,n\}\), where \(l_{m}\) means the \(m\)-th lane curve contains \(n\) key points, and \(k_{i}\) is the \(i\)-th point. The network firstly outputs the probability heat map, whose resolution is the same as the input, and the pixel value expresses the probability that the point is predicted as the key point of the lane curve. The key points are considered as the positive sample in the detection task, and each key point of the curve \(l_{m}\) has a ground-truth value, whereas other irrelevant background points are negative samples, as exhibited in Figure 5. As a result of the narrow and long property of lanes, the number of annotated lane points is far fewer than background points. We employed focal loss for the first heatmap, and added the balance factor \(\alpha\) on the basis of focal loss to prevent the network bias from a large number of negative samples during training. Furthermore, the farther the pixel cells is from the key points, the faster they converge, which helps the network training to be more concentrated to the pixel cells close to the key points. The following shows the loss function:  
\[L_{kp}=\frac{1}{N_{k}} \begin{cases}\sum\limits_{i=1}^{N_{k}}a(1-p_{i})^{7}\log (p_{i})&\quad\text{if }g_{i}=1\\ \sum\limits_{i=1}^{N_{k}}(1-a)(p_{i})^{7}\log(1-p_{i})&\quad\text{if }g_{i}=0\end{cases} , \tag{5}\]  
where \(P_{i}\) is the probability score of the \(i\)-th pixel at the heatmap, \(N_{k}\) is the number of key points in the current image and \(g_{i}\) represents the ground-truth values of positive and negative samples. \(\alpha\) is the balance factor, which balances the positive and negative sample loss during training. \(\gamma\) is a tunable hyperparameter that controls the penalty for simple samples. The loss function guide the network to learn positive samples and ignores the supervision of background pixels, which makes it easier to process arbitrary numbers of lanes. In order to gather high-level information and to reduce memory usage, the network maps the raw image to the smaller scale through down-sampling. Pixel locations \((x,y)\) in the raw image are mapped to the locations \((x/\beta,y/\beta)\) in the sampled feature map, where \(\beta\) is the scale factor of down-sampling. When the locations are remapped from the feature map to their original resolution, some precision may be lost due to interpolation or deconvolution, which greatly affects the prediction results. Therefore, we used another set  
Figure 5: Illustration of key points prediction. ‘Green’ grids are background pixels, and the grids marked ‘blue’ are key points of the lane curve. of heat maps to predict the location offset vector in order to slightly adjust the locations of key points when they are remapped to the original resolution. The network predicts the exact location offset vectors for each key point, which includes the horizontal and vertical coordinates. The vectors indicate the correct position of key points, which can make the final prediction result more accurate and smooth. For training, we applied the mean square error (MSE) loss for the horizontal and vertical axis positions:  
\[ \begin{split} L_{position}&=\ L_{X\_position}\ +\ L_{Y\_position}\\ &=\ \frac{1}{N_{k}}\sum_{i=1}^{N_{k}}\left(P_{i\_x}-G_{i\_x}\right)^{2} \ +\ \frac{1}{N_{k}}\sum_{i=1}^{N_{k}}\left(P_{i\_y}-G_{i\_y}\right)^{2}\,\end{split}