# Object Detection in Autonomous Driving Scenarios Based on an Improved Faster-RCNN
## 3 Proposed Algorithm: AD-Faster-RCNN  
### Principle of AD-Faster-RCNN  
Figure 1 shows the AD-Faster-RCNN model proposed in this paper. The backbone network uses Resnet-50 [18], which is mainly used for image feature information extraction tasks.  
The backbone network of AD-Resnet-50 is composed of five large structural blocks (Res1-Res5). Res1 contains convolution, BN layer, ReLU activation function, and maximum pooling to reduce the image resolution. The role of the BN layer is to prevent the gradient from disappearing or exploding, and to speed up the training, while the role of the ReLU activation function is to increase the non-linearity of the network. Res2-Res5 are used to extract information from different dimensions. It is composed of the Conv Block and Identity Block, and adopts a residual connection structure so that layers can copy their inputs to the next layer.  
In order to improve the model's adaptability to geometric deformation and the ability to extract small objects, we added a spatial attention mechanism to the last two structural blocks of the Resnet-50 backbone network; we also applied variability convolution V2 instead of the traditional convolution, and named it AD-Resnet-50. Then, the feature maps extracted from each layer of Res2-Res5 in the backbone network were fused using the improved feature pyramid (PAB-FPN) module to obtain feature maps Z2-Z6 of five scales, and then the fused feature maps were entered into the region proposal network to obtain candidate object regions. After the candidate region was selected, the ROI mapped to the original image was merged at a uniform size (7 \(\times\) 7) through the ROI Align layer, and then two fully connected layers FC were entered for classification and regression. The candidate object area was resampled through the bounding box regression output by the previous detector, the IOU (Intersection-Over-Union) threshold was gradually increased, and finally,a new classification score and bounding box regression were obtained by training. In the three cascade detectors, side-aware boundary localization was used to replace the traditional frame regression. Finally, the Soft-NMS (Soft Non-maximum Suppression) algorithm was used to remove the bounding boxes and retain the best results.  
The loss function of AD-Faster-RCNN is consistent with that of the original algorithm, and it consists of classification loss and regression loss. These two types of loss functions were used in the detection head part of the model. The category loss and location loss were calculated according to the model output and ground truth, and the model was guided to match the ground truth as much as possible in category and location to obtain the best detection results.  
The classification function is a two-class cross-entropy loss function, and the regression loss function uses smooth L1 loss [3].  
\[smooth_{L_{1}}(x)=\left\{\begin{array}{cl}0.5x^{2}&\quad\text{if}|x|<1\\ |x|-0.5&\quad\text{otherwise}\end{array}\right. \tag{1}\]  
In the formula, \(x\) is the difference between the prediction box and the ground truth.