Li3DeTr: A LiDAR based 3D Detection Transformer

Inspired by recent advances in vision transformers for object detection, we propose Li3DeTr, an end-to-end LiDAR based 3D Detection Transformer for autonomous driving, that inputs LiDAR point clouds and regresses 3D bounding boxes. The LiDAR local and global features are encoded using sparse convolution and multi-scale deformable attention respectively. In the decoder head, firstly, in the novel Li3DeTr cross-attention block, we link the LiDAR global features to 3D predictions leveraging the sparse set of object queries learnt from the data. Secondly, the object query interactions are formulated using multi-head self-attention. Finally, the decoder layer is repeated $L_{dec}$ number of times to refine the object queries. Inspired by DETR, we employ set-to-set loss to train the Li3DeTr network. Without bells and whistles, the Li3DeTr network achieves 61.3% mAP and 67.6% NDS surpassing the state-of-the-art methods with non-maximum suppression (NMS) on the nuScenes dataset and it also achieves competitive performance on the KITTI dataset. We also employ knowledge distillation (KD) using a teacher and student model that slightly improves the performance of our network.


Introduction
With the advent of deep learning networks for computer vision [16,37] and large-scale datasets [10] the research on perception systems for scene understanding of autonomous vehicles is growing rapidly. 3D object detection is one of the key processes of autonomous driving, which is a two fold process of classification and localization of the objects in the scene. LiDAR is one of the significant sensors of autonomous vehicles which provides precise 3D information of the scene. Although there is a huge progress in 2D object detection approaches [2,12,22,32,33,40], the CNN-based approaches are not well directly adapted to LiDAR point clouds due to their sparse, unordered and irregular nature.
Earlier approaches for 3D object detection on LiDAR data can be divided into two types: point-based and grid-based methods. Point-based methods [27,36,49] are based on point operations [29,30] which detect the 3D objects directly from the point clouds. Grid-based methods either voxelize the points into volumetric grids or project the points to Birds Eye View (BEV) space. The advantage of BEV projection is that it preserves euclidean distance, avoids overlapping of objects and the object size is invariant to distance from ego vehicle which is significant for autonomous driving scenarios. The sparse CNNbased voxel feature extraction [47] is advantageous but it can not extract rich semantic information with limited receptive fields. We mitigate this issue by employing a multiscale deformable attention [55] encoder to capture global LiDAR feature maps.
Earlier approaches either use two-stage detection pipeline [7,36] or anchors [19,53] or anchor-free networks [42,43,51] for 3D object detection, but all of them employ post-processing method like NMS to remove redundant boxes. Inspired by Object-DGCNN [45], we formulate the 3D object detection problem as a direct set prediction problem to avoid NMS.
We propose an end-to-end, single-stage LiDAR based 3D Detection Transformer (Li3DeTr) network to predict the 3D bounding boxes for autonomous driving. Firstly, the voxel features are extracted with SECOND [47] by leveraging sparse convolutions [15] and BEV transformation or with PointPillars [19]. Secondly, we employ an encoder module with multi-scale deformable attention [55] to capture rich semantic features and long range dependencies in BEV feature maps to generate LiDAR global features. The LiDAR global features are passed to the decoder module. Finally, we introduce a novel Li3DeTr cross-attention block in the decoder to link the LiDAR global features to the 3D object predictions leveraging the learnt object queries. The object queries interact with each other in multi-head selfattention block [41]. The object queries are iteratively refined and 3D bounding box parameters are regressed in every decoder layer. Inspired by DETR [2], we use set-to-set loss to optimize our network during training.
We conduct experiments on two publicly available au-  Table 3. The ablation study shown in Table 6 justifies our novel Li3DeTr cross-attention block. • We release our code and models to facilitate further research.

