Weighted Average Precision: Adversarial Example Detection in the Visual Perception of Autonomous Vehicles

Recent works have shown that neural networks are vulnerable to carefully crafted adversarial examples (AE). By adding small perturbations to input images, AEs are able to make the victim model predicts incorrect outputs. Several research work in adversarial machine learning started to focus on the detection of AEs in autonomous driving. However, the existing studies either use preliminary assumption on outputs of detections or ignore the tracking system in the perception pipeline. In this paper, we firstly propose a novel distance metric for practical autonomous driving object detection outputs. Then, we bridge the gap between the current AE detection research and the real-world autonomous systems by providing a temporal detection algorithm, which takes the impact of tracking system into consideration. We perform evaluation on Berkeley Deep Drive (BDD) and CityScapes datasets to show how our approach outperforms existing single-frame-mAP based AE detections by increasing 17.76% accuracy of performance.


I. INTRODUCTION
Significant progress in Machine Learning (ML) techniques like Deep Neural Networks (DNNs) recently has enabled the development of safety-critical ML systems like autonomous vehicles. Neural network based object detection models are widely implemented as an import part of the autonomous driving perception system. Recent results show that autonomous vehicles have become very efficient in practice and already driven millions of miles without any human interventions. Twenty US states including California, Texas, and New York have recently passed legislation to enable testing and deployment of autonomous vehicles. Since the control successors are highly depended on the outputs from the object detector and neural networks [1] [2] [3], the performance of object detection is significant to the security of autonomous driving. However, neural network based object detectors are shown to be vulnerable to adversarial examples by recent researches, inputs that are carefully crafted to fool the model [4][5] [6] [7]. Even worse, these perturbed images, if carefully crafted, can stay adversary when taken as input from the physical world using a camera. With development of neural networks, AEs are still threating the robustness [8] [9]. In order to solve this problem, many researches are focusing on improving the robustness of neural networks in order to totally defend the adversarial attacks [10] [11] [12]. Unfortunately, until now, attacking technology is more advanced to that of defending. Attacking methods are able to fool the system with high success rate. In this situation, some researches turn to focus on inventing adversarial examples detection methods, which rise alarms when adversarial attacks are detected during the runtime. One the successful detecting method is perturbation detection. Perturbation based detecting methods hypothesis that the generated adversarial images, different to benign samples, are unstable to perturbations. Adding perturbation to adversarial examples makes a neural network model predicts very different results, while adding perturbation to benign images will not make obvious changes. Therefore, for an input image, people add perturbation to the image, then do inferences for both original and perturbed images. If the outputs are different, the input image is regarded as an adversarial example.
Although the aforementioned AE detection method shows promising results on image classification, few works implement it to object detection, which is a more realistic scenario in real world. One significant challenge behind this is choosing the similarity distance metric for outputs of object detectors. Unlike classification problems, of which the output is a 1-D vector that represents the probabilities for each class, the output of object detection is an ensemble structure that contains bounding box location, label index and confidence scores. In order to deal with the difference, the existing works only have simple approaches. Some existed works simply assume there is only one bounding box in the image and fall the problem back to classification problem. In real world, one image often contains multiple objects. Thus, we cannot make the aforementioned assumption in autonomous driving scenario. The other works directly apply mean average precision (mAP) to calculate the distance between the outputs of two images. However, average precision (AP) based metric is designed for calculating similarity distance of multiple images. By using AP, all the bounding boxes are treated as equally weighted. It has to be noticed that for perturbation based AE detection method, even adding perturbation to benign images will causes output differences. The majority difference is the changes of small objects. Due to the reasons discussed above, AP based metric is not suitable for perturbation based AE detection.
In this paper, our goal is to bridge the gap between the current adversarial examples (AE) research and the realworld autonomous systems by providing a unified framework, which allows the AE detection techniques that have been developed for image classification tasks to be easily transferred to the visual perception tasks of autonomous vehicles. To achieve this goal, we first reevaluate the impact of AE in the presence of the end-to-end visual perceptual systems, and then propose a defense leveraging the evaluation results to effectively prevent the threat from AE in self-driving tasks. Code is publicly available at: https://github.com/erbloo/wAP feature squeezing. We make the following contributions:  (1) designing novel similarity metric to detect inconsistency between dense object detection results of two video frames, and (2) adding temporary information into the detection pipeline to further improve accuracy. • To evaluate our approach, we implements adversarial attacks against state-of-the-art object detectors based on the most effective attacks in the image classification domain. We conduct a large scale evaluation on diverse adversarial targets on different datasets, including Cityscapes [13] and real-world autonomous driving video datasets [14]. The results shows unprecedentedly high accuracy with x% FP and x% FN.

