Focal Loss in 3D Object Detection

Peng Yun, Lei Tai, Yuan Wang, Chengju Liu, Ming Liu · DOI

Abstract

3D object detection is still an open problem in autonomous driving scenes. When recognizing and localizing key objects from sparse 3D inputs, autonomous vehicles suffer from a larger continuous searching space and higher fore-background imbalance compared to image-based object detection. In this paper, we aim to solve this fore-background imbalance in 3D object detection. Inspired by the recent use of focal loss in image-based object detection, we extend this hard-mining improvement of binary cross entropy to point-cloud-based object detection and conduct experiments to show its performance based on two different 3D detectors: 3D-FCN and VoxelNet. The evaluation results show up to 11.2AP gains through the focal loss in a wide range of hyperparameters for 3D object detection.

Introduction: The Needle in a Haystack

In autonomous driving, detecting objects in 3D space using LiDAR or RGB-D sensors presents a significant challenge compared to traditional 2D image detection. This difficulty stems from three primary factors: extreme sparsity of point clouds, an exponentially larger search space due to the Z-axis, and a severe foreground-background imbalance. In a typical scene, a detector might evaluate 70,000 potential "anchor boxes," yet fewer than 30 typically contain an actual object of interest.

Visualization of 3D object detection in LiDAR point clouds and camera views.

Standard training often relies on Binary Cross Entropy (BCE) loss. However, BCE treats all classification errors equally. In sparse 3D environments, the overwhelming number of "easy" background examples generates a cumulative gradient that drowns out the signal from the few "hard" positive examples (actual cars or pedestrians). Consequently, the network fails to learn precise localization because it is constantly rewarded for simply identifying empty space.

Methods: Adapting Focal Loss for 3D

To address this imbalance, we propose replacing standard BCE with Focal Loss for 3D detectors. Focal Loss introduces a modulating factor, $(1 - p_t)^\gamma$, to the standard loss function. When the model is confident in its prediction ($p_t$ is high), the loss is significantly down-weighted. Conversely, when the model is uncertain ($p_t$ is low), the loss remains high. This "hard-mining" mechanism forces the network to prioritize difficult, ambiguous cases over the millions of trivial background voxels.

Architecture diagram of the 3D detection pipeline, including BodyNet and HeadNet components.

We evaluated this approach on two distinct 3D architectures:

  1. 3D-FCN: A dense approach that voxelizes the point cloud into a 3D grid and applies standard 3D convolutions.
  2. VoxelNet: A heterogeneous architecture that utilizes Voxel Feature Encoding (VFE) to learn features directly from sparse points before processing them with convolutional layers.

Experimental Setup and Results

Experiments were conducted using the KITTI 3D Object Detection Benchmark, focusing on the "Car" class across over 7,000 frames of LiDAR and camera data.

Key Insights

  • Architecture-Specific Benefits: Focal Loss impacts different networks uniquely. In 3D-FCN, it primarily helps the model ignore easy negatives. In VoxelNet, which already handles background well, it helps the model focus on "hard positives"—cars that are difficult to detect due to distance or occlusion.
  • Hyperparameter Robustness: The study found that a range of $0.1 \leq \gamma \leq 2.0$ consistently outperformed standard BCE.
  • Probability Distribution: Analysis showed that Focal Loss makes models more conservative, preventing overconfidence on easy samples by shifting the posterior probability distribution.

Performance Gains

The improvements were substantial across all difficulty levels (Easy, Moderate, Hard):

  • 3D-FCN: Achieved gains of up to 11.2 AP (Average Precision).
  • VoxelNet: Achieved gains of up to 9.1 AP.

Conclusion and Future Work

While Focal Loss significantly improves detection accuracy by solving the foreground-background imbalance, it does not address the underlying computational cost of 3D dense convolutions. Future work should explore more efficient sparse convolutional implementations to achieve real-time performance on edge hardware. Additionally, while demonstrated on the "Car" class, further tuning may be necessary for smaller, sparser objects like pedestrians or cyclists.

Summary updated

BibTeX
@article{yun2018focal,
  author = {Peng Yun and Lei Tai and Yuan Wang and Chengju Liu and Ming Liu},
  title = {{Focal Loss in 3D Object Detection}},
  journal = {IEEE Robotics Autom. Lett.},
  year = {2018},
  doi = {10.48550/arxiv.1809.06065},
}
Figure