Related Work
The LiDAR point cloud based 3D object detection approaches can be divided into two categories: point-based and grid-based, depending on the type of data representation used to predict the 3D bounding boxes. Point-based methods [28,35,36,49,50] directly use the sparse and unordered set of points to predict 3D bounding boxes. The point features are aggregated by multiscale/multi-resolution grouping and set abstraction [29,30]. PointRCNN [36] employs a two-stage pipeline for 3D object prediction. PVRCNN [35] models point-voxel based set abstraction layer to leverage the advantage of point and voxel based methods. Frustum-PointNet [28] uses 2D object detection to sample a frustum of points to apply Point-Net [29] to predict 3D objects. Although point-based methods achieve large receptive fields with set abstraction layer, they are computationally expensive. Grid-based methods. As the LiDAR point clouds are sparse and unordered set of points, many methods project the points to regular grids such as voxels [47,53], BEV pillars [19] or range projection [3,13,39]. The point clouds are discretized into 3D voxels [38,53] and 3D CNNs are employed to extract voxel-wise features. However, 3D CNNs are computationally expensive and requires large memory, in order to mitigate this problem [5,47] use sparse 3D CNNs [15] for efficient voxel processing. The LiDAR point cloud is projected into BEV map in Point-Pillars [19] and PIXOR [48] and 2D CNNs are employed to reduce the computational cost, however such projection induces 3D information loss. In order to mitigate this issue, some methods [47,51] compute voxel features using sprase convolutions and then project the voxel features into BEV space, and finally predict the 3D bounding boxes in the BEV space. As this approach takes the advantage of voxel and BEV space, we test our network with SECOND [47] and PointPillars [19] feature extraction networks. In order to achieve large receptive fields similar to point-based methods [29,30], we model long-range interactions of local LiDAR features using multi-scale deformable attention [55] block in our encoder to obtain LiDAR global features.
Transformer-based methods. Earlier approaches [7,19,35,36,50,53] object detection head employ anchor boxes to predict the objects, however anchor boxes involve handcrafted parameter tuning and they are statistically obtained from the dataset. To mitigate this issue, some approaches [5,43,48,51] followed anchor-free pipeline by computing per-pixel or per-pillar prediction. But these approaches use NMS to remove redundant boxes. DETR [2] is the first transformer architecture which formulated 2D detection problem as a direct set prediction to remove NMS. Our network follows similar formulation for 3D object detection. Some approaches [24,27,34] used transformer for feature extraction networks. 3DETR [25] is a fully transformer based architecture for 3D object detection using vanilla transformer [41] block with minimal modifications. 3DETR directly operate and attend on points whereas our approach voxelize the points and attend the BEV global voxel features which is computationally efficient for autonomous driving scenarios. 3DETR employs downsampling and set-aggregation operation [30] on the input points of indoor scenarios because the computational complexity of self-attention increases quadratically (O(n 2 )) with the number of input points. Moreover, 3DETR is effective on indoor datasets, where the points are dense and concentrated. Object-DGCNN [45] employs a graph-based model for transformer-based 3D object detection for outdoor environments. BoxeR [26] introduces a novel and simple Box-Attention which enables spatial interaction between grid features. BoxeR-2D enables end-to-end 2D object detection and segmentation tasks, which can be extended to BoxeR-3D for end-to-end 3D object detection. VISTA [11] is a plug and play module to adaptively fuse multi-view features in a global spatial context, incorporated with [5,51]. It introduces dual cross-view spatial attention to leverage the information in BEV and Range View (RV) features. We formulate our model with voxel-BEV based CNN backbone architecture for local feature extraction and an attention-based architecture for global feature extraction to increase the re-ceptive field size and finally a transformer decoder head to link global features and 3D predictions.

Methodology
Our LiDAR based 3D Detection Transformer (Li3DeTr) architecture inputs LiDAR point cloud and predicts 3D bounding boxes in large-scale outdoor environments such as autonomous driving. The network contains two main modules: backbone and transformer encoder-decoder as shown in Figure 1. Inspired by the state-of-the-art 3D object detection approaches [15,19], our CNN-based backbone ( § 3.1) module learns grid-based local voxel features. Specifically, we employ BEV grid, not only because the 2D grid-like features are a good trade-off between accuracy and efficiency but also very relevant for autonomous driving, as there is possibly one object on every grid cell on the ground plane. The multi-scale deformable attention [55] based encoder ( § 3.2) module learns the multi-scale global voxel features. The encoder module alternates between multiscale deformable attention block and multi-layer perceptron (MLP) block and is repeated L enc number of times. The novel Li3DeTr cross-attention block in the decoder ( § 3.3) module links the global voxel features to the 3D object predictions leveraging the learnt object queries. The object queries interact with each other in multi-head self-attention [41] block. The decoder module is repeated L dec number of times with alternating multi-head self-attention, Li3DeTr cross-attention and MLP blocks. The refined object queries are transformed into 3D bounding box parameters and the network is trained end-to-end using permutation-invariant loss [2] ( § 3.4).