A. Background on Object Detection
Deep convolutional neural networks have been applied to object detection successfully [15][16] [17]. Currently, one of the most popular object detection pipeline [18] [19] uses two stages processing: the first stage generates a number of proposals of different scales and positions, and the second stage classifies the proposals into foreground classes and performing post-processing such as non-maximal suppression (NMS). On the other hand, one stage based method [20] [21] [22] recently made remarkable improvements. One stage detection methods generate dense proposal bounding boxes from intermediate feature maps of backbones. Meanwhile, for each bounding box, regression and classification are performed simultaneously to obtain the final outputs.

B. Adversarial Examples
Carlini and Wagner (C&W) attack proposed different gradient based attacks using different L p norms, namely CW 2 , CW ∞ , CW 0 attacks. It has been recognized as the most effective attacks against DNNs, and in Madry et al. [23], it has been shown that a C&W attack is a universal adversary among all first-order attack methods. Their analysis and evidence from experiments all suggest any adversarial attack method that only incorporates gradients of the loss function w.r.t. the input cannot do significantly better than it.
Existing Defense. Defense mechanisms aims at preventing AE by hardening the DNN models, and are summarized by Papernot et al. [24] into two broad categories: adversarial training and gradient masking. Goodfellow et al. first introduced the idea of adversarial training [25], which try to integrate existing adversarial existing AE generation methods into the training process so that the trained model can easily defend such attacks [23], [26]. Recent work have also extended the idea of adversarial training to obtain certified robustness against certain attacks by introducing either abstract interpretation or perturbations into the training process [27], [28], [29], [30]. However, it requires prior knowledge of possible attacks and the robustness of adversarially trained model usually overfits to the choice of norms [31].
The idea of gradient masking is to enhance the training process by training the model with small gradients so that the model will not be sensitive to small changes in the input [32]. However, it was reported such models can be broken by advanced attacks. Papernot et al. [24] concluded that controlling gradient information in training has limited effects in defending adversarial attacks.
Existing Detection. Compared with those defense mechanisms, adversarial example detection choose to prevent the model from making predictions based on suspicious input instead of hardening the model itself. The existing state-ofthe-art AE detection works can be classified into two major categories.
1) Metric based detection: Researchers have proposed to perform statistical measurement of the inputs (and activation values) to detect adversarial samples [33][34] [35] [36]. Feinman et al. [37] proposed to use the Kernel Density estimation (KD) and Bayesian Uncertainty (BU) to identify adversarial subspace to separate benign inputs and adversarial samples. Carlini and Wagner [38] showed this method can be bypassed but also commented this method to be one of the promising directions. Inspired by ideas from the anomaly detection community, Ma et al. [39] recently proposed to use a measurement called Local Intrinsic Dimensionality (LID). For a given sample input, this method estimates a LID value which assesses its space-filling capability of the region surrounding the sample by calculating the distance distribution of the sample and a number of neighbors for individual layers. The authors empirically show that adversarial samples tend to have large LID values. Their results demonstrate that LID outperforms BU and KD in AE detection and currently represents the state-of-the-art for this kind of detectors. However, a key challenge of these techniques is how to define a high-quality statistical metric which can clearly tell the difference between clean samples and adversarial samples. Lu et al. [40] have shown that LID is sensitive to the confidence parameters deployed by an attack and vulnerable to transferred adversarial samples.
2) Prediction inconsistency based detection: Many other works are based on the prediction inconsistency [41], [42], [43]. These works are built based a empirically validated hypothesis that the robustness of DNNs to local changes  (e.g., squeezing, scale, position) does not generalize to the perturbations added by adversarial examples. Thus they propose different transformation methods T (·) either on input samples expecting the transformed sample will produce different prediction results as the original sample if it is adversary [41], [43], [44], [45], [46], or on the model expecting that the transferred model will make predictions different than the original model if the input sample is adversarially perturbed [47]. For example, transformation on inputs using foveation [45], smoothing [41], scaling [46], denoising [44], and transformation on model by strengthening interpretability [47] have all been proposed. Our framework allows all of these auxiliary transformations that have been demonstrated effective in unveiling adversarial examples in image classification and face recognition to be easily transferred to the object detection domain where new challenges present ( §IV) without sacrificing effectiveness.

