├── README.md ├── pcdet ├── __init__.py ├── config.py ├── datasets │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-36.pyc │ │ ├── __init__.cpython-37.pyc │ │ ├── __init__.cpython-38.pyc │ │ ├── dataset.cpython-37.pyc │ │ └── dataset.cpython-38.pyc │ ├── augmentor │ │ ├── __pycache__ │ │ │ ├── augmentor_utils.cpython-37.pyc │ │ │ ├── augmentor_utils.cpython-38.pyc │ │ │ ├── box_np_ops.cpython-37.pyc │ │ │ ├── data_augmentor.cpython-37.pyc │ │ │ ├── data_augmentor.cpython-38.pyc │ │ │ ├── database_sampler.cpython-37.pyc │ │ │ ├── database_sampler.cpython-38.pyc │ │ │ ├── geometry.cpython-37.pyc │ │ │ └── part_aware_augmentation.cpython-37.pyc │ │ ├── augmentor_utils.py │ │ ├── box_np_ops.py │ │ ├── data_augmentor.py │ │ ├── database_sampler.py │ │ ├── geometry.py │ │ └── part_aware_augmentation.py │ ├── dataset.py │ ├── kitti │ │ ├── __pycache__ │ │ │ ├── kitti_dataset.cpython-37.pyc │ │ │ └── kitti_dataset.cpython-38.pyc │ │ ├── kitti_dataset.py │ │ └── kitti_object_eval_python │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── __pycache__ │ │ │ ├── eval.cpython-37.pyc │ │ │ ├── eval.cpython-38.pyc │ │ │ ├── rotate_iou.cpython-37.pyc │ │ │ └── rotate_iou.cpython-38.pyc │ │ │ ├── eval.py │ │ │ ├── evaluate.py │ │ │ ├── kitti_common.py │ │ │ └── rotate_iou.py │ └── processor │ │ ├── __pycache__ │ │ ├── data_processor.cpython-37.pyc │ │ ├── data_processor.cpython-38.pyc │ │ ├── point_feature_encoder.cpython-37.pyc │ │ └── point_feature_encoder.cpython-38.pyc │ │ ├── data_processor.py │ │ └── point_feature_encoder.py ├── models │ ├── __init__.py │ ├── backbones_2d │ │ ├── __init__.py │ │ ├── base_bev_backbone.py │ │ └── map_to_bev │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-37.pyc │ │ │ ├── __init__.cpython-38.pyc │ │ │ ├── height_compression.cpython-37.pyc │ │ │ ├── height_compression.cpython-38.pyc │ │ │ ├── pointpillar_scatter.cpython-37.pyc │ │ │ └── pointpillar_scatter.cpython-38.pyc │ │ │ ├── height_compression.py │ │ │ └── pointpillar_scatter.py │ ├── backbones_3d │ │ ├── __init__.py │ │ ├── pointnet2_backbone.py │ │ └── vfe │ │ │ ├── __init__.py │ │ │ ├── attention_2view_pillar_vfe.py │ │ │ ├── dynamic_pillar_vfe.py │ │ │ ├── dynamic_pillar_vfe_multi_view.py │ │ │ ├── mean_vfe.py │ │ │ ├── multiview_conv.py │ │ │ ├── pillar_vfe.py │ │ │ ├── vfe_template.py │ │ │ └── view_wise_attention_vfe.py │ ├── dense_heads │ │ ├── __init__.py │ │ ├── anchor_head_multi.py │ │ ├── anchor_head_single.py │ │ ├── anchor_head_template.py │ │ └── target_assigner │ │ │ ├── anchor_generator.py │ │ │ ├── atss_target_assigner.py │ │ │ └── axis_aligned_target_assigner.py │ ├── detectors │ │ ├── __init__.py │ │ ├── detector3d_template.py │ │ └── pointpillar.py │ └── model_utils │ │ └── model_nms_utils.py ├── ops │ ├── iou3d │ │ ├── __pycache__ │ │ │ ├── iou3d_utils.cpython-37.pyc │ │ │ └── iou3d_utils.cpython-38.pyc │ │ ├── build │ │ │ ├── lib.linux-x86_64-3.7 │ │ │ │ └── iou3d_cuda.cpython-37m-x86_64-linux-gnu.so │ │ │ ├── lib.linux-x86_64-3.8 │ │ │ │ └── iou3d_cuda.cpython-38-x86_64-linux-gnu.so │ │ │ ├── temp.linux-x86_64-3.7 │ │ │ │ ├── .ninja_log │ │ │ │ ├── build.ninja │ │ │ │ └── src │ │ │ │ │ ├── iou3d.o │ │ │ │ │ └── iou3d_kernel.o │ │ │ └── temp.linux-x86_64-3.8 │ │ │ │ └── src │ │ │ │ ├── iou3d.o │ │ │ │ └── iou3d_kernel.o │ │ ├── iou3d_cuda.cpython-37m-x86_64-linux-gnu.so │ │ ├── iou3d_cuda.cpython-38-x86_64-linux-gnu.so │ │ ├── iou3d_utils.py │ │ ├── setup.py │ │ └── src │ │ │ ├── iou3d.cpp │ │ │ └── iou3d_kernel.cu │ ├── iou3d_nms │ │ ├── __pycache__ │ │ │ ├── iou3d_nms_utils.cpython-36.pyc │ │ │ ├── iou3d_nms_utils.cpython-37.pyc │ │ │ └── iou3d_nms_utils.cpython-38.pyc │ │ ├── build │ │ │ ├── lib.linux-x86_64-3.7 │ │ │ │ └── iou3d_nms_cuda.cpython-37m-x86_64-linux-gnu.so │ │ │ └── temp.linux-x86_64-3.7 │ │ │ │ ├── .ninja_deps │ │ │ │ ├── .ninja_log │ │ │ │ ├── build.ninja │ │ │ │ └── src │ │ │ │ ├── iou3d_cpu.o │ │ │ │ ├── iou3d_nms.o │ │ │ │ ├── iou3d_nms_api.o │ │ │ │ └── iou3d_nms_kernel.o │ │ ├── iou3d_nms.egg-info │ │ │ ├── PKG-INFO │ │ │ ├── SOURCES.txt │ │ │ ├── dependency_links.txt │ │ │ └── top_level.txt │ │ ├── iou3d_nms_cuda.cpython-36m-x86_64-linux-gnu.so │ │ ├── iou3d_nms_cuda.cpython-37m-x86_64-linux-gnu.so │ │ ├── iou3d_nms_cuda.cpython-38-x86_64-linux-gnu.so │ │ ├── iou3d_nms_utils.py │ │ ├── setup.py │ │ └── src │ │ │ ├── iou3d_cpu.cpp │ │ │ ├── iou3d_cpu.h │ │ │ ├── iou3d_nms.cpp │ │ │ ├── iou3d_nms.h │ │ │ ├── iou3d_nms_api.cpp │ │ │ └── iou3d_nms_kernel.cu │ ├── pointnet2 │ │ ├── pointnet2_batch │ │ │ ├── __pycache__ │ │ │ │ ├── pointnet2_modules.cpython-36.pyc │ │ │ │ ├── pointnet2_modules.cpython-37.pyc │ │ │ │ ├── pointnet2_modules.cpython-38.pyc │ │ │ │ ├── pointnet2_utils.cpython-36.pyc │ │ │ │ ├── pointnet2_utils.cpython-37.pyc │ │ │ │ └── pointnet2_utils.cpython-38.pyc │ │ │ ├── pointnet2_batch_cuda.cpython-36m-x86_64-linux-gnu.so │ │ │ ├── pointnet2_batch_cuda.cpython-37m-x86_64-linux-gnu.so │ │ │ ├── pointnet2_batch_cuda.cpython-38-x86_64-linux-gnu.so │ │ │ ├── pointnet2_modules.py │ │ │ ├── pointnet2_utils.py │ │ │ └── src │ │ │ │ ├── ball_query.cpp │ │ │ │ ├── ball_query_gpu.cu │ │ │ │ ├── ball_query_gpu.h │ │ │ │ ├── cuda_utils.h │ │ │ │ ├── group_points.cpp │ │ │ │ ├── group_points_gpu.cu │ │ │ │ ├── group_points_gpu.h │ │ │ │ ├── interpolate.cpp │ │ │ │ ├── interpolate_gpu.cu │ │ │ │ ├── interpolate_gpu.h │ │ │ │ ├── pointnet2_api.cpp │ │ │ │ ├── sampling.cpp │ │ │ │ ├── sampling_gpu.cu │ │ │ │ └── sampling_gpu.h │ │ └── pointnet2_stack │ │ │ ├── __pycache__ │ │ │ ├── pointnet2_modules.cpython-36.pyc │ │ │ ├── pointnet2_modules.cpython-37.pyc │ │ │ ├── pointnet2_modules.cpython-38.pyc │ │ │ ├── pointnet2_utils.cpython-36.pyc │ │ │ ├── pointnet2_utils.cpython-37.pyc │ │ │ └── pointnet2_utils.cpython-38.pyc │ │ │ ├── pointnet2_modules.py │ │ │ ├── pointnet2_stack_cuda.cpython-36m-x86_64-linux-gnu.so │ │ │ ├── pointnet2_stack_cuda.cpython-37m-x86_64-linux-gnu.so │ │ │ ├── pointnet2_stack_cuda.cpython-38-x86_64-linux-gnu.so │ │ │ ├── pointnet2_utils.py │ │ │ └── src │ │ │ ├── ball_query.cpp │ │ │ ├── ball_query_gpu.cu │ │ │ ├── ball_query_gpu.h │ │ │ ├── cuda_utils.h │ │ │ ├── group_points.cpp │ │ │ ├── group_points_gpu.cu │ │ │ ├── group_points_gpu.h │ │ │ ├── interpolate.cpp │ │ │ ├── interpolate_gpu.cu │ │ │ ├── interpolate_gpu.h │ │ │ ├── pointnet2_api.cpp │ │ │ ├── sampling.cpp │ │ │ ├── sampling_gpu.cu │ │ │ └── sampling_gpu.h │ ├── roiaware_pool3d │ │ ├── __pycache__ │ │ │ ├── roiaware_pool3d_utils.cpython-37.pyc │ │ │ └── roiaware_pool3d_utils.cpython-38.pyc │ │ ├── build │ │ │ ├── lib.linux-x86_64-3.7 │ │ │ │ ├── roi_aware_pool3d_cuda.cpython-37m-x86_64-linux-gnu.so │ │ │ │ └── roiaware_pool3d_cuda.cpython-37m-x86_64-linux-gnu.so │ │ │ └── temp.linux-x86_64-3.7 │ │ │ │ └── src │ │ │ │ ├── roiaware_pool3d.o │ │ │ │ └── roiaware_pool3d_kernel.o │ │ ├── roi_aware_pool3d.egg-info │ │ │ ├── PKG-INFO │ │ │ ├── SOURCES.txt │ │ │ ├── dependency_links.txt │ │ │ └── top_level.txt │ │ ├── roi_aware_pool3d_cuda.cpython-37m-x86_64-linux-gnu.so │ │ ├── roiaware_pool3d_cuda.cpython-36m-x86_64-linux-gnu.so │ │ ├── roiaware_pool3d_cuda.cpython-37m-x86_64-linux-gnu.so │ │ ├── roiaware_pool3d_cuda.cpython-38-x86_64-linux-gnu.so │ │ ├── roiaware_pool3d_utils.py │ │ ├── setup.py │ │ └── src │ │ │ ├── roiaware_pool3d.cpp │ │ │ └── roiaware_pool3d_kernel.cu │ └── roipoint_pool3d │ │ ├── __pycache__ │ │ ├── roipoint_pool3d_utils.cpython-37.pyc │ │ └── roipoint_pool3d_utils.cpython-38.pyc │ │ ├── roipoint_pool3d_cuda.cpython-36m-x86_64-linux-gnu.so │ │ ├── roipoint_pool3d_cuda.cpython-37m-x86_64-linux-gnu.so │ │ ├── roipoint_pool3d_cuda.cpython-38-x86_64-linux-gnu.so │ │ ├── roipoint_pool3d_utils.py │ │ └── src │ │ ├── roipoint_pool3d.cpp │ │ └── roipoint_pool3d_kernel.cu ├── utils │ ├── box_coder_utils.py │ ├── box_utils.py │ ├── calibration_kitti.py │ ├── common_utils.py │ ├── loss_utils.py │ ├── mmdet_utils │ │ └── core │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-37.pyc │ │ │ └── __init__.cpython-38.pyc │ │ │ ├── anchor │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ ├── __init__.cpython-38.pyc │ │ │ │ ├── anchor3d_generator.cpython-37.pyc │ │ │ │ ├── anchor3d_generator.cpython-38.pyc │ │ │ │ ├── anchor_generator.cpython-37.pyc │ │ │ │ ├── anchor_generator.cpython-38.pyc │ │ │ │ ├── anchor_target.cpython-37.pyc │ │ │ │ └── anchor_target.cpython-38.pyc │ │ │ ├── anchor3d_generator.py │ │ │ ├── anchor_generator.py │ │ │ └── anchor_target.py │ │ │ ├── bbox │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ ├── __init__.cpython-38.pyc │ │ │ │ ├── assignment.cpython-37.pyc │ │ │ │ ├── assignment.cpython-38.pyc │ │ │ │ ├── bbox_target.cpython-37.pyc │ │ │ │ ├── bbox_target.cpython-38.pyc │ │ │ │ ├── geometry.cpython-37.pyc │ │ │ │ ├── geometry.cpython-38.pyc │ │ │ │ ├── sampling.cpython-37.pyc │ │ │ │ ├── sampling.cpython-38.pyc │ │ │ │ ├── transforms.cpython-37.pyc │ │ │ │ └── transforms.cpython-38.pyc │ │ │ ├── assignment.py │ │ │ ├── bbox_target.py │ │ │ ├── geometry.py │ │ │ ├── sampling.py │ │ │ └── transforms.py │ │ │ ├── bbox3d │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ ├── __init__.cpython-38.pyc │ │ │ │ ├── bbox3d_target.cpython-37.pyc │ │ │ │ ├── bbox3d_target.cpython-38.pyc │ │ │ │ ├── box_coders.cpython-37.pyc │ │ │ │ ├── box_coders.cpython-38.pyc │ │ │ │ ├── geometry.cpython-37.pyc │ │ │ │ ├── geometry.cpython-38.pyc │ │ │ │ ├── region_similarity.cpython-37.pyc │ │ │ │ ├── region_similarity.cpython-38.pyc │ │ │ │ ├── target_ops.cpython-37.pyc │ │ │ │ └── target_ops.cpython-38.pyc │ │ │ ├── bbox3d_target.py │ │ │ ├── box_coders.py │ │ │ ├── geometry.py │ │ │ ├── region_similarity.py │ │ │ └── target_ops.py │ │ │ ├── evaluation │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ ├── __init__.cpython-38.pyc │ │ │ │ ├── bbox_overlaps.cpython-37.pyc │ │ │ │ ├── bbox_overlaps.cpython-38.pyc │ │ │ │ ├── class_names.cpython-37.pyc │ │ │ │ ├── class_names.cpython-38.pyc │ │ │ │ ├── coco_utils.cpython-37.pyc │ │ │ │ ├── coco_utils.cpython-38.pyc │ │ │ │ ├── eval_hooks.cpython-37.pyc │ │ │ │ ├── eval_hooks.cpython-38.pyc │ │ │ │ ├── kitti_eval.cpython-37.pyc │ │ │ │ ├── kitti_eval.cpython-38.pyc │ │ │ │ ├── mean_ap.cpython-37.pyc │ │ │ │ ├── mean_ap.cpython-38.pyc │ │ │ │ ├── recall.cpython-37.pyc │ │ │ │ └── recall.cpython-38.pyc │ │ │ ├── bbox_overlaps.py │ │ │ ├── class_names.py │ │ │ ├── coco_utils.py │ │ │ ├── eval_hooks.py │ │ │ ├── kitti_eval.py │ │ │ ├── mean_ap.py │ │ │ └── recall.py │ │ │ ├── loss │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ ├── __init__.cpython-38.pyc │ │ │ │ ├── losses.cpython-37.pyc │ │ │ │ └── losses.cpython-38.pyc │ │ │ └── losses.py │ │ │ ├── mask │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ ├── __init__.cpython-38.pyc │ │ │ │ ├── mask_target.cpython-37.pyc │ │ │ │ ├── mask_target.cpython-38.pyc │ │ │ │ ├── utils.cpython-37.pyc │ │ │ │ └── utils.cpython-38.pyc │ │ │ ├── mask_target.py │ │ │ └── utils.py │ │ │ ├── point_cloud │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ ├── __init__.cpython-38.pyc │ │ │ │ ├── point_augmentor.cpython-37.pyc │ │ │ │ ├── point_augmentor.cpython-38.pyc │ │ │ │ ├── voxel_generator.cpython-37.pyc │ │ │ │ └── voxel_generator.cpython-38.pyc │ │ │ ├── point_augmentor.py │ │ │ └── voxel_generator.py │ │ │ ├── post_processing │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-37.pyc │ │ │ │ ├── __init__.cpython-38.pyc │ │ │ │ ├── bbox_nms.cpython-37.pyc │ │ │ │ ├── bbox_nms.cpython-38.pyc │ │ │ │ ├── merge_augs.cpython-37.pyc │ │ │ │ ├── merge_augs.cpython-38.pyc │ │ │ │ ├── rotate_nms_gpu.cpython-37.pyc │ │ │ │ └── rotate_nms_gpu.cpython-38.pyc │ │ │ ├── bbox_nms.py │ │ │ ├── merge_augs.py │ │ │ └── rotate_nms_gpu.py │ │ │ └── utils │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-37.pyc │ │ │ ├── __init__.cpython-38.pyc │ │ │ ├── dist_utils.cpython-37.pyc │ │ │ ├── dist_utils.cpython-38.pyc │ │ │ ├── misc.cpython-37.pyc │ │ │ ├── misc.cpython-38.pyc │ │ │ └── multi_view_utils.cpython-37.pyc │ │ │ ├── dist_utils.py │ │ │ ├── misc.py │ │ │ └── multi_view_utils.py │ ├── multi_view_utils.py │ └── object3d_kitti.py └── version.py ├── requirements.txt ├── setup.py └── tools ├── .vscode └── settings.json ├── cfgs ├── dataset_configs │ ├── kitti_dataset.yaml │ ├── nuscenes_dataset.yaml │ └── waymo_dataset.yaml └── kitti_models │ ├── attention_2view_pointpillar.yaml │ ├── multiview_2conv.yaml │ ├── pointpillar.yaml │ └── view_wise_attention_pointpillar.yaml ├── eval_utils ├── __pycache__ │ ├── eval_utils.cpython-36.pyc │ ├── eval_utils.cpython-37.pyc │ └── eval_utils.cpython-38.pyc └── eval_utils.py ├── scripts ├── dist_test.sh ├── dist_train.sh ├── slurm_test_mgpu.sh ├── slurm_test_single.sh └── slurm_train.sh ├── test.py ├── train.py ├── train_utils ├── __pycache__ │ ├── train_utils.cpython-37.pyc │ └── train_utils.cpython-38.pyc ├── optimization │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-37.pyc │ │ ├── __init__.cpython-38.pyc │ │ ├── fastai_optim.cpython-37.pyc │ │ ├── fastai_optim.cpython-38.pyc │ │ ├── learning_schedules_fastai.cpython-37.pyc │ │ └── learning_schedules_fastai.cpython-38.pyc │ ├── fastai_optim.py │ └── learning_schedules_fastai.py └── train_utils.py └── visual_utils ├── __pycache__ ├── visualize_utils.cpython-37.pyc └── visualize_utils.cpython-38.pyc └── visualize_utils.py /README.md: -------------------------------------------------------------------------------- 1 | # MultiviewPointpillars 2 | 3 | MultiviewPointpillars is a variant of Pointpillars with both front view and BEV. 4 | The code structure is based on OpenPCDet. The main idea also refers to the paper [Pillar-based Object Detection for Autonomous Driving](https://github.com/WangYueFt/pillar-od), and could be viewed as its variant re-implementation from Tensorflow to PyTorch Version. 5 | 6 | # Dependencices 7 | 1. Python 3.5+ 8 | 2. pytorch_scatter 9 | 3. Pytorch (test on 1.4) 10 | 4. OpenPCDet(spconv will not be used) 11 | 5. mmdet3d(if use dynamic voxelization) 12 | 13 | # Installation 14 | 1. clone this repository 15 | ``` 16 | git clone git@github.com:ge25nab/MultiviewPointpillars.git 17 | ``` 18 | 2. install the dependet libraries 19 | ``` 20 | pip install -r requirements.txt 21 | ``` 22 | 3. install the library 23 | ``` 24 | python setup.py develop 25 | ``` 26 | 27 | # Data Preparation 28 | Follow the guidence from [OpenPCDet](https://github.com/open-mmlab/OpenPCDet/blob/master/docs/GETTING_STARTED.md). Only support KITTI dataset so far. 29 | 30 | 31 | # Train and Evaluation 32 | ## Train Multiview Pointpillars 33 | ``` 34 | cd ./MultiviewPointpillars 35 | python tools/train.py --cfg_file tools/cfgs/kitti_models/multiview_2conv.yaml 36 | ``` 37 | 38 | ## Evaluate Multiview Pointpillars 39 | ``` 40 | cd ./MultiviewPointpillars 41 | python tools/test.py --cfg_file tools/cfgs/kitti_models/multiview_2conv.yaml --ckpt /path/to/your/weight 42 | ``` 43 | 44 | # Pretrained Weight 45 | 46 | To be uploaded 47 | 48 | 49 | -------------------------------------------------------------------------------- /pcdet/__init__.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | from pathlib import Path 3 | 4 | from .version import __version__ 5 | 6 | __all__ = [ 7 | '__version__' 8 | ] 9 | 10 | 11 | def get_git_commit_number(): 12 | if not (Path(__file__).parent / '../.git').exists(): 13 | return '0000000' 14 | 15 | cmd_out = subprocess.run(['git', 'rev-parse', 'HEAD'], stdout=subprocess.PIPE) 16 | git_commit_number = cmd_out.stdout.decode('utf-8')[:7] 17 | return git_commit_number 18 | 19 | 20 | script_version = get_git_commit_number() 21 | 22 | 23 | if script_version not in __version__: 24 | __version__ = __version__ + '+py%s' % script_version 25 | -------------------------------------------------------------------------------- /pcdet/config.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | 3 | import yaml 4 | from easydict import EasyDict 5 | 6 | 7 | def log_config_to_file(cfg, pre='cfg', logger=None): 8 | for key, val in cfg.items(): 9 | if isinstance(cfg[key], EasyDict): 10 | logger.info('\n%s.%s = edict()' % (pre, key)) 11 | log_config_to_file(cfg[key], pre=pre + '.' + key, logger=logger) 12 | continue 13 | logger.info('%s.%s: %s' % (pre, key, val)) 14 | 15 | 16 | def cfg_from_list(cfg_list, config): 17 | """Set config keys via list (e.g., from command line).""" 18 | from ast import literal_eval 19 | assert len(cfg_list) % 2 == 0 20 | for k, v in zip(cfg_list[0::2], cfg_list[1::2]): 21 | key_list = k.split('.') 22 | d = config 23 | for subkey in key_list[:-1]: 24 | assert subkey in d, 'NotFoundKey: %s' % subkey 25 | d = d[subkey] 26 | subkey = key_list[-1] 27 | assert subkey in d, 'NotFoundKey: %s' % subkey 28 | try: 29 | value = literal_eval(v) 30 | except: 31 | value = v 32 | 33 | if type(value) != type(d[subkey]) and isinstance(d[subkey], EasyDict): 34 | key_val_list = value.split(',') 35 | for src in key_val_list: 36 | cur_key, cur_val = src.split(':') 37 | val_type = type(d[subkey][cur_key]) 38 | cur_val = val_type(cur_val) 39 | d[subkey][cur_key] = cur_val 40 | elif type(value) != type(d[subkey]) and isinstance(d[subkey], list): 41 | val_list = value.split(',') 42 | for k, x in enumerate(val_list): 43 | val_list[k] = type(d[subkey][0])(x) 44 | d[subkey] = val_list 45 | else: 46 | assert type(value) == type(d[subkey]), \ 47 | 'type {} does not match original type {}'.format(type(value), type(d[subkey])) 48 | d[subkey] = value 49 | 50 | 51 | def merge_new_config(config, new_config): 52 | if '_BASE_CONFIG_' in new_config: 53 | with open(new_config['_BASE_CONFIG_'], 'r') as f: 54 | try: 55 | yaml_config = yaml.load(f, Loader=yaml.FullLoader) 56 | except: 57 | yaml_config = yaml.load(f) 58 | config.update(EasyDict(yaml_config)) 59 | 60 | for key, val in new_config.items(): 61 | if not isinstance(val, dict): 62 | config[key] = val 63 | continue 64 | if key not in config: 65 | config[key] = EasyDict() 66 | merge_new_config(config[key], val) 67 | 68 | return config 69 | 70 | 71 | def cfg_from_yaml_file(cfg_file, config): 72 | with open(cfg_file, 'r') as f: 73 | try: 74 | new_config = yaml.load(f, Loader=yaml.FullLoader) 75 | except: 76 | new_config = yaml.load(f) 77 | 78 | merge_new_config(config=config, new_config=new_config) 79 | 80 | return config 81 | 82 | 83 | cfg = EasyDict() 84 | cfg.ROOT_DIR = (Path(__file__).resolve().parent / '../').resolve() 85 | cfg.LOCAL_RANK = 0 86 | -------------------------------------------------------------------------------- /pcdet/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from torch.utils.data import DataLoader 3 | from torch.utils.data import DistributedSampler as _DistributedSampler 4 | 5 | from pcdet.utils import common_utils 6 | 7 | from .dataset import DatasetTemplate 8 | from .kitti.kitti_dataset import KittiDataset 9 | # from .nuscenes.nuscenes_dataset import NuScenesDataset 10 | # from .waymo.waymo_dataset import WaymoDataset 11 | 12 | __all__ = { 13 | 'DatasetTemplate': DatasetTemplate, 14 | 'KittiDataset': KittiDataset, 15 | # 'NuScenesDataset': NuScenesDataset, 16 | # 'WaymoDataset': WaymoDataset 17 | } 18 | 19 | 20 | class DistributedSampler(_DistributedSampler): 21 | 22 | def __init__(self, dataset, num_replicas=None, rank=None, shuffle=True): 23 | super().__init__(dataset, num_replicas=num_replicas, rank=rank) 24 | self.shuffle = shuffle 25 | 26 | def __iter__(self): 27 | if self.shuffle: 28 | g = torch.Generator() 29 | g.manual_seed(self.epoch) 30 | indices = torch.randperm(len(self.dataset), generator=g).tolist() 31 | else: 32 | indices = torch.arange(len(self.dataset)).tolist() 33 | 34 | indices += indices[:(self.total_size - len(indices))] 35 | assert len(indices) == self.total_size 36 | 37 | indices = indices[self.rank:self.total_size:self.num_replicas] 38 | assert len(indices) == self.num_samples 39 | 40 | return iter(indices) 41 | 42 | 43 | def build_dataloader(dataset_cfg, class_names, batch_size, dist, root_path=None, workers=4, 44 | logger=None, training=True, merge_all_iters_to_one_epoch=False, total_epochs=0): 45 | 46 | dataset = __all__[dataset_cfg.DATASET]( 47 | dataset_cfg=dataset_cfg, 48 | class_names=class_names, 49 | root_path=root_path, 50 | training=training, 51 | logger=logger, 52 | ) 53 | 54 | if merge_all_iters_to_one_epoch: 55 | assert hasattr(dataset, 'merge_all_iters_to_one_epoch') 56 | dataset.merge_all_iters_to_one_epoch(merge=True, epochs=total_epochs) 57 | 58 | if dist: 59 | if training: 60 | sampler = torch.utils.data.distributed.DistributedSampler(dataset) 61 | else: 62 | rank, world_size = common_utils.get_dist_info() 63 | sampler = DistributedSampler(dataset, world_size, rank, shuffle=False) 64 | else: 65 | sampler = None 66 | dataloader = DataLoader( 67 | dataset, batch_size=batch_size, pin_memory=True, num_workers=workers, 68 | shuffle=(sampler is None) and training, collate_fn=dataset.collate_batch, 69 | drop_last=False, sampler=sampler, timeout=0 70 | ) 71 | 72 | return dataset, dataloader, sampler 73 | -------------------------------------------------------------------------------- /pcdet/datasets/__pycache__/__init__.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/__pycache__/__init__.cpython-36.pyc -------------------------------------------------------------------------------- /pcdet/datasets/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/datasets/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/datasets/__pycache__/dataset.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/__pycache__/dataset.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/datasets/__pycache__/dataset.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/__pycache__/dataset.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/datasets/augmentor/__pycache__/augmentor_utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/augmentor/__pycache__/augmentor_utils.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/datasets/augmentor/__pycache__/augmentor_utils.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/augmentor/__pycache__/augmentor_utils.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/datasets/augmentor/__pycache__/box_np_ops.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/augmentor/__pycache__/box_np_ops.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/datasets/augmentor/__pycache__/data_augmentor.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/augmentor/__pycache__/data_augmentor.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/datasets/augmentor/__pycache__/data_augmentor.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/augmentor/__pycache__/data_augmentor.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/datasets/augmentor/__pycache__/database_sampler.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/augmentor/__pycache__/database_sampler.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/datasets/augmentor/__pycache__/database_sampler.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/augmentor/__pycache__/database_sampler.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/datasets/augmentor/__pycache__/geometry.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/augmentor/__pycache__/geometry.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/datasets/augmentor/__pycache__/part_aware_augmentation.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/augmentor/__pycache__/part_aware_augmentation.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/datasets/augmentor/augmentor_utils.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from ...utils import common_utils 4 | 5 | def random_flip_along_x(gt_boxes, points): 6 | """ 7 | Args: 8 | gt_boxes: (N, 7 + C), [x, y, z, dx, dy, dz, heading, [vx], [vy]] 9 | points: (M, 3 + C) 10 | Returns: 11 | """ 12 | enable = np.random.choice([False, True], replace=False, p=[0.5, 0.5]) 13 | if enable: 14 | gt_boxes[:, 1] = -gt_boxes[:, 1] 15 | gt_boxes[:, 6] = -gt_boxes[:, 6] 16 | points[:, 1] = -points[:, 1] 17 | 18 | if gt_boxes.shape[1] > 7: 19 | gt_boxes[:, 8] = -gt_boxes[:, 8] 20 | 21 | return gt_boxes, points 22 | 23 | 24 | def random_flip_along_y(gt_boxes, points): 25 | """ 26 | Args: 27 | gt_boxes: (N, 7 + C), [x, y, z, dx, dy, dz, heading, [vx], [vy]] 28 | points: (M, 3 + C) 29 | Returns: 30 | """ 31 | enable = np.random.choice([False, True], replace=False, p=[0.5, 0.5]) 32 | if enable: 33 | gt_boxes[:, 0] = -gt_boxes[:, 0] 34 | gt_boxes[:, 6] = -(gt_boxes[:, 6] + np.pi) 35 | points[:, 0] = -points[:, 0] 36 | 37 | if gt_boxes.shape[1] > 7: 38 | gt_boxes[:, 7] = -gt_boxes[:, 7] 39 | 40 | return gt_boxes, points 41 | 42 | 43 | def global_rotation(gt_boxes, points, rot_range): 44 | """ 45 | Args: 46 | gt_boxes: (N, 7 + C), [x, y, z, dx, dy, dz, heading, [vx], [vy]] 47 | points: (M, 3 + C), 48 | rot_range: [min, max] 49 | Returns: 50 | """ 51 | noise_rotation = np.random.uniform(rot_range[0], rot_range[1]) 52 | points = common_utils.rotate_points_along_z(points[np.newaxis, :, :], np.array([noise_rotation]))[0] 53 | gt_boxes[:, 0:3] = common_utils.rotate_points_along_z(gt_boxes[np.newaxis, :, 0:3], np.array([noise_rotation]))[0] 54 | gt_boxes[:, 6] += noise_rotation 55 | if gt_boxes.shape[1] > 7: 56 | gt_boxes[:, 7:9] = common_utils.rotate_points_along_z( 57 | np.hstack((gt_boxes[:, 7:9], np.zeros((gt_boxes.shape[0], 1))))[np.newaxis, :, :], 58 | np.array([noise_rotation]) 59 | )[0][:, 0:2] 60 | 61 | return gt_boxes, points 62 | 63 | 64 | def global_scaling(gt_boxes, points, scale_range): 65 | """ 66 | Args: 67 | gt_boxes: (N, 7), [x, y, z, dx, dy, dz, heading] 68 | points: (M, 3 + C), 69 | scale_range: [min, max] 70 | Returns: 71 | """ 72 | if scale_range[1] - scale_range[0] < 1e-3: 73 | return gt_boxes, points 74 | noise_scale = np.random.uniform(scale_range[0], scale_range[1]) 75 | points[:, :3] *= noise_scale 76 | gt_boxes[:, :6] *= noise_scale 77 | return gt_boxes, points 78 | -------------------------------------------------------------------------------- /pcdet/datasets/kitti/__pycache__/kitti_dataset.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/kitti/__pycache__/kitti_dataset.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/datasets/kitti/__pycache__/kitti_dataset.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/kitti/__pycache__/kitti_dataset.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/datasets/kitti/kitti_object_eval_python/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /pcdet/datasets/kitti/kitti_object_eval_python/README.md: -------------------------------------------------------------------------------- 1 | # kitti-object-eval-python 2 | **Note**: This is borrowed from [traveller59/kitti-object-eval-python](https://github.com/traveller59/kitti-object-eval-python) 3 | 4 | Fast kitti object detection eval in python(finish eval in less than 10 second), support 2d/bev/3d/aos. , support coco-style AP. If you use command line interface, numba need some time to compile jit functions. 5 | ## Dependencies 6 | Only support python 3.6+, need `numpy`, `skimage`, `numba`, `fire`. If you have Anaconda, just install `cudatoolkit` in anaconda. Otherwise, please reference to this [page](https://github.com/numba/numba#custom-python-environments) to set up llvm and cuda for numba. 7 | * Install by conda: 8 | ``` 9 | conda install -c numba cudatoolkit=x.x (8.0, 9.0, 9.1, depend on your environment) 10 | ``` 11 | ## Usage 12 | * commandline interface: 13 | ``` 14 | python evaluate.py evaluate --label_path=/path/to/your_gt_label_folder --result_path=/path/to/your_result_folder --label_split_file=/path/to/val.txt --current_class=0 --coco=False 15 | ``` 16 | * python interface: 17 | ```Python 18 | import kitti_common as kitti 19 | from eval import get_official_eval_result, get_coco_eval_result 20 | def _read_imageset_file(path): 21 | with open(path, 'r') as f: 22 | lines = f.readlines() 23 | return [int(line) for line in lines] 24 | det_path = "/path/to/your_result_folder" 25 | dt_annos = kitti.get_label_annos(det_path) 26 | gt_path = "/path/to/your_gt_label_folder" 27 | gt_split_file = "/path/to/val.txt" # from https://xiaozhichen.github.io/files/mv3d/imagesets.tar.gz 28 | val_image_ids = _read_imageset_file(gt_split_file) 29 | gt_annos = kitti.get_label_annos(gt_path, val_image_ids) 30 | print(get_official_eval_result(gt_annos, dt_annos, 0)) # 6s in my computer 31 | print(get_coco_eval_result(gt_annos, dt_annos, 0)) # 18s in my computer 32 | ``` 33 | -------------------------------------------------------------------------------- /pcdet/datasets/kitti/kitti_object_eval_python/__pycache__/eval.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/kitti/kitti_object_eval_python/__pycache__/eval.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/datasets/kitti/kitti_object_eval_python/__pycache__/eval.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/kitti/kitti_object_eval_python/__pycache__/eval.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/datasets/kitti/kitti_object_eval_python/__pycache__/rotate_iou.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/kitti/kitti_object_eval_python/__pycache__/rotate_iou.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/datasets/kitti/kitti_object_eval_python/__pycache__/rotate_iou.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/kitti/kitti_object_eval_python/__pycache__/rotate_iou.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/datasets/kitti/kitti_object_eval_python/evaluate.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | import fire 4 | 5 | import .kitti_common as kitti 6 | from .eval import get_coco_eval_result, get_official_eval_result 7 | 8 | 9 | def _read_imageset_file(path): 10 | with open(path, 'r') as f: 11 | lines = f.readlines() 12 | return [int(line) for line in lines] 13 | 14 | 15 | def evaluate(label_path, 16 | result_path, 17 | label_split_file, 18 | current_class=0, 19 | coco=False, 20 | score_thresh=-1): 21 | dt_annos = kitti.get_label_annos(result_path) 22 | if score_thresh > 0: 23 | dt_annos = kitti.filter_annos_low_score(dt_annos, score_thresh) 24 | val_image_ids = _read_imageset_file(label_split_file) 25 | gt_annos = kitti.get_label_annos(label_path, val_image_ids) 26 | if coco: 27 | return get_coco_eval_result(gt_annos, dt_annos, current_class) 28 | else: 29 | return get_official_eval_result(gt_annos, dt_annos, current_class) 30 | 31 | 32 | if __name__ == '__main__': 33 | fire.Fire() 34 | -------------------------------------------------------------------------------- /pcdet/datasets/processor/__pycache__/data_processor.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/processor/__pycache__/data_processor.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/datasets/processor/__pycache__/data_processor.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/processor/__pycache__/data_processor.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/datasets/processor/__pycache__/point_feature_encoder.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/processor/__pycache__/point_feature_encoder.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/datasets/processor/__pycache__/point_feature_encoder.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/datasets/processor/__pycache__/point_feature_encoder.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/datasets/processor/point_feature_encoder.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | class PointFeatureEncoder(object): 5 | def __init__(self, config, point_cloud_range=None): 6 | super().__init__() 7 | self.point_encoding_config = config 8 | assert list(self.point_encoding_config.src_feature_list[0:3]) == ['x', 'y', 'z'] 9 | self.used_feature_list = self.point_encoding_config.used_feature_list 10 | self.src_feature_list = self.point_encoding_config.src_feature_list 11 | self.point_cloud_range = point_cloud_range 12 | 13 | @property 14 | def num_point_features(self): 15 | return getattr(self, self.point_encoding_config.encoding_type)(points=None) 16 | 17 | def forward(self, data_dict): 18 | """ 19 | Args: 20 | data_dict: 21 | points: (N, 3 + C_in) 22 | ... 23 | Returns: 24 | data_dict: 25 | points: (N, 3 + C_out), 26 | use_lead_xyz: whether to use xyz as point-wise features 27 | ... 28 | """ 29 | data_dict['points'], use_lead_xyz = getattr(self, self.point_encoding_config.encoding_type)( 30 | data_dict['points'] 31 | ) 32 | data_dict['use_lead_xyz'] = use_lead_xyz 33 | return data_dict 34 | 35 | def absolute_coordinates_encoding(self, points=None): 36 | if points is None: 37 | num_output_features = len(self.used_feature_list) 38 | return num_output_features 39 | 40 | point_feature_list = [points[:, 0:3]] 41 | for x in self.used_feature_list: 42 | if x in ['x', 'y', 'z']: 43 | continue 44 | idx = self.src_feature_list.index(x) 45 | point_feature_list.append(points[:, idx:idx+1]) 46 | point_features = np.concatenate(point_feature_list, axis=1) 47 | return point_features, True 48 | -------------------------------------------------------------------------------- /pcdet/models/__init__.py: -------------------------------------------------------------------------------- 1 | from collections import namedtuple 2 | 3 | import numpy as np 4 | import torch 5 | 6 | from .detectors import build_detector 7 | 8 | 9 | def build_network(model_cfg, num_class, dataset): 10 | model = build_detector( 11 | model_cfg=model_cfg, num_class=num_class, dataset=dataset 12 | ) 13 | return model 14 | 15 | 16 | def load_data_to_gpu(batch_dict): 17 | for key, val in batch_dict.items(): 18 | if not isinstance(val, np.ndarray): 19 | continue 20 | if key in ['frame_id', 'metadata', 'calib', 'image_shape']: 21 | continue 22 | batch_dict[key] = torch.from_numpy(val).float().cuda() 23 | 24 | 25 | def model_fn_decorator(): 26 | ModelReturn = namedtuple('ModelReturn', ['loss', 'tb_dict', 'disp_dict']) 27 | 28 | def model_func(model, batch_dict): 29 | load_data_to_gpu(batch_dict) 30 | ret_dict, tb_dict, disp_dict = model(batch_dict) 31 | 32 | loss = ret_dict['loss'] #.mean() 33 | if hasattr(model, 'update_global_step'): 34 | model.update_global_step() 35 | else: 36 | model.module.update_global_step() 37 | 38 | return ModelReturn(loss, tb_dict, disp_dict) 39 | 40 | return model_func 41 | -------------------------------------------------------------------------------- /pcdet/models/backbones_2d/__init__.py: -------------------------------------------------------------------------------- 1 | from .base_bev_backbone import BaseBEVBackbone 2 | 3 | __all__ = { 4 | 'BaseBEVBackbone': BaseBEVBackbone 5 | } 6 | -------------------------------------------------------------------------------- /pcdet/models/backbones_2d/map_to_bev/__init__.py: -------------------------------------------------------------------------------- 1 | from .height_compression import HeightCompression 2 | from .pointpillar_scatter import PointPillarScatter 3 | 4 | __all__ = { 5 | 'HeightCompression': HeightCompression, 6 | 'PointPillarScatter': PointPillarScatter 7 | } 8 | -------------------------------------------------------------------------------- /pcdet/models/backbones_2d/map_to_bev/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/models/backbones_2d/map_to_bev/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/models/backbones_2d/map_to_bev/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/models/backbones_2d/map_to_bev/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/models/backbones_2d/map_to_bev/__pycache__/height_compression.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/models/backbones_2d/map_to_bev/__pycache__/height_compression.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/models/backbones_2d/map_to_bev/__pycache__/height_compression.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/models/backbones_2d/map_to_bev/__pycache__/height_compression.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/models/backbones_2d/map_to_bev/__pycache__/pointpillar_scatter.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/models/backbones_2d/map_to_bev/__pycache__/pointpillar_scatter.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/models/backbones_2d/map_to_bev/__pycache__/pointpillar_scatter.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/models/backbones_2d/map_to_bev/__pycache__/pointpillar_scatter.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/models/backbones_2d/map_to_bev/height_compression.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | 3 | 4 | class HeightCompression(nn.Module): 5 | def __init__(self, model_cfg, **kwargs): 6 | super().__init__() 7 | self.model_cfg = model_cfg 8 | self.num_bev_features = self.model_cfg.NUM_BEV_FEATURES 9 | 10 | def forward(self, batch_dict): 11 | """ 12 | Args: 13 | batch_dict: 14 | encoded_spconv_tensor: sparse tensor 15 | Returns: 16 | batch_dict: 17 | spatial_features: 18 | 19 | """ 20 | encoded_spconv_tensor = batch_dict['encoded_spconv_tensor'] 21 | spatial_features = encoded_spconv_tensor.dense() 22 | N, C, D, H, W = spatial_features.shape 23 | spatial_features = spatial_features.view(N, C * D, H, W) 24 | batch_dict['spatial_features'] = spatial_features 25 | batch_dict['spatial_features_stride'] = batch_dict['encoded_spconv_tensor_stride'] 26 | return batch_dict 27 | -------------------------------------------------------------------------------- /pcdet/models/backbones_2d/map_to_bev/pointpillar_scatter.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | 4 | 5 | class PointPillarScatter(nn.Module): 6 | def __init__(self, model_cfg, grid_size, **kwargs): 7 | super().__init__() 8 | 9 | self.model_cfg = model_cfg 10 | self.num_bev_features = self.model_cfg.NUM_BEV_FEATURES 11 | self.dynamic_voxel = self.model_cfg.DYNAMIC_VOXEL 12 | self.nx, self.ny, self.nz = grid_size 13 | assert self.nz == 1 14 | 15 | def forward(self, batch_dict, **kwargs): 16 | pillar_features = batch_dict['pillar_features'] 17 | if self.dynamic_voxel: 18 | coords = batch_dict['pillar_coords'] #[24264,4 batch_ind,z,y max495,x max431] 19 | else: 20 | coords = batch_dict['voxel_coords'] #[24264,4 batch_ind,z,y max 495,x max 431] 21 | batch_spatial_features = [] 22 | batch_size = coords[:, 0].max().int().item() + 1 23 | for batch_idx in range(batch_size): 24 | spatial_feature = torch.zeros( 25 | self.num_bev_features, 26 | self.nz * self.nx * self.ny, 27 | dtype=pillar_features.dtype, 28 | device=pillar_features.device) 29 | 30 | batch_mask = coords[:, 0] == batch_idx 31 | this_coords = coords[batch_mask, :] 32 | indices = this_coords[:, 3] + this_coords[:, 2] * self.nx #+ this_coords[:, 3] 33 | indices = indices.type(torch.long) 34 | pillars = pillar_features[batch_mask, :] 35 | pillars = pillars.t() 36 | spatial_feature[:, indices] = pillars 37 | batch_spatial_features.append(spatial_feature) 38 | 39 | batch_spatial_features = torch.stack(batch_spatial_features, 0) 40 | batch_spatial_features = batch_spatial_features.view(batch_size, self.num_bev_features * self.nz, self.ny, self.nx) 41 | batch_dict['spatial_features'] = batch_spatial_features 42 | return batch_dict 43 | -------------------------------------------------------------------------------- /pcdet/models/backbones_3d/__init__.py: -------------------------------------------------------------------------------- 1 | # from .pointnet2_backbone import PointNet2Backbone, PointNet2MSG 2 | # from .spconv_backbone import VoxelBackBone8x, VoxelResBackBone8x 3 | # from .spconv_unet import UNetV2 4 | 5 | # __all__ = { 6 | # 'VoxelBackBone8x': VoxelBackBone8x, 7 | # 'UNetV2': UNetV2, 8 | # 'PointNet2Backbone': PointNet2Backbone, 9 | # 'PointNet2MSG': PointNet2MSG, 10 | # 'VoxelResBackBone8x': VoxelResBackBone8x, 11 | # } 12 | -------------------------------------------------------------------------------- /pcdet/models/backbones_3d/vfe/__init__.py: -------------------------------------------------------------------------------- 1 | from .mean_vfe import MeanVFE 2 | from .pillar_vfe import PillarVFE 3 | from .vfe_template import VFETemplate 4 | # from .dynamic_pillar_vfe import DynamicPillarVFE 5 | from .pillar_vfe_2view import MultiViewPillarNet 6 | from .attention_2view_pillar_vfe import Attention2ViewPillarNet 7 | from .view_wise_attention_vfe import ViewWiseAttentionPillarNet 8 | from .multiview_conv import Multiview2Conv 9 | from .dynamic_pillar_vfe_multi_view import MultiViewDynamicPillarVFE 10 | __all__ = { 11 | 'VFETemplate': VFETemplate, 12 | 'MeanVFE': MeanVFE, 13 | 'PillarVFE': PillarVFE, 14 | # 'DynamicPillarVFE': DynamicPillarVFE, 15 | 'MultiViewPillarNet': MultiViewPillarNet, 16 | 'Attention2ViewPillarNet': Attention2ViewPillarNet, 17 | 'ViewWiseAttentionPillarNet': ViewWiseAttentionPillarNet, 18 | 'Multiview2Conv': Multiview2Conv, 19 | 'MultiViewDynamicPillarVFE': MultiViewDynamicPillarVFE 20 | 21 | } 22 | -------------------------------------------------------------------------------- /pcdet/models/backbones_3d/vfe/mean_vfe.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | from .vfe_template import VFETemplate 4 | 5 | 6 | class MeanVFE(VFETemplate): 7 | def __init__(self, model_cfg, num_point_features, **kwargs): 8 | super().__init__(model_cfg=model_cfg) 9 | self.num_point_features = num_point_features 10 | 11 | def get_output_feature_dim(self): 12 | return self.num_point_features 13 | 14 | def forward(self, batch_dict, **kwargs): 15 | """ 16 | Args: 17 | batch_dict: 18 | voxels: (num_voxels, max_points_per_voxel, C) 19 | voxel_num_points: optional (num_voxels) 20 | **kwargs: 21 | 22 | Returns: 23 | vfe_features: (num_voxels, C) 24 | """ 25 | voxel_features, voxel_num_points = batch_dict['voxels'], batch_dict['voxel_num_points'] 26 | points_mean = voxel_features[:, :, :].sum(dim=1, keepdim=False) 27 | normalizer = torch.clamp_min(voxel_num_points.view(-1, 1), min=1.0).type_as(voxel_features) 28 | points_mean = points_mean / normalizer 29 | batch_dict['voxel_features'] = points_mean.contiguous() 30 | 31 | return batch_dict 32 | -------------------------------------------------------------------------------- /pcdet/models/backbones_3d/vfe/vfe_template.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | 3 | 4 | class VFETemplate(nn.Module): 5 | def __init__(self, model_cfg, **kwargs): 6 | super().__init__() 7 | self.model_cfg = model_cfg 8 | 9 | def get_output_feature_dim(self): 10 | raise NotImplementedError 11 | 12 | def forward(self, **kwargs): 13 | """ 14 | Args: 15 | **kwargs: 16 | 17 | Returns: 18 | batch_dict: 19 | ... 20 | vfe_features: (num_voxels, C) 21 | """ 22 | raise NotImplementedError 23 | -------------------------------------------------------------------------------- /pcdet/models/dense_heads/__init__.py: -------------------------------------------------------------------------------- 1 | # from .anchor_head_multi import AnchorHeadMulti 2 | from .anchor_head_single import AnchorHeadSingle 3 | from .anchor_head_template import AnchorHeadTemplate 4 | # from .point_head_box import PointHeadBox 5 | # from .point_head_simple import PointHeadSimple 6 | # from .point_intra_part_head import PointIntraPartOffsetHead 7 | # from .ssd_rotate_head import SSDRotateHead 8 | 9 | __all__ = { 10 | 'AnchorHeadTemplate': AnchorHeadTemplate, 11 | 'AnchorHeadSingle': AnchorHeadSingle, 12 | # 'PointIntraPartOffsetHead': PointIntraPartOffsetHead, 13 | # 'PointHeadSimple': PointHeadSimple, 14 | # 'PointHeadBox': PointHeadBox, 15 | # 'AnchorHeadMulti': AnchorHeadMulti, 16 | # 'SSDRotatedHead': SSDRotateHead 17 | } 18 | -------------------------------------------------------------------------------- /pcdet/models/dense_heads/anchor_head_single.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import torch.nn as nn 3 | 4 | from .anchor_head_template import AnchorHeadTemplate 5 | 6 | 7 | class AnchorHeadSingle(AnchorHeadTemplate): 8 | def __init__(self, model_cfg, input_channels, num_class, class_names, grid_size, point_cloud_range, 9 | predict_boxes_when_training=True): 10 | super().__init__( 11 | model_cfg=model_cfg, num_class=num_class, class_names=class_names, grid_size=grid_size, point_cloud_range=point_cloud_range, 12 | predict_boxes_when_training=predict_boxes_when_training 13 | ) 14 | 15 | self.num_anchors_per_location = sum(self.num_anchors_per_location) 16 | 17 | self.conv_cls = nn.Conv2d( 18 | input_channels, self.num_anchors_per_location * self.num_class, 19 | kernel_size=1 20 | ) 21 | self.conv_box = nn.Conv2d( 22 | input_channels, self.num_anchors_per_location * self.box_coder.code_size, 23 | kernel_size=1 24 | ) 25 | 26 | if self.model_cfg.get('USE_DIRECTION_CLASSIFIER', None) is not None: 27 | self.conv_dir_cls = nn.Conv2d( 28 | input_channels, 29 | self.num_anchors_per_location * self.model_cfg.NUM_DIR_BINS, 30 | kernel_size=1 31 | ) 32 | else: 33 | self.conv_dir_cls = None 34 | self.init_weights() 35 | 36 | def init_weights(self): 37 | pi = 0.01 38 | nn.init.constant_(self.conv_cls.bias, -np.log((1 - pi) / pi)) 39 | nn.init.normal_(self.conv_box.weight, mean=0, std=0.001) 40 | 41 | def forward(self, data_dict): 42 | spatial_features_2d = data_dict['spatial_features_2d'] 43 | 44 | cls_preds = self.conv_cls(spatial_features_2d) 45 | box_preds = self.conv_box(spatial_features_2d) 46 | 47 | cls_preds = cls_preds.permute(0, 2, 3, 1).contiguous() # [N, H, W, C] 48 | box_preds = box_preds.permute(0, 2, 3, 1).contiguous() # [N, H, W, C] 49 | 50 | self.forward_ret_dict['cls_preds'] = cls_preds 51 | self.forward_ret_dict['box_preds'] = box_preds 52 | 53 | if self.conv_dir_cls is not None: 54 | dir_cls_preds = self.conv_dir_cls(spatial_features_2d) 55 | dir_cls_preds = dir_cls_preds.permute(0, 2, 3, 1).contiguous() 56 | self.forward_ret_dict['dir_cls_preds'] = dir_cls_preds 57 | else: 58 | dir_cls_preds = None 59 | 60 | if self.training: 61 | targets_dict = self.assign_targets( 62 | gt_boxes=data_dict['gt_boxes'] 63 | ) 64 | self.forward_ret_dict.update(targets_dict) 65 | 66 | if not self.training or self.predict_boxes_when_training: 67 | batch_cls_preds, batch_box_preds = self.generate_predicted_boxes( 68 | batch_size=data_dict['batch_size'], 69 | cls_preds=cls_preds, box_preds=box_preds, dir_cls_preds=dir_cls_preds 70 | ) 71 | data_dict['batch_cls_preds'] = batch_cls_preds 72 | data_dict['batch_box_preds'] = batch_box_preds 73 | data_dict['cls_preds_normalized'] = False 74 | 75 | return data_dict 76 | -------------------------------------------------------------------------------- /pcdet/models/dense_heads/target_assigner/anchor_generator.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | 4 | class AnchorGenerator(object): 5 | def __init__(self, anchor_range, anchor_generator_config): 6 | super().__init__() 7 | self.anchor_generator_cfg = anchor_generator_config 8 | self.anchor_range = anchor_range 9 | self.anchor_sizes = [config['anchor_sizes'] for config in anchor_generator_config] 10 | self.anchor_rotations = [config['anchor_rotations'] for config in anchor_generator_config] 11 | self.anchor_heights = [config['anchor_bottom_heights'] for config in anchor_generator_config] 12 | self.align_center = [config.get('align_center', False) for config in anchor_generator_config] 13 | 14 | assert len(self.anchor_sizes) == len(self.anchor_rotations) == len(self.anchor_heights) 15 | self.num_of_anchor_sets = len(self.anchor_sizes) 16 | 17 | def generate_anchors(self, grid_sizes): 18 | assert len(grid_sizes) == self.num_of_anchor_sets 19 | all_anchors = [] 20 | num_anchors_per_location = [] 21 | for grid_size, anchor_size, anchor_rotation, anchor_height, align_center in zip( 22 | grid_sizes, self.anchor_sizes, self.anchor_rotations, self.anchor_heights, self.align_center): 23 | 24 | num_anchors_per_location.append(len(anchor_rotation) * len(anchor_size) * len(anchor_height)) 25 | if align_center: 26 | x_stride = (self.anchor_range[3] - self.anchor_range[0]) / grid_size[0] 27 | y_stride = (self.anchor_range[4] - self.anchor_range[1]) / grid_size[1] 28 | x_offset, y_offset = x_stride / 2, y_stride / 2 29 | else: 30 | x_stride = (self.anchor_range[3] - self.anchor_range[0]) / (grid_size[0] - 1) 31 | y_stride = (self.anchor_range[4] - self.anchor_range[1]) / (grid_size[1] - 1) 32 | x_offset, y_offset = 0, 0 33 | 34 | x_shifts = torch.arange( 35 | self.anchor_range[0] + x_offset, self.anchor_range[3] + 1e-5, step=x_stride, dtype=torch.float32, 36 | ).cuda() 37 | y_shifts = torch.arange( 38 | self.anchor_range[1] + y_offset, self.anchor_range[4] + 1e-5, step=y_stride, dtype=torch.float32, 39 | ).cuda() 40 | z_shifts = x_shifts.new_tensor(anchor_height) 41 | 42 | num_anchor_size, num_anchor_rotation = anchor_size.__len__(), anchor_rotation.__len__() 43 | anchor_rotation = x_shifts.new_tensor(anchor_rotation) 44 | anchor_size = x_shifts.new_tensor(anchor_size) 45 | x_shifts, y_shifts, z_shifts = torch.meshgrid([ 46 | x_shifts, y_shifts, z_shifts 47 | ]) # [x_grid, y_grid, z_grid] 48 | anchors = torch.stack((x_shifts, y_shifts, z_shifts), dim=-1) # [x, y, z, 3] 49 | anchors = anchors[:, :, :, None, :].repeat(1, 1, 1, anchor_size.shape[0], 1) 50 | anchor_size = anchor_size.view(1, 1, 1, -1, 3).repeat([*anchors.shape[0:3], 1, 1]) 51 | anchors = torch.cat((anchors, anchor_size), dim=-1) 52 | anchors = anchors[:, :, :, :, None, :].repeat(1, 1, 1, 1, num_anchor_rotation, 1) 53 | anchor_rotation = anchor_rotation.view(1, 1, 1, 1, -1, 1).repeat([*anchors.shape[0:3], num_anchor_size, 1, 1]) 54 | anchors = torch.cat((anchors, anchor_rotation), dim=-1) # [x, y, z, num_size, num_rot, 7] 55 | 56 | anchors = anchors.permute(2, 1, 0, 3, 4, 5).contiguous() 57 | #anchors = anchors.view(-1, anchors.shape[-1]) 58 | anchors[..., 2] += anchors[..., 5] / 2 # shift to box centers 59 | all_anchors.append(anchors) 60 | return all_anchors, num_anchors_per_location 61 | 62 | 63 | if __name__ == '__main__': 64 | from easydict import EasyDict 65 | config = [ 66 | EasyDict({ 67 | 'anchor_sizes': [[2.1, 4.7, 1.7], [0.86, 0.91, 1.73], [0.84, 1.78, 1.78]], 68 | 'anchor_rotations': [0, 1.57], 69 | 'anchor_heights': [0, 0.5] 70 | }) 71 | ] 72 | 73 | A = AnchorGenerator( 74 | anchor_range=[-75.2, -75.2, -2, 75.2, 75.2, 4], 75 | anchor_generator_config=config 76 | ) 77 | import pdb 78 | pdb.set_trace() 79 | A.generate_anchors([[188, 188]]) 80 | -------------------------------------------------------------------------------- /pcdet/models/detectors/__init__.py: -------------------------------------------------------------------------------- 1 | from .detector3d_template import Detector3DTemplate 2 | from .PartA2_net import PartA2Net 3 | from .point_rcnn import PointRCNN 4 | from .pointpillar import PointPillar 5 | from .pv_rcnn import PVRCNN 6 | from .second_net import SECONDNet 7 | from .multiview_pswarp import MultiviewPSWarp 8 | 9 | __all__ = { 10 | 'Detector3DTemplate': Detector3DTemplate, 11 | 'SECONDNet': SECONDNet, 12 | 'PartA2Net': PartA2Net, 13 | 'PVRCNN': PVRCNN, 14 | 'PointPillar': PointPillar, 15 | 'PointRCNN': PointRCNN, 16 | 'MultiviewPSWarp': MultiviewPSWarp 17 | } 18 | 19 | 20 | def build_detector(model_cfg, num_class, dataset): 21 | model = __all__[model_cfg.NAME]( 22 | model_cfg=model_cfg, num_class=num_class, dataset=dataset 23 | ) 24 | 25 | return model 26 | -------------------------------------------------------------------------------- /pcdet/models/detectors/pointpillar.py: -------------------------------------------------------------------------------- 1 | from .detector3d_template import Detector3DTemplate 2 | 3 | 4 | class PointPillar(Detector3DTemplate): 5 | def __init__(self, model_cfg, num_class, dataset): 6 | super().__init__(model_cfg=model_cfg, num_class=num_class, dataset=dataset) 7 | self.module_list = self.build_networks() 8 | 9 | def forward(self, batch_dict): 10 | for cur_module in self.module_list: 11 | batch_dict = cur_module(batch_dict) 12 | 13 | if self.training: 14 | loss, tb_dict, disp_dict = self.get_training_loss() 15 | 16 | ret_dict = { 17 | 'loss': loss 18 | } 19 | return ret_dict, tb_dict, disp_dict 20 | else: 21 | pred_dicts, recall_dicts = self.post_processing(batch_dict) 22 | return pred_dicts, recall_dicts 23 | 24 | def get_training_loss(self): 25 | disp_dict = {} 26 | 27 | loss_rpn, tb_dict = self.dense_head.get_loss() 28 | tb_dict = { 29 | 'loss_rpn': loss_rpn.item(), 30 | **tb_dict 31 | } 32 | 33 | loss = loss_rpn 34 | return loss, tb_dict, disp_dict 35 | -------------------------------------------------------------------------------- /pcdet/models/model_utils/model_nms_utils.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | from ...ops.iou3d_nms import iou3d_nms_utils 4 | from ...ops.iou3d import iou3d_utils 5 | 6 | 7 | def class_agnostic_nms(box_scores, box_preds, nms_config, score_thresh=None): 8 | src_box_scores = box_scores 9 | if score_thresh is not None: 10 | scores_mask = (box_scores >= score_thresh) 11 | box_scores = box_scores[scores_mask] 12 | box_preds = box_preds[scores_mask] 13 | 14 | selected = [] 15 | if box_scores.shape[0] > 0: 16 | box_scores_nms, indices = torch.topk(box_scores, k=min(nms_config.NMS_PRE_MAXSIZE, box_scores.shape[0])) 17 | boxes_for_nms = box_preds[indices] 18 | keep_idx, selected_scores = getattr(iou3d_nms_utils, nms_config.NMS_TYPE)( 19 | boxes_for_nms[:, 0:7], box_scores_nms, nms_config.NMS_THRESH, **nms_config 20 | ) 21 | selected = indices[keep_idx[:nms_config.NMS_POST_MAXSIZE]] 22 | 23 | if score_thresh is not None: 24 | original_idxs = scores_mask.nonzero().view(-1) 25 | selected = original_idxs[selected] 26 | return selected, src_box_scores[selected] 27 | 28 | 29 | def multi_classes_nms(cls_scores, box_preds, nms_config, score_thresh=None): 30 | """ 31 | Args: 32 | cls_scores: (N, num_class) 33 | box_preds: (N, 7 + C) 34 | nms_config: 35 | score_thresh: 36 | 37 | Returns: 38 | 39 | """ 40 | pred_scores, pred_labels, pred_boxes = [], [], [] 41 | for k in range(cls_scores.shape[1]): 42 | if score_thresh is not None: 43 | scores_mask = (cls_scores[:, k] >= score_thresh) 44 | box_scores = cls_scores[scores_mask, k] 45 | cur_box_preds = box_preds[scores_mask] 46 | else: 47 | box_scores = cls_scores[:, k] 48 | 49 | selected = [] 50 | if box_scores.shape[0] > 0: 51 | box_scores_nms, indices = torch.topk(box_scores, k=min(nms_config.NMS_PRE_MAXSIZE, box_scores.shape[0])) 52 | boxes_for_nms = cur_box_preds[indices] 53 | keep_idx, selected_scores = getattr(iou3d_nms_utils, nms_config.NMS_TYPE)( 54 | boxes_for_nms[:, 0:7], box_scores_nms, nms_config.NMS_THRESH, **nms_config 55 | ) 56 | selected = indices[keep_idx[:nms_config.NMS_POST_MAXSIZE]] 57 | 58 | pred_scores.append(box_scores[selected]) 59 | pred_labels.append(box_scores.new_ones(len(selected)).long() * k) 60 | pred_boxes.append(cur_box_preds[selected]) 61 | 62 | pred_scores = torch.cat(pred_scores, dim=0) 63 | pred_labels = torch.cat(pred_labels, dim=0) 64 | pred_boxes = torch.cat(pred_boxes, dim=0) 65 | 66 | return pred_scores, pred_labels, pred_boxes 67 | -------------------------------------------------------------------------------- /pcdet/ops/iou3d/__pycache__/iou3d_utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/iou3d/__pycache__/iou3d_utils.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/ops/iou3d/__pycache__/iou3d_utils.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/iou3d/__pycache__/iou3d_utils.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/ops/iou3d/build/lib.linux-x86_64-3.7/iou3d_cuda.cpython-37m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/iou3d/build/lib.linux-x86_64-3.7/iou3d_cuda.cpython-37m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/iou3d/build/lib.linux-x86_64-3.8/iou3d_cuda.cpython-38-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/iou3d/build/lib.linux-x86_64-3.8/iou3d_cuda.cpython-38-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/iou3d/build/temp.linux-x86_64-3.7/.ninja_log: -------------------------------------------------------------------------------- 1 | # ninja log v5 2 | 0 987 1610577973120037182 /home/xingcheng/Workspace/OpenPCDet/pcdet/ops/iou3d/build/temp.linux-x86_64-3.7/src/iou3d_kernel.o 91b1bb8b2dc63cb1 3 | -------------------------------------------------------------------------------- /pcdet/ops/iou3d/build/temp.linux-x86_64-3.7/build.ninja: -------------------------------------------------------------------------------- 1 | ninja_required_version = 1.3 2 | cxx = c++ 3 | nvcc = /usr/local/cuda/bin/nvcc 4 | 5 | cflags = -pthread -B /home/xingcheng/miniconda3/envs/open-mmlab/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/xingcheng/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/include -I/home/xingcheng/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/xingcheng/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/include/TH -I/home/xingcheng/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/include/THC -I/usr/local/cuda/include -I/home/xingcheng/miniconda3/envs/open-mmlab/include/python3.7m -c 6 | post_cflags = -g -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=iou3d_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14 7 | cuda_cflags = -I/home/xingcheng/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/include -I/home/xingcheng/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/xingcheng/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/include/TH -I/home/xingcheng/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/include/THC -I/usr/local/cuda/include -I/home/xingcheng/miniconda3/envs/open-mmlab/include/python3.7m -c 8 | cuda_post_cflags = -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' -O2 -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=iou3d_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_75,code=sm_75 -std=c++14 9 | ldflags = 10 | 11 | rule compile 12 | command = $cxx -MMD -MF $out.d $cflags -c $in -o $out $post_cflags 13 | depfile = $out.d 14 | deps = gcc 15 | 16 | rule cuda_compile 17 | command = $nvcc $cuda_cflags -c $in -o $out $cuda_post_cflags 18 | 19 | 20 | 21 | build /home/xingcheng/Workspace/OpenPCDet/pcdet/ops/iou3d/build/temp.linux-x86_64-3.7/src/iou3d.o: compile /home/xingcheng/Workspace/OpenPCDet/pcdet/ops/iou3d/src/iou3d.cpp 22 | build /home/xingcheng/Workspace/OpenPCDet/pcdet/ops/iou3d/build/temp.linux-x86_64-3.7/src/iou3d_kernel.o: cuda_compile /home/xingcheng/Workspace/OpenPCDet/pcdet/ops/iou3d/src/iou3d_kernel.cu 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /pcdet/ops/iou3d/build/temp.linux-x86_64-3.7/src/iou3d.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/iou3d/build/temp.linux-x86_64-3.7/src/iou3d.o -------------------------------------------------------------------------------- /pcdet/ops/iou3d/build/temp.linux-x86_64-3.7/src/iou3d_kernel.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/iou3d/build/temp.linux-x86_64-3.7/src/iou3d_kernel.o -------------------------------------------------------------------------------- /pcdet/ops/iou3d/build/temp.linux-x86_64-3.8/src/iou3d.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/iou3d/build/temp.linux-x86_64-3.8/src/iou3d.o -------------------------------------------------------------------------------- /pcdet/ops/iou3d/build/temp.linux-x86_64-3.8/src/iou3d_kernel.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/iou3d/build/temp.linux-x86_64-3.8/src/iou3d_kernel.o -------------------------------------------------------------------------------- /pcdet/ops/iou3d/iou3d_cuda.cpython-37m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/iou3d/iou3d_cuda.cpython-37m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/iou3d/iou3d_cuda.cpython-38-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/iou3d/iou3d_cuda.cpython-38-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/iou3d/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | from torch.utils.cpp_extension import BuildExtension, CUDAExtension 3 | 4 | setup( 5 | name='iou3d', 6 | ext_modules=[ 7 | CUDAExtension('iou3d_cuda', [ 8 | 'src/iou3d.cpp', 9 | 'src/iou3d_kernel.cu', 10 | ], 11 | extra_compile_args={'cxx': ['-g'], 12 | 'nvcc': ['-O2']}) 13 | ], 14 | cmdclass={'build_ext': BuildExtension}) 15 | -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/__pycache__/iou3d_nms_utils.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/iou3d_nms/__pycache__/iou3d_nms_utils.cpython-36.pyc -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/__pycache__/iou3d_nms_utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/iou3d_nms/__pycache__/iou3d_nms_utils.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/__pycache__/iou3d_nms_utils.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/iou3d_nms/__pycache__/iou3d_nms_utils.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/build/lib.linux-x86_64-3.7/iou3d_nms_cuda.cpython-37m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/iou3d_nms/build/lib.linux-x86_64-3.7/iou3d_nms_cuda.cpython-37m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/build/temp.linux-x86_64-3.7/.ninja_deps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/iou3d_nms/build/temp.linux-x86_64-3.7/.ninja_deps -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/build/temp.linux-x86_64-3.7/.ninja_log: -------------------------------------------------------------------------------- 1 | # ninja log v5 2 | 0 1128 1610578111268240663 /home/xingcheng/Workspace/OpenPCDet/pcdet/ops/iou3d_nms/build/temp.linux-x86_64-3.7/src/iou3d_nms_kernel.o f06b23be34b0a1c7 3 | 0 5729 1610578115868380382 /home/xingcheng/Workspace/OpenPCDet/pcdet/ops/iou3d_nms/build/temp.linux-x86_64-3.7/src/iou3d_cpu.o b8ff7daf3c96843e 4 | 0 6757 1610578116892411488 /home/xingcheng/Workspace/OpenPCDet/pcdet/ops/iou3d_nms/build/temp.linux-x86_64-3.7/src/iou3d_nms.o 6f346cd7bc79ef07 5 | 0 9795 1610578119928503718 /home/xingcheng/Workspace/OpenPCDet/pcdet/ops/iou3d_nms/build/temp.linux-x86_64-3.7/src/iou3d_nms_api.o ea5ba611894ca943 6 | -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/build/temp.linux-x86_64-3.7/build.ninja: -------------------------------------------------------------------------------- 1 | ninja_required_version = 1.3 2 | cxx = c++ 3 | nvcc = /usr/local/cuda/bin/nvcc 4 | 5 | cflags = -pthread -B /home/xingcheng/miniconda3/envs/open-mmlab/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/xingcheng/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/include -I/home/xingcheng/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/xingcheng/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/include/TH -I/home/xingcheng/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/include/THC -I/usr/local/cuda/include -I/home/xingcheng/miniconda3/envs/open-mmlab/include/python3.7m -c 6 | post_cflags = -g -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=iou3d_nms_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14 7 | cuda_cflags = -I/home/xingcheng/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/include -I/home/xingcheng/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/xingcheng/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/include/TH -I/home/xingcheng/miniconda3/envs/open-mmlab/lib/python3.7/site-packages/torch/include/THC -I/usr/local/cuda/include -I/home/xingcheng/miniconda3/envs/open-mmlab/include/python3.7m -c 8 | cuda_post_cflags = -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' -O2 -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=iou3d_nms_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_75,code=sm_75 -std=c++14 9 | ldflags = 10 | 11 | rule compile 12 | command = $cxx -MMD -MF $out.d $cflags -c $in -o $out $post_cflags 13 | depfile = $out.d 14 | deps = gcc 15 | 16 | rule cuda_compile 17 | command = $nvcc $cuda_cflags -c $in -o $out $cuda_post_cflags 18 | 19 | 20 | 21 | build /home/xingcheng/Workspace/OpenPCDet/pcdet/ops/iou3d_nms/build/temp.linux-x86_64-3.7/src/iou3d_cpu.o: compile /home/xingcheng/Workspace/OpenPCDet/pcdet/ops/iou3d_nms/src/iou3d_cpu.cpp 22 | build /home/xingcheng/Workspace/OpenPCDet/pcdet/ops/iou3d_nms/build/temp.linux-x86_64-3.7/src/iou3d_nms_api.o: compile /home/xingcheng/Workspace/OpenPCDet/pcdet/ops/iou3d_nms/src/iou3d_nms_api.cpp 23 | build /home/xingcheng/Workspace/OpenPCDet/pcdet/ops/iou3d_nms/build/temp.linux-x86_64-3.7/src/iou3d_nms.o: compile /home/xingcheng/Workspace/OpenPCDet/pcdet/ops/iou3d_nms/src/iou3d_nms.cpp 24 | build /home/xingcheng/Workspace/OpenPCDet/pcdet/ops/iou3d_nms/build/temp.linux-x86_64-3.7/src/iou3d_nms_kernel.o: cuda_compile /home/xingcheng/Workspace/OpenPCDet/pcdet/ops/iou3d_nms/src/iou3d_nms_kernel.cu 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/build/temp.linux-x86_64-3.7/src/iou3d_cpu.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/iou3d_nms/build/temp.linux-x86_64-3.7/src/iou3d_cpu.o -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/build/temp.linux-x86_64-3.7/src/iou3d_nms.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/iou3d_nms/build/temp.linux-x86_64-3.7/src/iou3d_nms.o -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/build/temp.linux-x86_64-3.7/src/iou3d_nms_api.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/iou3d_nms/build/temp.linux-x86_64-3.7/src/iou3d_nms_api.o -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/build/temp.linux-x86_64-3.7/src/iou3d_nms_kernel.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/iou3d_nms/build/temp.linux-x86_64-3.7/src/iou3d_nms_kernel.o -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/iou3d_nms.egg-info/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 1.0 2 | Name: iou3d-nms 3 | Version: 0.0.0 4 | Summary: UNKNOWN 5 | Home-page: UNKNOWN 6 | Author: UNKNOWN 7 | Author-email: UNKNOWN 8 | License: UNKNOWN 9 | Description: UNKNOWN 10 | Platform: UNKNOWN 11 | -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/iou3d_nms.egg-info/SOURCES.txt: -------------------------------------------------------------------------------- 1 | setup.py 2 | iou3d_nms.egg-info/PKG-INFO 3 | iou3d_nms.egg-info/SOURCES.txt 4 | iou3d_nms.egg-info/dependency_links.txt 5 | iou3d_nms.egg-info/top_level.txt 6 | src/iou3d_cpu.cpp 7 | src/iou3d_nms.cpp 8 | src/iou3d_nms_api.cpp 9 | src/iou3d_nms_kernel.cu -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/iou3d_nms.egg-info/dependency_links.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/iou3d_nms.egg-info/top_level.txt: -------------------------------------------------------------------------------- 1 | iou3d_nms_cuda 2 | -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/iou3d_nms_cuda.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/iou3d_nms/iou3d_nms_cuda.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/iou3d_nms_cuda.cpython-37m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/iou3d_nms/iou3d_nms_cuda.cpython-37m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/iou3d_nms_cuda.cpython-38-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/iou3d_nms/iou3d_nms_cuda.cpython-38-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/iou3d_nms_utils.py: -------------------------------------------------------------------------------- 1 | """ 2 | 3D IoU Calculation and Rotated NMS 3 | Written by Shaoshuai Shi 4 | All Rights Reserved 2019-2020. 5 | """ 6 | import torch 7 | 8 | from ...utils import common_utils 9 | from . import iou3d_nms_cuda 10 | 11 | 12 | def boxes_bev_iou_cpu(boxes_a, boxes_b): 13 | """ 14 | Args: 15 | boxes_a: (N, 7) [x, y, z, dx, dy, dz, heading] 16 | boxes_b: (N, 7) [x, y, z, dx, dy, dz, heading] 17 | 18 | Returns: 19 | 20 | """ 21 | boxes_a, is_numpy = common_utils.check_numpy_to_torch(boxes_a) 22 | boxes_b, is_numpy = common_utils.check_numpy_to_torch(boxes_b) 23 | assert not (boxes_a.is_cuda or boxes_b.is_cuda), 'Only support CPU tensors' 24 | assert boxes_a.shape[1] == 7 and boxes_b.shape[1] == 7 25 | ans_iou = boxes_a.new_zeros(torch.Size((boxes_a.shape[0], boxes_b.shape[0]))) 26 | iou3d_nms_cuda.boxes_iou_bev_cpu(boxes_a.contiguous(), boxes_b.contiguous(), ans_iou) 27 | 28 | return ans_iou.numpy() if is_numpy else ans_iou 29 | 30 | 31 | def boxes_iou_bev(boxes_a, boxes_b): 32 | """ 33 | Args: 34 | boxes_a: (N, 7) [x, y, z, dx, dy, dz, heading] 35 | boxes_b: (N, 7) [x, y, z, dx, dy, dz, heading] 36 | 37 | Returns: 38 | ans_iou: (N, M) 39 | """ 40 | assert boxes_a.shape[1] == boxes_b.shape[1] == 7 41 | ans_iou = torch.cuda.FloatTensor(torch.Size((boxes_a.shape[0], boxes_b.shape[0]))).zero_() 42 | 43 | iou3d_nms_cuda.boxes_iou_bev_gpu(boxes_a.contiguous(), boxes_b.contiguous(), ans_iou) 44 | 45 | return ans_iou 46 | 47 | 48 | def boxes_iou3d_gpu(boxes_a, boxes_b): 49 | """ 50 | Args: 51 | boxes_a: (N, 7) [x, y, z, dx, dy, dz, heading] 52 | boxes_b: (N, 7) [x, y, z, dx, dy, dz, heading] 53 | 54 | Returns: 55 | ans_iou: (N, M) 56 | """ 57 | assert boxes_a.shape[1] == boxes_b.shape[1] == 7 58 | 59 | # height overlap 60 | boxes_a_height_max = (boxes_a[:, 2] + boxes_a[:, 5] / 2).view(-1, 1) 61 | boxes_a_height_min = (boxes_a[:, 2] - boxes_a[:, 5] / 2).view(-1, 1) 62 | boxes_b_height_max = (boxes_b[:, 2] + boxes_b[:, 5] / 2).view(1, -1) 63 | boxes_b_height_min = (boxes_b[:, 2] - boxes_b[:, 5] / 2).view(1, -1) 64 | 65 | # bev overlap 66 | overlaps_bev = torch.cuda.FloatTensor(torch.Size((boxes_a.shape[0], boxes_b.shape[0]))).zero_() # (N, M) 67 | iou3d_nms_cuda.boxes_overlap_bev_gpu(boxes_a.contiguous(), boxes_b.contiguous(), overlaps_bev) 68 | 69 | max_of_min = torch.max(boxes_a_height_min, boxes_b_height_min) 70 | min_of_max = torch.min(boxes_a_height_max, boxes_b_height_max) 71 | overlaps_h = torch.clamp(min_of_max - max_of_min, min=0) 72 | 73 | # 3d iou 74 | overlaps_3d = overlaps_bev * overlaps_h 75 | 76 | vol_a = (boxes_a[:, 3] * boxes_a[:, 4] * boxes_a[:, 5]).view(-1, 1) 77 | vol_b = (boxes_b[:, 3] * boxes_b[:, 4] * boxes_b[:, 5]).view(1, -1) 78 | 79 | iou3d = overlaps_3d / torch.clamp(vol_a + vol_b - overlaps_3d, min=1e-6) 80 | 81 | return iou3d 82 | 83 | 84 | def nms_gpu(boxes, scores, thresh, pre_maxsize=None, **kwargs): 85 | """ 86 | :param boxes: (N, 7) [x, y, z, dx, dy, dz, heading] 87 | :param scores: (N) 88 | :param thresh: 89 | :return: 90 | """ 91 | assert boxes.shape[1] == 7 92 | order = scores.sort(0, descending=True)[1] 93 | if pre_maxsize is not None: 94 | order = order[:pre_maxsize] 95 | 96 | boxes = boxes[order].contiguous() 97 | keep = torch.LongTensor(boxes.size(0)) 98 | num_out = iou3d_nms_cuda.nms_gpu(boxes, keep, thresh) 99 | return order[keep[:num_out].cuda()].contiguous(), None 100 | 101 | 102 | def nms_normal_gpu(boxes, scores, thresh, **kwargs): 103 | """ 104 | :param boxes: (N, 7) [x, y, z, dx, dy, dz, heading] 105 | :param scores: (N) 106 | :param thresh: 107 | :return: 108 | """ 109 | assert boxes.shape[1] == 7 110 | order = scores.sort(0, descending=True)[1] 111 | 112 | boxes = boxes[order].contiguous() 113 | 114 | keep = torch.LongTensor(boxes.size(0)) 115 | num_out = iou3d_nms_cuda.nms_normal_gpu(boxes, keep, thresh) 116 | return order[keep[:num_out].cuda()].contiguous(), None 117 | -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | from torch.utils.cpp_extension import BuildExtension, CUDAExtension 3 | 4 | setup( 5 | name='iou3d_nms', 6 | ext_modules=[ 7 | CUDAExtension('iou3d_nms_cuda', [ 8 | 'src/iou3d_cpu.cpp', 9 | 'src/iou3d_nms_api.cpp', 10 | 'src/iou3d_nms.cpp', 11 | 'src/iou3d_nms_kernel.cu', 12 | ], 13 | extra_compile_args={'cxx': ['-g'], 14 | 'nvcc': ['-O2']}) 15 | ], 16 | cmdclass={'build_ext': BuildExtension}) 17 | -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/src/iou3d_cpu.h: -------------------------------------------------------------------------------- 1 | #ifndef IOU3D_CPU_H 2 | #define IOU3D_CPU_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | int boxes_iou_bev_cpu(at::Tensor boxes_a_tensor, at::Tensor boxes_b_tensor, at::Tensor ans_iou_tensor); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/src/iou3d_nms.h: -------------------------------------------------------------------------------- 1 | #ifndef IOU3D_NMS_H 2 | #define IOU3D_NMS_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | int boxes_overlap_bev_gpu(at::Tensor boxes_a, at::Tensor boxes_b, at::Tensor ans_overlap); 10 | int boxes_iou_bev_gpu(at::Tensor boxes_a, at::Tensor boxes_b, at::Tensor ans_iou); 11 | int nms_gpu(at::Tensor boxes, at::Tensor keep, float nms_overlap_thresh); 12 | int nms_normal_gpu(at::Tensor boxes, at::Tensor keep, float nms_overlap_thresh); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /pcdet/ops/iou3d_nms/src/iou3d_nms_api.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "iou3d_cpu.h" 8 | #include "iou3d_nms.h" 9 | 10 | 11 | PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { 12 | m.def("boxes_overlap_bev_gpu", &boxes_overlap_bev_gpu, "oriented boxes overlap"); 13 | m.def("boxes_iou_bev_gpu", &boxes_iou_bev_gpu, "oriented boxes iou"); 14 | m.def("nms_gpu", &nms_gpu, "oriented nms gpu"); 15 | m.def("nms_normal_gpu", &nms_normal_gpu, "nms gpu"); 16 | m.def("boxes_iou_bev_cpu", &boxes_iou_bev_cpu, "oriented boxes iou"); 17 | } 18 | -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_batch/__pycache__/pointnet2_modules.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/pointnet2/pointnet2_batch/__pycache__/pointnet2_modules.cpython-36.pyc -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_batch/__pycache__/pointnet2_modules.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/pointnet2/pointnet2_batch/__pycache__/pointnet2_modules.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_batch/__pycache__/pointnet2_modules.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/pointnet2/pointnet2_batch/__pycache__/pointnet2_modules.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_batch/__pycache__/pointnet2_utils.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/pointnet2/pointnet2_batch/__pycache__/pointnet2_utils.cpython-36.pyc -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_batch/__pycache__/pointnet2_utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/pointnet2/pointnet2_batch/__pycache__/pointnet2_utils.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_batch/__pycache__/pointnet2_utils.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/pointnet2/pointnet2_batch/__pycache__/pointnet2_utils.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_batch/pointnet2_batch_cuda.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/pointnet2/pointnet2_batch/pointnet2_batch_cuda.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_batch/pointnet2_batch_cuda.cpython-37m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/pointnet2/pointnet2_batch/pointnet2_batch_cuda.cpython-37m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_batch/pointnet2_batch_cuda.cpython-38-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/pointnet2/pointnet2_batch/pointnet2_batch_cuda.cpython-38-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_batch/src/ball_query.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | batch version of ball query, modified from the original implementation of official PointNet++ codes. 3 | Written by Shaoshuai Shi 4 | All Rights Reserved 2018. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "ball_query_gpu.h" 14 | 15 | extern THCState *state; 16 | 17 | #define CHECK_CUDA(x) do { \ 18 | if (!x.type().is_cuda()) { \ 19 | fprintf(stderr, "%s must be CUDA tensor at %s:%d\n", #x, __FILE__, __LINE__); \ 20 | exit(-1); \ 21 | } \ 22 | } while (0) 23 | #define CHECK_CONTIGUOUS(x) do { \ 24 | if (!x.is_contiguous()) { \ 25 | fprintf(stderr, "%s must be contiguous tensor at %s:%d\n", #x, __FILE__, __LINE__); \ 26 | exit(-1); \ 27 | } \ 28 | } while (0) 29 | #define CHECK_INPUT(x) CHECK_CUDA(x);CHECK_CONTIGUOUS(x) 30 | 31 | 32 | int ball_query_wrapper_fast(int b, int n, int m, float radius, int nsample, 33 | at::Tensor new_xyz_tensor, at::Tensor xyz_tensor, at::Tensor idx_tensor) { 34 | CHECK_INPUT(new_xyz_tensor); 35 | CHECK_INPUT(xyz_tensor); 36 | const float *new_xyz = new_xyz_tensor.data(); 37 | const float *xyz = xyz_tensor.data(); 38 | int *idx = idx_tensor.data(); 39 | 40 | ball_query_kernel_launcher_fast(b, n, m, radius, nsample, new_xyz, xyz, idx); 41 | return 1; 42 | } 43 | -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_batch/src/ball_query_gpu.cu: -------------------------------------------------------------------------------- 1 | /* 2 | batch version of ball query, modified from the original implementation of official PointNet++ codes. 3 | Written by Shaoshuai Shi 4 | All Rights Reserved 2018. 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #include "ball_query_gpu.h" 12 | #include "cuda_utils.h" 13 | 14 | 15 | __global__ void ball_query_kernel_fast(int b, int n, int m, float radius, int nsample, 16 | const float *__restrict__ new_xyz, const float *__restrict__ xyz, int *__restrict__ idx) { 17 | // new_xyz: (B, M, 3) 18 | // xyz: (B, N, 3) 19 | // output: 20 | // idx: (B, M, nsample) 21 | int bs_idx = blockIdx.y; 22 | int pt_idx = blockIdx.x * blockDim.x + threadIdx.x; 23 | if (bs_idx >= b || pt_idx >= m) return; 24 | 25 | new_xyz += bs_idx * m * 3 + pt_idx * 3; 26 | xyz += bs_idx * n * 3; 27 | idx += bs_idx * m * nsample + pt_idx * nsample; 28 | 29 | float radius2 = radius * radius; 30 | float new_x = new_xyz[0]; 31 | float new_y = new_xyz[1]; 32 | float new_z = new_xyz[2]; 33 | 34 | int cnt = 0; 35 | for (int k = 0; k < n; ++k) { 36 | float x = xyz[k * 3 + 0]; 37 | float y = xyz[k * 3 + 1]; 38 | float z = xyz[k * 3 + 2]; 39 | float d2 = (new_x - x) * (new_x - x) + (new_y - y) * (new_y - y) + (new_z - z) * (new_z - z); 40 | if (d2 < radius2){ 41 | if (cnt == 0){ 42 | for (int l = 0; l < nsample; ++l) { 43 | idx[l] = k; 44 | } 45 | } 46 | idx[cnt] = k; 47 | ++cnt; 48 | if (cnt >= nsample) break; 49 | } 50 | } 51 | } 52 | 53 | 54 | void ball_query_kernel_launcher_fast(int b, int n, int m, float radius, int nsample, \ 55 | const float *new_xyz, const float *xyz, int *idx) { 56 | // new_xyz: (B, M, 3) 57 | // xyz: (B, N, 3) 58 | // output: 59 | // idx: (B, M, nsample) 60 | 61 | cudaError_t err; 62 | 63 | dim3 blocks(DIVUP(m, THREADS_PER_BLOCK), b); // blockIdx.x(col), blockIdx.y(row) 64 | dim3 threads(THREADS_PER_BLOCK); 65 | 66 | ball_query_kernel_fast<<>>(b, n, m, radius, nsample, new_xyz, xyz, idx); 67 | // cudaDeviceSynchronize(); // for using printf in kernel function 68 | err = cudaGetLastError(); 69 | if (cudaSuccess != err) { 70 | fprintf(stderr, "CUDA kernel failed : %s\n", cudaGetErrorString(err)); 71 | exit(-1); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_batch/src/ball_query_gpu.h: -------------------------------------------------------------------------------- 1 | #ifndef _BALL_QUERY_GPU_H 2 | #define _BALL_QUERY_GPU_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | int ball_query_wrapper_fast(int b, int n, int m, float radius, int nsample, 10 | at::Tensor new_xyz_tensor, at::Tensor xyz_tensor, at::Tensor idx_tensor); 11 | 12 | void ball_query_kernel_launcher_fast(int b, int n, int m, float radius, int nsample, 13 | const float *xyz, const float *new_xyz, int *idx); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_batch/src/cuda_utils.h: -------------------------------------------------------------------------------- 1 | #ifndef _CUDA_UTILS_H 2 | #define _CUDA_UTILS_H 3 | 4 | #include 5 | 6 | #define TOTAL_THREADS 1024 7 | #define THREADS_PER_BLOCK 256 8 | #define DIVUP(m,n) ((m) / (n) + ((m) % (n) > 0)) 9 | 10 | inline int opt_n_threads(int work_size) { 11 | const int pow_2 = std::log(static_cast(work_size)) / std::log(2.0); 12 | 13 | return max(min(1 << pow_2, TOTAL_THREADS), 1); 14 | } 15 | #endif 16 | -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_batch/src/group_points.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | batch version of point grouping, modified from the original implementation of official PointNet++ codes. 3 | Written by Shaoshuai Shi 4 | All Rights Reserved 2018. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "group_points_gpu.h" 14 | 15 | extern THCState *state; 16 | 17 | 18 | int group_points_grad_wrapper_fast(int b, int c, int n, int npoints, int nsample, 19 | at::Tensor grad_out_tensor, at::Tensor idx_tensor, at::Tensor grad_points_tensor) { 20 | 21 | float *grad_points = grad_points_tensor.data(); 22 | const int *idx = idx_tensor.data(); 23 | const float *grad_out = grad_out_tensor.data(); 24 | 25 | group_points_grad_kernel_launcher_fast(b, c, n, npoints, nsample, grad_out, idx, grad_points); 26 | return 1; 27 | } 28 | 29 | 30 | int group_points_wrapper_fast(int b, int c, int n, int npoints, int nsample, 31 | at::Tensor points_tensor, at::Tensor idx_tensor, at::Tensor out_tensor) { 32 | 33 | const float *points = points_tensor.data(); 34 | const int *idx = idx_tensor.data(); 35 | float *out = out_tensor.data(); 36 | 37 | group_points_kernel_launcher_fast(b, c, n, npoints, nsample, points, idx, out); 38 | return 1; 39 | } 40 | -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_batch/src/group_points_gpu.cu: -------------------------------------------------------------------------------- 1 | /* 2 | batch version of point grouping, modified from the original implementation of official PointNet++ codes. 3 | Written by Shaoshuai Shi 4 | All Rights Reserved 2018. 5 | */ 6 | 7 | #include 8 | #include 9 | 10 | #include "cuda_utils.h" 11 | #include "group_points_gpu.h" 12 | 13 | 14 | __global__ void group_points_grad_kernel_fast(int b, int c, int n, int npoints, int nsample, 15 | const float *__restrict__ grad_out, const int *__restrict__ idx, float *__restrict__ grad_points) { 16 | // grad_out: (B, C, npoints, nsample) 17 | // idx: (B, npoints, nsample) 18 | // output: 19 | // grad_points: (B, C, N) 20 | int bs_idx = blockIdx.z; 21 | int c_idx = blockIdx.y; 22 | int index = blockIdx.x * blockDim.x + threadIdx.x; 23 | int pt_idx = index / nsample; 24 | if (bs_idx >= b || c_idx >= c || pt_idx >= npoints) return; 25 | 26 | int sample_idx = index % nsample; 27 | grad_out += bs_idx * c * npoints * nsample + c_idx * npoints * nsample + pt_idx * nsample + sample_idx; 28 | idx += bs_idx * npoints * nsample + pt_idx * nsample + sample_idx; 29 | 30 | atomicAdd(grad_points + bs_idx * c * n + c_idx * n + idx[0] , grad_out[0]); 31 | } 32 | 33 | void group_points_grad_kernel_launcher_fast(int b, int c, int n, int npoints, int nsample, 34 | const float *grad_out, const int *idx, float *grad_points) { 35 | // grad_out: (B, C, npoints, nsample) 36 | // idx: (B, npoints, nsample) 37 | // output: 38 | // grad_points: (B, C, N) 39 | cudaError_t err; 40 | dim3 blocks(DIVUP(npoints * nsample, THREADS_PER_BLOCK), c, b); // blockIdx.x(col), blockIdx.y(row) 41 | dim3 threads(THREADS_PER_BLOCK); 42 | 43 | group_points_grad_kernel_fast<<>>(b, c, n, npoints, nsample, grad_out, idx, grad_points); 44 | 45 | err = cudaGetLastError(); 46 | if (cudaSuccess != err) { 47 | fprintf(stderr, "CUDA kernel failed : %s\n", cudaGetErrorString(err)); 48 | exit(-1); 49 | } 50 | } 51 | 52 | 53 | __global__ void group_points_kernel_fast(int b, int c, int n, int npoints, int nsample, 54 | const float *__restrict__ points, const int *__restrict__ idx, float *__restrict__ out) { 55 | // points: (B, C, N) 56 | // idx: (B, npoints, nsample) 57 | // output: 58 | // out: (B, C, npoints, nsample) 59 | int bs_idx = blockIdx.z; 60 | int c_idx = blockIdx.y; 61 | int index = blockIdx.x * blockDim.x + threadIdx.x; 62 | int pt_idx = index / nsample; 63 | if (bs_idx >= b || c_idx >= c || pt_idx >= npoints) return; 64 | 65 | int sample_idx = index % nsample; 66 | 67 | idx += bs_idx * npoints * nsample + pt_idx * nsample + sample_idx; 68 | int in_idx = bs_idx * c * n + c_idx * n + idx[0]; 69 | int out_idx = bs_idx * c * npoints * nsample + c_idx * npoints * nsample + pt_idx * nsample + sample_idx; 70 | 71 | out[out_idx] = points[in_idx]; 72 | } 73 | 74 | 75 | void group_points_kernel_launcher_fast(int b, int c, int n, int npoints, int nsample, 76 | const float *points, const int *idx, float *out) { 77 | // points: (B, C, N) 78 | // idx: (B, npoints, nsample) 79 | // output: 80 | // out: (B, C, npoints, nsample) 81 | cudaError_t err; 82 | dim3 blocks(DIVUP(npoints * nsample, THREADS_PER_BLOCK), c, b); // blockIdx.x(col), blockIdx.y(row) 83 | dim3 threads(THREADS_PER_BLOCK); 84 | 85 | group_points_kernel_fast<<>>(b, c, n, npoints, nsample, points, idx, out); 86 | // cudaDeviceSynchronize(); // for using printf in kernel function 87 | err = cudaGetLastError(); 88 | if (cudaSuccess != err) { 89 | fprintf(stderr, "CUDA kernel failed : %s\n", cudaGetErrorString(err)); 90 | exit(-1); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_batch/src/group_points_gpu.h: -------------------------------------------------------------------------------- 1 | #ifndef _GROUP_POINTS_GPU_H 2 | #define _GROUP_POINTS_GPU_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | int group_points_wrapper_fast(int b, int c, int n, int npoints, int nsample, 11 | at::Tensor points_tensor, at::Tensor idx_tensor, at::Tensor out_tensor); 12 | 13 | void group_points_kernel_launcher_fast(int b, int c, int n, int npoints, int nsample, 14 | const float *points, const int *idx, float *out); 15 | 16 | int group_points_grad_wrapper_fast(int b, int c, int n, int npoints, int nsample, 17 | at::Tensor grad_out_tensor, at::Tensor idx_tensor, at::Tensor grad_points_tensor); 18 | 19 | void group_points_grad_kernel_launcher_fast(int b, int c, int n, int npoints, int nsample, 20 | const float *grad_out, const int *idx, float *grad_points); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_batch/src/interpolate.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | batch version of point interpolation, modified from the original implementation of official PointNet++ codes. 3 | Written by Shaoshuai Shi 4 | All Rights Reserved 2018. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "interpolate_gpu.h" 17 | 18 | extern THCState *state; 19 | 20 | 21 | void three_nn_wrapper_fast(int b, int n, int m, at::Tensor unknown_tensor, 22 | at::Tensor known_tensor, at::Tensor dist2_tensor, at::Tensor idx_tensor) { 23 | const float *unknown = unknown_tensor.data(); 24 | const float *known = known_tensor.data(); 25 | float *dist2 = dist2_tensor.data(); 26 | int *idx = idx_tensor.data(); 27 | 28 | three_nn_kernel_launcher_fast(b, n, m, unknown, known, dist2, idx); 29 | } 30 | 31 | 32 | void three_interpolate_wrapper_fast(int b, int c, int m, int n, 33 | at::Tensor points_tensor, 34 | at::Tensor idx_tensor, 35 | at::Tensor weight_tensor, 36 | at::Tensor out_tensor) { 37 | 38 | const float *points = points_tensor.data(); 39 | const float *weight = weight_tensor.data(); 40 | float *out = out_tensor.data(); 41 | const int *idx = idx_tensor.data(); 42 | 43 | three_interpolate_kernel_launcher_fast(b, c, m, n, points, idx, weight, out); 44 | } 45 | 46 | void three_interpolate_grad_wrapper_fast(int b, int c, int n, int m, 47 | at::Tensor grad_out_tensor, 48 | at::Tensor idx_tensor, 49 | at::Tensor weight_tensor, 50 | at::Tensor grad_points_tensor) { 51 | 52 | const float *grad_out = grad_out_tensor.data(); 53 | const float *weight = weight_tensor.data(); 54 | float *grad_points = grad_points_tensor.data(); 55 | const int *idx = idx_tensor.data(); 56 | 57 | three_interpolate_grad_kernel_launcher_fast(b, c, n, m, grad_out, idx, weight, grad_points); 58 | } 59 | -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_batch/src/interpolate_gpu.h: -------------------------------------------------------------------------------- 1 | #ifndef _INTERPOLATE_GPU_H 2 | #define _INTERPOLATE_GPU_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | void three_nn_wrapper_fast(int b, int n, int m, at::Tensor unknown_tensor, 11 | at::Tensor known_tensor, at::Tensor dist2_tensor, at::Tensor idx_tensor); 12 | 13 | void three_nn_kernel_launcher_fast(int b, int n, int m, const float *unknown, 14 | const float *known, float *dist2, int *idx); 15 | 16 | 17 | void three_interpolate_wrapper_fast(int b, int c, int m, int n, at::Tensor points_tensor, 18 | at::Tensor idx_tensor, at::Tensor weight_tensor, at::Tensor out_tensor); 19 | 20 | void three_interpolate_kernel_launcher_fast(int b, int c, int m, int n, 21 | const float *points, const int *idx, const float *weight, float *out); 22 | 23 | 24 | void three_interpolate_grad_wrapper_fast(int b, int c, int n, int m, at::Tensor grad_out_tensor, 25 | at::Tensor idx_tensor, at::Tensor weight_tensor, at::Tensor grad_points_tensor); 26 | 27 | void three_interpolate_grad_kernel_launcher_fast(int b, int c, int n, int m, const float *grad_out, 28 | const int *idx, const float *weight, float *grad_points); 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_batch/src/pointnet2_api.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "ball_query_gpu.h" 5 | #include "group_points_gpu.h" 6 | #include "sampling_gpu.h" 7 | #include "interpolate_gpu.h" 8 | 9 | 10 | PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { 11 | m.def("ball_query_wrapper", &ball_query_wrapper_fast, "ball_query_wrapper_fast"); 12 | 13 | m.def("group_points_wrapper", &group_points_wrapper_fast, "group_points_wrapper_fast"); 14 | m.def("group_points_grad_wrapper", &group_points_grad_wrapper_fast, "group_points_grad_wrapper_fast"); 15 | 16 | m.def("gather_points_wrapper", &gather_points_wrapper_fast, "gather_points_wrapper_fast"); 17 | m.def("gather_points_grad_wrapper", &gather_points_grad_wrapper_fast, "gather_points_grad_wrapper_fast"); 18 | 19 | m.def("furthest_point_sampling_wrapper", &furthest_point_sampling_wrapper, "furthest_point_sampling_wrapper"); 20 | 21 | m.def("three_nn_wrapper", &three_nn_wrapper_fast, "three_nn_wrapper_fast"); 22 | m.def("three_interpolate_wrapper", &three_interpolate_wrapper_fast, "three_interpolate_wrapper_fast"); 23 | m.def("three_interpolate_grad_wrapper", &three_interpolate_grad_wrapper_fast, "three_interpolate_grad_wrapper_fast"); 24 | } 25 | -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_batch/src/sampling.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | batch version of point sampling and gathering, modified from the original implementation of official PointNet++ codes. 3 | Written by Shaoshuai Shi 4 | All Rights Reserved 2018. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "sampling_gpu.h" 14 | 15 | extern THCState *state; 16 | 17 | 18 | int gather_points_wrapper_fast(int b, int c, int n, int npoints, 19 | at::Tensor points_tensor, at::Tensor idx_tensor, at::Tensor out_tensor){ 20 | const float *points = points_tensor.data(); 21 | const int *idx = idx_tensor.data(); 22 | float *out = out_tensor.data(); 23 | 24 | gather_points_kernel_launcher_fast(b, c, n, npoints, points, idx, out); 25 | return 1; 26 | } 27 | 28 | 29 | int gather_points_grad_wrapper_fast(int b, int c, int n, int npoints, 30 | at::Tensor grad_out_tensor, at::Tensor idx_tensor, at::Tensor grad_points_tensor) { 31 | 32 | const float *grad_out = grad_out_tensor.data(); 33 | const int *idx = idx_tensor.data(); 34 | float *grad_points = grad_points_tensor.data(); 35 | 36 | gather_points_grad_kernel_launcher_fast(b, c, n, npoints, grad_out, idx, grad_points); 37 | return 1; 38 | } 39 | 40 | 41 | int furthest_point_sampling_wrapper(int b, int n, int m, 42 | at::Tensor points_tensor, at::Tensor temp_tensor, at::Tensor idx_tensor) { 43 | 44 | const float *points = points_tensor.data(); 45 | float *temp = temp_tensor.data(); 46 | int *idx = idx_tensor.data(); 47 | 48 | furthest_point_sampling_kernel_launcher(b, n, m, points, temp, idx); 49 | return 1; 50 | } 51 | -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_batch/src/sampling_gpu.h: -------------------------------------------------------------------------------- 1 | #ifndef _SAMPLING_GPU_H 2 | #define _SAMPLING_GPU_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | int gather_points_wrapper_fast(int b, int c, int n, int npoints, 10 | at::Tensor points_tensor, at::Tensor idx_tensor, at::Tensor out_tensor); 11 | 12 | void gather_points_kernel_launcher_fast(int b, int c, int n, int npoints, 13 | const float *points, const int *idx, float *out); 14 | 15 | 16 | int gather_points_grad_wrapper_fast(int b, int c, int n, int npoints, 17 | at::Tensor grad_out_tensor, at::Tensor idx_tensor, at::Tensor grad_points_tensor); 18 | 19 | void gather_points_grad_kernel_launcher_fast(int b, int c, int n, int npoints, 20 | const float *grad_out, const int *idx, float *grad_points); 21 | 22 | 23 | int furthest_point_sampling_wrapper(int b, int n, int m, 24 | at::Tensor points_tensor, at::Tensor temp_tensor, at::Tensor idx_tensor); 25 | 26 | void furthest_point_sampling_kernel_launcher(int b, int n, int m, 27 | const float *dataset, float *temp, int *idxs); 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_stack/__pycache__/pointnet2_modules.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/pointnet2/pointnet2_stack/__pycache__/pointnet2_modules.cpython-36.pyc -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_stack/__pycache__/pointnet2_modules.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/pointnet2/pointnet2_stack/__pycache__/pointnet2_modules.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_stack/__pycache__/pointnet2_modules.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/pointnet2/pointnet2_stack/__pycache__/pointnet2_modules.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_stack/__pycache__/pointnet2_utils.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/pointnet2/pointnet2_stack/__pycache__/pointnet2_utils.cpython-36.pyc -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_stack/__pycache__/pointnet2_utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/pointnet2/pointnet2_stack/__pycache__/pointnet2_utils.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_stack/__pycache__/pointnet2_utils.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/pointnet2/pointnet2_stack/__pycache__/pointnet2_utils.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_stack/pointnet2_stack_cuda.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/pointnet2/pointnet2_stack/pointnet2_stack_cuda.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_stack/pointnet2_stack_cuda.cpython-37m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/pointnet2/pointnet2_stack/pointnet2_stack_cuda.cpython-37m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_stack/pointnet2_stack_cuda.cpython-38-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/pointnet2/pointnet2_stack/pointnet2_stack_cuda.cpython-38-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_stack/src/ball_query.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Stacked-batch-data version of ball query, modified from the original implementation of official PointNet++ codes. 3 | Written by Shaoshuai Shi 4 | All Rights Reserved 2019-2020. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "ball_query_gpu.h" 14 | 15 | extern THCState *state; 16 | 17 | #define CHECK_CUDA(x) do { \ 18 | if (!x.type().is_cuda()) { \ 19 | fprintf(stderr, "%s must be CUDA tensor at %s:%d\n", #x, __FILE__, __LINE__); \ 20 | exit(-1); \ 21 | } \ 22 | } while (0) 23 | #define CHECK_CONTIGUOUS(x) do { \ 24 | if (!x.is_contiguous()) { \ 25 | fprintf(stderr, "%s must be contiguous tensor at %s:%d\n", #x, __FILE__, __LINE__); \ 26 | exit(-1); \ 27 | } \ 28 | } while (0) 29 | #define CHECK_INPUT(x) CHECK_CUDA(x);CHECK_CONTIGUOUS(x) 30 | 31 | int ball_query_wrapper_stack(int B, int M, float radius, int nsample, 32 | at::Tensor new_xyz_tensor, at::Tensor new_xyz_batch_cnt_tensor, 33 | at::Tensor xyz_tensor, at::Tensor xyz_batch_cnt_tensor, at::Tensor idx_tensor) { 34 | CHECK_INPUT(new_xyz_tensor); 35 | CHECK_INPUT(xyz_tensor); 36 | CHECK_INPUT(new_xyz_batch_cnt_tensor); 37 | CHECK_INPUT(xyz_batch_cnt_tensor); 38 | 39 | const float *new_xyz = new_xyz_tensor.data(); 40 | const float *xyz = xyz_tensor.data(); 41 | const int *new_xyz_batch_cnt = new_xyz_batch_cnt_tensor.data(); 42 | const int *xyz_batch_cnt = xyz_batch_cnt_tensor.data(); 43 | int *idx = idx_tensor.data(); 44 | 45 | ball_query_kernel_launcher_stack(B, M, radius, nsample, new_xyz, new_xyz_batch_cnt, xyz, xyz_batch_cnt, idx); 46 | return 1; 47 | } 48 | -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_stack/src/ball_query_gpu.cu: -------------------------------------------------------------------------------- 1 | /* 2 | Stacked-batch-data version of ball query, modified from the original implementation of official PointNet++ codes. 3 | Written by Shaoshuai Shi 4 | All Rights Reserved 2019-2020. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include "ball_query_gpu.h" 13 | #include "cuda_utils.h" 14 | 15 | 16 | __global__ void ball_query_kernel_stack(int B, int M, float radius, int nsample, \ 17 | const float *new_xyz, const int *new_xyz_batch_cnt, const float *xyz, const int *xyz_batch_cnt, int *idx) { 18 | // :param xyz: (N1 + N2 ..., 3) xyz coordinates of the features 19 | // :param xyz_batch_cnt: (batch_size), [N1, N2, ...] 20 | // :param new_xyz: (M1 + M2 ..., 3) centers of the ball query 21 | // :param new_xyz_batch_cnt: (batch_size), [M1, M2, ...] 22 | // output: 23 | // idx: (M, nsample) 24 | int pt_idx = blockIdx.x * blockDim.x + threadIdx.x; 25 | if (pt_idx >= M) return; 26 | 27 | int bs_idx = 0, pt_cnt = new_xyz_batch_cnt[0]; 28 | for (int k = 1; k < B; k++){ 29 | if (pt_idx < pt_cnt) break; 30 | pt_cnt += new_xyz_batch_cnt[k]; 31 | bs_idx = k; 32 | } 33 | 34 | int xyz_batch_start_idx = 0; 35 | for (int k = 0; k < bs_idx; k++) xyz_batch_start_idx += xyz_batch_cnt[k]; 36 | // for (int k = 0; k < bs_idx; k++) new_xyz_batch_start_idx += new_xyz_batch_cnt[k]; 37 | 38 | new_xyz += pt_idx * 3; 39 | xyz += xyz_batch_start_idx * 3; 40 | idx += pt_idx * nsample; 41 | 42 | float radius2 = radius * radius; 43 | float new_x = new_xyz[0]; 44 | float new_y = new_xyz[1]; 45 | float new_z = new_xyz[2]; 46 | int n = xyz_batch_cnt[bs_idx]; 47 | 48 | int cnt = 0; 49 | for (int k = 0; k < n; ++k) { 50 | float x = xyz[k * 3 + 0]; 51 | float y = xyz[k * 3 + 1]; 52 | float z = xyz[k * 3 + 2]; 53 | float d2 = (new_x - x) * (new_x - x) + (new_y - y) * (new_y - y) + (new_z - z) * (new_z - z); 54 | if (d2 < radius2){ 55 | if (cnt == 0){ 56 | for (int l = 0; l < nsample; ++l) { 57 | idx[l] = k; 58 | } 59 | } 60 | idx[cnt] = k; 61 | ++cnt; 62 | if (cnt >= nsample) break; 63 | } 64 | } 65 | if (cnt == 0) idx[0] = -1; 66 | } 67 | 68 | 69 | void ball_query_kernel_launcher_stack(int B, int M, float radius, int nsample, 70 | const float *new_xyz, const int *new_xyz_batch_cnt, const float *xyz, const int *xyz_batch_cnt, int *idx){ 71 | // :param xyz: (N1 + N2 ..., 3) xyz coordinates of the features 72 | // :param xyz_batch_cnt: (batch_size), [N1, N2, ...] 73 | // :param new_xyz: (M1 + M2 ..., 3) centers of the ball query 74 | // :param new_xyz_batch_cnt: (batch_size), [M1, M2, ...] 75 | // output: 76 | // idx: (M, nsample) 77 | 78 | cudaError_t err; 79 | 80 | dim3 blocks(DIVUP(M, THREADS_PER_BLOCK)); // blockIdx.x(col), blockIdx.y(row) 81 | dim3 threads(THREADS_PER_BLOCK); 82 | 83 | ball_query_kernel_stack<<>>(B, M, radius, nsample, new_xyz, new_xyz_batch_cnt, xyz, xyz_batch_cnt, idx); 84 | // cudaDeviceSynchronize(); // for using printf in kernel function 85 | err = cudaGetLastError(); 86 | if (cudaSuccess != err) { 87 | fprintf(stderr, "CUDA kernel failed : %s\n", cudaGetErrorString(err)); 88 | exit(-1); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_stack/src/ball_query_gpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | Stacked-batch-data version of ball query, modified from the original implementation of official PointNet++ codes. 3 | Written by Shaoshuai Shi 4 | All Rights Reserved 2019-2020. 5 | */ 6 | 7 | 8 | #ifndef _STACK_BALL_QUERY_GPU_H 9 | #define _STACK_BALL_QUERY_GPU_H 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | int ball_query_wrapper_stack(int B, int M, float radius, int nsample, 17 | at::Tensor new_xyz_tensor, at::Tensor new_xyz_batch_cnt_tensor, 18 | at::Tensor xyz_tensor, at::Tensor xyz_batch_cnt_tensor, at::Tensor idx_tensor); 19 | 20 | 21 | void ball_query_kernel_launcher_stack(int B, int M, float radius, int nsample, 22 | const float *new_xyz, const int *new_xyz_batch_cnt, const float *xyz, const int *xyz_batch_cnt, int *idx); 23 | 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_stack/src/cuda_utils.h: -------------------------------------------------------------------------------- 1 | #ifndef _STACK_CUDA_UTILS_H 2 | #define _STACK_CUDA_UTILS_H 3 | 4 | #include 5 | 6 | #define THREADS_PER_BLOCK 256 7 | #define DIVUP(m,n) ((m) / (n) + ((m) % (n) > 0)) 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_stack/src/group_points.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Stacked-batch-data version of point grouping, modified from the original implementation of official PointNet++ codes. 3 | Written by Shaoshuai Shi 4 | All Rights Reserved 2019-2020. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "group_points_gpu.h" 14 | 15 | extern THCState *state; 16 | #define CHECK_CUDA(x) do { \ 17 | if (!x.type().is_cuda()) { \ 18 | fprintf(stderr, "%s must be CUDA tensor at %s:%d\n", #x, __FILE__, __LINE__); \ 19 | exit(-1); \ 20 | } \ 21 | } while (0) 22 | #define CHECK_CONTIGUOUS(x) do { \ 23 | if (!x.is_contiguous()) { \ 24 | fprintf(stderr, "%s must be contiguous tensor at %s:%d\n", #x, __FILE__, __LINE__); \ 25 | exit(-1); \ 26 | } \ 27 | } while (0) 28 | #define CHECK_INPUT(x) CHECK_CUDA(x);CHECK_CONTIGUOUS(x) 29 | 30 | 31 | int group_points_grad_wrapper_stack(int B, int M, int C, int N, int nsample, 32 | at::Tensor grad_out_tensor, at::Tensor idx_tensor, at::Tensor idx_batch_cnt_tensor, 33 | at::Tensor features_batch_cnt_tensor, at::Tensor grad_features_tensor) { 34 | 35 | CHECK_INPUT(grad_out_tensor); 36 | CHECK_INPUT(idx_tensor); 37 | CHECK_INPUT(idx_batch_cnt_tensor); 38 | CHECK_INPUT(features_batch_cnt_tensor); 39 | CHECK_INPUT(grad_features_tensor); 40 | 41 | const float *grad_out = grad_out_tensor.data(); 42 | const int *idx = idx_tensor.data(); 43 | const int *idx_batch_cnt = idx_batch_cnt_tensor.data(); 44 | const int *features_batch_cnt = features_batch_cnt_tensor.data(); 45 | float *grad_features = grad_features_tensor.data(); 46 | 47 | group_points_grad_kernel_launcher_stack(B, M, C, N, nsample, grad_out, idx, idx_batch_cnt, features_batch_cnt, grad_features); 48 | return 1; 49 | } 50 | 51 | 52 | int group_points_wrapper_stack(int B, int M, int C, int nsample, 53 | at::Tensor features_tensor, at::Tensor features_batch_cnt_tensor, 54 | at::Tensor idx_tensor, at::Tensor idx_batch_cnt_tensor, at::Tensor out_tensor) { 55 | 56 | CHECK_INPUT(features_tensor); 57 | CHECK_INPUT(features_batch_cnt_tensor); 58 | CHECK_INPUT(idx_tensor); 59 | CHECK_INPUT(idx_batch_cnt_tensor); 60 | CHECK_INPUT(out_tensor); 61 | 62 | const float *features = features_tensor.data(); 63 | const int *idx = idx_tensor.data(); 64 | const int *features_batch_cnt = features_batch_cnt_tensor.data(); 65 | const int *idx_batch_cnt = idx_batch_cnt_tensor.data(); 66 | float *out = out_tensor.data(); 67 | 68 | group_points_kernel_launcher_stack(B, M, C, nsample, features, features_batch_cnt, idx, idx_batch_cnt, out); 69 | return 1; 70 | } -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_stack/src/group_points_gpu.h: -------------------------------------------------------------------------------- 1 | /* 2 | Stacked-batch-data version of point grouping, modified from the original implementation of official PointNet++ codes. 3 | Written by Shaoshuai Shi 4 | All Rights Reserved 2019-2020. 5 | */ 6 | 7 | 8 | #ifndef _STACK_GROUP_POINTS_GPU_H 9 | #define _STACK_GROUP_POINTS_GPU_H 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | 17 | int group_points_wrapper_stack(int B, int M, int C, int nsample, 18 | at::Tensor features_tensor, at::Tensor features_batch_cnt_tensor, 19 | at::Tensor idx_tensor, at::Tensor idx_batch_cnt_tensor, at::Tensor out_tensor); 20 | 21 | void group_points_kernel_launcher_stack(int B, int M, int C, int nsample, 22 | const float *features, const int *features_batch_cnt, const int *idx, const int *idx_batch_cnt, float *out); 23 | 24 | int group_points_grad_wrapper_stack(int B, int M, int C, int N, int nsample, 25 | at::Tensor grad_out_tensor, at::Tensor idx_tensor, at::Tensor idx_batch_cnt_tensor, 26 | at::Tensor features_batch_cnt_tensor, at::Tensor grad_features_tensor); 27 | 28 | void group_points_grad_kernel_launcher_stack(int B, int M, int C, int N, int nsample, 29 | const float *grad_out, const int *idx, const int *idx_batch_cnt, const int *features_batch_cnt, float *grad_features); 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_stack/src/interpolate.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Stacked-batch-data version of point interpolation, modified from the original implementation of official PointNet++ codes. 3 | Written by Shaoshuai Shi 4 | All Rights Reserved 2019-2020. 5 | */ 6 | 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include "interpolate_gpu.h" 17 | 18 | extern THCState *state; 19 | 20 | #define CHECK_CUDA(x) do { \ 21 | if (!x.type().is_cuda()) { \ 22 | fprintf(stderr, "%s must be CUDA tensor at %s:%d\n", #x, __FILE__, __LINE__); \ 23 | exit(-1); \ 24 | } \ 25 | } while (0) 26 | #define CHECK_CONTIGUOUS(x) do { \ 27 | if (!x.is_contiguous()) { \ 28 | fprintf(stderr, "%s must be contiguous tensor at %s:%d\n", #x, __FILE__, __LINE__); \ 29 | exit(-1); \ 30 | } \ 31 | } while (0) 32 | #define CHECK_INPUT(x) CHECK_CUDA(x);CHECK_CONTIGUOUS(x) 33 | 34 | 35 | void three_nn_wrapper_stack(at::Tensor unknown_tensor, 36 | at::Tensor unknown_batch_cnt_tensor, at::Tensor known_tensor, 37 | at::Tensor known_batch_cnt_tensor, at::Tensor dist2_tensor, at::Tensor idx_tensor){ 38 | // unknown: (N1 + N2 ..., 3) 39 | // unknown_batch_cnt: (batch_size), [N1, N2, ...] 40 | // known: (M1 + M2 ..., 3) 41 | // known_batch_cnt: (batch_size), [M1, M2, ...] 42 | // Return: 43 | // dist: (N1 + N2 ..., 3) l2 distance to the three nearest neighbors 44 | // idx: (N1 + N2 ..., 3) index of the three nearest neighbors 45 | CHECK_INPUT(unknown_tensor); 46 | CHECK_INPUT(unknown_batch_cnt_tensor); 47 | CHECK_INPUT(known_tensor); 48 | CHECK_INPUT(known_batch_cnt_tensor); 49 | CHECK_INPUT(dist2_tensor); 50 | CHECK_INPUT(idx_tensor); 51 | 52 | int batch_size = unknown_batch_cnt_tensor.size(0); 53 | int N = unknown_tensor.size(0); 54 | int M = known_tensor.size(0); 55 | const float *unknown = unknown_tensor.data(); 56 | const int *unknown_batch_cnt = unknown_batch_cnt_tensor.data(); 57 | const float *known = known_tensor.data(); 58 | const int *known_batch_cnt = known_batch_cnt_tensor.data(); 59 | float *dist2 = dist2_tensor.data(); 60 | int *idx = idx_tensor.data(); 61 | 62 | three_nn_kernel_launcher_stack(batch_size, N, M, unknown, unknown_batch_cnt, known, known_batch_cnt, dist2, idx); 63 | } 64 | 65 | 66 | void three_interpolate_wrapper_stack(at::Tensor features_tensor, 67 | at::Tensor idx_tensor, at::Tensor weight_tensor, at::Tensor out_tensor) { 68 | // features_tensor: (M1 + M2 ..., C) 69 | // idx_tensor: [N1 + N2 ..., 3] 70 | // weight_tensor: [N1 + N2 ..., 3] 71 | // Return: 72 | // out_tensor: (N1 + N2 ..., C) 73 | CHECK_INPUT(features_tensor); 74 | CHECK_INPUT(idx_tensor); 75 | CHECK_INPUT(weight_tensor); 76 | CHECK_INPUT(out_tensor); 77 | 78 | int N = out_tensor.size(0); 79 | int channels = features_tensor.size(1); 80 | const float *features = features_tensor.data(); 81 | const float *weight = weight_tensor.data(); 82 | const int *idx = idx_tensor.data(); 83 | float *out = out_tensor.data(); 84 | 85 | three_interpolate_kernel_launcher_stack(N, channels, features, idx, weight, out); 86 | } 87 | 88 | 89 | void three_interpolate_grad_wrapper_stack(at::Tensor grad_out_tensor, at::Tensor idx_tensor, 90 | at::Tensor weight_tensor, at::Tensor grad_features_tensor) { 91 | // grad_out_tensor: (N1 + N2 ..., C) 92 | // idx_tensor: [N1 + N2 ..., 3] 93 | // weight_tensor: [N1 + N2 ..., 3] 94 | // Return: 95 | // grad_features_tensor: (M1 + M2 ..., C) 96 | CHECK_INPUT(grad_out_tensor); 97 | CHECK_INPUT(idx_tensor); 98 | CHECK_INPUT(weight_tensor); 99 | CHECK_INPUT(grad_features_tensor); 100 | 101 | int N = grad_out_tensor.size(0); 102 | int channels = grad_out_tensor.size(1); 103 | const float *grad_out = grad_out_tensor.data(); 104 | const float *weight = weight_tensor.data(); 105 | const int *idx = idx_tensor.data(); 106 | float *grad_features = grad_features_tensor.data(); 107 | 108 | // printf("N=%d, channels=%d\n", N, channels); 109 | three_interpolate_grad_kernel_launcher_stack(N, channels, grad_out, idx, weight, grad_features); 110 | } -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_stack/src/interpolate_gpu.h: -------------------------------------------------------------------------------- 1 | #ifndef _INTERPOLATE_GPU_H 2 | #define _INTERPOLATE_GPU_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | void three_nn_wrapper_stack(at::Tensor unknown_tensor, 11 | at::Tensor unknown_batch_cnt_tensor, at::Tensor known_tensor, 12 | at::Tensor known_batch_cnt_tensor, at::Tensor dist2_tensor, at::Tensor idx_tensor); 13 | 14 | 15 | void three_interpolate_wrapper_stack(at::Tensor features_tensor, 16 | at::Tensor idx_tensor, at::Tensor weight_tensor, at::Tensor out_tensor); 17 | 18 | 19 | 20 | void three_interpolate_grad_wrapper_stack(at::Tensor grad_out_tensor, at::Tensor idx_tensor, 21 | at::Tensor weight_tensor, at::Tensor grad_features_tensor); 22 | 23 | 24 | void three_nn_kernel_launcher_stack(int batch_size, int N, int M, const float *unknown, 25 | const int *unknown_batch_cnt, const float *known, const int *known_batch_cnt, 26 | float *dist2, int *idx); 27 | 28 | 29 | void three_interpolate_kernel_launcher_stack(int N, int channels, 30 | const float *features, const int *idx, const float *weight, float *out); 31 | 32 | 33 | 34 | void three_interpolate_grad_kernel_launcher_stack(int N, int channels, const float *grad_out, 35 | const int *idx, const float *weight, float *grad_features); 36 | 37 | 38 | 39 | #endif -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_stack/src/pointnet2_api.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "ball_query_gpu.h" 5 | #include "group_points_gpu.h" 6 | #include "sampling_gpu.h" 7 | #include "interpolate_gpu.h" 8 | 9 | 10 | PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { 11 | m.def("ball_query_wrapper", &ball_query_wrapper_stack, "ball_query_wrapper_stack"); 12 | 13 | m.def("furthest_point_sampling_wrapper", &furthest_point_sampling_wrapper, "furthest_point_sampling_wrapper"); 14 | 15 | m.def("group_points_wrapper", &group_points_wrapper_stack, "group_points_wrapper_stack"); 16 | m.def("group_points_grad_wrapper", &group_points_grad_wrapper_stack, "group_points_grad_wrapper_stack"); 17 | 18 | m.def("three_nn_wrapper", &three_nn_wrapper_stack, "three_nn_wrapper_stack"); 19 | m.def("three_interpolate_wrapper", &three_interpolate_wrapper_stack, "three_interpolate_wrapper_stack"); 20 | m.def("three_interpolate_grad_wrapper", &three_interpolate_grad_wrapper_stack, "three_interpolate_grad_wrapper_stack"); 21 | } 22 | -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_stack/src/sampling.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "sampling_gpu.h" 7 | 8 | extern THCState *state; 9 | #define CHECK_CUDA(x) do { \ 10 | if (!x.type().is_cuda()) { \ 11 | fprintf(stderr, "%s must be CUDA tensor at %s:%d\n", #x, __FILE__, __LINE__); \ 12 | exit(-1); \ 13 | } \ 14 | } while (0) 15 | #define CHECK_CONTIGUOUS(x) do { \ 16 | if (!x.is_contiguous()) { \ 17 | fprintf(stderr, "%s must be contiguous tensor at %s:%d\n", #x, __FILE__, __LINE__); \ 18 | exit(-1); \ 19 | } \ 20 | } while (0) 21 | #define CHECK_INPUT(x) CHECK_CUDA(x);CHECK_CONTIGUOUS(x) 22 | 23 | 24 | int furthest_point_sampling_wrapper(int b, int n, int m, 25 | at::Tensor points_tensor, at::Tensor temp_tensor, at::Tensor idx_tensor) { 26 | 27 | CHECK_INPUT(points_tensor); 28 | CHECK_INPUT(temp_tensor); 29 | CHECK_INPUT(idx_tensor); 30 | 31 | const float *points = points_tensor.data(); 32 | float *temp = temp_tensor.data(); 33 | int *idx = idx_tensor.data(); 34 | 35 | furthest_point_sampling_kernel_launcher(b, n, m, points, temp, idx); 36 | return 1; 37 | } 38 | -------------------------------------------------------------------------------- /pcdet/ops/pointnet2/pointnet2_stack/src/sampling_gpu.h: -------------------------------------------------------------------------------- 1 | #ifndef _SAMPLING_GPU_H 2 | #define _SAMPLING_GPU_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | int furthest_point_sampling_wrapper(int b, int n, int m, 10 | at::Tensor points_tensor, at::Tensor temp_tensor, at::Tensor idx_tensor); 11 | 12 | void furthest_point_sampling_kernel_launcher(int b, int n, int m, 13 | const float *dataset, float *temp, int *idxs); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /pcdet/ops/roiaware_pool3d/__pycache__/roiaware_pool3d_utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/roiaware_pool3d/__pycache__/roiaware_pool3d_utils.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/ops/roiaware_pool3d/__pycache__/roiaware_pool3d_utils.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/roiaware_pool3d/__pycache__/roiaware_pool3d_utils.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/ops/roiaware_pool3d/build/lib.linux-x86_64-3.7/roi_aware_pool3d_cuda.cpython-37m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/roiaware_pool3d/build/lib.linux-x86_64-3.7/roi_aware_pool3d_cuda.cpython-37m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/roiaware_pool3d/build/lib.linux-x86_64-3.7/roiaware_pool3d_cuda.cpython-37m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/roiaware_pool3d/build/lib.linux-x86_64-3.7/roiaware_pool3d_cuda.cpython-37m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/roiaware_pool3d/build/temp.linux-x86_64-3.7/src/roiaware_pool3d.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/roiaware_pool3d/build/temp.linux-x86_64-3.7/src/roiaware_pool3d.o -------------------------------------------------------------------------------- /pcdet/ops/roiaware_pool3d/build/temp.linux-x86_64-3.7/src/roiaware_pool3d_kernel.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/roiaware_pool3d/build/temp.linux-x86_64-3.7/src/roiaware_pool3d_kernel.o -------------------------------------------------------------------------------- /pcdet/ops/roiaware_pool3d/roi_aware_pool3d.egg-info/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 1.0 2 | Name: roi-aware-pool3d 3 | Version: 0.0.0 4 | Summary: UNKNOWN 5 | Home-page: UNKNOWN 6 | Author: UNKNOWN 7 | Author-email: UNKNOWN 8 | License: UNKNOWN 9 | Description: UNKNOWN 10 | Platform: UNKNOWN 11 | -------------------------------------------------------------------------------- /pcdet/ops/roiaware_pool3d/roi_aware_pool3d.egg-info/SOURCES.txt: -------------------------------------------------------------------------------- 1 | setup.py 2 | roi_aware_pool3d.egg-info/PKG-INFO 3 | roi_aware_pool3d.egg-info/SOURCES.txt 4 | roi_aware_pool3d.egg-info/dependency_links.txt 5 | roi_aware_pool3d.egg-info/top_level.txt 6 | src/roiaware_pool3d.cpp 7 | src/roiaware_pool3d_kernel.cu -------------------------------------------------------------------------------- /pcdet/ops/roiaware_pool3d/roi_aware_pool3d.egg-info/dependency_links.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /pcdet/ops/roiaware_pool3d/roi_aware_pool3d.egg-info/top_level.txt: -------------------------------------------------------------------------------- 1 | roiaware_pool3d_cuda 2 | -------------------------------------------------------------------------------- /pcdet/ops/roiaware_pool3d/roi_aware_pool3d_cuda.cpython-37m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/roiaware_pool3d/roi_aware_pool3d_cuda.cpython-37m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/roiaware_pool3d/roiaware_pool3d_cuda.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/roiaware_pool3d/roiaware_pool3d_cuda.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/roiaware_pool3d/roiaware_pool3d_cuda.cpython-37m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/roiaware_pool3d/roiaware_pool3d_cuda.cpython-37m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/roiaware_pool3d/roiaware_pool3d_cuda.cpython-38-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/roiaware_pool3d/roiaware_pool3d_cuda.cpython-38-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/roiaware_pool3d/roiaware_pool3d_utils.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | from torch.autograd import Function 4 | 5 | from ...utils import common_utils 6 | from . import roiaware_pool3d_cuda 7 | 8 | 9 | def points_in_boxes_cpu(points, boxes): 10 | """ 11 | Args: 12 | points: (num_points, 3) 13 | boxes: [x, y, z, dx, dy, dz, heading], (x, y, z) is the box center, each box DO NOT overlaps 14 | Returns: 15 | point_indices: (N, num_points) 16 | """ 17 | assert boxes.shape[1] == 7 18 | assert points.shape[1] == 3 19 | points, is_numpy = common_utils.check_numpy_to_torch(points) 20 | boxes, is_numpy = common_utils.check_numpy_to_torch(boxes) 21 | 22 | point_indices = points.new_zeros((boxes.shape[0], points.shape[0]), dtype=torch.int) 23 | roiaware_pool3d_cuda.points_in_boxes_cpu(boxes.float().contiguous(), points.float().contiguous(), point_indices) 24 | 25 | return point_indices.numpy() if is_numpy else point_indices 26 | 27 | 28 | def points_in_boxes_gpu(points, boxes): 29 | """ 30 | :param points: (B, M, 3) 31 | :param boxes: (B, T, 7), num_valid_boxes <= T 32 | :return box_idxs_of_pts: (B, M), default background = -1 33 | """ 34 | assert boxes.shape[0] == points.shape[0] 35 | assert boxes.shape[2] == 7 and points.shape[2] == 3 36 | batch_size, num_points, _ = points.shape 37 | 38 | box_idxs_of_pts = points.new_zeros((batch_size, num_points), dtype=torch.int).fill_(-1) 39 | roiaware_pool3d_cuda.points_in_boxes_gpu(boxes.contiguous(), points.contiguous(), box_idxs_of_pts) 40 | 41 | return box_idxs_of_pts 42 | 43 | 44 | class RoIAwarePool3d(nn.Module): 45 | def __init__(self, out_size, max_pts_each_voxel=128): 46 | super().__init__() 47 | self.out_size = out_size 48 | self.max_pts_each_voxel = max_pts_each_voxel 49 | 50 | def forward(self, rois, pts, pts_feature, pool_method='max'): 51 | assert pool_method in ['max', 'avg'] 52 | return RoIAwarePool3dFunction.apply(rois, pts, pts_feature, self.out_size, self.max_pts_each_voxel, pool_method) 53 | 54 | 55 | class RoIAwarePool3dFunction(Function): 56 | @staticmethod 57 | def forward(ctx, rois, pts, pts_feature, out_size, max_pts_each_voxel, pool_method): 58 | """ 59 | Args: 60 | ctx: 61 | rois: (N, 7) [x, y, z, dx, dy, dz, heading] (x, y, z) is the box center 62 | pts: (npoints, 3) 63 | pts_feature: (npoints, C) 64 | out_size: int or tuple, like 7 or (7, 7, 7) 65 | max_pts_each_voxel: 66 | pool_method: 'max' or 'avg' 67 | 68 | Returns: 69 | pooled_features: (N, out_x, out_y, out_z, C) 70 | """ 71 | assert rois.shape[1] == 7 and pts.shape[1] == 3 72 | if isinstance(out_size, int): 73 | out_x = out_y = out_z = out_size 74 | else: 75 | assert len(out_size) == 3 76 | for k in range(3): 77 | assert isinstance(out_size[k], int) 78 | out_x, out_y, out_z = out_size 79 | 80 | num_rois = rois.shape[0] 81 | num_channels = pts_feature.shape[-1] 82 | num_pts = pts.shape[0] 83 | 84 | pooled_features = pts_feature.new_zeros((num_rois, out_x, out_y, out_z, num_channels)) 85 | argmax = pts_feature.new_zeros((num_rois, out_x, out_y, out_z, num_channels), dtype=torch.int) 86 | pts_idx_of_voxels = pts_feature.new_zeros((num_rois, out_x, out_y, out_z, max_pts_each_voxel), dtype=torch.int) 87 | 88 | pool_method_map = {'max': 0, 'avg': 1} 89 | pool_method = pool_method_map[pool_method] 90 | roiaware_pool3d_cuda.forward(rois, pts, pts_feature, argmax, pts_idx_of_voxels, pooled_features, pool_method) 91 | 92 | ctx.roiaware_pool3d_for_backward = (pts_idx_of_voxels, argmax, pool_method, num_pts, num_channels) 93 | return pooled_features 94 | 95 | @staticmethod 96 | def backward(ctx, grad_out): 97 | """ 98 | :param grad_out: (N, out_x, out_y, out_z, C) 99 | :return: 100 | grad_in: (npoints, C) 101 | """ 102 | pts_idx_of_voxels, argmax, pool_method, num_pts, num_channels = ctx.roiaware_pool3d_for_backward 103 | 104 | grad_in = grad_out.new_zeros((num_pts, num_channels)) 105 | roiaware_pool3d_cuda.backward(pts_idx_of_voxels, argmax, grad_out.contiguous(), grad_in, pool_method) 106 | 107 | return None, None, grad_in, None, None, None 108 | 109 | 110 | if __name__ == '__main__': 111 | pass 112 | -------------------------------------------------------------------------------- /pcdet/ops/roiaware_pool3d/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | from torch.utils.cpp_extension import BuildExtension, CUDAExtension 3 | 4 | setup( 5 | name='roi_aware_pool3d', 6 | ext_modules=[ 7 | CUDAExtension('roiaware_pool3d_cuda', [ 8 | 'src/roiaware_pool3d_kernel.cu', 9 | 'src/roiaware_pool3d.cpp', 10 | ], 11 | extra_compile_args={'cxx': ['-g'], 12 | 'nvcc': ['-O2']}) 13 | ], 14 | cmdclass={'build_ext': BuildExtension}) 15 | -------------------------------------------------------------------------------- /pcdet/ops/roipoint_pool3d/__pycache__/roipoint_pool3d_utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/roipoint_pool3d/__pycache__/roipoint_pool3d_utils.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/ops/roipoint_pool3d/__pycache__/roipoint_pool3d_utils.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/roipoint_pool3d/__pycache__/roipoint_pool3d_utils.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/ops/roipoint_pool3d/roipoint_pool3d_cuda.cpython-36m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/roipoint_pool3d/roipoint_pool3d_cuda.cpython-36m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/roipoint_pool3d/roipoint_pool3d_cuda.cpython-37m-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/roipoint_pool3d/roipoint_pool3d_cuda.cpython-37m-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/roipoint_pool3d/roipoint_pool3d_cuda.cpython-38-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/ops/roipoint_pool3d/roipoint_pool3d_cuda.cpython-38-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /pcdet/ops/roipoint_pool3d/roipoint_pool3d_utils.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | from torch.autograd import Function 4 | 5 | from ...utils import box_utils 6 | from . import roipoint_pool3d_cuda 7 | 8 | 9 | class RoIPointPool3d(nn.Module): 10 | def __init__(self, num_sampled_points=512, pool_extra_width=1.0): 11 | super().__init__() 12 | self.num_sampled_points = num_sampled_points 13 | self.pool_extra_width = pool_extra_width 14 | 15 | def forward(self, points, point_features, boxes3d): 16 | """ 17 | Args: 18 | points: (B, N, 3) 19 | point_features: (B, N, C) 20 | boxes3d: (B, M, 7), [x, y, z, dx, dy, dz, heading] 21 | 22 | Returns: 23 | pooled_features: (B, M, 512, 3 + C) 24 | pooled_empty_flag: (B, M) 25 | """ 26 | return RoIPointPool3dFunction.apply( 27 | points, point_features, boxes3d, self.pool_extra_width, self.num_sampled_points 28 | ) 29 | 30 | 31 | class RoIPointPool3dFunction(Function): 32 | @staticmethod 33 | def forward(ctx, points, point_features, boxes3d, pool_extra_width, num_sampled_points=512): 34 | """ 35 | Args: 36 | ctx: 37 | points: (B, N, 3) 38 | point_features: (B, N, C) 39 | boxes3d: (B, num_boxes, 7), [x, y, z, dx, dy, dz, heading] 40 | pool_extra_width: 41 | num_sampled_points: 42 | 43 | Returns: 44 | pooled_features: (B, num_boxes, 512, 3 + C) 45 | pooled_empty_flag: (B, num_boxes) 46 | """ 47 | assert points.shape.__len__() == 3 and points.shape[2] == 3 48 | batch_size, boxes_num, feature_len = points.shape[0], boxes3d.shape[1], point_features.shape[2] 49 | pooled_boxes3d = box_utils.enlarge_box3d(boxes3d.view(-1, 7), pool_extra_width).view(batch_size, -1, 7) 50 | 51 | pooled_features = point_features.new_zeros((batch_size, boxes_num, num_sampled_points, 3 + feature_len)) 52 | pooled_empty_flag = point_features.new_zeros((batch_size, boxes_num)).int() 53 | 54 | roipoint_pool3d_cuda.forward( 55 | points.contiguous(), pooled_boxes3d.contiguous(), 56 | point_features.contiguous(), pooled_features, pooled_empty_flag 57 | ) 58 | 59 | return pooled_features, pooled_empty_flag 60 | 61 | @staticmethod 62 | def backward(ctx, grad_out): 63 | raise NotImplementedError 64 | 65 | 66 | if __name__ == '__main__': 67 | pass 68 | -------------------------------------------------------------------------------- /pcdet/ops/roipoint_pool3d/src/roipoint_pool3d.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #define CHECK_CUDA(x) do { \ 5 | if (!x.type().is_cuda()) { \ 6 | fprintf(stderr, "%s must be CUDA tensor at %s:%d\n", #x, __FILE__, __LINE__); \ 7 | exit(-1); \ 8 | } \ 9 | } while (0) 10 | #define CHECK_CONTIGUOUS(x) do { \ 11 | if (!x.is_contiguous()) { \ 12 | fprintf(stderr, "%s must be contiguous tensor at %s:%d\n", #x, __FILE__, __LINE__); \ 13 | exit(-1); \ 14 | } \ 15 | } while (0) 16 | #define CHECK_INPUT(x) CHECK_CUDA(x);CHECK_CONTIGUOUS(x) 17 | 18 | 19 | void roipool3dLauncher(int batch_size, int pts_num, int boxes_num, int feature_in_len, int sampled_pts_num, 20 | const float *xyz, const float *boxes3d, const float *pts_feature, float *pooled_features, int *pooled_empty_flag); 21 | 22 | 23 | int roipool3d_gpu(at::Tensor xyz, at::Tensor boxes3d, at::Tensor pts_feature, at::Tensor pooled_features, at::Tensor pooled_empty_flag){ 24 | // params xyz: (B, N, 3) 25 | // params boxes3d: (B, M, 7) 26 | // params pts_feature: (B, N, C) 27 | // params pooled_features: (B, M, 512, 3+C) 28 | // params pooled_empty_flag: (B, M) 29 | CHECK_INPUT(xyz); 30 | CHECK_INPUT(boxes3d); 31 | CHECK_INPUT(pts_feature); 32 | CHECK_INPUT(pooled_features); 33 | CHECK_INPUT(pooled_empty_flag); 34 | 35 | int batch_size = xyz.size(0); 36 | int pts_num = xyz.size(1); 37 | int boxes_num = boxes3d.size(1); 38 | int feature_in_len = pts_feature.size(2); 39 | int sampled_pts_num = pooled_features.size(2); 40 | 41 | 42 | const float * xyz_data = xyz.data(); 43 | const float * boxes3d_data = boxes3d.data(); 44 | const float * pts_feature_data = pts_feature.data(); 45 | float * pooled_features_data = pooled_features.data(); 46 | int * pooled_empty_flag_data = pooled_empty_flag.data(); 47 | 48 | roipool3dLauncher(batch_size, pts_num, boxes_num, feature_in_len, sampled_pts_num, 49 | xyz_data, boxes3d_data, pts_feature_data, pooled_features_data, pooled_empty_flag_data); 50 | 51 | 52 | 53 | return 1; 54 | } 55 | 56 | 57 | PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { 58 | m.def("forward", &roipool3d_gpu, "roipool3d forward (CUDA)"); 59 | } 60 | 61 | -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/__init__.py: -------------------------------------------------------------------------------- 1 | from .anchor import * # noqa: F401, F403 2 | from .bbox import * # noqa: F401, F403 3 | from .mask import * # noqa: F401, F403 4 | from .loss import * # noqa: F401, F403 5 | from .evaluation import * # noqa: F401, F403 6 | from .post_processing import * # noqa: F401, F403 7 | from .utils import * # noqa: F401, F403 8 | -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/anchor/__init__.py: -------------------------------------------------------------------------------- 1 | from .anchor_generator import AnchorGenerator 2 | from .anchor_target import anchor_target 3 | 4 | __all__ = ['AnchorGenerator', 'anchor_target'] 5 | -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/anchor/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/anchor/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/anchor/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/anchor/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/anchor/__pycache__/anchor3d_generator.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/anchor/__pycache__/anchor3d_generator.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/anchor/__pycache__/anchor3d_generator.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/anchor/__pycache__/anchor3d_generator.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/anchor/__pycache__/anchor_generator.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/anchor/__pycache__/anchor_generator.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/anchor/__pycache__/anchor_generator.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/anchor/__pycache__/anchor_generator.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/anchor/__pycache__/anchor_target.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/anchor/__pycache__/anchor_target.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/anchor/__pycache__/anchor_target.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/anchor/__pycache__/anchor_target.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/anchor/anchor_generator.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | 4 | class AnchorGenerator(object): 5 | 6 | def __init__(self, base_size, scales, ratios, scale_major=True): 7 | self.base_size = base_size 8 | self.scales = torch.Tensor(scales) 9 | self.ratios = torch.Tensor(ratios) 10 | self.scale_major = scale_major 11 | self.base_anchors = self.gen_base_anchors() 12 | 13 | @property 14 | def num_base_anchors(self): 15 | return self.base_anchors.size(0) 16 | 17 | def gen_base_anchors(self): 18 | base_anchor = torch.Tensor( 19 | [0, 0, self.base_size - 1, self.base_size - 1]) 20 | 21 | w = base_anchor[2] - base_anchor[0] + 1 22 | h = base_anchor[3] - base_anchor[1] + 1 23 | x_ctr = base_anchor[0] + 0.5 * (w - 1) 24 | y_ctr = base_anchor[1] + 0.5 * (h - 1) 25 | 26 | h_ratios = torch.sqrt(self.ratios) 27 | w_ratios = 1 / h_ratios 28 | if self.scale_major: 29 | ws = (w * w_ratios[:, None] * self.scales[None, :]).view(-1) 30 | hs = (h * h_ratios[:, None] * self.scales[None, :]).view(-1) 31 | else: 32 | ws = (w * self.scales[:, None] * w_ratios[None, :]).view(-1) 33 | hs = (h * self.scales[:, None] * h_ratios[None, :]).view(-1) 34 | 35 | base_anchors = torch.stack( 36 | [ 37 | x_ctr - 0.5 * (ws - 1), y_ctr - 0.5 * (hs - 1), 38 | x_ctr + 0.5 * (ws - 1), y_ctr + 0.5 * (hs - 1) 39 | ], 40 | dim=-1).round() 41 | 42 | return base_anchors 43 | 44 | def _meshgrid(self, x, y, row_major=True): 45 | xx = x.repeat(len(y)) 46 | yy = y.view(-1, 1).repeat(1, len(x)).view(-1) 47 | if row_major: 48 | return xx, yy 49 | else: 50 | return yy, xx 51 | 52 | def grid_anchors(self, featmap_size, stride=16, device='cuda'): 53 | base_anchors = self.base_anchors.to(device) 54 | 55 | feat_h, feat_w = featmap_size 56 | shift_x = torch.arange(0, feat_w, device=device) * stride 57 | shift_y = torch.arange(0, feat_h, device=device) * stride 58 | shift_xx, shift_yy = self._meshgrid(shift_x, shift_y) 59 | shifts = torch.stack([shift_xx, shift_yy, shift_xx, shift_yy], dim=-1) 60 | shifts = shifts.type_as(base_anchors) 61 | # first feat_w elements correspond to the first row of shifts 62 | # add A anchors (1, A, 4) to K shifts (K, 1, 4) to get 63 | # shifted anchors (K, A, 4), reshape to (K*A, 4) 64 | 65 | all_anchors = base_anchors[None, :, :] + shifts[:, None, :] 66 | all_anchors = all_anchors.view(-1, 4) 67 | # first A rows correspond to A anchors of (0, 0) in feature map, 68 | # then (0, 1), (0, 2), ... 69 | return all_anchors 70 | 71 | def valid_flags(self, featmap_size, valid_size, device='cuda'): 72 | feat_h, feat_w = featmap_size 73 | valid_h, valid_w = valid_size 74 | assert valid_h <= feat_h and valid_w <= feat_w 75 | valid_x = torch.zeros(feat_w, dtype=torch.uint8, device=device) 76 | valid_y = torch.zeros(feat_h, dtype=torch.uint8, device=device) 77 | valid_x[:valid_w] = 1 78 | valid_y[:valid_h] = 1 79 | valid_xx, valid_yy = self._meshgrid(valid_x, valid_y) 80 | valid = valid_xx & valid_yy 81 | valid = valid[:, None].expand( 82 | valid.size(0), self.num_base_anchors).contiguous().view(-1) 83 | return valid 84 | -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox/__init__.py: -------------------------------------------------------------------------------- 1 | from .geometry import bbox_overlaps 2 | from .assignment import BBoxAssigner, AssignResult 3 | from .sampling import (BBoxSampler, SamplingResult, assign_and_sample, 4 | random_choice) 5 | from .transforms import (bbox2delta, delta2bbox, bbox_flip, bbox_mapping, rbbox3d2delta, delta2rbbox3d, add_sin_difference, 6 | bbox_mapping_back, bbox2roi, roi2bbox, bbox2result, rbbox2roi, kitti_bbox2results, tensor2points) 7 | from .bbox_target import bbox_target 8 | 9 | __all__ = [ 10 | 'bbox_overlaps', 'BBoxAssigner', 'AssignResult', 'BBoxSampler', 11 | 'SamplingResult', 'assign_and_sample', 'random_choice', 'bbox2delta', 12 | 'delta2bbox', 'bbox_flip', 'bbox_mapping', 'bbox_mapping_back', 'bbox2roi', 13 | 'roi2bbox', 'bbox2result', 'bbox_target','rbbox3d2delta','delta2rbbox3d', 14 | 'rbbox2roi', 'kitti_bbox2results','add_sin_difference','tensor2points', 15 | ] 16 | -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox/__pycache__/assignment.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox/__pycache__/assignment.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox/__pycache__/assignment.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox/__pycache__/assignment.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox/__pycache__/bbox_target.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox/__pycache__/bbox_target.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox/__pycache__/bbox_target.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox/__pycache__/bbox_target.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox/__pycache__/geometry.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox/__pycache__/geometry.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox/__pycache__/geometry.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox/__pycache__/geometry.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox/__pycache__/sampling.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox/__pycache__/sampling.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox/__pycache__/sampling.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox/__pycache__/sampling.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox/__pycache__/transforms.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox/__pycache__/transforms.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox/__pycache__/transforms.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox/__pycache__/transforms.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox/bbox_target.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | from .transforms import bbox2delta, rbbox3d2delta 4 | from ..utils import multi_apply 5 | 6 | 7 | def bbox_target(pos_bboxes_list, 8 | neg_bboxes_list, 9 | pos_gt_bboxes_list, 10 | pos_gt_labels_list, 11 | cfg, 12 | reg_classes=1, 13 | target_means=[.0, .0, .0, .0], 14 | target_stds=[1.0, 1.0, 1.0, 1.0], 15 | concat=True): 16 | labels, label_weights, bbox_targets, bbox_weights = multi_apply( 17 | bbox_target_single, 18 | pos_bboxes_list, 19 | neg_bboxes_list, 20 | pos_gt_bboxes_list, 21 | pos_gt_labels_list, 22 | cfg=cfg, 23 | reg_classes=reg_classes, 24 | target_means=target_means, 25 | target_stds=target_stds) 26 | 27 | if concat: 28 | labels = torch.cat(labels, 0) 29 | label_weights = torch.cat(label_weights, 0) 30 | bbox_targets = torch.cat(bbox_targets, 0) 31 | bbox_weights = torch.cat(bbox_weights, 0) 32 | return labels, label_weights, bbox_targets, bbox_weights 33 | 34 | 35 | def bbox_target_single(pos_bboxes, 36 | neg_bboxes, 37 | pos_gt_bboxes, 38 | pos_gt_labels, 39 | cfg, 40 | reg_classes=1, 41 | target_means=[.0, .0, .0, .0], 42 | target_stds=[1.0, 1.0, 1.0, 1.0]): 43 | num_pos = pos_bboxes.size(0) 44 | num_neg = neg_bboxes.size(0) 45 | num_samples = num_pos + num_neg 46 | labels = pos_bboxes.new_zeros(num_samples, dtype=torch.long) 47 | label_weights = pos_bboxes.new_zeros(num_samples) 48 | bbox_targets = pos_bboxes.new_zeros(num_samples, 7) 49 | bbox_weights = pos_bboxes.new_zeros(num_samples, 7) 50 | if num_pos > 0: 51 | labels[:num_pos] = pos_gt_labels 52 | pos_weight = 1.0 if cfg.pos_weight <= 0 else cfg.pos_weight 53 | label_weights[:num_pos] = pos_weight 54 | 55 | pos_bbox_targets = rbbox3d2delta(pos_bboxes, pos_gt_bboxes, target_means, 56 | target_stds) 57 | bbox_targets[:num_pos, :] = pos_bbox_targets 58 | bbox_weights[:num_pos, :] = 1 59 | if num_neg > 0: 60 | label_weights[-num_neg:] = 1.0 61 | if reg_classes > 1: 62 | bbox_targets, bbox_weights = expand_target(bbox_targets, bbox_weights, 63 | labels, reg_classes) 64 | 65 | return labels, label_weights, bbox_targets, bbox_weights 66 | 67 | 68 | def expand_target(bbox_targets, bbox_weights, labels, num_classes): 69 | bbox_targets_expand = bbox_targets.new_zeros((bbox_targets.size(0), 70 | 7 * num_classes)) 71 | bbox_weights_expand = bbox_weights.new_zeros((bbox_weights.size(0), 72 | 7 * num_classes)) 73 | for i in torch.nonzero(labels > 0).squeeze(-1): 74 | start, end = labels[i] * 7, (labels[i] + 1) * 7 75 | bbox_targets_expand[i, start:end] = bbox_targets[i, :] 76 | bbox_weights_expand[i, start:end] = bbox_weights[i, :] 77 | return bbox_targets_expand, bbox_weights_expand 78 | -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox/geometry.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | 4 | def bbox_overlaps(bboxes1, bboxes2, mode='iou', is_aligned=False): 5 | """Calculate overlap between two set of bboxes. 6 | 7 | If ``is_aligned`` is ``False``, then calculate the ious between each bbox 8 | of bboxes1 and bboxes2, otherwise the ious between each aligned pair of 9 | bboxes1 and bboxes2. 10 | 11 | Args: 12 | bboxes1 (Tensor): shape (m, 4) 13 | bboxes2 (Tensor): shape (n, 4), if is_aligned is ``True``, then m and n 14 | must be equal. 15 | mode (str): "iou" (intersection over union) or iof (intersection over 16 | foreground). 17 | 18 | Returns: 19 | ious(Tensor): shape (n, k) if is_aligned == False else shape (n, 1) 20 | """ 21 | 22 | assert mode in ['iou', 'iof'] 23 | 24 | rows = bboxes1.size(0) 25 | cols = bboxes2.size(0) 26 | if is_aligned: 27 | assert rows == cols 28 | 29 | if rows * cols == 0: 30 | return bboxes1.new(rows, 1) if is_aligned else bboxes1.new(rows, cols) 31 | 32 | if is_aligned: 33 | lt = torch.max(bboxes1[:, :2], bboxes2[:, :2]) # [rows, 2] 34 | rb = torch.min(bboxes1[:, 2:], bboxes2[:, 2:]) # [rows, 2] 35 | 36 | wh = (rb - lt + 1).clamp(min=0) # [rows, 2] 37 | overlap = wh[:, 0] * wh[:, 1] 38 | area1 = (bboxes1[:, 2] - bboxes1[:, 0] + 1) * ( 39 | bboxes1[:, 3] - bboxes1[:, 1] + 1) 40 | 41 | if mode == 'iou': 42 | area2 = (bboxes2[:, 2] - bboxes2[:, 0] + 1) * ( 43 | bboxes2[:, 3] - bboxes2[:, 1] + 1) 44 | ious = overlap / (area1 + area2 - overlap) 45 | else: 46 | ious = overlap / area1 47 | else: 48 | lt = torch.max(bboxes1[:, None, :2], bboxes2[:, :2]) # [rows, cols, 2] 49 | rb = torch.min(bboxes1[:, None, 2:], bboxes2[:, 2:]) # [rows, cols, 2] 50 | 51 | wh = (rb - lt + 1).clamp(min=0) # [rows, cols, 2] 52 | overlap = wh[:, :, 0] * wh[:, :, 1] 53 | area1 = (bboxes1[:, 2] - bboxes1[:, 0] + 1) * ( 54 | bboxes1[:, 3] - bboxes1[:, 1] + 1) 55 | 56 | if mode == 'iou': 57 | area2 = (bboxes2[:, 2] - bboxes2[:, 0] + 1) * ( 58 | bboxes2[:, 3] - bboxes2[:, 1] + 1) 59 | ious = overlap / (area1[:, None] + area2 - overlap) 60 | else: 61 | ious = overlap / (area1[:, None]) 62 | 63 | return ious 64 | -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox3d/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox3d/__init__.py -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/bbox3d_target.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/bbox3d_target.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/bbox3d_target.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/bbox3d_target.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/box_coders.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/box_coders.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/box_coders.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/box_coders.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/geometry.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/geometry.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/geometry.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/geometry.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/region_similarity.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/region_similarity.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/region_similarity.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/region_similarity.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/target_ops.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/target_ops.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/target_ops.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/bbox3d/__pycache__/target_ops.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/bbox3d/bbox3d_target.py: -------------------------------------------------------------------------------- 1 | from mmdet.core.bbox3d.target_ops import create_target_np 2 | from mmdet.core.bbox3d import region_similarity as regionSimilarity 3 | from mmdet.core.bbox3d import box_coders as boxCoders 4 | 5 | class TargetEncoder: 6 | def __init__(self, 7 | box_coders, 8 | region_similarity): 9 | 10 | self._similarity_fn = getattr(regionSimilarity, region_similarity)() 11 | self._box_coder = getattr(boxCoders, box_coders)() 12 | 13 | @property 14 | def box_coder(self): 15 | return self._box_coder 16 | 17 | def assign(self, 18 | anchors, 19 | gt_boxes, 20 | anchors_mask=None, 21 | gt_classes=None, 22 | pos_iou_thr=0.6, 23 | neg_iou_thr=0.45, 24 | positive_fraction=None, 25 | sample_size=512, 26 | ): 27 | 28 | return create_target_np( 29 | anchors, 30 | gt_boxes, 31 | anchors_mask, 32 | gt_classes, 33 | similarity_fn=self._similarity_fn, 34 | box_encoding_fn = self._box_coder.encode, 35 | matched_threshold=pos_iou_thr, 36 | unmatched_threshold=neg_iou_thr, 37 | positive_fraction=positive_fraction, 38 | rpn_batch_size=sample_size, 39 | norm_by_num_examples=False, 40 | box_code_size=self.box_coder.code_size) 41 | 42 | -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/evaluation/__init__.py: -------------------------------------------------------------------------------- 1 | from .class_names import (voc_classes, imagenet_det_classes, 2 | imagenet_vid_classes, coco_classes, dataset_aliases, 3 | get_classes) 4 | from .coco_utils import coco_eval, fast_eval_recall, results2json 5 | from .eval_hooks import (DistEvalHook, CocoDistEvalRecallHook, 6 | CocoDistEvalmAPHook,KittiEvalmAPHook, DistEvalmAPHook) 7 | from .mean_ap import average_precision, eval_map, print_map_summary 8 | from .recall import (eval_recalls, print_recall_summary, plot_num_recall, 9 | plot_iou_recall) 10 | 11 | __all__ = [ 12 | 'voc_classes', 'imagenet_det_classes', 'imagenet_vid_classes', 13 | 'coco_classes', 'dataset_aliases', 'get_classes', 'coco_eval', 14 | 'fast_eval_recall', 'results2json', 'DistEvalHook', 15 | 'CocoDistEvalRecallHook', 'CocoDistEvalmAPHook', 'average_precision', 16 | 'eval_map', 'print_map_summary', 'eval_recalls', 'print_recall_summary', 17 | 'plot_num_recall', 'plot_iou_recall','KittiEvalmAPHook','DistEvalmAPHook' 18 | ] 19 | -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/evaluation/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/evaluation/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/evaluation/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/evaluation/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/evaluation/__pycache__/bbox_overlaps.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/evaluation/__pycache__/bbox_overlaps.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/evaluation/__pycache__/bbox_overlaps.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/evaluation/__pycache__/bbox_overlaps.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/evaluation/__pycache__/class_names.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/evaluation/__pycache__/class_names.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/evaluation/__pycache__/class_names.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/evaluation/__pycache__/class_names.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/evaluation/__pycache__/coco_utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/evaluation/__pycache__/coco_utils.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/evaluation/__pycache__/coco_utils.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/evaluation/__pycache__/coco_utils.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/evaluation/__pycache__/eval_hooks.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/evaluation/__pycache__/eval_hooks.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/evaluation/__pycache__/eval_hooks.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/evaluation/__pycache__/eval_hooks.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/evaluation/__pycache__/kitti_eval.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/evaluation/__pycache__/kitti_eval.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/evaluation/__pycache__/kitti_eval.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/evaluation/__pycache__/kitti_eval.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/evaluation/__pycache__/mean_ap.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/evaluation/__pycache__/mean_ap.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/evaluation/__pycache__/mean_ap.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/evaluation/__pycache__/mean_ap.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/evaluation/__pycache__/recall.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/evaluation/__pycache__/recall.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/evaluation/__pycache__/recall.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/evaluation/__pycache__/recall.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/evaluation/bbox_overlaps.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | def bbox_overlaps(bboxes1, bboxes2, mode='iou'): 5 | """Calculate the ious between each bbox of bboxes1 and bboxes2. 6 | 7 | Args: 8 | bboxes1(ndarray): shape (n, 4) 9 | bboxes2(ndarray): shape (k, 4) 10 | mode(str): iou (intersection over union) or iof (intersection 11 | over foreground) 12 | 13 | Returns: 14 | ious(ndarray): shape (n, k) 15 | """ 16 | 17 | assert mode in ['iou', 'iof'] 18 | 19 | bboxes1 = bboxes1.astype(np.float32) 20 | bboxes2 = bboxes2.astype(np.float32) 21 | rows = bboxes1.shape[0] 22 | cols = bboxes2.shape[0] 23 | ious = np.zeros((rows, cols), dtype=np.float32) 24 | if rows * cols == 0: 25 | return ious 26 | exchange = False 27 | if bboxes1.shape[0] > bboxes2.shape[0]: 28 | bboxes1, bboxes2 = bboxes2, bboxes1 29 | ious = np.zeros((cols, rows), dtype=np.float32) 30 | exchange = True 31 | area1 = (bboxes1[:, 2] - bboxes1[:, 0] + 1) * ( 32 | bboxes1[:, 3] - bboxes1[:, 1] + 1) 33 | area2 = (bboxes2[:, 2] - bboxes2[:, 0] + 1) * ( 34 | bboxes2[:, 3] - bboxes2[:, 1] + 1) 35 | for i in range(bboxes1.shape[0]): 36 | x_start = np.maximum(bboxes1[i, 0], bboxes2[:, 0]) 37 | y_start = np.maximum(bboxes1[i, 1], bboxes2[:, 1]) 38 | x_end = np.minimum(bboxes1[i, 2], bboxes2[:, 2]) 39 | y_end = np.minimum(bboxes1[i, 3], bboxes2[:, 3]) 40 | overlap = np.maximum(x_end - x_start + 1, 0) * np.maximum( 41 | y_end - y_start + 1, 0) 42 | if mode == 'iou': 43 | union = area1[i] + area2 - overlap 44 | else: 45 | union = area1[i] if not exchange else area2 46 | ious[i, :] = overlap / union 47 | if exchange: 48 | ious = ious.T 49 | return ious 50 | -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/loss/__init__.py: -------------------------------------------------------------------------------- 1 | from .losses import (weighted_nll_loss, weighted_cross_entropy, 2 | weighted_binary_cross_entropy, sigmoid_focal_loss, 3 | weighted_sigmoid_focal_loss, mask_cross_entropy, 4 | smooth_l1_loss, weighted_smoothl1, l1_loss, weighted_l1, accuracy) 5 | 6 | __all__ = [ 7 | 'weighted_nll_loss', 'weighted_cross_entropy', 8 | 'weighted_binary_cross_entropy', 'sigmoid_focal_loss', 9 | 'weighted_sigmoid_focal_loss', 'mask_cross_entropy', 'smooth_l1_loss', 10 | 'weighted_smoothl1', 'l1_loss', 'weighted_l1', 'accuracy' 11 | ] 12 | -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/loss/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/loss/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/loss/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/loss/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/loss/__pycache__/losses.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/loss/__pycache__/losses.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/loss/__pycache__/losses.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/loss/__pycache__/losses.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/mask/__init__.py: -------------------------------------------------------------------------------- 1 | from .utils import split_combined_polys 2 | from .mask_target import mask_target 3 | 4 | __all__ = ['split_combined_polys', 'mask_target'] 5 | -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/mask/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/mask/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/mask/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/mask/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/mask/__pycache__/mask_target.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/mask/__pycache__/mask_target.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/mask/__pycache__/mask_target.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/mask/__pycache__/mask_target.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/mask/__pycache__/utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/mask/__pycache__/utils.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/mask/__pycache__/utils.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/mask/__pycache__/utils.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/mask/mask_target.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import numpy as np 3 | import mmcv 4 | 5 | 6 | def mask_target(pos_proposals_list, pos_assigned_gt_inds_list, gt_masks_list, 7 | cfg): 8 | cfg_list = [cfg for _ in range(len(pos_proposals_list))] 9 | mask_targets = map(mask_target_single, pos_proposals_list, 10 | pos_assigned_gt_inds_list, gt_masks_list, cfg_list) 11 | mask_targets = torch.cat(list(mask_targets)) 12 | return mask_targets 13 | 14 | 15 | def mask_target_single(pos_proposals, pos_assigned_gt_inds, gt_masks, cfg): 16 | mask_size = cfg.mask_size 17 | num_pos = pos_proposals.size(0) 18 | mask_targets = [] 19 | if num_pos > 0: 20 | proposals_np = pos_proposals.cpu().numpy() 21 | pos_assigned_gt_inds = pos_assigned_gt_inds.cpu().numpy() 22 | for i in range(num_pos): 23 | gt_mask = gt_masks[pos_assigned_gt_inds[i]] 24 | bbox = proposals_np[i, :].astype(np.int32) 25 | x1, y1, x2, y2 = bbox 26 | w = np.maximum(x2 - x1 + 1, 1) 27 | h = np.maximum(y2 - y1 + 1, 1) 28 | # mask is uint8 both before and after resizing 29 | target = mmcv.imresize(gt_mask[y1:y1 + h, x1:x1 + w], 30 | (mask_size, mask_size)) 31 | mask_targets.append(target) 32 | mask_targets = torch.from_numpy(np.stack(mask_targets)).float().to( 33 | pos_proposals.device) 34 | else: 35 | mask_targets = pos_proposals.new_zeros((0, mask_size, mask_size)) 36 | return mask_targets 37 | -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/mask/utils.py: -------------------------------------------------------------------------------- 1 | import mmcv 2 | 3 | 4 | def split_combined_polys(polys, poly_lens, polys_per_mask): 5 | """Split the combined 1-D polys into masks. 6 | 7 | A mask is represented as a list of polys, and a poly is represented as 8 | a 1-D array. In dataset, all masks are concatenated into a single 1-D 9 | tensor. Here we need to split the tensor into original representations. 10 | 11 | Args: 12 | polys (list): a list (length = image num) of 1-D tensors 13 | poly_lens (list): a list (length = image num) of poly length 14 | polys_per_mask (list): a list (length = image num) of poly number 15 | of each mask 16 | 17 | Returns: 18 | list: a list (length = image num) of list (length = mask num) of 19 | list (length = poly num) of numpy array 20 | """ 21 | mask_polys_list = [] 22 | for img_id in range(len(polys)): 23 | polys_single = polys[img_id] 24 | polys_lens_single = poly_lens[img_id].tolist() 25 | polys_per_mask_single = polys_per_mask[img_id].tolist() 26 | 27 | split_polys = mmcv.slice_list(polys_single, polys_lens_single) 28 | mask_polys = mmcv.slice_list(split_polys, polys_per_mask_single) 29 | mask_polys_list.append(mask_polys) 30 | return mask_polys_list 31 | -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/point_cloud/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/point_cloud/__init__.py -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/point_cloud/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/point_cloud/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/point_cloud/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/point_cloud/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/point_cloud/__pycache__/point_augmentor.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/point_cloud/__pycache__/point_augmentor.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/point_cloud/__pycache__/point_augmentor.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/point_cloud/__pycache__/point_augmentor.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/point_cloud/__pycache__/voxel_generator.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/point_cloud/__pycache__/voxel_generator.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/point_cloud/__pycache__/voxel_generator.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/point_cloud/__pycache__/voxel_generator.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/point_cloud/voxel_generator.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from mmdet.ops.points_op import points_to_voxel 3 | 4 | class VoxelGenerator: 5 | def __init__(self, 6 | voxel_size, 7 | point_cloud_range, 8 | max_num_points, 9 | max_voxels=20000): 10 | point_cloud_range = np.array(point_cloud_range, dtype=np.float32) 11 | # [0, -40, -3, 70.4, 40, 1] 12 | voxel_size = np.array(voxel_size, dtype=np.float32) 13 | grid_size = ( 14 | point_cloud_range[3:] - point_cloud_range[:3]) / voxel_size 15 | grid_size = np.round(grid_size).astype(np.int64) 16 | self._voxel_size = voxel_size 17 | self._point_cloud_range = point_cloud_range 18 | self._max_num_points = max_num_points 19 | self._max_voxels = max_voxels 20 | self._grid_size = grid_size 21 | 22 | def generate(self, points): 23 | return points_to_voxel( 24 | points, self._voxel_size, self._point_cloud_range, 25 | self._max_num_points, True, self._max_voxels) 26 | 27 | @property 28 | def voxel_size(self): 29 | return self._voxel_size 30 | 31 | @property 32 | def max_num_points_per_voxel(self): 33 | return self._max_num_points 34 | 35 | @property 36 | def point_cloud_range(self): 37 | return self._point_cloud_range 38 | 39 | @property 40 | def grid_size(self): 41 | return self._grid_size 42 | 43 | 44 | -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/post_processing/__init__.py: -------------------------------------------------------------------------------- 1 | from .merge_augs import (merge_aug_proposals, merge_aug_bboxes, 2 | merge_aug_scores, merge_aug_masks) 3 | from .rotate_nms_gpu import rotate_nms_gpu 4 | __all__ = [ 5 | 'merge_aug_proposals', 'merge_aug_bboxes', 6 | 'merge_aug_scores', 'merge_aug_masks','rotate_nms_gpu' 7 | ] 8 | -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/post_processing/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/post_processing/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/post_processing/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/post_processing/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/post_processing/__pycache__/bbox_nms.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/post_processing/__pycache__/bbox_nms.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/post_processing/__pycache__/bbox_nms.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/post_processing/__pycache__/bbox_nms.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/post_processing/__pycache__/merge_augs.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/post_processing/__pycache__/merge_augs.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/post_processing/__pycache__/merge_augs.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/post_processing/__pycache__/merge_augs.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/post_processing/__pycache__/rotate_nms_gpu.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/post_processing/__pycache__/rotate_nms_gpu.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/post_processing/__pycache__/rotate_nms_gpu.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/post_processing/__pycache__/rotate_nms_gpu.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/post_processing/bbox_nms.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from mmdet.ops.iou3d.iou3d_utils import nms_gpu 3 | 4 | def rotate_nms_torch(rbboxes, 5 | scores, 6 | pre_max_size=None, 7 | post_max_size=None, 8 | iou_threshold=0.5): 9 | if pre_max_size is not None: 10 | num_keeped_scores = scores.shape[0] 11 | pre_max_size = min(num_keeped_scores, pre_max_size) 12 | scores, indices = torch.topk(scores, k=pre_max_size) 13 | rbboxes = rbboxes[indices] 14 | 15 | if len(rbboxes) == 0: 16 | keep = torch.empty((0,), dtype=torch.int64) 17 | else: 18 | ret = nms_gpu(rbboxes, scores, iou_threshold) 19 | keep = ret[:post_max_size] 20 | 21 | if keep.shape[0] == 0: 22 | return None 23 | 24 | if pre_max_size is not None: 25 | return indices[keep] 26 | else: 27 | return keep -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/post_processing/merge_augs.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | import numpy as np 4 | from mmdet.core.bbox.transforms import bbox_mapping_back 5 | 6 | 7 | def merge_aug_proposals(aug_proposals, img_metas, rpn_test_cfg): 8 | """Merge augmented proposals (multiscale, flip, etc.) 9 | 10 | Args: 11 | aug_proposals (list[Tensor]): proposals from different testing 12 | schemes, shape (n, 5). Note that they are not rescaled to the 13 | original image size. 14 | img_metas (list[dict]): image info including "shape_scale" and "flip". 15 | rpn_test_cfg (dict): rpn test config. 16 | 17 | Returns: 18 | Tensor: shape (n, 4), proposals corresponding to original image scale. 19 | """ 20 | recovered_proposals = [] 21 | for proposals, img_info in zip(aug_proposals, img_metas): 22 | img_shape = img_info['img_shape'] 23 | scale_factor = img_info['scale_factor'] 24 | flip = img_info['flip'] 25 | _proposals = proposals.clone() 26 | _proposals[:, :4] = bbox_mapping_back(_proposals[:, :4], img_shape, 27 | scale_factor, flip) 28 | recovered_proposals.append(_proposals) 29 | aug_proposals = torch.cat(recovered_proposals, dim=0) 30 | merged_proposals, _ = nms(aug_proposals, rpn_test_cfg.nms_thr) 31 | scores = merged_proposals[:, 4] 32 | _, order = scores.sort(0, descending=True) 33 | num = min(rpn_test_cfg.max_num, merged_proposals.shape[0]) 34 | order = order[:num] 35 | merged_proposals = merged_proposals[order, :] 36 | return merged_proposals 37 | 38 | 39 | def merge_aug_bboxes(aug_bboxes, aug_scores, img_metas, rcnn_test_cfg): 40 | """Merge augmented detection bboxes and scores. 41 | 42 | Args: 43 | aug_bboxes (list[Tensor]): shape (n, 4*#class) 44 | aug_scores (list[Tensor] or None): shape (n, #class) 45 | img_shapes (list[Tensor]): shape (3, ). 46 | rcnn_test_cfg (dict): rcnn test config. 47 | 48 | Returns: 49 | tuple: (bboxes, scores) 50 | """ 51 | recovered_bboxes = [] 52 | for bboxes, img_info in zip(aug_bboxes, img_metas): 53 | img_shape = img_info[0]['img_shape'] 54 | scale_factor = img_info[0]['scale_factor'] 55 | flip = img_info[0]['flip'] 56 | bboxes = bbox_mapping_back(bboxes, img_shape, scale_factor, flip) 57 | recovered_bboxes.append(bboxes) 58 | bboxes = torch.stack(recovered_bboxes).mean(dim=0) 59 | if aug_scores is None: 60 | return bboxes 61 | else: 62 | scores = torch.stack(aug_scores).mean(dim=0) 63 | return bboxes, scores 64 | 65 | 66 | def merge_aug_scores(aug_scores): 67 | """Merge augmented bbox scores.""" 68 | if isinstance(aug_scores[0], torch.Tensor): 69 | return torch.mean(torch.stack(aug_scores), dim=0) 70 | else: 71 | return np.mean(aug_scores, axis=0) 72 | 73 | 74 | def merge_aug_masks(aug_masks, img_metas, rcnn_test_cfg, weights=None): 75 | """Merge augmented mask prediction. 76 | 77 | Args: 78 | aug_masks (list[ndarray]): shape (n, #class, h, w) 79 | img_shapes (list[ndarray]): shape (3, ). 80 | rcnn_test_cfg (dict): rcnn test config. 81 | 82 | Returns: 83 | tuple: (bboxes, scores) 84 | """ 85 | recovered_masks = [ 86 | mask if not img_info[0]['flip'] else mask[..., ::-1] 87 | for mask, img_info in zip(aug_masks, img_metas) 88 | ] 89 | if weights is None: 90 | merged_masks = np.mean(recovered_masks, axis=0) 91 | else: 92 | merged_masks = np.average( 93 | np.array(recovered_masks), axis=0, weights=np.array(weights)) 94 | return merged_masks 95 | -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .dist_utils import allreduce_grads, DistOptimizerHook 2 | from .misc import tensor2imgs, unmap, multi_apply 3 | 4 | __all__ = [ 5 | 'allreduce_grads', 'DistOptimizerHook', 'tensor2imgs', 'unmap', 6 | 'multi_apply' 7 | ] 8 | -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/utils/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/utils/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/utils/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/utils/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/utils/__pycache__/dist_utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/utils/__pycache__/dist_utils.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/utils/__pycache__/dist_utils.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/utils/__pycache__/dist_utils.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/utils/__pycache__/misc.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/utils/__pycache__/misc.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/utils/__pycache__/misc.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/utils/__pycache__/misc.cpython-38.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/utils/__pycache__/multi_view_utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/pcdet/utils/mmdet_utils/core/utils/__pycache__/multi_view_utils.cpython-37.pyc -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/utils/dist_utils.py: -------------------------------------------------------------------------------- 1 | from collections import OrderedDict 2 | 3 | import torch.distributed as dist 4 | from torch._utils import (_flatten_dense_tensors, _unflatten_dense_tensors, 5 | _take_tensors) 6 | from mmcv.runner import OptimizerHook 7 | 8 | 9 | def _allreduce_coalesced(tensors, world_size, bucket_size_mb=-1): 10 | if bucket_size_mb > 0: 11 | bucket_size_bytes = bucket_size_mb * 1024 * 1024 12 | buckets = _take_tensors(tensors, bucket_size_bytes) 13 | else: 14 | buckets = OrderedDict() 15 | for tensor in tensors: 16 | tp = tensor.type() 17 | if tp not in buckets: 18 | buckets[tp] = [] 19 | buckets[tp].append(tensor) 20 | buckets = buckets.values() 21 | 22 | for bucket in buckets: 23 | flat_tensors = _flatten_dense_tensors(bucket) 24 | dist.all_reduce(flat_tensors) 25 | flat_tensors.div_(world_size) 26 | for tensor, synced in zip( 27 | bucket, _unflatten_dense_tensors(flat_tensors, bucket)): 28 | tensor.copy_(synced) 29 | 30 | 31 | def allreduce_grads(model, coalesce=True, bucket_size_mb=-1): 32 | grads = [ 33 | param.grad.data for param in model.parameters() 34 | if param.requires_grad and param.grad is not None 35 | ] 36 | world_size = dist.get_world_size() 37 | if coalesce: 38 | _allreduce_coalesced(grads, world_size, bucket_size_mb) 39 | else: 40 | for tensor in grads: 41 | dist.all_reduce(tensor.div_(world_size)) 42 | 43 | 44 | class DistOptimizerHook(OptimizerHook): 45 | 46 | def __init__(self, grad_clip=None, coalesce=True, bucket_size_mb=-1): 47 | self.grad_clip = grad_clip 48 | self.coalesce = coalesce 49 | self.bucket_size_mb = bucket_size_mb 50 | 51 | def after_train_iter(self, runner): 52 | runner.optimizer.zero_grad() 53 | runner.outputs['loss'].backward() 54 | allreduce_grads(runner.model, self.coalesce, self.bucket_size_mb) 55 | if self.grad_clip is not None: 56 | self.clip_grads(runner.model.parameters()) 57 | runner.optimizer.step() 58 | -------------------------------------------------------------------------------- /pcdet/utils/mmdet_utils/core/utils/misc.py: -------------------------------------------------------------------------------- 1 | from functools import partial 2 | import mmcv 3 | import numpy as np 4 | from six.moves import map, zip 5 | import time 6 | import torch 7 | 8 | def tensor2imgs(tensor, mean=(0, 0, 0), std=(1, 1, 1), to_rgb=True): 9 | num_imgs = tensor.size(0) 10 | mean = np.array(mean, dtype=np.float32) 11 | std = np.array(std, dtype=np.float32) 12 | imgs = [] 13 | for img_id in range(num_imgs): 14 | img = tensor[img_id, ...].cpu().numpy().transpose(1, 2, 0) 15 | img = mmcv.imdenormalize( 16 | img, mean, std, to_bgr=to_rgb).astype(np.uint8) 17 | imgs.append(np.ascontiguousarray(img)) 18 | return imgs 19 | 20 | 21 | def multi_apply(func, *args, **kwargs): 22 | pfunc = partial(func, **kwargs) if kwargs else func 23 | map_results = map(pfunc, *args) 24 | return tuple(map(list, zip(*map_results))) 25 | 26 | 27 | def unmap(data, count, inds, fill=0): 28 | """ Unmap a subset of item (data) back to the original set of items (of 29 | size count) """ 30 | if data.dim() == 1: 31 | ret = data.new_full((count, ), fill) 32 | ret[inds] = data 33 | else: 34 | new_size = (count, ) + data.size()[1:] 35 | ret = data.new_full(new_size, fill) 36 | ret[inds, :] = data 37 | return ret 38 | 39 | class TimeCatcher(object): 40 | def __init__(self, show=True, cuda=True): 41 | self.show=show 42 | self.cuda = cuda 43 | 44 | def __enter__(self): 45 | if self.cuda: 46 | torch.cuda.synchronize() 47 | self.start = time.time() 48 | return self 49 | 50 | def __exit__(self, type, value, traceback): 51 | if self.cuda: 52 | torch.cuda.synchronize() 53 | self.end = time.time() 54 | ms = (self.end - self.start) * 1000 55 | if self.show: 56 | print("%.5f ms" % ms) -------------------------------------------------------------------------------- /pcdet/utils/object3d_kitti.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | 4 | def get_objects_from_label(label_file): 5 | with open(label_file, 'r') as f: 6 | lines = f.readlines() 7 | objects = [Object3d(line) for line in lines] 8 | return objects 9 | 10 | 11 | def cls_type_to_id(cls_type): 12 | type_to_id = {'Car': 1, 'Pedestrian': 2, 'Cyclist': 3, 'Van': 4} 13 | if cls_type not in type_to_id.keys(): 14 | return -1 15 | return type_to_id[cls_type] 16 | 17 | 18 | class Object3d(object): 19 | def __init__(self, line): 20 | label = line.strip().split(' ') 21 | self.src = line 22 | self.cls_type = label[0] 23 | self.cls_id = cls_type_to_id(self.cls_type) 24 | self.truncation = float(label[1]) 25 | self.occlusion = float(label[2]) # 0:fully visible 1:partly occluded 2:largely occluded 3:unknown 26 | self.alpha = float(label[3]) 27 | self.box2d = np.array((float(label[4]), float(label[5]), float(label[6]), float(label[7])), dtype=np.float32) 28 | self.h = float(label[8]) 29 | self.w = float(label[9]) 30 | self.l = float(label[10]) 31 | self.loc = np.array((float(label[11]), float(label[12]), float(label[13])), dtype=np.float32) 32 | self.dis_to_cam = np.linalg.norm(self.loc) 33 | self.ry = float(label[14]) 34 | self.score = float(label[15]) if label.__len__() == 16 else -1.0 35 | self.level_str = None 36 | self.level = self.get_kitti_obj_level() 37 | 38 | def get_kitti_obj_level(self): 39 | height = float(self.box2d[3]) - float(self.box2d[1]) + 1 40 | 41 | if height >= 40 and self.truncation <= 0.15 and self.occlusion <= 0: 42 | self.level_str = 'Easy' 43 | return 0 # Easy 44 | elif height >= 25 and self.truncation <= 0.3 and self.occlusion <= 1: 45 | self.level_str = 'Moderate' 46 | return 1 # Moderate 47 | elif height >= 25 and self.truncation <= 0.5 and self.occlusion <= 2: 48 | self.level_str = 'Hard' 49 | return 2 # Hard 50 | else: 51 | self.level_str = 'UnKnown' 52 | return -1 53 | 54 | def generate_corners3d(self): 55 | """ 56 | generate corners3d representation for this object 57 | :return corners_3d: (8, 3) corners of box3d in camera coord 58 | """ 59 | l, h, w = self.l, self.h, self.w 60 | x_corners = [l / 2, l / 2, -l / 2, -l / 2, l / 2, l / 2, -l / 2, -l / 2] 61 | y_corners = [0, 0, 0, 0, -h, -h, -h, -h] 62 | z_corners = [w / 2, -w / 2, -w / 2, w / 2, w / 2, -w / 2, -w / 2, w / 2] 63 | 64 | R = np.array([[np.cos(self.ry), 0, np.sin(self.ry)], 65 | [0, 1, 0], 66 | [-np.sin(self.ry), 0, np.cos(self.ry)]]) 67 | corners3d = np.vstack([x_corners, y_corners, z_corners]) # (3, 8) 68 | corners3d = np.dot(R, corners3d).T 69 | corners3d = corners3d + self.loc 70 | return corners3d 71 | 72 | def to_str(self): 73 | print_str = '%s %.3f %.3f %.3f box2d: %s hwl: [%.3f %.3f %.3f] pos: %s ry: %.3f' \ 74 | % (self.cls_type, self.truncation, self.occlusion, self.alpha, self.box2d, self.h, self.w, self.l, 75 | self.loc, self.ry) 76 | return print_str 77 | 78 | def to_kitti_format(self): 79 | kitti_str = '%s %.2f %d %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f' \ 80 | % (self.cls_type, self.truncation, int(self.occlusion), self.alpha, self.box2d[0], self.box2d[1], 81 | self.box2d[2], self.box2d[3], self.h, self.w, self.l, self.loc[0], self.loc[1], self.loc[2], 82 | self.ry) 83 | return kitti_str 84 | -------------------------------------------------------------------------------- /pcdet/version.py: -------------------------------------------------------------------------------- 1 | __version__ = "0.3.0+59565c7" 2 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | numpy 2 | torch>=1.1 3 | numba 4 | tensorboardX 5 | easydict 6 | pyyaml 7 | scikit-image 8 | tqdm 9 | torch_scatter 10 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import os 2 | import subprocess 3 | 4 | from setuptools import find_packages, setup 5 | from torch.utils.cpp_extension import BuildExtension, CUDAExtension 6 | 7 | 8 | def get_git_commit_number(): 9 | if not os.path.exists('.git'): 10 | return '0000000' 11 | 12 | cmd_out = subprocess.run(['git', 'rev-parse', 'HEAD'], stdout=subprocess.PIPE) 13 | git_commit_number = cmd_out.stdout.decode('utf-8')[:7] 14 | return git_commit_number 15 | 16 | 17 | def make_cuda_ext(name, module, sources): 18 | cuda_ext = CUDAExtension( 19 | name='%s.%s' % (module, name), 20 | sources=[os.path.join(*module.split('.'), src) for src in sources] 21 | ) 22 | return cuda_ext 23 | 24 | 25 | def write_version_to_file(version, target_file): 26 | with open(target_file, 'w') as f: 27 | print('__version__ = "%s"' % version, file=f) 28 | 29 | 30 | if __name__ == '__main__': 31 | version = '0.3.0+%s' % get_git_commit_number() 32 | write_version_to_file(version, 'pcdet/version.py') 33 | 34 | setup( 35 | name='pcdet', 36 | version=version, 37 | description='OpenPCDet is a general codebase for 3D object detection from point cloud', 38 | install_requires=[ 39 | 'numpy', 40 | 'torch>=1.1', 41 | # 'spconv', 42 | 'numba', 43 | 'tensorboardX', 44 | 'easydict', 45 | 'pyyaml' 46 | ], 47 | author='Shaoshuai Shi', 48 | author_email='shaoshuaics@gmail.com', 49 | license='Apache License 2.0', 50 | packages=find_packages(exclude=['tools', 'data', 'output']), 51 | cmdclass={'build_ext': BuildExtension}, 52 | ext_modules=[ 53 | make_cuda_ext( 54 | name='iou3d_nms_cuda', 55 | module='pcdet.ops.iou3d_nms', 56 | sources=[ 57 | 'src/iou3d_cpu.cpp', 58 | 'src/iou3d_nms_api.cpp', 59 | 'src/iou3d_nms.cpp', 60 | 'src/iou3d_nms_kernel.cu', 61 | ] 62 | ), 63 | make_cuda_ext( 64 | name='roiaware_pool3d_cuda', 65 | module='pcdet.ops.roiaware_pool3d', 66 | sources=[ 67 | 'src/roiaware_pool3d.cpp', 68 | 'src/roiaware_pool3d_kernel.cu', 69 | ] 70 | ), 71 | make_cuda_ext( 72 | name='roipoint_pool3d_cuda', 73 | module='pcdet.ops.roipoint_pool3d', 74 | sources=[ 75 | 'src/roipoint_pool3d.cpp', 76 | 'src/roipoint_pool3d_kernel.cu', 77 | ] 78 | ), 79 | make_cuda_ext( 80 | name='pointnet2_stack_cuda', 81 | module='pcdet.ops.pointnet2.pointnet2_stack', 82 | sources=[ 83 | 'src/pointnet2_api.cpp', 84 | 'src/ball_query.cpp', 85 | 'src/ball_query_gpu.cu', 86 | 'src/group_points.cpp', 87 | 'src/group_points_gpu.cu', 88 | 'src/sampling.cpp', 89 | 'src/sampling_gpu.cu', 90 | 'src/interpolate.cpp', 91 | 'src/interpolate_gpu.cu', 92 | ], 93 | ), 94 | make_cuda_ext( 95 | name='pointnet2_batch_cuda', 96 | module='pcdet.ops.pointnet2.pointnet2_batch', 97 | sources=[ 98 | 'src/pointnet2_api.cpp', 99 | 'src/ball_query.cpp', 100 | 'src/ball_query_gpu.cu', 101 | 'src/group_points.cpp', 102 | 'src/group_points_gpu.cu', 103 | 'src/interpolate.cpp', 104 | 'src/interpolate_gpu.cu', 105 | 'src/sampling.cpp', 106 | 'src/sampling_gpu.cu', 107 | 108 | ], 109 | ), 110 | ], 111 | ) 112 | -------------------------------------------------------------------------------- /tools/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "python.pythonPath": "/home/xingcheng/miniconda3/envs/open-mmlab/bin/python" 3 | } -------------------------------------------------------------------------------- /tools/cfgs/dataset_configs/kitti_dataset.yaml: -------------------------------------------------------------------------------- 1 | DATASET: 'KittiDataset' 2 | DATA_PATH: '../data/kitti' 3 | 4 | POINT_CLOUD_RANGE: [0, -40, -3, 70.4, 40, 1] 5 | 6 | DATA_SPLIT: { 7 | 'train': train, 8 | 'test': val 9 | } 10 | 11 | INFO_PATH: { 12 | 'train': [kitti_infos_train.pkl], 13 | 'test': [kitti_infos_val.pkl], 14 | } 15 | 16 | FOV_POINTS_ONLY: True 17 | 18 | 19 | DATA_AUGMENTOR: 20 | DISABLE_AUG_LIST: ['placeholder'] 21 | AUG_CONFIG_LIST: 22 | - NAME: gt_sampling 23 | USE_ROAD_PLANE: True 24 | DB_INFO_PATH: 25 | - kitti_dbinfos_train.pkl 26 | PREPARE: { 27 | filter_by_min_points: ['Car:5', 'Pedestrian:5', 'Cyclist:5'], 28 | filter_by_difficulty: [-1], 29 | } 30 | 31 | SAMPLE_GROUPS: ['Car:20','Pedestrian:15', 'Cyclist:15'] 32 | NUM_POINT_FEATURES: 4 33 | DATABASE_WITH_FAKELIDAR: False 34 | REMOVE_EXTRA_WIDTH: [0.0, 0.0, 0.0] 35 | LIMIT_WHOLE_SCENE: True 36 | 37 | - NAME: random_world_flip 38 | ALONG_AXIS_LIST: ['x'] 39 | 40 | - NAME: random_world_rotation 41 | WORLD_ROT_ANGLE: [-0.78539816, 0.78539816] 42 | 43 | - NAME: random_world_scaling 44 | WORLD_SCALE_RANGE: [0.95, 1.05] 45 | 46 | 47 | POINT_FEATURE_ENCODING: { 48 | encoding_type: absolute_coordinates_encoding, 49 | used_feature_list: ['x', 'y', 'z', 'intensity'], 50 | src_feature_list: ['x', 'y', 'z', 'intensity'], 51 | } 52 | 53 | 54 | DATA_PROCESSOR: 55 | - NAME: mask_points_and_boxes_outside_range 56 | REMOVE_OUTSIDE_BOXES: True 57 | 58 | - NAME: shuffle_points 59 | SHUFFLE_ENABLED: { 60 | 'train': True, 61 | 'test': False 62 | } 63 | 64 | # - NAME: transform_points_to_voxels 65 | # VOXEL_SIZE: [0.05, 0.05, 0.1] 66 | # MAX_POINTS_PER_VOXEL: 5 67 | # MAX_NUMBER_OF_VOXELS: { 68 | # 'train': 16000, 69 | # 'test': 40000 70 | # } 71 | -------------------------------------------------------------------------------- /tools/cfgs/dataset_configs/nuscenes_dataset.yaml: -------------------------------------------------------------------------------- 1 | DATASET: 'NuScenesDataset' 2 | DATA_PATH: '../data/nuscenes' 3 | 4 | VERSION: 'v1.0-trainval' 5 | MAX_SWEEPS: 10 6 | PRED_VELOCITY: True 7 | SET_NAN_VELOCITY_TO_ZEROS: True 8 | FILTER_MIN_POINTS_IN_GT: 1 9 | 10 | DATA_SPLIT: { 11 | 'train': train, 12 | 'test': val 13 | } 14 | 15 | INFO_PATH: { 16 | 'train': [nuscenes_infos_10sweeps_train.pkl], 17 | 'test': [nuscenes_infos_10sweeps_val.pkl], 18 | } 19 | 20 | POINT_CLOUD_RANGE: [-51.2, -51.2, -5.0, 51.2, 51.2, 3.0] 21 | 22 | BALANCED_RESAMPLING: True 23 | 24 | DATA_AUGMENTOR: 25 | DISABLE_AUG_LIST: ['placeholder'] 26 | AUG_CONFIG_LIST: 27 | - NAME: gt_sampling 28 | DB_INFO_PATH: 29 | - nuscenes_dbinfos_10sweeps_withvelo.pkl 30 | PREPARE: { 31 | filter_by_min_points: [ 32 | 'car:5','truck:5', 'construction_vehicle:5', 'bus:5', 'trailer:5', 33 | 'barrier:5', 'motorcycle:5', 'bicycle:5', 'pedestrian:5', 'traffic_cone:5' 34 | ], 35 | } 36 | 37 | SAMPLE_GROUPS: [ 38 | 'car:2','truck:3', 'construction_vehicle:7', 'bus:4', 'trailer:6', 39 | 'barrier:2', 'motorcycle:6', 'bicycle:6', 'pedestrian:2', 'traffic_cone:2' 40 | ] 41 | 42 | NUM_POINT_FEATURES: 5 43 | DATABASE_WITH_FAKELIDAR: False 44 | REMOVE_EXTRA_WIDTH: [0.0, 0.0, 0.0] 45 | LIMIT_WHOLE_SCENE: True 46 | 47 | - NAME: random_world_flip 48 | ALONG_AXIS_LIST: ['x', 'y'] 49 | 50 | - NAME: random_world_rotation 51 | WORLD_ROT_ANGLE: [-0.3925, 0.3925] 52 | 53 | - NAME: random_world_scaling 54 | WORLD_SCALE_RANGE: [0.95, 1.05] 55 | 56 | 57 | POINT_FEATURE_ENCODING: { 58 | encoding_type: absolute_coordinates_encoding, 59 | used_feature_list: ['x', 'y', 'z', 'intensity', 'timestamp'], 60 | src_feature_list: ['x', 'y', 'z', 'intensity', 'timestamp'], 61 | } 62 | 63 | 64 | DATA_PROCESSOR: 65 | - NAME: mask_points_and_boxes_outside_range 66 | REMOVE_OUTSIDE_BOXES: True 67 | 68 | - NAME: shuffle_points 69 | SHUFFLE_ENABLED: { 70 | 'train': True, 71 | 'test': True 72 | } 73 | 74 | - NAME: transform_points_to_voxels 75 | VOXEL_SIZE: [0.1, 0.1, 0.2] 76 | MAX_POINTS_PER_VOXEL: 10 77 | MAX_NUMBER_OF_VOXELS: { 78 | 'train': 60000, 79 | 'test': 60000 80 | } 81 | -------------------------------------------------------------------------------- /tools/cfgs/dataset_configs/waymo_dataset.yaml: -------------------------------------------------------------------------------- 1 | DATASET: 'WaymoDataset' 2 | DATA_PATH: '../data/waymo' 3 | PROCESSED_DATA_TAG: 'waymo_processed_data' 4 | 5 | POINT_CLOUD_RANGE: [-75.2, -75.2, -2, 75.2, 75.2, 4] 6 | 7 | DATA_SPLIT: { 8 | 'train': train, 9 | 'test': val 10 | } 11 | 12 | SAMPLED_INTERVAL: { 13 | 'train': 5, 14 | 'test': 5 15 | } 16 | 17 | DATA_AUGMENTOR: 18 | DISABLE_AUG_LIST: ['placeholder'] 19 | AUG_CONFIG_LIST: 20 | - NAME: gt_sampling 21 | USE_ROAD_PLANE: False 22 | DB_INFO_PATH: 23 | - pcdet_waymo_dbinfos_train_sampled_10.pkl 24 | PREPARE: { 25 | filter_by_min_points: ['Vehicle:5', 'Pedestrian:5', 'Cyclist:5'], 26 | filter_by_difficulty: [-1], 27 | } 28 | 29 | SAMPLE_GROUPS: ['Vehicle:15', 'Pedestrian:10', 'Cyclist:10'] 30 | NUM_POINT_FEATURES: 5 31 | REMOVE_EXTRA_WIDTH: [0.0, 0.0, 0.0] 32 | LIMIT_WHOLE_SCENE: True 33 | 34 | - NAME: random_world_flip 35 | ALONG_AXIS_LIST: ['x', 'y'] 36 | 37 | - NAME: random_world_rotation 38 | WORLD_ROT_ANGLE: [-0.78539816, 0.78539816] 39 | 40 | - NAME: random_world_scaling 41 | WORLD_SCALE_RANGE: [0.95, 1.05] 42 | 43 | 44 | POINT_FEATURE_ENCODING: { 45 | encoding_type: absolute_coordinates_encoding, 46 | used_feature_list: ['x', 'y', 'z', 'intensity', 'elongation'], 47 | src_feature_list: ['x', 'y', 'z', 'intensity', 'elongation'], 48 | } 49 | 50 | 51 | DATA_PROCESSOR: 52 | - NAME: mask_points_and_boxes_outside_range 53 | REMOVE_OUTSIDE_BOXES: True 54 | 55 | - NAME: shuffle_points 56 | SHUFFLE_ENABLED: { 57 | 'train': True, 58 | 'test': True 59 | } 60 | 61 | - NAME: transform_points_to_voxels 62 | VOXEL_SIZE: [0.1, 0.1, 0.15] 63 | MAX_POINTS_PER_VOXEL: 5 64 | MAX_NUMBER_OF_VOXELS: { 65 | 'train': 80000, 66 | 'test': 90000 67 | } 68 | -------------------------------------------------------------------------------- /tools/eval_utils/__pycache__/eval_utils.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/tools/eval_utils/__pycache__/eval_utils.cpython-36.pyc -------------------------------------------------------------------------------- /tools/eval_utils/__pycache__/eval_utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/tools/eval_utils/__pycache__/eval_utils.cpython-37.pyc -------------------------------------------------------------------------------- /tools/eval_utils/__pycache__/eval_utils.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/tools/eval_utils/__pycache__/eval_utils.cpython-38.pyc -------------------------------------------------------------------------------- /tools/scripts/dist_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -x 4 | NGPUS=$1 5 | PY_ARGS=${@:2} 6 | 7 | python -m torch.distributed.launch --nproc_per_node=${NGPUS} test.py --launcher pytorch ${PY_ARGS} 8 | 9 | -------------------------------------------------------------------------------- /tools/scripts/dist_train.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -x 4 | NGPUS=$1 5 | PY_ARGS=${@:2} 6 | 7 | python -m torch.distributed.launch --nproc_per_node=${NGPUS} train.py --launcher pytorch ${PY_ARGS} 8 | 9 | -------------------------------------------------------------------------------- /tools/scripts/slurm_test_mgpu.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -x 4 | 5 | PARTITION=$1 6 | GPUS=$2 7 | GPUS_PER_NODE=$GPUS 8 | PY_ARGS=${@:3} 9 | JOB_NAME=eval 10 | SRUN_ARGS=${SRUN_ARGS:-""} 11 | 12 | while true 13 | do 14 | PORT=$(( ((RANDOM<<15)|RANDOM) % 49152 + 10000 )) 15 | status="$(nc -z 127.0.0.1 $PORT < /dev/null &>/dev/null; echo $?)" 16 | if [ "${status}" != "0" ]; then 17 | break; 18 | fi 19 | done 20 | echo $PORT 21 | 22 | srun -p ${PARTITION} \ 23 | --job-name=${JOB_NAME} \ 24 | --gres=gpu:${GPUS_PER_NODE} \ 25 | --ntasks=${GPUS} \ 26 | --ntasks-per-node=${GPUS_PER_NODE} \ 27 | --kill-on-bad-exit=1 \ 28 | ${SRUN_ARGS} \ 29 | python -u test.py --launcher slurm --tcp_port $PORT ${PY_ARGS} 30 | 31 | -------------------------------------------------------------------------------- /tools/scripts/slurm_test_single.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -x 4 | 5 | PARTITION=$1 6 | GPUS=1 7 | GPUS_PER_NODE=1 8 | PY_ARGS=${@:2} 9 | JOB_NAME=eval 10 | SRUN_ARGS=${SRUN_ARGS:-""} 11 | 12 | srun -p ${PARTITION} \ 13 | --job-name=${JOB_NAME} \ 14 | --gres=gpu:${GPUS_PER_NODE} \ 15 | --ntasks=${GPUS} \ 16 | --ntasks-per-node=${GPUS_PER_NODE} \ 17 | --kill-on-bad-exit=1 \ 18 | ${SRUN_ARGS} \ 19 | python -u test.py ${PY_ARGS} 20 | -------------------------------------------------------------------------------- /tools/scripts/slurm_train.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -x 4 | 5 | PARTITION=$1 6 | JOB_NAME=$2 7 | GPUS=$3 8 | PY_ARGS=${@:4} 9 | 10 | GPUS_PER_NODE=${GPUS_PER_NODE:-8} 11 | CPUS_PER_TASK=${CPUS_PER_TASK:-5} 12 | SRUN_ARGS=${SRUN_ARGS:-""} 13 | 14 | while true 15 | do 16 | PORT=$(( ((RANDOM<<15)|RANDOM) % 49152 + 10000 )) 17 | status="$(nc -z 127.0.0.1 $PORT < /dev/null &>/dev/null; echo $?)" 18 | if [ "${status}" != "0" ]; then 19 | break; 20 | fi 21 | done 22 | echo $PORT 23 | 24 | srun -p ${PARTITION} \ 25 | --job-name=${JOB_NAME} \ 26 | --gres=gpu:${GPUS_PER_NODE} \ 27 | --ntasks=${GPUS} \ 28 | --ntasks-per-node=${GPUS_PER_NODE} \ 29 | --cpus-per-task=${CPUS_PER_TASK} \ 30 | --kill-on-bad-exit=1 \ 31 | ${SRUN_ARGS} \ 32 | python -u train.py --launcher slurm --tcp_port $PORT ${PY_ARGS} 33 | -------------------------------------------------------------------------------- /tools/train_utils/__pycache__/train_utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/tools/train_utils/__pycache__/train_utils.cpython-37.pyc -------------------------------------------------------------------------------- /tools/train_utils/__pycache__/train_utils.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/tools/train_utils/__pycache__/train_utils.cpython-38.pyc -------------------------------------------------------------------------------- /tools/train_utils/optimization/__init__.py: -------------------------------------------------------------------------------- 1 | from functools import partial 2 | 3 | import torch.nn as nn 4 | import torch.optim as optim 5 | import torch.optim.lr_scheduler as lr_sched 6 | 7 | from .fastai_optim import OptimWrapper 8 | from .learning_schedules_fastai import CosineWarmupLR, OneCycle 9 | 10 | 11 | def build_optimizer(model, optim_cfg): 12 | if optim_cfg.OPTIMIZER == 'adam': 13 | optimizer = optim.Adam(model.parameters(), lr=optim_cfg.LR, weight_decay=optim_cfg.WEIGHT_DECAY) 14 | elif optim_cfg.OPTIMIZER == 'sgd': 15 | optimizer = optim.SGD( 16 | model.parameters(), lr=optim_cfg.LR, weight_decay=optim_cfg.WEIGHT_DECAY, 17 | momentum=optim_cfg.MOMENTUM 18 | ) 19 | elif optim_cfg.OPTIMIZER == 'adam_onecycle': 20 | def children(m: nn.Module): 21 | return list(m.children()) 22 | 23 | def num_children(m: nn.Module) -> int: 24 | return len(children(m)) 25 | 26 | flatten_model = lambda m: sum(map(flatten_model, m.children()), []) if num_children(m) else [m] 27 | get_layer_groups = lambda m: [nn.Sequential(*flatten_model(m))] 28 | 29 | optimizer_func = partial(optim.Adam, betas=(0.9, 0.99)) 30 | optimizer = OptimWrapper.create( 31 | optimizer_func, 3e-3, get_layer_groups(model), wd=optim_cfg.WEIGHT_DECAY, true_wd=True, bn_wd=True 32 | ) 33 | else: 34 | raise NotImplementedError 35 | 36 | return optimizer 37 | 38 | 39 | def build_scheduler(optimizer, total_iters_each_epoch, total_epochs, last_epoch, optim_cfg): 40 | decay_steps = [x * total_iters_each_epoch for x in optim_cfg.DECAY_STEP_LIST] 41 | def lr_lbmd(cur_epoch): 42 | cur_decay = 1 43 | for decay_step in decay_steps: 44 | if cur_epoch >= decay_step: 45 | cur_decay = cur_decay * optim_cfg.LR_DECAY 46 | return max(cur_decay, optim_cfg.LR_CLIP / optim_cfg.LR) 47 | 48 | lr_warmup_scheduler = None 49 | total_steps = total_iters_each_epoch * total_epochs 50 | if optim_cfg.OPTIMIZER == 'adam_onecycle': 51 | lr_scheduler = OneCycle( 52 | optimizer, total_steps, optim_cfg.LR, list(optim_cfg.MOMS), optim_cfg.DIV_FACTOR, optim_cfg.PCT_START 53 | ) 54 | else: 55 | lr_scheduler = lr_sched.LambdaLR(optimizer, lr_lbmd, last_epoch=last_epoch) 56 | 57 | if optim_cfg.LR_WARMUP: 58 | lr_warmup_scheduler = CosineWarmupLR( 59 | optimizer, T_max=optim_cfg.WARMUP_EPOCH * len(total_iters_each_epoch), 60 | eta_min=optim_cfg.LR / optim_cfg.DIV_FACTOR 61 | ) 62 | 63 | return lr_scheduler, lr_warmup_scheduler 64 | -------------------------------------------------------------------------------- /tools/train_utils/optimization/__pycache__/__init__.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/tools/train_utils/optimization/__pycache__/__init__.cpython-37.pyc -------------------------------------------------------------------------------- /tools/train_utils/optimization/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/tools/train_utils/optimization/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /tools/train_utils/optimization/__pycache__/fastai_optim.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/tools/train_utils/optimization/__pycache__/fastai_optim.cpython-37.pyc -------------------------------------------------------------------------------- /tools/train_utils/optimization/__pycache__/fastai_optim.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/tools/train_utils/optimization/__pycache__/fastai_optim.cpython-38.pyc -------------------------------------------------------------------------------- /tools/train_utils/optimization/__pycache__/learning_schedules_fastai.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/tools/train_utils/optimization/__pycache__/learning_schedules_fastai.cpython-37.pyc -------------------------------------------------------------------------------- /tools/train_utils/optimization/__pycache__/learning_schedules_fastai.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/tools/train_utils/optimization/__pycache__/learning_schedules_fastai.cpython-38.pyc -------------------------------------------------------------------------------- /tools/visual_utils/__pycache__/visualize_utils.cpython-37.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/tools/visual_utils/__pycache__/visualize_utils.cpython-37.pyc -------------------------------------------------------------------------------- /tools/visual_utils/__pycache__/visualize_utils.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ge25nab/MultiviewPointpillars/f5f20051890d44c112096bc0a4af4f95a37a07fe/tools/visual_utils/__pycache__/visualize_utils.cpython-38.pyc --------------------------------------------------------------------------------