Backbone: Local features
Our network inputs LiDAR point cloud P = {p 1 , . . . , p i , . . . , p N } ⊂ R 3 . To accelerate the 3D object detection for large-scale point clouds, we scatter the points into BEV grid and use CNNs to extract local point features. We test two pipeline: 1) We voxelize the point cloud with [0.1, 0.1, 0.2] metres voxel size and employ SparseConv [15] to compute 3D sparse convolutions and obtain local voxel features. The empty voxels are filled with zeros and the sparse voxels are transformed to a BEV 2D grid-like features. 2) We convert the point cloud into a dense BEV pillar map as in PointPillars [19] with [0.2, 0.2, 8] metres pillar resolution. We use pillar feature net to transform the pillar features. Finally, we employ SEC-OND [47] backbone to extract local voxel features from the sparse voxel or BEV pillar features and further transform them using a feature pyramid network (FPN) [20] to obtain multi-scale local voxel feature maps F 1 ,

Encoder: Global features
In order to obtain global voxel features from the local voxel feature maps, we employ multi-scale deformable attention [55] mechanism because the conventional attention mechanism [41] leads to unacceptable computational complexities in encoding high resolution feature maps. The multi-scale deformable attention combines the best of the sparse sampling of deformable convolution [9] and longrange relation framework of transformers [41]. The input and output to encoder module are multi-scale feature maps with the same resolution. The deformable attention attends only a small set of key sampling points around a reference point and thereby reduces the computational complexity. The reference point in the deformable self-attention for each query pixel is itself. Each encoder layer consist of multi-scale deformable self-attention and MLP blocks with residual connections and is repeated L enc times. The global voxel features extracted from the encoder is passed to Li3DeTr cross-attention block in the decoder.

Decoder
The state-of-the-art 3D object detection approaches either formulates the detection head with dense set of anchor boxes or dense per-pillar prediction such as [43,51], followed by NMS. We remove the need of post-processing step (like NMS) by formulating the detection head to predict a set of bounding boxes instead of per-pillar prediction. This is formulated in the decoder as detailed below.
The decoder inputs a set of object queries . . , L dec }, N q is number of queries and Q 1 are learnt with the model weights) and global voxel feature maps {F j } 4 j=1 and it consists of decoder layer that is repeated L dec number of times to refine the object queries.
For the first decoder layer, the 3D reference points are encoded from the object queries using a single-layer fully connected (FC) network and sigmoid normalization as in Equation 1.
where r i ∈ [0, 1] 3 and ϕ ref is a FC layer. Each decoder layer consists of Li3DeTr cross-attention block, multi-head self attention block and MLP block with skip connections as shown in Figure 1.
Li3DeTr cross-attention block inputs the object queries (we drop the layer index for simplicity), 3D reference points r i and LiDAR global multi-scale feature maps {F j } 4 j=1 . The formulation of Li3DeTr cross-attention block is illustrated in Figure 2.
Let R ji represents the transformation for the projection of reference point r i into scale j of LiDAR global voxel feature map. The LiDAR BEV feature map at scale j is bilinearly sampled at the location of projection of reference point  Figure 2: An overview of Li3DeTr cross-attention block (R ji (r i )), given by F j (R ji (r i )). The attention weights (w ij ) for each query q i at each sampled feature scale j is computed by a FC layer (ϕ samp ) and sigmoid normalization, where w ij = ϕ samp (q i ). The sampled features from multi-scale feature maps are added together to obtain crossattention features (F CAttn i ) for i-th reference point as: Finally, we update the queries as, where PE is positional encoding of reference point to make the queries location aware. The queries interact with each other in the multi-head self-attention block and we follow skip connection following [41]. The object queries (Q l ) are updated in each decoder layer.
We employ two FC layers ϕ reg l and ϕ cls l to predict offset to box position ∆p l i ∈ R 3 , box size (l l i , w l i , h l i ), box orientation (sin θ l i , cos θ l i ), box velocity (v l xi , v l yi ) and class label (ŷ l i ) respectively for each object query (q l i ). We refine the reference points for each query in each decoder layer except for the first decoder layer (which are encoded using Equation. 1) by using the predictions of box position in the previous layer, as