C. Notions
• Testing image input x, model predicts f (x).

III. RE-ESTIMATION OF ADVERSARIAL THREAT
Autonomous systems employ object tracking algorithms to post-process the object detection results to mitigate the variance and uncertainty of the sensor estimate, before using them to produce control decisions. Taking an initial set of object detections (set of bounding boxes and labels), an object tracking algorithm creates a unique ID for each of the initial detections and tracks each of the objects as they move around frames in a video.
An ideal object tracking algorithm is able to handle when the tracked object "disappears" or moves outside the boundaries of the video frame, and is able to pick up objects it has "lost" in between frames. Also it is robust to occlusion. Kalman filter [48], also known as linear quadratic estimation (LQE), is the most commonly used object tracking algorithm, and is employed by in the popular open source self-driving platforms including Apollo [49] and Autoware [50]. Shown in Figure 2, a Kalman filter first produces estimates of the current state variables, along with their uncertainties, and once the outcome of the next measurement (necessarily corrupted with some amount of error, including random noise) is observed, these estimates are updated using a weighted average, with more weight being given to estimates with higher certainty. The algorithm is recursive. It can run in real time, using only the present input measurements and the previously calculated state and its uncertainty matrix; no additional past information is required. Since Kalman filter is designed and has been proven effective in tolerating for missing frames and occasional inaccurate object detection results [51], it's nature to review the hypothesis that adversarial examples that are not strong enough to reliably deceive object detectors have only limited effects on the perception results.
Recent works [6] study adversarial machine learning attacks considering the practical and complete visual perception pipeline in autonomous driving. Both object detection and object tracking are taken into consideration. The study shows that because of the existence of Kalman filter based tracking system, only temporal adversarial attacks that successfully attack several frames are able to fool the whole perception pipeline in autonomous driving. However, current physical adversary attacking technologies are not robust enough to generate high success rate AEs in consecutive frames. Thus, by aforementioned research, we assume physical adversary examples that are not robust enough to consistently fool object detectors have only limited effects on perception results due to Kalman filter on autonomous vehicles.
The threat reestimation results suggest that though Kalman filter raises the bar for adversarial attack, strong and robust adversarial examples can still fool the detector and cause wrong perception results.

IV. DESIGN
A. Overview Figure 3 shows an overview of our AE detection framework. First, for each frame x t coming from the camera at time t, the system obtains a transformed input x t using an auxiliary transformation T (x). It is based on a hypothesis that the robustness of DNNs to local changes (e.g., squeezing, scale, position) does not generalize to the perturbations added by adversarial examples, which have been validated by previous AE detection works [45], [41], [44]. Thus if x is an adversarial example, it is highly likely that the object However, there is no available metric to describe and quantify the similarity of two object detection results. Previous adversarial detections on image classification tasks simply need to compare the predicted classes and their confidences for differences, while in object detection, we need to deal with dense and sometimes overlapped bounding boxes, and it's non-trivial to design a metric that balances precision and recall well. Mean average precision (mAP) is the most commonly used metric to evaluate the performance of an object detector, but we will show later that the false positives can be prohibitively high if using mAP as the distance metric, since it assigns all equal weights to detected objects regardless of their sizes and classes. Also calculating mAP between two frames instead of a set of testing images provides no statistical significance.
Thus we design a novel distance metric D(x, y) to precisely describe the differences between two object detection results (detailed in §IV-B).
At last by monitoring the variance of a temporal inconsistency metric T (D t ), adversarial examples can be detected in real time, and mitigation actions, such as requiring human control, or rolling back to the predictions by Kalman filter could be taken in time.

B. Frame-based Distance Metric D(x, y)
We propose a frame-based distance metric given detection results of two images x and y. From output of image

C. Temporal Consistency
In perception system, a tracker will be deleted if no objects is associated with for a duration of R frames, or called a reserved age (R). It prevents the tracks from being accidentally deleted due to infrequent false negatives of object detectors. [6] Thus, for detection algorithm for AE, only attacks that last longer than reserved age should be regarded as a valid adversarial example. Inspired by this fact, we propose a temporal detection algorithm T (D t ), which can be explained as Where sgn is signum function and θ is the threshold for distance metric D(·).

A. Experimental Setup
Original testing data set comes from BDD10k [52] and Cityscapes [13] datasets. We implement both white-box and black-box attacks and insert adversarial frames into the videos to build our adversarial evaluation set. For whitebox attack, we implement CW inf attack that is the state of the art white-box attacking methodology. For black-box attack, we implement Gaussian Noise and Brightness attacks. We choose best performance feature squeezing methods: bitwise squeeze. For generating object detection outputs, we use Yolo-v3 [20], which is widely implemented in autonomous driving perception system.

B. Evaluation on Single Frame Adversarial Example Detection
Single frame adversarial examples results are shown in Figure 4 and Table I. Figure 4 shows ROC curves for mAP and proposed wAP methods. C&W, Gaussian Noise and Brightness attacks are performed and Bit4, Bit5, Bit6 and Bit7 are implemented as squeezing methods. Table I presents the detailed accuracy results of single frame experiments using testing set of BDD10k and CityScapes. In the table, C&W, Gaussian Noise and Brightness attacks are implemented and Bit (3,4,5,6,7) squeezes are used as AE detection algorithm. We can see that our proposed method outperformed the mAP based algorithm on both Bdd10k and CityScapes datasets. For 27 over 30 experiments using black-box and white-box attacks, our proposed method shows higher detection accuracies. Bit7 shows better results comparing to other bits squeezes. For instance, the proposed method reports 83.77% and 83.88%  accuracy on C&W-Bit7 experiment, respectively. The accuracies are 3.71% and 3.77% more that that of mAP metric. Figure 5 shows the statistical results. The average accuracy of two datasets are shown in the figure. We can see that the proposed wAP algorithm outperforms mAP baselines in all experiments.

C. Evaluation on Temporal Adversarial Example Detection
As discussed in [6], the state of the art temporal attack is able to successfully attack tracking system in 3 frames. Thus, we set temporal frames i = 3. Figure II shows the accuracy results that compare the performance between single frame and temporal experiments. Bit7 is used as squeezing method, since it shows the best performance in Table I. We can see that both temporal based AE detection results from mAP and wAP have better results than single frame based results. This shows that the algorithm IV-C improves the detection performance. It should be noticed that the proposed temporal wAP algorithm achieves the best accuracy result for all the attacking methods.

A. Applicability to other Perception Tasks
As discussed in [41], the feature-squeezing approach could be used in many domains where deep learning is used. Additionally, the proposed wAP metric is calculated based on IoU. Thus, any overlapping based perception tasks such as object detection, semantic segmentation and text detection & recognition are fitful to the proposed detecting algorithm. As for proposed temporal algorithm, whatever temporal and tracking systems that based tasks such as video and audio processing can be applied.

B. Adaptive Attack
Comparing to mAP baseline distance metric, our proposed wAP metric is the optimized version, which focuses on single image instead of the whole dataset and introduces weights to bounding boxes. Thus, for different sorts of attacks, even any of them that is able to effectively attacking the detecting pipeline, the proposed metric may still perform better than mAP.

VII. CONCLUSION
In this paper, we propose a weighted-AP (wAP) distance metric and temporal optimization method to improve the detecting of adversarial example for object detection in autonomous driving perception system. Specifically, our proposed metric focuses on single image bounding boxes and is applied on sequential frames to fit tracking system. Compared to existing single frame mAP detecting method, the results on BDD and CityScapes show that our proposed method performs better on detecting adversarial examples for autonomous driving perception system. One intuition behind the temporal wAP is that fooling single frame is not enough to successfully attack the perception system. This is because tracking system is able to make predictions Accuracy(%)   when bounding boxes of objects miss for a small number of frames. Moreover, practical object detection outputs contain dense bounding boxes that cannot easily obtain a scalar distance between two output results and mAP is a metric widely used for dataset based evaluation but not for calculating distance for two single images. Evaluation on different autonomous driving datasets show that this proposed pipeline greatly enhance detecting performance by a large margin compared to the baseline method. We hope that our proposed distance metric and temporal solution can make research that are related to detecting of object detection more realistic. Code is publicly available at: https://github.com/erbloo/wAP feature squeezing.