Loss
Similar to [2,44,45], the error between predictions and ground-truths is calculated by set-to-set loss. Firstly, the one-to-one assignment between predictions and groundtruths is performed by Hungarian algorithm [18]. Secondly, we use bipartite matching to match predictions and groundtruths. Finally, we employ L 1 loss and focal loss [21] to calculate bounding box regression and classification loss respectively, given the bipartite matching.

Experiments
We evaluate Li3DeTr network on the publicly available autonomous driving datasets, nuScenes [1] and KITTI [14]. We introduce the experimental setup ( § 4.1) with dataset details and evaluation metrics (model settings and training details are provided in supplementary), and then present both qualitative and quantitative results ( § 4.2) and analysis on the nuScenes and KITTI dataset. We perform ablation studies ( § 4.3) to study the different configurations of our network.

Experimental Setup
nuScenes dataset [1] contains 750, 150 and 150 sequences (of ∼20s duration) with 28K, 6K and 6K annotated samples for training, validation and testing respectively. Each sample consists of 32-beam LiDAR point cloud with 30K points. The dataset also provides 9 non-key frames (called sweeps) to aggregate to one key-frame, resulting in ∼300K points per annotated frame. 10 different categories of objects are available to compute the metrics. Kitti dataset [14] consists of 7481 and 7518 training and testing samples. The training samples are further divided into 3712 train and 3769 val splits. Each sample consists of 32-beam LiDAR point cloud. Cars, pedestrians and cyclists are the three main categories for evaluation. Evaluation metrics. The two main metrics following the official evaluation of nuScenes dataset [1] are mean average precsion (mAP) and nuscenes detection score (NDS). In addition, we also evaluate true positive (TP) metrics: average translation error (ATE), average scale error (ASE), average orientation error (AOE), average velocity error (AVE), average attribute error (AAE). We follow the official evaluation metric of KITTI dataset [14] mean average precision (mAP) with IoU threshold of 0.7 for car category and 0.5 for pedestrian and cyclist categories..

Quantitative Results
We compare Li3DeTr network with the state-of-the-art methods on the nuScenes [1] test dataset as shown in Table 1. Our network surpassed the state-of-the-art CNNbased CenterPoint [51] by 3.3% mAP and 2.1% NDS and transformer-based Object-DGCNN [45] network by 2.6% mAP and 1.6% NDS. Albeit CenterPoint [51] uses postprocessing method like NMS, our approach of formulating object detection as a direct set prediction problem inspired by DETR [2] doesn't require NMS to obtain the gain in mAP and NDS. We also compare with the NMS-free state-of-the-art transformer-based network Object-DGCNN [45] with two different backbones: PointPillars [19] and VoxelNet [53]. Our transformer based NMS-free approach surpassed in both pillar [19] and voxel [53] backbones by 0.6% mAP (and 0.2% NDS) and 2.6% mAP (and 1.6% NDS) respectively. Although our Li3DeTr network outperforms most of the other methods in terms of mAP and NDS, VISTA-OHS [11] performs slightly better than our approach on the nuScenes test dataset. VISTA is a plug and play module to fuse multi-view features incorporated with [5] which requires post-processing methods like NMS, whereas our approach is a standalone method for 3D object detection without NMS. The perfromance of our approach compared with state-of-the-art approaches on nuScenes val dataset is provided in supplementary.
We employ knowledge distillation (KD) with a teacher and student model. The earlier works on 3D object detection involve NMS, so it is not effective to distill those models. As our approach is NMS-free, we can effectively distill the information between models with similar detection heads. We train a teacher model with the loss given in § 3.4 and then we train a student model (with same architecture as teacher model) with the supervision of output of teacher model and the ground-truth. With the KD, we achieve 62.2% mAP and 68.0% NDS which is 0.9% mAP and 0.4% NDS improvement over our model without KD.
We compare the recent works on KITTI [14] dataset for car category as shown in Table 2. Our network achieves a competitive performance to the state-of-the-art LiDARbased approaches like VoxelNet [53], PointPillars [19], TANet [23] and SECOND [47] in terms of AP 3D and AP BEV for easy, moderate and hard samples. Our network could not achieve the state-of-the-art performance on KITTI [14] dataset as compared to nuScenes [1] dataset because the transformer network is data hungry and KITTI dataset has 3712 samples for training which is approximately 7.5 times less number of training samples than nuScenes dataset (which has 28K training samples). In addition to this, the nuScenes dataset provides 9 non-key frames (called sweeps) to aggregate to one key frame, resulting in dense LiDAR points but KITTI dataset provides only one LiDAR key frame which results in sparse point cloud. However, our approach obtains competitive performance to the state-of-the-art transformer based architecture VoTr-SSD [24] which uses NMS. To the best of our knowledge this is the first transformer based 3D detection network to report results both on nuScenes and KITTI datasets, which compares the results of detection with an emphasis on training sample size which is significant for transformer based architectures alongside the density of LiDAR point clouds. We further provide comparison of methods in terms of AP 3D and AP BEV on the pedestrian and cyclist categories for easy, moderate and hard samples in the supplementary.

Qualitative Results
The visualization of 3D bounding box predictions of our approach on the nuScenes dataset is shown in Figure 3. Although the LiDAR point clouds are sparse, our approach not only detects small objects like traffic cones but also efficiently detect large size objects like truck, bus, construction vehicle. This is possible with the local and global feature maps of backbone and attention mechanism in encoder alongside the cross-attention in the decoder. Our approach is also able to detect some cars which are not annotated in ground-truth. A short demo video of 3D object predictions of our network projected into BEV map is presented at https://youtu.be/5pLnLRO_2-U.

Analysis
The performance analysis of our approach by object category, object distance and object size compared to state-ofthe-art LiDAR based CNN and transformer models is detailed below. Object category. The performance of our network in terms of Average Precision (AP) for each object category compared to other state-of-the-art networks on the nuScenes [1] val dataset is shown in Table 3. We compare with Object-DGCNN [45] as it a standalone transformer model like ours for fair comparison. The transformer encoder which extracts global LiDAR features leveraging long range interactions using multi-scale deformable attention and decoder cross-attention significantly improves the AP of large   Table 4. Our approach significantly improves the mAP of objects at object distance greater than 30m compared to CNN-based CenterPoint [51]. Although the Li-DAR point cloud is sparse at far distance from ego vehicle, our attention mechanism in encoder and decoder models long range interactions between the sparse points to predict the objects at far distance.  Table 5. Our transformer based approach predominantly improves the mAP of large size objects than small size objects compared to CNN-based Cen-terPoint [51]. This proves our hypothesis that long range interactions made possible by attention mechanism improves the detection performance.

Ablation Studies
Attention blocks. The performance of our network in terms of mAP and NDS with different attention operations for self and cross-attention blocks in the decoder ( § 3.3) is shown in Table 6. We test our approach by employing DGCNN [46] similar to [45] and multi-head self-attention  Number of queries. The performance of our network in terms of mAP and NDS on the nuScenes [1] dataset for different number of queries in the decoder is shown in Table 7.
The performance of our network in terms of mAP and NDS slightly increases with increase in number of queries because object queries represent the potential positions of objects. However, the performance has slight impact for over 900 queries. So, we fix number of queries to 900. Backbones. The performance of our network in terms of mAP and NDS on nuScenes dataset for different backbones compared with CenterPoint [51] and Object-DGCNN [45] is shown in Table 8. We test our approach with Point-Pillars [19] with 0.2m voxel size and VoxelNet [53] with 0.1m voxel size for LiDAR point cloud feature extraction. As shown in Table 8, our approach with VoxelNet feature extraction outperforms the network with PointPillars backbone. However, our architecture is flexible to plugin various backbones depending on the specific requirements of different applications.

Conclusion
We present an end-to-end, single-stage LiDAR based 3D Detection Transformer (Li3DeTr) architecture which inputs LiDAR point clouds and predicts 3D bounding boxes. Inspired by DETR [2], we formulate our model with set-toset loss and thereby remove the need for post processing methods like NMS. We introduce a novel Li3DeTr crossattention block in the decoder head to link the global Li-DAR voxel feature maps (obtained from encoder network) and 3D predictions, leveraged by sparse set of object queries learnt from the data. Without bells and whistles, our network archives 61.3% mAP and 67.6% NDS surpassing the state-of-the-art methods on the nuScenes dataset and achieves competitive performance on the KITTI dataset.