├── projects ├── __init__.py └── mmdet3d_plugin │ ├── ops │ ├── voxel_pool │ │ ├── __init__.py │ │ └── voxel_pool.py │ ├── point_ops │ │ ├── __init__.py │ │ ├── point_ops.py │ │ └── src │ │ │ ├── point_ops.cpp │ │ │ └── point_ops_cuda.cu │ └── smooth_sampler │ │ └── __init__.py │ ├── core │ ├── bbox │ │ ├── coders │ │ │ └── __init__.py │ │ ├── assigners │ │ │ └── __init__.py │ │ ├── iou_calculators │ │ │ └── __init__.py │ │ └── match_costs │ │ │ ├── __init__.py │ │ │ └── match_cost.py │ └── hook │ │ ├── __init__.py │ │ ├── utils.py │ │ ├── sequentialcontrol.py │ │ └── syncbncontrol.py │ ├── models │ ├── dense_heads │ │ ├── render_utils │ │ │ ├── fields │ │ │ │ └── __init__.py │ │ │ ├── models │ │ │ │ ├── __init__.py │ │ │ │ ├── volsdf.py │ │ │ │ └── neus.py │ │ │ └── renderers.py │ │ └── __init__.py │ ├── detectors │ │ └── __init__.py │ ├── voxel_encoders │ │ └── __init__.py │ ├── necks │ │ └── __init__.py │ ├── __init__,py │ ├── pts_encoder │ │ └── __init__.py │ ├── backbones │ │ └── __init__.py │ └── utils │ │ └── __init__.py │ ├── datasets │ ├── __init__.py │ └── pipelines │ │ └── __init__.py │ └── __init__.py ├── requirements ├── build.txt ├── optional.txt ├── readthedocs.txt ├── mminstall.txt ├── docs.txt ├── tests.txt └── runtime.txt ├── mmdet3d ├── ops │ ├── knn │ │ ├── __init__.py │ │ └── src │ │ │ └── knn.cpp │ ├── ball_query │ │ ├── __init__.py │ │ ├── ball_query.py │ │ └── src │ │ │ └── ball_query.cpp │ ├── gather_points │ │ ├── __init__.py │ │ └── gather_points.py │ ├── iou3d │ │ └── __init__.py │ ├── interpolate │ │ ├── __init__.py │ │ └── three_nn.py │ ├── group_points │ │ └── __init__.py │ ├── paconv │ │ ├── __init__.py │ │ └── src │ │ │ └── assign_score_withk.cpp │ ├── voxel │ │ ├── __init__.py │ │ └── src │ │ │ └── voxelization.cpp │ ├── furthest_point_sample │ │ ├── __init__.py │ │ └── utils.py │ ├── roiaware_pool3d │ │ └── __init__.py │ ├── pointnet_modules │ │ ├── __init__.py │ │ └── builder.py │ └── spconv │ │ ├── include │ │ ├── tensorview │ │ │ └── helper_launch.h │ │ ├── spconv │ │ │ ├── mp_helper.h │ │ │ ├── reordering.h │ │ │ └── maxpool.h │ │ ├── utility │ │ │ └── timer.h │ │ └── pybind11_utils.h │ │ └── __init__.py ├── models │ ├── utils │ │ ├── __init__.py │ │ ├── clip_sigmoid.py │ │ └── mlp.py │ ├── decode_heads │ │ └── __init__.py │ ├── model_utils │ │ └── __init__.py │ ├── segmentors │ │ └── __init__.py │ ├── roi_heads │ │ ├── mask_heads │ │ │ └── __init__.py │ │ ├── roi_extractors │ │ │ ├── __init__.py │ │ │ └── single_roiaware_extractor.py │ │ ├── __init__.py │ │ └── bbox_heads │ │ │ └── __init__.py │ ├── necks │ │ └── __init__.py │ ├── middle_encoders │ │ └── __init__.py │ ├── voxel_encoders │ │ └── __init__.py │ ├── fusion_layers │ │ └── __init__.py │ ├── losses │ │ └── __init__.py │ ├── detectors │ │ ├── two_stage.py │ │ ├── ssd3dnet.py │ │ ├── fcos_mono3d.py │ │ └── __init__.py │ ├── backbones │ │ ├── __init__.py │ │ └── base_pointnet.py │ ├── dense_heads │ │ └── __init__.py │ └── __init__.py ├── core │ ├── evaluation │ │ ├── kitti_utils │ │ │ └── __init__.py │ │ └── __init__.py │ ├── bbox │ │ ├── assigners │ │ │ └── __init__.py │ │ ├── iou_calculators │ │ │ └── __init__.py │ │ ├── coders │ │ │ └── __init__.py │ │ ├── samplers │ │ │ └── __init__.py │ │ ├── structures │ │ │ └── __init__.py │ │ └── __init__.py │ ├── utils │ │ └── __init__.py │ ├── voxel │ │ ├── __init__.py │ │ └── builder.py │ ├── visualizer │ │ └── __init__.py │ ├── __init__.py │ ├── anchor │ │ └── __init__.py │ ├── post_processing │ │ └── __init__.py │ └── points │ │ └── __init__.py ├── utils │ ├── __init__.py │ ├── collect_env.py │ └── logger.py ├── version.py ├── apis │ ├── __init__.py │ └── train.py ├── datasets │ ├── pipelines │ │ └── __init__.py │ └── builder.py └── __init__.py ├── tools ├── data_converter │ ├── __init__.py │ └── lyft_data_fixer.py ├── dist_train.sh ├── dist_test.sh ├── create_data.sh ├── slurm_test.sh ├── slurm_train.sh ├── misc │ ├── print_config.py │ └── visualize_results.py └── model_converters │ └── publish_model.py ├── assets └── architecture.png ├── requirements.txt ├── configs ├── nuimages │ ├── mask_rcnn_r101_fpn_1x_nuim.py │ ├── cascade_mask_rcnn_r101_fpn_1x_nuim.py │ ├── htc_r50_fpn_coco-20e_20e_nuim.py │ ├── htc_r50_fpn_coco-20e_1x_nuim.py │ ├── cascade_mask_rcnn_r50_fpn_coco-20e_1x_nuim.py │ ├── mask_rcnn_r50_fpn_1x_nuim.py │ ├── cascade_mask_rcnn_r50_fpn_coco-20e_20e_nuim.py │ ├── mask_rcnn_x101_32x4d_fpn_1x_nuim.py │ ├── cascade_mask_rcnn_x101_32x4d_fpn_1x_nuim.py │ ├── mask_rcnn_r50_fpn_coco-2x_1x_nuim.py │ ├── htc_x101_64x4d_fpn_dconv_c3-c5_coco-20e_16x1_20e_nuim.py │ ├── mask_rcnn_r50_fpn_coco-2x_1x_nus-2d.py │ ├── htc_r50_fpn_1x_nuim.py │ ├── mask_rcnn_r50_caffe_fpn_1x_nuim.py │ ├── mask_rcnn_r50_caffe_fpn_coco-3x_1x_nuim.py │ └── mask_rcnn_r50_caffe_fpn_coco-3x_20e_nuim.py ├── fp16 │ ├── hv_second_secfpn_fp16_6x8_80e_kitti-3d-car.py │ ├── hv_second_secfpn_fp16_6x8_80e_kitti-3d-3class.py │ ├── hv_pointpillars_fpn_sbn-all_fp16_2x8_2x_nus-3d.py │ ├── hv_pointpillars_secfpn_sbn-all_fp16_2x8_2x_nus-3d.py │ └── hv_pointpillars_regnet-400mf_fpn_sbn-all_fp16_2x8_2x_nus-3d.py ├── centerpoint │ ├── centerpoint_01voxel_second_secfpn_circlenms_4x8_cyclic_20e_nus.py │ ├── centerpoint_02pillar_second_secfpn_circlenms_4x8_cyclic_20e_nus.py │ ├── centerpoint_0075voxel_second_secfpn_circlenms_4x8_cyclic_20e_nus.py │ ├── centerpoint_01voxel_second_secfpn_dcn_4x8_cyclic_20e_nus.py │ ├── centerpoint_02pillar_second_secfpn_dcn_4x8_cyclic_20e_nus.py │ ├── centerpoint_0075voxel_second_secfpn_dcn_4x8_cyclic_20e_nus.py │ ├── centerpoint_01voxel_second_secfpn_dcn_circlenms_4x8_cyclic_20e_nus.py │ ├── centerpoint_0075voxel_second_secfpn_dcn_circlenms_4x8_cyclic_20e_nus.py │ ├── centerpoint_02pillar_second_secfpn_dcn_circlenms_4x8_cyclic_20e_nus.py │ ├── centerpoint_0075voxel_second_secfpn_dcn_4x8_cyclic_flip-tta_20e_nus.py │ ├── centerpoint_0075voxel_second_secfpn_dcn_4x8_cyclic_tta_20e_nus.py │ └── centerpoint_0075voxel_second_secfpn_dcn_circlenms_4x8_cyclic_flip-tta_20e_nus.py ├── _base_ │ ├── models │ │ ├── paconv_cuda_ssg.py │ │ ├── hv_pointpillars_fpn_lyft.py │ │ ├── hv_pointpillars_fpn_range100_lyft.py │ │ ├── pointnet2_msg.py │ │ ├── pointnet2_ssg.py │ │ └── paconv_ssg.py │ ├── schedules │ │ ├── mmdet_schedule_1x.py │ │ ├── seg_cosine_200e.py │ │ ├── seg_cosine_50e.py │ │ ├── seg_cosine_150e.py │ │ ├── schedule_3x.py │ │ ├── schedule_2x.py │ │ ├── cosine.py │ │ ├── cyclic_20e.py │ │ └── cyclic_40e.py │ ├── default_runtime.py │ └── datasets │ │ ├── coco_instance.py │ │ └── nuim_instance.py ├── pointpillars │ ├── hv_pointpillars_fpn_sbn-all_4x8_2x_nus-3d.py │ ├── hv_pointpillars_fpn_sbn-all_2x8_2x_lyft-3d.py │ ├── hv_pointpillars_fpn_sbn-all_range100_2x8_2x_lyft-3d.py │ ├── hv_pointpillars_secfpn_sbn_2x16_2x_waymoD5-3d-3class.py │ ├── hv_pointpillars_secfpn_sbn_2x16_2x_waymo-3d-3class.py │ ├── hv_pointpillars_secfpn_sbn_2x16_2x_waymoD5-3d-car.py │ ├── hv_pointpillars_secfpn_sbn_2x16_2x_waymo-3d-car.py │ ├── hv_pointpillars_secfpn_sbn-all_4x8_2x_nus-3d.py │ ├── hv_pointpillars_secfpn_sbn-all_2x8_2x_lyft-3d.py │ └── hv_pointpillars_secfpn_sbn-all_range100_2x8_2x_lyft-3d.py ├── second │ ├── hv_second_secfpn_6x8_80e_kitti-3d-3class.py │ ├── hv_second_secfpn_6x8_80e_kitti-3d-car.py │ └── metafile.yml ├── votenet │ ├── votenet_iouloss_8x8_scannet-3d-18class.py │ ├── votenet_16x8_sunrgbd-3d-10class.py │ ├── votenet_8x8_scannet-3d-18class.py │ └── metafile.yml ├── fcos3d │ ├── fcos3d_r101_caffe_fpn_gn-head_dcn_2x8_1x_nus-mono3d_finetune.py │ └── metafile.yml ├── dynamic_voxelization │ ├── dv_second_secfpn_6x8_80e_kitti-3d-car.py │ ├── dv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py │ └── dv_second_secfpn_2x8_cosine_80e_kitti-3d-3class.py ├── free_anchor │ ├── hv_pointpillars_regnet-400mf_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py │ ├── hv_pointpillars_regnet-1.6gf_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py │ ├── hv_pointpillars_regnet-3.2gf_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py │ └── hv_pointpillars_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py ├── ssn │ ├── hv_ssn_regnet-400mf_secfpn_sbn-all_2x16_2x_nus-3d.py │ └── hv_ssn_regnet-400mf_secfpn_sbn-all_1x16_2x_lyft-3d.py ├── pointnet2 │ ├── pointnet2_ssg_16x2_cosine_50e_s3dis_seg-3d-13class.py │ ├── pointnet2_msg_16x2_cosine_80e_s3dis_seg-3d-13class.py │ ├── pointnet2_ssg_16x2_cosine_200e_scannet_seg-3d-20class.py │ └── pointnet2_msg_16x2_cosine_250e_scannet_seg-3d-20class.py ├── regnet │ ├── hv_pointpillars_regnet-1.6gf_fpn_sbn-all_4x8_2x_nus-3d.py │ ├── hv_pointpillars_regnet-400mf_fpn_sbn-all_4x8_2x_nus-3d.py │ ├── hv_pointpillars_regnet-400mf_fpn_sbn-all_2x8_2x_lyft-3d.py │ ├── hv_pointpillars_regnet-400mf_fpn_sbn-all_range100_2x8_2x_lyft-3d.py │ ├── hv_pointpillars_regnet-400mf_secfpn_sbn-all_4x8_2x_nus-3d.py │ ├── hv_pointpillars_regnet-400mf_secfpn_sbn-all_2x8_2x_lyft-3d.py │ └── hv_pointpillars_regnet-400mf_secfpn_sbn-all_range100_2x8_2x_lyft-3d.py ├── 3dssd │ └── metafile.yml ├── h3dnet │ ├── metafile.yml │ └── README.md ├── imvoxelnet │ ├── metafile.yml │ └── README.md ├── paconv │ └── metafile.yml ├── mvxnet │ ├── metafile.yml │ └── README.md ├── parta2 │ ├── metafile.yml │ └── README.md └── imvotenet │ ├── metafile.yml │ └── README.md └── extra_tools ├── dist_test_ssl.sh ├── create_data.sh └── dist_train_ssl.sh /projects/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /requirements/build.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /requirements/optional.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /requirements/readthedocs.txt: -------------------------------------------------------------------------------- 1 | mmcv 2 | torch 3 | torchvision 4 | -------------------------------------------------------------------------------- /mmdet3d/ops/knn/__init__.py: -------------------------------------------------------------------------------- 1 | from .knn import knn 2 | 3 | __all__ = ['knn'] 4 | -------------------------------------------------------------------------------- /tools/data_converter/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | -------------------------------------------------------------------------------- /assets/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hustvl/MIM4D/HEAD/assets/architecture.png -------------------------------------------------------------------------------- /mmdet3d/ops/ball_query/__init__.py: -------------------------------------------------------------------------------- 1 | from .ball_query import ball_query 2 | 3 | __all__ = ['ball_query'] 4 | -------------------------------------------------------------------------------- /requirements/mminstall.txt: -------------------------------------------------------------------------------- 1 | mmcv-full>=1.3.8,<=1.4.0 2 | mmdet>=2.14.0,<=3.0.0 3 | mmsegmentation>=0.14.1,<=1.0.0 4 | -------------------------------------------------------------------------------- /mmdet3d/ops/gather_points/__init__.py: -------------------------------------------------------------------------------- 1 | from .gather_points import gather_points 2 | 3 | __all__ = ['gather_points'] 4 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/ops/voxel_pool/__init__.py: -------------------------------------------------------------------------------- 1 | from .voxel_pool import voxel_pool 2 | 3 | __all__ = ["voxel_pool"] 4 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/core/bbox/coders/__init__.py: -------------------------------------------------------------------------------- 1 | from .nms_free_coder import NMSFreeCoder 2 | 3 | __all__ = ["NMSFreeCoder"] 4 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/ops/point_ops/__init__.py: -------------------------------------------------------------------------------- 1 | from .point_ops import group_inner_inds 2 | 3 | __all__ = ["group_inner_inds"] 4 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/ops/smooth_sampler/__init__.py: -------------------------------------------------------------------------------- 1 | from .smooth_sampler import SmoothSampler 2 | 3 | __all__ = ['SmoothSampler'] -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/models/dense_heads/render_utils/fields/__init__.py: -------------------------------------------------------------------------------- 1 | from .sdf_field import SDFField 2 | 3 | __all__ = ['SDFField'] 4 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | -r requirements/build.txt 2 | -r requirements/optional.txt 3 | -r requirements/tests.txt 4 | -r requirements/runtime.txt 5 | 6 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/core/bbox/assigners/__init__.py: -------------------------------------------------------------------------------- 1 | from .hungarian_assigner_3d import HungarianAssigner3D 2 | 3 | __all__ = ["HungarianAssigner3D"] 4 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | from .nuscenes_dataset import NuScenesSweepDataset 2 | 3 | __all__ = [ 4 | "NuScenesSweepDataset", 5 | ] 6 | -------------------------------------------------------------------------------- /mmdet3d/ops/iou3d/__init__.py: -------------------------------------------------------------------------------- 1 | from .iou3d_utils import boxes_iou_bev, nms_gpu, nms_normal_gpu 2 | 3 | __all__ = ['boxes_iou_bev', 'nms_gpu', 'nms_normal_gpu'] 4 | -------------------------------------------------------------------------------- /configs/nuimages/mask_rcnn_r101_fpn_1x_nuim.py: -------------------------------------------------------------------------------- 1 | _base_ = './mask_rcnn_r50_fpn_1x_nuim.py' 2 | model = dict(pretrained='torchvision://resnet101', backbone=dict(depth=101)) 3 | -------------------------------------------------------------------------------- /configs/fp16/hv_second_secfpn_fp16_6x8_80e_kitti-3d-car.py: -------------------------------------------------------------------------------- 1 | _base_ = '../second/hv_second_secfpn_6x8_80e_kitti-3d-car.py' 2 | # fp16 settings 3 | fp16 = dict(loss_scale=512.) 4 | -------------------------------------------------------------------------------- /mmdet3d/ops/interpolate/__init__.py: -------------------------------------------------------------------------------- 1 | from .three_interpolate import three_interpolate 2 | from .three_nn import three_nn 3 | 4 | __all__ = ['three_nn', 'three_interpolate'] 5 | -------------------------------------------------------------------------------- /configs/fp16/hv_second_secfpn_fp16_6x8_80e_kitti-3d-3class.py: -------------------------------------------------------------------------------- 1 | _base_ = '../second/hv_second_secfpn_6x8_80e_kitti-3d-3class.py' 2 | # fp16 settings 3 | fp16 = dict(loss_scale=512.) 4 | -------------------------------------------------------------------------------- /mmdet3d/ops/group_points/__init__.py: -------------------------------------------------------------------------------- 1 | from .group_points import GroupAll, QueryAndGroup, grouping_operation 2 | 3 | __all__ = ['QueryAndGroup', 'GroupAll', 'grouping_operation'] 4 | -------------------------------------------------------------------------------- /mmdet3d/ops/paconv/__init__.py: -------------------------------------------------------------------------------- 1 | from .assign_score import assign_score_withk 2 | from .paconv import PAConv, PAConvCUDA 3 | 4 | __all__ = ['assign_score_withk', 'PAConv', 'PAConvCUDA'] 5 | -------------------------------------------------------------------------------- /configs/nuimages/cascade_mask_rcnn_r101_fpn_1x_nuim.py: -------------------------------------------------------------------------------- 1 | _base_ = './cascade_mask_rcnn_r50_fpn_1x_nuim.py' 2 | model = dict(pretrained='torchvision://resnet101', backbone=dict(depth=101)) 3 | -------------------------------------------------------------------------------- /configs/nuimages/htc_r50_fpn_coco-20e_20e_nuim.py: -------------------------------------------------------------------------------- 1 | _base_ = './htc_r50_fpn_coco-20e_1x_nuim.py' 2 | # learning policy 3 | lr_config = dict(step=[16, 19]) 4 | runner = dict(max_epochs=20) 5 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/models/dense_heads/render_utils/models/__init__.py: -------------------------------------------------------------------------------- 1 | from .neus import NeuSModel 2 | from .volsdf import VolSDFModel 3 | 4 | __all__ = ['NeuSModel', 'VolSDFModel'] 5 | -------------------------------------------------------------------------------- /mmdet3d/models/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .clip_sigmoid import clip_sigmoid 3 | from .mlp import MLP 4 | 5 | __all__ = ['clip_sigmoid', 'MLP'] 6 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/models/detectors/__init__.py: -------------------------------------------------------------------------------- 1 | from .uvtr import UVTR 2 | from .uvtr_ssl_hop import UVTRSSL 3 | from .uvtr_dn import UVTRDN 4 | 5 | __all__ = ["UVTR", "UVTRSSL","UVTRDN"] 6 | -------------------------------------------------------------------------------- /mmdet3d/core/evaluation/kitti_utils/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .eval import kitti_eval, kitti_eval_coco_style 3 | 4 | __all__ = ['kitti_eval', 'kitti_eval_coco_style'] 5 | -------------------------------------------------------------------------------- /configs/centerpoint/centerpoint_01voxel_second_secfpn_circlenms_4x8_cyclic_20e_nus.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./centerpoint_01voxel_second_secfpn_4x8_cyclic_20e_nus.py'] 2 | 3 | model = dict(test_cfg=dict(pts=dict(nms_type='circle'))) 4 | -------------------------------------------------------------------------------- /configs/centerpoint/centerpoint_02pillar_second_secfpn_circlenms_4x8_cyclic_20e_nus.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./centerpoint_02pillar_second_secfpn_4x8_cyclic_20e_nus.py'] 2 | 3 | model = dict(test_cfg=dict(pts=dict(nms_type='circle'))) 4 | -------------------------------------------------------------------------------- /mmdet3d/models/decode_heads/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .paconv_head import PAConvHead 3 | from .pointnet2_head import PointNet2Head 4 | 5 | __all__ = ['PointNet2Head', 'PAConvHead'] 6 | -------------------------------------------------------------------------------- /mmdet3d/models/model_utils/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .transformer import GroupFree3DMHA 3 | from .vote_module import VoteModule 4 | 5 | __all__ = ['VoteModule', 'GroupFree3DMHA'] 6 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/core/bbox/iou_calculators/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .iou3d_calculator import PairedBboxOverlaps3D 3 | 4 | __all__ = [ 5 | 'PairedBboxOverlaps3D' 6 | ] 7 | -------------------------------------------------------------------------------- /configs/centerpoint/centerpoint_0075voxel_second_secfpn_circlenms_4x8_cyclic_20e_nus.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./centerpoint_0075voxel_second_secfpn_4x8_cyclic_20e_nus.py'] 2 | 3 | model = dict(test_cfg=dict(pts=dict(nms_type='circle'))) 4 | -------------------------------------------------------------------------------- /configs/nuimages/htc_r50_fpn_coco-20e_1x_nuim.py: -------------------------------------------------------------------------------- 1 | _base_ = './htc_r50_fpn_1x_nuim.py' 2 | 3 | load_from = 'http://download.openmmlab.com/mmdetection/v2.0/htc/htc_r50_fpn_20e_coco/htc_r50_fpn_20e_coco_20200319-fe28c577.pth' # noqa 4 | -------------------------------------------------------------------------------- /mmdet3d/core/bbox/assigners/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmdet.core.bbox import AssignResult, BaseAssigner, MaxIoUAssigner 3 | 4 | __all__ = ['BaseAssigner', 'MaxIoUAssigner', 'AssignResult'] 5 | -------------------------------------------------------------------------------- /mmdet3d/models/segmentors/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .base import Base3DSegmentor 3 | from .encoder_decoder import EncoderDecoder3D 4 | 5 | __all__ = ['Base3DSegmentor', 'EncoderDecoder3D'] 6 | -------------------------------------------------------------------------------- /mmdet3d/ops/voxel/__init__.py: -------------------------------------------------------------------------------- 1 | from .scatter_points import DynamicScatter, dynamic_scatter 2 | from .voxelize import Voxelization, voxelization 3 | 4 | __all__ = ['Voxelization', 'voxelization', 'dynamic_scatter', 'DynamicScatter'] 5 | -------------------------------------------------------------------------------- /mmdet3d/core/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .gaussian import draw_heatmap_gaussian, gaussian_2d, gaussian_radius 3 | 4 | __all__ = ['gaussian_2d', 'gaussian_radius', 'draw_heatmap_gaussian'] 5 | -------------------------------------------------------------------------------- /mmdet3d/core/voxel/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .builder import build_voxel_generator 3 | from .voxel_generator import VoxelGenerator 4 | 5 | __all__ = ['build_voxel_generator', 'VoxelGenerator'] 6 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/core/bbox/match_costs/__init__.py: -------------------------------------------------------------------------------- 1 | from mmdet.core.bbox.match_costs import build_match_cost 2 | from .match_cost import BBox3DL1Cost, BBox3DIoUCost 3 | 4 | __all__ = ['build_match_cost', 'BBox3DL1Cost', 'BBox3DIoUCost'] -------------------------------------------------------------------------------- /configs/_base_/models/paconv_cuda_ssg.py: -------------------------------------------------------------------------------- 1 | _base_ = './paconv_ssg.py' 2 | 3 | model = dict( 4 | backbone=dict( 5 | sa_cfg=dict( 6 | type='PAConvCUDASAModule', 7 | scorenet_cfg=dict(mlp_channels=[8, 16, 16])))) 8 | -------------------------------------------------------------------------------- /configs/pointpillars/hv_pointpillars_fpn_sbn-all_4x8_2x_nus-3d.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../_base_/models/hv_pointpillars_fpn_nus.py', 3 | '../_base_/datasets/nus-3d.py', '../_base_/schedules/schedule_2x.py', 4 | '../_base_/default_runtime.py' 5 | ] 6 | -------------------------------------------------------------------------------- /configs/second/hv_second_secfpn_6x8_80e_kitti-3d-3class.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../_base_/models/hv_second_secfpn_kitti.py', 3 | '../_base_/datasets/kitti-3d-3class.py', 4 | '../_base_/schedules/cyclic_40e.py', '../_base_/default_runtime.py' 5 | ] 6 | -------------------------------------------------------------------------------- /configs/pointpillars/hv_pointpillars_fpn_sbn-all_2x8_2x_lyft-3d.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../_base_/models/hv_pointpillars_fpn_lyft.py', 3 | '../_base_/datasets/lyft-3d.py', '../_base_/schedules/schedule_2x.py', 4 | '../_base_/default_runtime.py' 5 | ] 6 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/models/voxel_encoders/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | # from .dyn_voxel_encoder import CustomDynamicSimpleVFE, GridSample 3 | # 4 | # __all__ = [ 5 | # 'CustomDynamicSimpleVFE', 'GridSample' 6 | # ] 7 | -------------------------------------------------------------------------------- /requirements/docs.txt: -------------------------------------------------------------------------------- 1 | docutils==0.16.0 2 | m2r 3 | myst-parser 4 | opencv-python 5 | -e git+https://github.com/open-mmlab/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme 6 | sphinx==4.0.2 7 | sphinx-copybutton 8 | sphinx_markdown_tables 9 | torch 10 | -------------------------------------------------------------------------------- /mmdet3d/models/roi_heads/mask_heads/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .pointwise_semantic_head import PointwiseSemanticHead 3 | from .primitive_head import PrimitiveHead 4 | 5 | __all__ = ['PointwiseSemanticHead', 'PrimitiveHead'] 6 | -------------------------------------------------------------------------------- /mmdet3d/models/necks/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmdet.models.necks.fpn import FPN 3 | from .imvoxel_neck import OutdoorImVoxelNeck 4 | from .second_fpn import SECONDFPN 5 | 6 | __all__ = ['FPN', 'SECONDFPN', 'OutdoorImVoxelNeck'] 7 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/models/necks/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .second3d_fpn import SECOND3DFPN 3 | from .fpn import CustomFPN, DummyFPN 4 | from .cp_fpn import CPFPN 5 | __all__ = ['SECOND3DFPN', 'CustomFPN', 'DummyFPN',"CPFPN"] 6 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/models/dense_heads/__init__.py: -------------------------------------------------------------------------------- 1 | from .uvtr_head import UVTRHead 2 | from .render_head_hop import RenderHead 3 | from .uvtr_dn_head import UVTRDNHead 4 | 5 | 6 | __all__ = [ 7 | "UVTRHead", 8 | "RenderHead", 9 | "UVTRDNHead", 10 | ] 11 | -------------------------------------------------------------------------------- /requirements/tests.txt: -------------------------------------------------------------------------------- 1 | asynctest 2 | codecov 3 | flake8 4 | interrogate 5 | isort 6 | # Note: used for kwarray.group_items, this may be ported to mmcv in the future. 7 | kwarray 8 | pytest 9 | pytest-cov 10 | pytest-runner 11 | ubelt 12 | xdoctest >= 0.10.0 13 | yapf 14 | -------------------------------------------------------------------------------- /configs/pointpillars/hv_pointpillars_fpn_sbn-all_range100_2x8_2x_lyft-3d.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../_base_/models/hv_pointpillars_fpn_range100_lyft.py', 3 | '../_base_/datasets/range100_lyft-3d.py', 4 | '../_base_/schedules/schedule_2x.py', '../_base_/default_runtime.py' 5 | ] 6 | -------------------------------------------------------------------------------- /mmdet3d/core/visualizer/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .show_result import (show_multi_modality_result, show_result, 3 | show_seg_result) 4 | 5 | __all__ = ['show_result', 'show_seg_result', 'show_multi_modality_result'] 6 | -------------------------------------------------------------------------------- /configs/fp16/hv_pointpillars_fpn_sbn-all_fp16_2x8_2x_nus-3d.py: -------------------------------------------------------------------------------- 1 | _base_ = '../pointpillars/hv_pointpillars_fpn_sbn-all_4x8_2x_nus-3d.py' 2 | data = dict(samples_per_gpu=2, workers_per_gpu=2) 3 | # fp16 settings, the loss scale is specifically tuned to avoid Nan 4 | fp16 = dict(loss_scale=32.) 5 | -------------------------------------------------------------------------------- /configs/pointpillars/hv_pointpillars_secfpn_sbn_2x16_2x_waymoD5-3d-3class.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../_base_/models/hv_pointpillars_secfpn_waymo.py', 3 | '../_base_/datasets/waymoD5-3d-3class.py', 4 | '../_base_/schedules/schedule_2x.py', 5 | '../_base_/default_runtime.py', 6 | ] 7 | -------------------------------------------------------------------------------- /configs/fp16/hv_pointpillars_secfpn_sbn-all_fp16_2x8_2x_nus-3d.py: -------------------------------------------------------------------------------- 1 | _base_ = '../pointpillars/hv_pointpillars_secfpn_sbn-all_4x8_2x_nus-3d.py' 2 | data = dict(samples_per_gpu=2, workers_per_gpu=2) 3 | # fp16 settings, the loss scale is specifically tuned to avoid Nan 4 | fp16 = dict(loss_scale=32.) 5 | -------------------------------------------------------------------------------- /mmdet3d/models/middle_encoders/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .pillar_scatter import PointPillarsScatter 3 | from .sparse_encoder import SparseEncoder 4 | from .sparse_unet import SparseUNet 5 | 6 | __all__ = ['PointPillarsScatter', 'SparseEncoder', 'SparseUNet'] 7 | -------------------------------------------------------------------------------- /tools/dist_train.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CONFIG=$1 4 | GPUS=$2 5 | PORT=${PORT:-29500} 6 | 7 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 8 | python -m torch.distributed.launch --nproc_per_node=$GPUS --master_port=$PORT \ 9 | $(dirname "$0")/train.py $CONFIG --launcher pytorch ${@:3} 10 | -------------------------------------------------------------------------------- /configs/fp16/hv_pointpillars_regnet-400mf_fpn_sbn-all_fp16_2x8_2x_nus-3d.py: -------------------------------------------------------------------------------- 1 | _base_ = '../regnet/hv_pointpillars_regnet-400mf_fpn_sbn-all_4x8_2x_nus-3d.py' 2 | data = dict(samples_per_gpu=2, workers_per_gpu=2) 3 | # fp16 settings, the loss scale is specifically tuned to avoid Nan 4 | fp16 = dict(loss_scale=32.) 5 | -------------------------------------------------------------------------------- /mmdet3d/models/roi_heads/roi_extractors/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmdet.models.roi_heads.roi_extractors import SingleRoIExtractor 3 | from .single_roiaware_extractor import Single3DRoIAwareExtractor 4 | 5 | __all__ = ['SingleRoIExtractor', 'Single3DRoIAwareExtractor'] 6 | -------------------------------------------------------------------------------- /configs/votenet/votenet_iouloss_8x8_scannet-3d-18class.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./votenet_8x8_scannet-3d-18class.py'] 2 | 3 | # model settings, add iou loss 4 | model = dict( 5 | bbox_head=dict( 6 | iou_loss=dict( 7 | type='AxisAlignedIoULoss', reduction='sum', loss_weight=10.0 / 8 | 3.0))) 9 | -------------------------------------------------------------------------------- /requirements/runtime.txt: -------------------------------------------------------------------------------- 1 | lyft_dataset_sdk 2 | networkx>=2.2,<2.3 3 | # we may unlock the verion of numba in the future 4 | # numba==0.48.0 5 | numpy<1.20.0 6 | nuscenes-devkit 7 | plyfile 8 | scikit-image 9 | # by default we also use tensorboard to log results 10 | tensorboard 11 | trimesh>=2.35.39,<2.35.40 12 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/models/__init__,py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .backbones import * # noqa: F401,F403 3 | from .dense_heads import * # noqa: F401,F403 4 | from .detectors import * # noqa: F401,F403 5 | from .necks import * # noqa: F401,F403 6 | from .voxel_encoders import * # noqa: F401,F403 -------------------------------------------------------------------------------- /configs/nuimages/cascade_mask_rcnn_r50_fpn_coco-20e_1x_nuim.py: -------------------------------------------------------------------------------- 1 | _base_ = './cascade_mask_rcnn_r50_fpn_1x_nuim.py' 2 | 3 | load_from = 'http://download.openmmlab.com/mmdetection/v2.0/cascade_rcnn/cascade_mask_rcnn_r50_fpn_20e_coco/cascade_mask_rcnn_r50_fpn_20e_coco_bbox_mAP-0.419__segm_mAP-0.365_20200504_174711-4af8e66e.pth' # noqa 4 | -------------------------------------------------------------------------------- /tools/dist_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CONFIG=$1 4 | CHECKPOINT=$2 5 | GPUS=$3 6 | PORT=${PORT:-29500} 7 | 8 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 9 | python -m torch.distributed.launch --nproc_per_node=$GPUS --master_port=$PORT \ 10 | $(dirname "$0")/test.py $CONFIG $CHECKPOINT --launcher pytorch ${@:4} 11 | -------------------------------------------------------------------------------- /mmdet3d/ops/furthest_point_sample/__init__.py: -------------------------------------------------------------------------------- 1 | from .furthest_point_sample import (furthest_point_sample, 2 | furthest_point_sample_with_dist) 3 | from .points_sampler import Points_Sampler 4 | 5 | __all__ = [ 6 | 'furthest_point_sample', 'furthest_point_sample_with_dist', 7 | 'Points_Sampler' 8 | ] 9 | -------------------------------------------------------------------------------- /mmdet3d/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmcv.utils import Registry, build_from_cfg, print_log 3 | 4 | from .collect_env import collect_env 5 | from .logger import get_root_logger 6 | 7 | __all__ = [ 8 | 'Registry', 'build_from_cfg', 'get_root_logger', 'collect_env', 'print_log' 9 | ] 10 | -------------------------------------------------------------------------------- /mmdet3d/ops/roiaware_pool3d/__init__.py: -------------------------------------------------------------------------------- 1 | from .points_in_boxes import (points_in_boxes_batch, points_in_boxes_cpu, 2 | points_in_boxes_gpu) 3 | from .roiaware_pool3d import RoIAwarePool3d 4 | 5 | __all__ = [ 6 | 'RoIAwarePool3d', 'points_in_boxes_gpu', 'points_in_boxes_cpu', 7 | 'points_in_boxes_batch' 8 | ] 9 | -------------------------------------------------------------------------------- /configs/nuimages/mask_rcnn_r50_fpn_1x_nuim.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../_base_/models/mask_rcnn_r50_fpn.py', 3 | '../_base_/datasets/nuim_instance.py', 4 | '../_base_/schedules/mmdet_schedule_1x.py', '../_base_/default_runtime.py' 5 | ] 6 | model = dict( 7 | roi_head=dict( 8 | bbox_head=dict(num_classes=10), mask_head=dict(num_classes=10))) 9 | -------------------------------------------------------------------------------- /configs/fcos3d/fcos3d_r101_caffe_fpn_gn-head_dcn_2x8_1x_nus-mono3d_finetune.py: -------------------------------------------------------------------------------- 1 | _base_ = './fcos3d_r101_caffe_fpn_gn-head_dcn_2x8_1x_nus-mono3d.py' 2 | # model settings 3 | model = dict( 4 | train_cfg=dict( 5 | code_weight=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.05, 0.05])) 6 | # optimizer 7 | optimizer = dict(lr=0.001) 8 | load_from = 'work_dirs/fcos3d_nus/latest.pth' 9 | -------------------------------------------------------------------------------- /configs/pointpillars/hv_pointpillars_secfpn_sbn_2x16_2x_waymo-3d-3class.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../_base_/models/hv_pointpillars_secfpn_waymo.py', 3 | '../_base_/datasets/waymoD5-3d-3class.py', 4 | '../_base_/schedules/schedule_2x.py', 5 | '../_base_/default_runtime.py', 6 | ] 7 | 8 | # data settings 9 | data = dict(train=dict(dataset=dict(load_interval=1))) 10 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/core/hook/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .ema import MEGVIIEMAHook 3 | from .utils import is_parallel 4 | from .sequentialcontrol import SequentialControlHook 5 | from .syncbncontrol import SyncbnControlHook 6 | 7 | __all__ = ['MEGVIIEMAHook', 'is_parallel', 'SequentialControlHook', 8 | 'SyncbnControlHook'] 9 | -------------------------------------------------------------------------------- /mmdet3d/core/evaluation/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .indoor_eval import indoor_eval 3 | from .kitti_utils import kitti_eval, kitti_eval_coco_style 4 | from .lyft_eval import lyft_eval 5 | from .seg_eval import seg_eval 6 | 7 | __all__ = [ 8 | 'kitti_eval_coco_style', 'kitti_eval', 'indoor_eval', 'lyft_eval', 9 | 'seg_eval' 10 | ] 11 | -------------------------------------------------------------------------------- /configs/_base_/schedules/mmdet_schedule_1x.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | optimizer = dict(type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0001) 3 | optimizer_config = dict(grad_clip=None) 4 | # learning policy 5 | lr_config = dict( 6 | policy='step', 7 | warmup='linear', 8 | warmup_iters=500, 9 | warmup_ratio=0.001, 10 | step=[8, 11]) 11 | runner = dict(type='EpochBasedRunner', max_epochs=12) 12 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/core/hook/utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from torch import nn 3 | 4 | __all__ = ['is_parallel'] 5 | 6 | 7 | def is_parallel(model): 8 | """check if model is in parallel mode.""" 9 | parallel_type = ( 10 | nn.parallel.DataParallel, 11 | nn.parallel.DistributedDataParallel, 12 | ) 13 | return isinstance(model, parallel_type) 14 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/models/pts_encoder/__init__.py: -------------------------------------------------------------------------------- 1 | # from .sparse_encoder_hd import SparseEncoderHD 2 | # from .mask_sparse_encoder_hd import MaskSparseEncoderHD 3 | # from .minkunet import MinkUNet 4 | # from .sparse_unet import SpUNetBase 5 | # 6 | # __all__ = [ 7 | # "SparseEncoderHD", 8 | # "MaskSparseEncoderHD", 9 | # "MinkUNet", 10 | # "SparseEncoderHDV2", 11 | # "SpUNetBase", 12 | # ] 13 | -------------------------------------------------------------------------------- /configs/_base_/schedules/seg_cosine_200e.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | # This schedule is mainly used on ScanNet dataset in segmentation task 3 | optimizer = dict(type='Adam', lr=0.001, weight_decay=0.01) 4 | optimizer_config = dict(grad_clip=None) 5 | lr_config = dict(policy='CosineAnnealing', warmup=None, min_lr=1e-5) 6 | momentum_config = None 7 | 8 | # runtime settings 9 | runner = dict(type='EpochBasedRunner', max_epochs=200) 10 | -------------------------------------------------------------------------------- /configs/_base_/schedules/seg_cosine_50e.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | # This schedule is mainly used on S3DIS dataset in segmentation task 3 | optimizer = dict(type='Adam', lr=0.001, weight_decay=0.001) 4 | optimizer_config = dict(grad_clip=None) 5 | lr_config = dict(policy='CosineAnnealing', warmup=None, min_lr=1e-5) 6 | momentum_config = None 7 | 8 | # runtime settings 9 | runner = dict(type='EpochBasedRunner', max_epochs=50) 10 | -------------------------------------------------------------------------------- /configs/nuimages/cascade_mask_rcnn_r50_fpn_coco-20e_20e_nuim.py: -------------------------------------------------------------------------------- 1 | _base_ = './cascade_mask_rcnn_r50_fpn_1x_nuim.py' 2 | 3 | # learning policy 4 | lr_config = dict(step=[16, 19]) 5 | runner = dict(max_epochs=20) 6 | 7 | load_from = 'http://download.openmmlab.com/mmdetection/v2.0/cascade_rcnn/cascade_mask_rcnn_r50_fpn_20e_coco/cascade_mask_rcnn_r50_fpn_20e_coco_bbox_mAP-0.419__segm_mAP-0.365_20200504_174711-4af8e66e.pth' # noqa 8 | -------------------------------------------------------------------------------- /mmdet3d/models/voxel_encoders/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .pillar_encoder import PillarFeatureNet 3 | from .voxel_encoder import DynamicSimpleVFE, DynamicVFE, HardSimpleVFE, HardVFE 4 | # from projects.mmdet3d_plugin.models.voxel_encoders import CustomDynamicSimpleVFE 5 | 6 | __all__ = [ 7 | 'PillarFeatureNet', 'HardVFE', 'DynamicVFE', 'HardSimpleVFE', 8 | 'DynamicSimpleVFE' 9 | ] 10 | -------------------------------------------------------------------------------- /configs/_base_/schedules/seg_cosine_150e.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | # This schedule is mainly used on S3DIS dataset in segmentation task 3 | optimizer = dict(type='SGD', lr=0.2, weight_decay=0.0001, momentum=0.9) 4 | optimizer_config = dict(grad_clip=None) 5 | lr_config = dict(policy='CosineAnnealing', warmup=None, min_lr=0.002) 6 | momentum_config = None 7 | 8 | # runtime settings 9 | runner = dict(type='EpochBasedRunner', max_epochs=150) 10 | -------------------------------------------------------------------------------- /mmdet3d/models/fusion_layers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .coord_transform import (apply_3d_transformation, bbox_2d_transform, 3 | coord_2d_transform) 4 | from .point_fusion import PointFusion 5 | from .vote_fusion import VoteFusion 6 | 7 | __all__ = [ 8 | 'PointFusion', 'VoteFusion', 'apply_3d_transformation', 9 | 'bbox_2d_transform', 'coord_2d_transform' 10 | ] 11 | -------------------------------------------------------------------------------- /mmdet3d/core/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .anchor import * # noqa: F401, F403 3 | from .bbox import * # noqa: F401, F403 4 | from .evaluation import * # noqa: F401, F403 5 | from .points import * # noqa: F401, F403 6 | from .post_processing import * # noqa: F401, F403 7 | from .utils import * # noqa: F401, F403 8 | from .visualizer import * # noqa: F401, F403 9 | from .voxel import * # noqa: F401, F403 10 | -------------------------------------------------------------------------------- /configs/_base_/schedules/schedule_3x.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | # This schedule is mainly used by models on indoor dataset, 3 | # e.g., VoteNet on SUNRGBD and ScanNet 4 | lr = 0.008 # max learning rate 5 | optimizer = dict(type='AdamW', lr=lr, weight_decay=0.01) 6 | optimizer_config = dict(grad_clip=dict(max_norm=10, norm_type=2)) 7 | lr_config = dict(policy='step', warmup=None, step=[24, 32]) 8 | # runtime settings 9 | runner = dict(type='EpochBasedRunner', max_epochs=36) 10 | -------------------------------------------------------------------------------- /configs/nuimages/mask_rcnn_x101_32x4d_fpn_1x_nuim.py: -------------------------------------------------------------------------------- 1 | _base_ = './mask_rcnn_r50_fpn_1x_nuim.py' 2 | model = dict( 3 | pretrained='open-mmlab://resnext101_32x4d', 4 | backbone=dict( 5 | type='ResNeXt', 6 | depth=101, 7 | groups=32, 8 | base_width=4, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | frozen_stages=1, 12 | norm_cfg=dict(type='BN', requires_grad=True), 13 | style='pytorch')) 14 | -------------------------------------------------------------------------------- /configs/nuimages/cascade_mask_rcnn_x101_32x4d_fpn_1x_nuim.py: -------------------------------------------------------------------------------- 1 | _base_ = './cascade_mask_rcnn_r50_fpn_1x_nuim.py' 2 | model = dict( 3 | pretrained='open-mmlab://resnext101_32x4d', 4 | backbone=dict( 5 | type='ResNeXt', 6 | depth=101, 7 | groups=32, 8 | base_width=4, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | frozen_stages=1, 12 | norm_cfg=dict(type='BN', requires_grad=True), 13 | style='pytorch')) 14 | -------------------------------------------------------------------------------- /mmdet3d/core/anchor/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmdet.core.anchor import build_prior_generator 3 | from .anchor_3d_generator import (AlignedAnchor3DRangeGenerator, 4 | AlignedAnchor3DRangeGeneratorPerCls, 5 | Anchor3DRangeGenerator) 6 | 7 | __all__ = [ 8 | 'AlignedAnchor3DRangeGenerator', 'Anchor3DRangeGenerator', 9 | 'build_prior_generator', 'AlignedAnchor3DRangeGeneratorPerCls' 10 | ] 11 | -------------------------------------------------------------------------------- /extra_tools/dist_test_ssl.sh: -------------------------------------------------------------------------------- 1 | 2 | #!/usr/bin/env bash 3 | 4 | while true 5 | do 6 | PORT=$(( ((RANDOM<<15)|RANDOM) % 49152 + 10000 )) 7 | status="$(nc -z 127.0.0.1 $PORT < /dev/null &>/dev/null; echo $?)" 8 | if [ "${status}" != "0" ]; then 9 | break; 10 | fi 11 | done 12 | echo $PORT 13 | 14 | CONFIG=projects/configs/MIM4D/uvtr_convnext_s_vs0.075_finetune.py 15 | CHECKPOINT=ckpts/uvtrs_mim4d_vs0.075/uvtrs_mim4d_vs0.075_finetune.pth 16 | 17 | 18 | python3 $(dirname "$0")/test.py $CONFIG $CHECKPOINT --eval bbox -------------------------------------------------------------------------------- /configs/_base_/schedules/schedule_2x.py: -------------------------------------------------------------------------------- 1 | # optimizer 2 | # This schedule is mainly used by models on nuScenes dataset 3 | optimizer = dict(type='AdamW', lr=0.001, weight_decay=0.01) 4 | # max_norm=10 is better for SECOND 5 | optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) 6 | lr_config = dict( 7 | policy='step', 8 | warmup='linear', 9 | warmup_iters=1000, 10 | warmup_ratio=1.0 / 1000, 11 | step=[20, 23]) 12 | momentum_config = None 13 | # runtime settings 14 | runner = dict(type='EpochBasedRunner', max_epochs=24) 15 | -------------------------------------------------------------------------------- /configs/nuimages/mask_rcnn_r50_fpn_coco-2x_1x_nuim.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../_base_/models/mask_rcnn_r50_fpn.py', 3 | '../_base_/datasets/nuim_instance.py', 4 | '../_base_/schedules/mmdet_schedule_1x.py', '../_base_/default_runtime.py' 5 | ] 6 | model = dict( 7 | roi_head=dict( 8 | bbox_head=dict(num_classes=10), mask_head=dict(num_classes=10))) 9 | load_from = 'https://download.openmmlab.com/mmdetection/v2.0/mask_rcnn/mask_rcnn_r50_fpn_2x_coco/mask_rcnn_r50_fpn_2x_coco_bbox_mAP-0.392__segm_mAP-0.354_20200505_003907-3e542a40.pth' # noqa 10 | -------------------------------------------------------------------------------- /mmdet3d/models/utils/clip_sigmoid.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import torch 3 | 4 | 5 | def clip_sigmoid(x, eps=1e-4): 6 | """Sigmoid function for input feature. 7 | 8 | Args: 9 | x (torch.Tensor): Input feature map with the shape of [B, N, H, W]. 10 | eps (float): Lower bound of the range to be clamped to. Defaults 11 | to 1e-4. 12 | 13 | Returns: 14 | torch.Tensor: Feature map after sigmoid. 15 | """ 16 | y = torch.clamp(x.sigmoid_(), min=eps, max=1 - eps) 17 | return y 18 | -------------------------------------------------------------------------------- /mmdet3d/core/bbox/iou_calculators/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .iou3d_calculator import (AxisAlignedBboxOverlaps3D, BboxOverlaps3D, 3 | BboxOverlapsNearest3D, 4 | axis_aligned_bbox_overlaps_3d, bbox_overlaps_3d, 5 | bbox_overlaps_nearest_3d) 6 | 7 | __all__ = [ 8 | 'BboxOverlapsNearest3D', 'BboxOverlaps3D', 'bbox_overlaps_nearest_3d', 9 | 'bbox_overlaps_3d', 'AxisAlignedBboxOverlaps3D', 10 | 'axis_aligned_bbox_overlaps_3d' 11 | ] 12 | -------------------------------------------------------------------------------- /configs/centerpoint/centerpoint_01voxel_second_secfpn_dcn_4x8_cyclic_20e_nus.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./centerpoint_01voxel_second_secfpn_4x8_cyclic_20e_nus.py'] 2 | 3 | model = dict( 4 | pts_bbox_head=dict( 5 | separate_head=dict( 6 | type='DCNSeparateHead', 7 | dcn_config=dict( 8 | type='DCN', 9 | in_channels=64, 10 | out_channels=64, 11 | kernel_size=3, 12 | padding=1, 13 | groups=4), 14 | init_bias=-2.19, 15 | final_kernel=3))) 16 | -------------------------------------------------------------------------------- /configs/centerpoint/centerpoint_02pillar_second_secfpn_dcn_4x8_cyclic_20e_nus.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./centerpoint_02pillar_second_secfpn_4x8_cyclic_20e_nus.py'] 2 | 3 | model = dict( 4 | pts_bbox_head=dict( 5 | separate_head=dict( 6 | type='DCNSeparateHead', 7 | dcn_config=dict( 8 | type='DCN', 9 | in_channels=64, 10 | out_channels=64, 11 | kernel_size=3, 12 | padding=1, 13 | groups=4), 14 | init_bias=-2.19, 15 | final_kernel=3))) 16 | -------------------------------------------------------------------------------- /mmdet3d/core/voxel/builder.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import mmcv 3 | 4 | from . import voxel_generator 5 | 6 | 7 | def build_voxel_generator(cfg, **kwargs): 8 | """Builder of voxel generator.""" 9 | if isinstance(cfg, voxel_generator.VoxelGenerator): 10 | return cfg 11 | elif isinstance(cfg, dict): 12 | return mmcv.runner.obj_from_dict( 13 | cfg, voxel_generator, default_args=kwargs) 14 | else: 15 | raise TypeError('Invalid type {} for building a sampler'.format( 16 | type(cfg))) 17 | -------------------------------------------------------------------------------- /configs/centerpoint/centerpoint_0075voxel_second_secfpn_dcn_4x8_cyclic_20e_nus.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./centerpoint_0075voxel_second_secfpn_4x8_cyclic_20e_nus.py'] 2 | 3 | model = dict( 4 | pts_bbox_head=dict( 5 | separate_head=dict( 6 | type='DCNSeparateHead', 7 | dcn_config=dict( 8 | type='DCN', 9 | in_channels=64, 10 | out_channels=64, 11 | kernel_size=3, 12 | padding=1, 13 | groups=4), 14 | init_bias=-2.19, 15 | final_kernel=3))) 16 | -------------------------------------------------------------------------------- /configs/_base_/default_runtime.py: -------------------------------------------------------------------------------- 1 | checkpoint_config = dict(interval=1) 2 | # yapf:disable push 3 | # By default we use textlogger hook and tensorboard 4 | # For more loggers see 5 | # https://mmcv.readthedocs.io/en/latest/api.html#mmcv.runner.LoggerHook 6 | log_config = dict( 7 | interval=50, 8 | hooks=[ 9 | dict(type='TextLoggerHook'), 10 | dict(type='TensorboardLoggerHook') 11 | ]) 12 | # yapf:enable 13 | dist_params = dict(backend='nccl') 14 | log_level = 'INFO' 15 | work_dir = None 16 | load_from = None 17 | resume_from = None 18 | workflow = [('train', 1)] 19 | -------------------------------------------------------------------------------- /mmdet3d/models/losses/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmdet.models.losses import FocalLoss, SmoothL1Loss, binary_cross_entropy 3 | from .axis_aligned_iou_loss import AxisAlignedIoULoss, axis_aligned_iou_loss 4 | from .chamfer_distance import ChamferDistance, chamfer_distance 5 | from .paconv_regularization_loss import PAConvRegularizationLoss 6 | 7 | __all__ = [ 8 | 'FocalLoss', 'SmoothL1Loss', 'binary_cross_entropy', 'ChamferDistance', 9 | 'chamfer_distance', 'axis_aligned_iou_loss', 'AxisAlignedIoULoss', 10 | 'PAConvRegularizationLoss' 11 | ] 12 | -------------------------------------------------------------------------------- /mmdet3d/ops/pointnet_modules/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .builder import build_sa_module 3 | from .paconv_sa_module import (PAConvCUDASAModule, PAConvCUDASAModuleMSG, 4 | PAConvSAModule, PAConvSAModuleMSG) 5 | from .point_fp_module import PointFPModule 6 | from .point_sa_module import PointSAModule, PointSAModuleMSG 7 | 8 | __all__ = [ 9 | 'build_sa_module', 'PointSAModuleMSG', 'PointSAModule', 'PointFPModule', 10 | 'PAConvSAModule', 'PAConvSAModuleMSG', 'PAConvCUDASAModule', 11 | 'PAConvCUDASAModuleMSG' 12 | ] 13 | -------------------------------------------------------------------------------- /mmdet3d/ops/voxel/src/voxelization.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "voxelization.h" 3 | 4 | namespace voxelization { 5 | 6 | PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { 7 | m.def("hard_voxelize", &hard_voxelize, "hard voxelize"); 8 | m.def("dynamic_voxelize", &dynamic_voxelize, "dynamic voxelization"); 9 | m.def("dynamic_point_to_voxel_forward", &dynamic_point_to_voxel_forward, "dynamic point to voxel forward"); 10 | m.def("dynamic_point_to_voxel_backward", &dynamic_point_to_voxel_backward, "dynamic point to voxel backward"); 11 | } 12 | 13 | } // namespace voxelization 14 | -------------------------------------------------------------------------------- /mmdet3d/version.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Open-MMLab. All rights reserved. 2 | 3 | __version__ = '0.17.3' 4 | short_version = __version__ 5 | 6 | 7 | def parse_version_info(version_str): 8 | version_info = [] 9 | for x in version_str.split('.'): 10 | if x.isdigit(): 11 | version_info.append(int(x)) 12 | elif x.find('rc') != -1: 13 | patch_version = x.split('rc') 14 | version_info.append(int(patch_version[0])) 15 | version_info.append(f'rc{patch_version[1]}') 16 | return tuple(version_info) 17 | 18 | 19 | version_info = parse_version_info(__version__) 20 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/models/backbones/__init__.py: -------------------------------------------------------------------------------- 1 | from .second_3d import SECOND3D 2 | from .mask_convnext import MaskConvNeXt 3 | from .mask_resnet import MaskResNet 4 | from .temporal_backbone import TemporalDecoder, BiTemporalPredictor, BiTemporalPredictor_longshort 5 | from .bevformerencoder import BEVFormerEncoder, BEVFormerLayer 6 | from .temporal_cross_attention import TemporalCrossAttention 7 | # from .pool_3d import Pool3D 8 | 9 | __all__ = ["SECOND3D", "MaskConvNeXt", "MaskResNet","TemporalDecoder","BiTemporalPredictor","BEVFormerEncoder","BEVFormerLayer","TemporalCrossAttention", "BiTemporalPredictor_longshort"] 10 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/ops/point_ops/point_ops.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from . import point_ops_ext 3 | 4 | 5 | def group_inner_inds(points, inverse_inds, K): 6 | """ 7 | Args: 8 | points: (N, C) 9 | inverse_inds: (N, ) 10 | Return: 11 | group_points: (valid_voxel_num, K, C) 12 | """ 13 | valid_voxel_num = inverse_inds.max().item() + 1 14 | group_inds = torch.full((valid_voxel_num, K), -1, dtype=torch.long, device=points.device) 15 | point_ops_ext.group_inner_inds_wrapper(inverse_inds.contiguous(), group_inds) 16 | group_points = points[group_inds] 17 | return group_points -------------------------------------------------------------------------------- /mmdet3d/models/detectors/two_stage.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmdet.models import DETECTORS, TwoStageDetector 3 | from .base import Base3DDetector 4 | 5 | 6 | @DETECTORS.register_module() 7 | class TwoStage3DDetector(Base3DDetector, TwoStageDetector): 8 | """Base class of two-stage 3D detector. 9 | 10 | It inherits original ``:class:TwoStageDetector`` and 11 | ``:class:Base3DDetector``. This class could serve as a base class for all 12 | two-stage 3D detectors. 13 | """ 14 | 15 | def __init__(self, **kwargs): 16 | super(TwoStage3DDetector, self).__init__(**kwargs) 17 | -------------------------------------------------------------------------------- /configs/centerpoint/centerpoint_01voxel_second_secfpn_dcn_circlenms_4x8_cyclic_20e_nus.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./centerpoint_01voxel_second_secfpn_4x8_cyclic_20e_nus.py'] 2 | 3 | model = dict( 4 | pts_bbox_head=dict( 5 | separate_head=dict( 6 | type='DCNSeparateHead', 7 | dcn_config=dict( 8 | type='DCN', 9 | in_channels=64, 10 | out_channels=64, 11 | kernel_size=3, 12 | padding=1, 13 | groups=4), 14 | init_bias=-2.19, 15 | final_kernel=3)), 16 | test_cfg=dict(pts=dict(nms_type='circle'))) 17 | -------------------------------------------------------------------------------- /mmdet3d/core/bbox/coders/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmdet.core.bbox import build_bbox_coder 3 | from .anchor_free_bbox_coder import AnchorFreeBBoxCoder 4 | from .centerpoint_bbox_coders import CenterPointBBoxCoder 5 | from .delta_xyzwhlr_bbox_coder import DeltaXYZWLHRBBoxCoder 6 | from .groupfree3d_bbox_coder import GroupFree3DBBoxCoder 7 | from .partial_bin_based_bbox_coder import PartialBinBasedBBoxCoder 8 | 9 | __all__ = [ 10 | 'build_bbox_coder', 'DeltaXYZWLHRBBoxCoder', 'PartialBinBasedBBoxCoder', 11 | 'CenterPointBBoxCoder', 'AnchorFreeBBoxCoder', 'GroupFree3DBBoxCoder' 12 | ] 13 | -------------------------------------------------------------------------------- /configs/centerpoint/centerpoint_0075voxel_second_secfpn_dcn_circlenms_4x8_cyclic_20e_nus.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./centerpoint_0075voxel_second_secfpn_4x8_cyclic_20e_nus.py'] 2 | 3 | model = dict( 4 | pts_bbox_head=dict( 5 | separate_head=dict( 6 | type='DCNSeparateHead', 7 | dcn_config=dict( 8 | type='DCN', 9 | in_channels=64, 10 | out_channels=64, 11 | kernel_size=3, 12 | padding=1, 13 | groups=4), 14 | init_bias=-2.19, 15 | final_kernel=3)), 16 | test_cfg=dict(pts=dict(nms_type='circle'))) 17 | -------------------------------------------------------------------------------- /configs/centerpoint/centerpoint_02pillar_second_secfpn_dcn_circlenms_4x8_cyclic_20e_nus.py: -------------------------------------------------------------------------------- 1 | _base_ = ['./centerpoint_02pillar_second_secfpn_4x8_cyclic_20e_nus.py'] 2 | 3 | model = dict( 4 | pts_bbox_head=dict( 5 | separate_head=dict( 6 | type='DCNSeparateHead', 7 | dcn_config=dict( 8 | type='DCN', 9 | in_channels=64, 10 | out_channels=64, 11 | kernel_size=3, 12 | padding=1, 13 | groups=4), 14 | init_bias=-2.19, 15 | final_kernel=3)), 16 | test_cfg=dict(pts=dict(nms_type='circle'))) 17 | -------------------------------------------------------------------------------- /mmdet3d/models/roi_heads/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .base_3droi_head import Base3DRoIHead 3 | from .bbox_heads import PartA2BboxHead 4 | from .h3d_roi_head import H3DRoIHead 5 | from .mask_heads import PointwiseSemanticHead, PrimitiveHead 6 | from .part_aggregation_roi_head import PartAggregationROIHead 7 | from .roi_extractors import Single3DRoIAwareExtractor, SingleRoIExtractor 8 | 9 | __all__ = [ 10 | 'Base3DRoIHead', 'PartAggregationROIHead', 'PointwiseSemanticHead', 11 | 'Single3DRoIAwareExtractor', 'PartA2BboxHead', 'SingleRoIExtractor', 12 | 'H3DRoIHead', 'PrimitiveHead' 13 | ] 14 | -------------------------------------------------------------------------------- /configs/_base_/schedules/cosine.py: -------------------------------------------------------------------------------- 1 | # This schedule is mainly used by models with dynamic voxelization 2 | # optimizer 3 | lr = 0.003 # max learning rate 4 | optimizer = dict( 5 | type='AdamW', 6 | lr=lr, 7 | betas=(0.95, 0.99), # the momentum is change during training 8 | weight_decay=0.001) 9 | optimizer_config = dict(grad_clip=dict(max_norm=10, norm_type=2)) 10 | 11 | lr_config = dict( 12 | policy='CosineAnnealing', 13 | warmup='linear', 14 | warmup_iters=1000, 15 | warmup_ratio=1.0 / 10, 16 | min_lr_ratio=1e-5) 17 | 18 | momentum_config = None 19 | 20 | runner = dict(type='EpochBasedRunner', max_epochs=40) 21 | -------------------------------------------------------------------------------- /configs/dynamic_voxelization/dv_second_secfpn_6x8_80e_kitti-3d-car.py: -------------------------------------------------------------------------------- 1 | _base_ = '../second/hv_second_secfpn_6x8_80e_kitti-3d-car.py' 2 | 3 | point_cloud_range = [0, -40, -3, 70.4, 40, 1] 4 | voxel_size = [0.05, 0.05, 0.1] 5 | 6 | model = dict( 7 | type='DynamicVoxelNet', 8 | voxel_layer=dict( 9 | _delete_=True, 10 | max_num_points=-1, 11 | point_cloud_range=point_cloud_range, 12 | voxel_size=voxel_size, 13 | max_voxels=(-1, -1)), 14 | voxel_encoder=dict( 15 | _delete_=True, 16 | type='DynamicSimpleVFE', 17 | voxel_size=voxel_size, 18 | point_cloud_range=point_cloud_range)) 19 | -------------------------------------------------------------------------------- /mmdet3d/apis/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .inference import (convert_SyncBN, inference_detector, 3 | inference_mono_3d_detector, 4 | inference_multi_modality_detector, inference_segmentor, 5 | init_model, show_result_meshlab) 6 | from .test import single_gpu_test 7 | from .train import train_model 8 | 9 | __all__ = [ 10 | 'inference_detector', 'init_model', 'single_gpu_test', 11 | 'inference_mono_3d_detector', 'show_result_meshlab', 'convert_SyncBN', 12 | 'train_model', 'inference_multi_modality_detector', 'inference_segmentor' 13 | ] 14 | -------------------------------------------------------------------------------- /mmdet3d/core/post_processing/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmdet.core.post_processing import (merge_aug_bboxes, merge_aug_masks, 3 | merge_aug_proposals, merge_aug_scores, 4 | multiclass_nms) 5 | from .box3d_nms import aligned_3d_nms, box3d_multiclass_nms, circle_nms 6 | from .merge_augs import merge_aug_bboxes_3d 7 | 8 | __all__ = [ 9 | 'multiclass_nms', 'merge_aug_proposals', 'merge_aug_bboxes', 10 | 'merge_aug_scores', 'merge_aug_masks', 'box3d_multiclass_nms', 11 | 'aligned_3d_nms', 'merge_aug_bboxes_3d', 'circle_nms' 12 | ] 13 | -------------------------------------------------------------------------------- /mmdet3d/models/roi_heads/bbox_heads/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmdet.models.roi_heads.bbox_heads import (BBoxHead, ConvFCBBoxHead, 3 | DoubleConvFCBBoxHead, 4 | Shared2FCBBoxHead, 5 | Shared4Conv1FCBBoxHead) 6 | from .h3d_bbox_head import H3DBboxHead 7 | from .parta2_bbox_head import PartA2BboxHead 8 | 9 | __all__ = [ 10 | 'BBoxHead', 'ConvFCBBoxHead', 'Shared2FCBBoxHead', 11 | 'Shared4Conv1FCBBoxHead', 'DoubleConvFCBBoxHead', 'PartA2BboxHead', 12 | 'H3DBboxHead' 13 | ] 14 | -------------------------------------------------------------------------------- /tools/create_data.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -x 4 | export PYTHONPATH=`pwd`:$PYTHONPATH 5 | 6 | PARTITION=$1 7 | JOB_NAME=$2 8 | CONFIG=$3 9 | WORK_DIR=$4 10 | GPUS=${GPUS:-1} 11 | GPUS_PER_NODE=${GPUS_PER_NODE:-1} 12 | SRUN_ARGS=${SRUN_ARGS:-""} 13 | JOB_NAME=create_data 14 | 15 | srun -p ${PARTITION} \ 16 | --job-name=${JOB_NAME} \ 17 | --gres=gpu:${GPUS_PER_NODE} \ 18 | --ntasks=${GPUS} \ 19 | --ntasks-per-node=${GPUS_PER_NODE} \ 20 | --kill-on-bad-exit=1 \ 21 | ${SRUN_ARGS} \ 22 | python -u tools/create_data.py kitti \ 23 | --root-path ./data/kitti \ 24 | --out-dir ./data/kitti \ 25 | --extra-tag kitti 26 | -------------------------------------------------------------------------------- /tools/slurm_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -x 4 | 5 | PARTITION=$1 6 | JOB_NAME=$2 7 | CONFIG=$3 8 | CHECKPOINT=$4 9 | GPUS=${GPUS:-8} 10 | GPUS_PER_NODE=${GPUS_PER_NODE:-8} 11 | CPUS_PER_TASK=${CPUS_PER_TASK:-5} 12 | PY_ARGS=${@:5} 13 | SRUN_ARGS=${SRUN_ARGS:-""} 14 | 15 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 16 | srun -p ${PARTITION} \ 17 | --job-name=${JOB_NAME} \ 18 | --gres=gpu:${GPUS_PER_NODE} \ 19 | --ntasks=${GPUS} \ 20 | --ntasks-per-node=${GPUS_PER_NODE} \ 21 | --cpus-per-task=${CPUS_PER_TASK} \ 22 | --kill-on-bad-exit=1 \ 23 | ${SRUN_ARGS} \ 24 | python -u tools/test.py ${CONFIG} ${CHECKPOINT} --launcher="slurm" ${PY_ARGS} 25 | -------------------------------------------------------------------------------- /extra_tools/create_data.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -x 4 | export PYTHONPATH=`pwd`:$PYTHONPATH 5 | 6 | PARTITION=$1 7 | JOB_NAME=$2 8 | CONFIG=$3 9 | WORK_DIR=$4 10 | GPUS=${GPUS:-1} 11 | GPUS_PER_NODE=${GPUS_PER_NODE:-1} 12 | SRUN_ARGS=${SRUN_ARGS:-""} 13 | JOB_NAME=create_data 14 | 15 | srun -p ${PARTITION} \ 16 | --job-name=${JOB_NAME} \ 17 | --gres=gpu:${GPUS_PER_NODE} \ 18 | --ntasks=${GPUS} \ 19 | --ntasks-per-node=${GPUS_PER_NODE} \ 20 | --kill-on-bad-exit=1 \ 21 | ${SRUN_ARGS} \ 22 | python3 -u tools/create_data.py kitti \ 23 | --root-path ./data/kitti \ 24 | --out-dir ./data/kitti \ 25 | --extra-tag kitti 26 | -------------------------------------------------------------------------------- /mmdet3d/ops/spconv/include/tensorview/helper_launch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // from pytorch.aten 3 | #include "tensorview.h" 4 | namespace tv 5 | { 6 | namespace launch 7 | { 8 | 9 | template 10 | inline int DivUp(const T1 a, const T2 b) { return (a + b - 1) / b; } 11 | 12 | // Use 1024 threads per block, which requires cuda sm_2x or above 13 | constexpr int CUDA_NUM_THREADS = 1024; 14 | // CUDA: number of blocks for threads. 15 | inline int getBlocks(const int N) 16 | { 17 | TV_ASSERT_RT_ERR(N > 0, "CUDA kernel launch blocks must be positive, but got N=", N); 18 | return DivUp(N, CUDA_NUM_THREADS); 19 | } 20 | } // namespace launch 21 | } // namespace tv 22 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/__init__.py: -------------------------------------------------------------------------------- 1 | from .core.bbox.assigners.hungarian_assigner_3d import HungarianAssigner3D 2 | from .core.bbox.coders.nms_free_coder import NMSFreeCoder 3 | from .core.bbox.match_costs import BBox3DL1Cost 4 | from .datasets import NuScenesSweepDataset 5 | from .datasets.pipelines import ( 6 | PhotoMetricDistortionMultiViewImage, 7 | PadMultiViewImage, 8 | NormalizeMultiviewImage, 9 | RandomResizeCropFlipMultiViewImage, 10 | ) 11 | from .models.backbones import MaskResNet 12 | from .models.detectors import UVTR 13 | from .models.dense_heads import UVTRHead 14 | # from .models.pts_encoder import SparseEncoderHD 15 | from .models.necks import SECOND3DFPN 16 | -------------------------------------------------------------------------------- /tools/slurm_train.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -x 4 | 5 | PARTITION=$1 6 | JOB_NAME=$2 7 | CONFIG=$3 8 | WORK_DIR=$4 9 | GPUS=${GPUS:-8} 10 | GPUS_PER_NODE=${GPUS_PER_NODE:-8} 11 | CPUS_PER_TASK=${CPUS_PER_TASK:-5} 12 | SRUN_ARGS=${SRUN_ARGS:-""} 13 | PY_ARGS=${@:5} 14 | 15 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 16 | srun -p ${PARTITION} \ 17 | --job-name=${JOB_NAME} \ 18 | --gres=gpu:${GPUS_PER_NODE} \ 19 | --ntasks=${GPUS} \ 20 | --ntasks-per-node=${GPUS_PER_NODE} \ 21 | --cpus-per-task=${CPUS_PER_TASK} \ 22 | --kill-on-bad-exit=1 \ 23 | ${SRUN_ARGS} \ 24 | python -u tools/train.py ${CONFIG} --work-dir=${WORK_DIR} --launcher="slurm" ${PY_ARGS} 25 | -------------------------------------------------------------------------------- /mmdet3d/utils/collect_env.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmcv.utils import collect_env as collect_base_env 3 | from mmcv.utils import get_git_hash 4 | 5 | import mmdet 6 | import mmdet3d 7 | import mmseg 8 | 9 | 10 | def collect_env(): 11 | """Collect the information of the running environments.""" 12 | env_info = collect_base_env() 13 | env_info['MMDetection'] = mmdet.__version__ 14 | env_info['MMSegmentation'] = mmseg.__version__ 15 | env_info['MMDetection3D'] = mmdet3d.__version__ + '+' + get_git_hash()[:7] 16 | 17 | return env_info 18 | 19 | 20 | if __name__ == '__main__': 21 | for name, val in collect_env().items(): 22 | print(f'{name}: {val}') 23 | -------------------------------------------------------------------------------- /configs/dynamic_voxelization/dv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py: -------------------------------------------------------------------------------- 1 | _base_ = '../pointpillars/hv_pointpillars_secfpn_6x8_160e_kitti-3d-car.py' 2 | 3 | voxel_size = [0.16, 0.16, 4] 4 | point_cloud_range = [0, -39.68, -3, 69.12, 39.68, 1] 5 | 6 | model = dict( 7 | type='DynamicVoxelNet', 8 | voxel_layer=dict( 9 | max_num_points=-1, 10 | point_cloud_range=point_cloud_range, 11 | voxel_size=voxel_size, 12 | max_voxels=(-1, -1)), 13 | voxel_encoder=dict( 14 | type='DynamicPillarFeatureNet', 15 | in_channels=4, 16 | feat_channels=[64], 17 | with_distance=False, 18 | voxel_size=voxel_size, 19 | point_cloud_range=point_cloud_range)) 20 | -------------------------------------------------------------------------------- /mmdet3d/core/bbox/samplers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmdet.core.bbox.samplers import (BaseSampler, CombinedSampler, 3 | InstanceBalancedPosSampler, 4 | IoUBalancedNegSampler, OHEMSampler, 5 | PseudoSampler, RandomSampler, 6 | SamplingResult) 7 | from .iou_neg_piecewise_sampler import IoUNegPiecewiseSampler 8 | 9 | __all__ = [ 10 | 'BaseSampler', 'PseudoSampler', 'RandomSampler', 11 | 'InstanceBalancedPosSampler', 'IoUBalancedNegSampler', 'CombinedSampler', 12 | 'OHEMSampler', 'SamplingResult', 'IoUNegPiecewiseSampler' 13 | ] 14 | -------------------------------------------------------------------------------- /mmdet3d/models/backbones/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmdet.models.backbones import SSDVGG, HRNet, ResNet, ResNetV1d, ResNeXt 3 | from .multi_backbone import MultiBackbone 4 | from .nostem_regnet import NoStemRegNet 5 | from .pointnet2_sa_msg import PointNet2SAMSG 6 | from .pointnet2_sa_ssg import PointNet2SASSG 7 | from .second import SECOND 8 | # from projects_unipad.mmdet3d_plugin.models.backbones import MaskConvNeXt 9 | 10 | __all__ = [ 11 | "ResNet", 12 | "ResNetV1d", 13 | "ResNeXt", 14 | "SSDVGG", 15 | "HRNet", 16 | "NoStemRegNet", 17 | "SECOND", 18 | "PointNet2SASSG", 19 | "PointNet2SAMSG", 20 | "MultiBackbone", 21 | # "MaskConvNeXt", 22 | ] 23 | -------------------------------------------------------------------------------- /configs/free_anchor/hv_pointpillars_regnet-400mf_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py: -------------------------------------------------------------------------------- 1 | _base_ = './hv_pointpillars_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py' 2 | 3 | model = dict( 4 | pts_backbone=dict( 5 | _delete_=True, 6 | type='NoStemRegNet', 7 | arch='regnetx_400mf', 8 | init_cfg=dict( 9 | type='Pretrained', checkpoint='open-mmlab://regnetx_400mf'), 10 | out_indices=(1, 2, 3), 11 | frozen_stages=-1, 12 | strides=(1, 2, 2, 2), 13 | base_channels=64, 14 | stem_channels=64, 15 | norm_cfg=dict(type='naiveSyncBN2d', eps=1e-3, momentum=0.01), 16 | norm_eval=False, 17 | style='pytorch'), 18 | pts_neck=dict(in_channels=[64, 160, 384])) 19 | -------------------------------------------------------------------------------- /configs/free_anchor/hv_pointpillars_regnet-1.6gf_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py: -------------------------------------------------------------------------------- 1 | _base_ = './hv_pointpillars_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py' 2 | 3 | model = dict( 4 | pts_backbone=dict( 5 | _delete_=True, 6 | type='NoStemRegNet', 7 | arch='regnetx_1.6gf', 8 | init_cfg=dict( 9 | type='Pretrained', checkpoint='open-mmlab://regnetx_1.6gf'), 10 | out_indices=(1, 2, 3), 11 | frozen_stages=-1, 12 | strides=(1, 2, 2, 2), 13 | base_channels=64, 14 | stem_channels=64, 15 | norm_cfg=dict(type='naiveSyncBN2d', eps=1e-3, momentum=0.01), 16 | norm_eval=False, 17 | style='pytorch'), 18 | pts_neck=dict(in_channels=[168, 408, 912])) 19 | -------------------------------------------------------------------------------- /configs/free_anchor/hv_pointpillars_regnet-3.2gf_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py: -------------------------------------------------------------------------------- 1 | _base_ = './hv_pointpillars_fpn_sbn-all_free-anchor_4x8_2x_nus-3d.py' 2 | 3 | model = dict( 4 | pts_backbone=dict( 5 | _delete_=True, 6 | type='NoStemRegNet', 7 | arch='regnetx_3.2gf', 8 | init_cfg=dict( 9 | type='Pretrained', checkpoint='open-mmlab://regnetx_3.2gf'), 10 | out_indices=(1, 2, 3), 11 | frozen_stages=-1, 12 | strides=(1, 2, 2, 2), 13 | base_channels=64, 14 | stem_channels=64, 15 | norm_cfg=dict(type='naiveSyncBN2d', eps=1e-3, momentum=0.01), 16 | norm_eval=False, 17 | style='pytorch'), 18 | pts_neck=dict(in_channels=[192, 432, 1008])) 19 | -------------------------------------------------------------------------------- /tools/misc/print_config.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import argparse 3 | from mmcv import Config, DictAction 4 | 5 | 6 | def parse_args(): 7 | parser = argparse.ArgumentParser(description='Print the whole config') 8 | parser.add_argument('config', help='config file path') 9 | parser.add_argument( 10 | '--options', nargs='+', action=DictAction, help='arguments in dict') 11 | args = parser.parse_args() 12 | 13 | return args 14 | 15 | 16 | def main(): 17 | args = parse_args() 18 | 19 | cfg = Config.fromfile(args.config) 20 | if args.options is not None: 21 | cfg.merge_from_dict(args.options) 22 | print(f'Config:\n{cfg.pretty_text}') 23 | 24 | 25 | if __name__ == '__main__': 26 | main() 27 | -------------------------------------------------------------------------------- /configs/dynamic_voxelization/dv_second_secfpn_2x8_cosine_80e_kitti-3d-3class.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../_base_/models/hv_second_secfpn_kitti.py', 3 | '../_base_/datasets/kitti-3d-3class.py', '../_base_/schedules/cosine.py', 4 | '../_base_/default_runtime.py' 5 | ] 6 | 7 | point_cloud_range = [0, -40, -3, 70.4, 40, 1] 8 | voxel_size = [0.05, 0.05, 0.1] 9 | 10 | model = dict( 11 | type='DynamicVoxelNet', 12 | voxel_layer=dict( 13 | _delete_=True, 14 | max_num_points=-1, 15 | point_cloud_range=point_cloud_range, 16 | voxel_size=voxel_size, 17 | max_voxels=(-1, -1)), 18 | voxel_encoder=dict( 19 | _delete_=True, 20 | type='DynamicSimpleVFE', 21 | voxel_size=voxel_size, 22 | point_cloud_range=point_cloud_range)) 23 | -------------------------------------------------------------------------------- /configs/ssn/hv_ssn_regnet-400mf_secfpn_sbn-all_2x16_2x_nus-3d.py: -------------------------------------------------------------------------------- 1 | _base_ = './hv_ssn_secfpn_sbn-all_2x16_2x_nus-3d.py' 2 | # model settings 3 | model = dict( 4 | type='MVXFasterRCNN', 5 | pts_backbone=dict( 6 | _delete_=True, 7 | type='NoStemRegNet', 8 | arch=dict(w0=24, wa=24.48, wm=2.54, group_w=16, depth=22, bot_mul=1.0), 9 | init_cfg=dict( 10 | type='Pretrained', checkpoint='open-mmlab://regnetx_400mf'), 11 | out_indices=(1, 2, 3), 12 | frozen_stages=-1, 13 | strides=(1, 2, 2, 2), 14 | base_channels=64, 15 | stem_channels=64, 16 | norm_cfg=dict(type='naiveSyncBN2d', eps=1e-3, momentum=0.01), 17 | norm_eval=False, 18 | style='pytorch'), 19 | pts_neck=dict(in_channels=[64, 160, 384])) 20 | -------------------------------------------------------------------------------- /mmdet3d/models/detectors/ssd3dnet.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmdet.models import DETECTORS 3 | from .votenet import VoteNet 4 | 5 | 6 | @DETECTORS.register_module() 7 | class SSD3DNet(VoteNet): 8 | """3DSSDNet model. 9 | 10 | https://arxiv.org/abs/2002.10187.pdf 11 | """ 12 | 13 | def __init__(self, 14 | backbone, 15 | bbox_head=None, 16 | train_cfg=None, 17 | test_cfg=None, 18 | init_cfg=None, 19 | pretrained=None): 20 | super(SSD3DNet, self).__init__( 21 | backbone=backbone, 22 | bbox_head=bbox_head, 23 | train_cfg=train_cfg, 24 | test_cfg=test_cfg, 25 | init_cfg=init_cfg, 26 | pretrained=pretrained) 27 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/models/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .uni3d_detr import Uni3DDETR, UniTransformerDecoder, UniCrossAtten 2 | from .uni3d_viewtrans import Uni3DViewTrans 3 | from .uni3d_voxelpool import Uni3DVoxelPool 4 | from .uni3d_crossattn import Uni3DCrossAttn 5 | from .uni3d_voxelpooldepth import Uni3DVoxelPoolDepth 6 | from .uni3d_viewtransego import Uni3DViewTransEgo 7 | from .uni3d_detr_v2 import Uni3DTransformer, UniTransformerDecoderV2, UniCrossAttenV2 8 | 9 | __all__ = [ 10 | "Uni3DDETR", 11 | "UniTransformerDecoder", 12 | "UniCrossAtten", 13 | "Uni3DViewTrans", 14 | "Uni3DVoxelPool", 15 | "Uni3DCrossAttn", 16 | "Uni3DVoxelPoolDepth", 17 | "Uni3DTransformer", 18 | "UniTransformerDecoderV2", 19 | "UniCrossAttenV2", 20 | "UniTransformerDecoderV3", 21 | "Uni3DViewTransEgo", 22 | ] 23 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/datasets/pipelines/__init__.py: -------------------------------------------------------------------------------- 1 | from .transform_3d import ( 2 | PadMultiViewImage, NormalizeMultiviewImage, 3 | PhotoMetricDistortionMultiViewImage, 4 | RandomResizeCropFlipMultiViewImage, 5 | UnifiedRotScaleTransFlip, 6 | NormalizeIntensity) 7 | from .loading_3d import (LoadMultiViewMultiSweepImageFromFiles) 8 | from .dbsampler import UnifiedDataBaseSampler 9 | from .formatting import CollectUnified3D 10 | from .test_time_aug import MultiRotScaleFlipAug3D 11 | 12 | __all__ = [ 13 | 'PadMultiViewImage', 'NormalizeMultiviewImage', 14 | 'PhotoMetricDistortionMultiViewImage', 15 | 'RandomResizeCropFlipMultiViewImage', 16 | 'LoadMultiViewMultiSweepImageFromFiles', 17 | 'UnifiedRotScaleTransFlip', 'UnifiedDataBaseSampler', 18 | 'MultiRotScaleFlipAug3D', 'NormalizeIntensity' 19 | ] -------------------------------------------------------------------------------- /configs/pointnet2/pointnet2_ssg_16x2_cosine_50e_s3dis_seg-3d-13class.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../_base_/datasets/s3dis_seg-3d-13class.py', 3 | '../_base_/models/pointnet2_ssg.py', 4 | '../_base_/schedules/seg_cosine_50e.py', '../_base_/default_runtime.py' 5 | ] 6 | 7 | # data settings 8 | data = dict(samples_per_gpu=16) 9 | evaluation = dict(interval=2) 10 | 11 | # model settings 12 | model = dict( 13 | backbone=dict(in_channels=9), # [xyz, rgb, normalized_xyz] 14 | decode_head=dict( 15 | num_classes=13, ignore_index=13, 16 | loss_decode=dict(class_weight=None)), # S3DIS doesn't use class_weight 17 | test_cfg=dict( 18 | num_points=4096, 19 | block_size=1.0, 20 | sample_rate=0.5, 21 | use_normalized_coord=True, 22 | batch_size=24)) 23 | 24 | # runtime settings 25 | checkpoint_config = dict(interval=2) 26 | -------------------------------------------------------------------------------- /mmdet3d/core/bbox/structures/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .base_box3d import BaseInstance3DBoxes 3 | from .box_3d_mode import Box3DMode 4 | from .cam_box3d import CameraInstance3DBoxes 5 | from .coord_3d_mode import Coord3DMode 6 | from .depth_box3d import DepthInstance3DBoxes 7 | from .lidar_box3d import LiDARInstance3DBoxes 8 | from .utils import (get_box_type, get_proj_mat_by_coord_type, limit_period, 9 | mono_cam_box2vis, points_cam2img, rotation_3d_in_axis, 10 | xywhr2xyxyr) 11 | 12 | __all__ = [ 13 | 'Box3DMode', 'BaseInstance3DBoxes', 'LiDARInstance3DBoxes', 14 | 'CameraInstance3DBoxes', 'DepthInstance3DBoxes', 'xywhr2xyxyr', 15 | 'get_box_type', 'rotation_3d_in_axis', 'limit_period', 'points_cam2img', 16 | 'Coord3DMode', 'mono_cam_box2vis', 'get_proj_mat_by_coord_type' 17 | ] 18 | -------------------------------------------------------------------------------- /configs/ssn/hv_ssn_regnet-400mf_secfpn_sbn-all_1x16_2x_lyft-3d.py: -------------------------------------------------------------------------------- 1 | _base_ = './hv_ssn_secfpn_sbn-all_2x16_2x_lyft-3d.py' 2 | # model settings 3 | model = dict( 4 | type='MVXFasterRCNN', 5 | pts_backbone=dict( 6 | _delete_=True, 7 | type='NoStemRegNet', 8 | arch=dict(w0=24, wa=24.48, wm=2.54, group_w=16, depth=22, bot_mul=1.0), 9 | init_cfg=dict( 10 | type='Pretrained', checkpoint='open-mmlab://regnetx_400mf'), 11 | out_indices=(1, 2, 3), 12 | frozen_stages=-1, 13 | strides=(1, 2, 2, 2), 14 | base_channels=64, 15 | stem_channels=64, 16 | norm_cfg=dict(type='naiveSyncBN2d', eps=1e-3, momentum=0.01), 17 | norm_eval=False, 18 | style='pytorch'), 19 | pts_neck=dict(in_channels=[64, 160, 384])) 20 | # dataset settings 21 | data = dict(samples_per_gpu=1, workers_per_gpu=2) 22 | -------------------------------------------------------------------------------- /extra_tools/dist_train_ssl.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | while true 4 | do 5 | PORT=$(( ((RANDOM<<15)|RANDOM) % 49152 + 10000 )) 6 | status="$(nc -z 127.0.0.1 $PORT < /dev/null &>/dev/null; echo $?)" 7 | if [ "${status}" != "0" ]; then 8 | break; 9 | fi 10 | done 11 | echo $PORT 12 | 13 | GPUS=8 14 | 15 | CONFIG=projects/configs/MIM4D/uvtr_convnext_s_vs0.1_pretrain.py 16 | 17 | 18 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 19 | python3 -m torch.distributed.launch --nproc_per_node=$GPUS --master_port=$PORT \ 20 | $(dirname "$0")/train.py $CONFIG --launcher pytorch --no-validate 21 | 22 | 23 | CONFIG=projects/configs/MIM4D/uvtr_convnext_s_vs0.1_finetune.py 24 | 25 | PYTHONPATH="$(dirname $0)/..":$PYTHONPATH \ 26 | python3 -m torch.distributed.launch --nproc_per_node=$GPUS --master_port=$PORT \ 27 | $(dirname "$0")/train.py $CONFIG --launcher pytorch 28 | 29 | -------------------------------------------------------------------------------- /configs/regnet/hv_pointpillars_regnet-1.6gf_fpn_sbn-all_4x8_2x_nus-3d.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../_base_/models/hv_pointpillars_fpn_nus.py', 3 | '../_base_/datasets/nus-3d.py', 4 | '../_base_/schedules/schedule_2x.py', 5 | '../_base_/default_runtime.py', 6 | ] 7 | # model settings 8 | model = dict( 9 | type='MVXFasterRCNN', 10 | pts_backbone=dict( 11 | _delete_=True, 12 | type='NoStemRegNet', 13 | arch='regnetx_1.6gf', 14 | init_cfg=dict( 15 | type='Pretrained', checkpoint='open-mmlab://regnetx_1.6gf'), 16 | out_indices=(1, 2, 3), 17 | frozen_stages=-1, 18 | strides=(1, 2, 2, 2), 19 | base_channels=64, 20 | stem_channels=64, 21 | norm_cfg=dict(type='naiveSyncBN2d', eps=1e-3, momentum=0.01), 22 | norm_eval=False, 23 | style='pytorch'), 24 | pts_neck=dict(in_channels=[168, 408, 912])) 25 | -------------------------------------------------------------------------------- /configs/_base_/schedules/cyclic_20e.py: -------------------------------------------------------------------------------- 1 | # For nuScenes dataset, we usually evaluate the model at the end of training. 2 | # Since the models are trained by 24 epochs by default, we set evaluation 3 | # interval to be 20. Please change the interval accordingly if you do not 4 | # use a default schedule. 5 | # optimizer 6 | # This schedule is mainly used by models on nuScenes dataset 7 | optimizer = dict(type='AdamW', lr=1e-4, weight_decay=0.01) 8 | # max_norm=10 is better for SECOND 9 | optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2)) 10 | lr_config = dict( 11 | policy='cyclic', 12 | target_ratio=(10, 1e-4), 13 | cyclic_times=1, 14 | step_ratio_up=0.4, 15 | ) 16 | momentum_config = dict( 17 | policy='cyclic', 18 | target_ratio=(0.85 / 0.95, 1), 19 | cyclic_times=1, 20 | step_ratio_up=0.4, 21 | ) 22 | 23 | # runtime settings 24 | runner = dict(type='EpochBasedRunner', max_epochs=20) 25 | -------------------------------------------------------------------------------- /mmdet3d/models/dense_heads/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .anchor3d_head import Anchor3DHead 3 | from .anchor_free_mono3d_head import AnchorFreeMono3DHead 4 | from .base_conv_bbox_head import BaseConvBboxHead 5 | from .base_mono3d_dense_head import BaseMono3DDenseHead 6 | from .centerpoint_head import CenterHead 7 | from .fcos_mono3d_head import FCOSMono3DHead 8 | from .free_anchor3d_head import FreeAnchor3DHead 9 | from .groupfree3d_head import GroupFree3DHead 10 | from .parta2_rpn_head import PartA2RPNHead 11 | from .shape_aware_head import ShapeAwareHead 12 | from .ssd_3d_head import SSD3DHead 13 | from .vote_head import VoteHead 14 | 15 | __all__ = [ 16 | 'Anchor3DHead', 'FreeAnchor3DHead', 'PartA2RPNHead', 'VoteHead', 17 | 'SSD3DHead', 'BaseConvBboxHead', 'CenterHead', 'ShapeAwareHead', 18 | 'BaseMono3DDenseHead', 'AnchorFreeMono3DHead', 'FCOSMono3DHead', 19 | 'GroupFree3DHead' 20 | ] 21 | -------------------------------------------------------------------------------- /configs/regnet/hv_pointpillars_regnet-400mf_fpn_sbn-all_4x8_2x_nus-3d.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../_base_/models/hv_pointpillars_fpn_nus.py', 3 | '../_base_/datasets/nus-3d.py', 4 | '../_base_/schedules/schedule_2x.py', 5 | '../_base_/default_runtime.py', 6 | ] 7 | # model settings 8 | model = dict( 9 | type='MVXFasterRCNN', 10 | pts_backbone=dict( 11 | _delete_=True, 12 | type='NoStemRegNet', 13 | arch=dict(w0=24, wa=24.48, wm=2.54, group_w=16, depth=22, bot_mul=1.0), 14 | init_cfg=dict( 15 | type='Pretrained', checkpoint='open-mmlab://regnetx_400mf'), 16 | out_indices=(1, 2, 3), 17 | frozen_stages=-1, 18 | strides=(1, 2, 2, 2), 19 | base_channels=64, 20 | stem_channels=64, 21 | norm_cfg=dict(type='naiveSyncBN2d', eps=1e-3, momentum=0.01), 22 | norm_eval=False, 23 | style='pytorch'), 24 | pts_neck=dict(in_channels=[64, 160, 384])) 25 | -------------------------------------------------------------------------------- /configs/regnet/hv_pointpillars_regnet-400mf_fpn_sbn-all_2x8_2x_lyft-3d.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../_base_/models/hv_pointpillars_fpn_lyft.py', 3 | '../_base_/datasets/lyft-3d.py', 4 | '../_base_/schedules/schedule_2x.py', 5 | '../_base_/default_runtime.py', 6 | ] 7 | # model settings 8 | model = dict( 9 | type='MVXFasterRCNN', 10 | pts_backbone=dict( 11 | _delete_=True, 12 | type='NoStemRegNet', 13 | arch=dict(w0=24, wa=24.48, wm=2.54, group_w=16, depth=22, bot_mul=1.0), 14 | init_cfg=dict( 15 | type='Pretrained', checkpoint='open-mmlab://regnetx_400mf'), 16 | out_indices=(1, 2, 3), 17 | frozen_stages=-1, 18 | strides=(1, 2, 2, 2), 19 | base_channels=64, 20 | stem_channels=64, 21 | norm_cfg=dict(type='naiveSyncBN2d', eps=1e-3, momentum=0.01), 22 | norm_eval=False, 23 | style='pytorch'), 24 | pts_neck=dict(in_channels=[64, 160, 384])) 25 | -------------------------------------------------------------------------------- /configs/votenet/votenet_16x8_sunrgbd-3d-10class.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../_base_/datasets/sunrgbd-3d-10class.py', '../_base_/models/votenet.py', 3 | '../_base_/schedules/schedule_3x.py', '../_base_/default_runtime.py' 4 | ] 5 | # model settings 6 | model = dict( 7 | bbox_head=dict( 8 | num_classes=10, 9 | bbox_coder=dict( 10 | type='PartialBinBasedBBoxCoder', 11 | num_sizes=10, 12 | num_dir_bins=12, 13 | with_rot=True, 14 | mean_sizes=[ 15 | [2.114256, 1.620300, 0.927272], [0.791118, 1.279516, 0.718182], 16 | [0.923508, 1.867419, 0.845495], [0.591958, 0.552978, 0.827272], 17 | [0.699104, 0.454178, 0.75625], [0.69519, 1.346299, 0.736364], 18 | [0.528526, 1.002642, 1.172878], [0.500618, 0.632163, 0.683424], 19 | [0.404671, 1.071108, 1.688889], [0.76584, 1.398258, 0.472728] 20 | ]), 21 | )) 22 | -------------------------------------------------------------------------------- /mmdet3d/models/detectors/fcos_mono3d.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmdet.models.builder import DETECTORS 3 | from .single_stage_mono3d import SingleStageMono3DDetector 4 | 5 | 6 | @DETECTORS.register_module() 7 | class FCOSMono3D(SingleStageMono3DDetector): 8 | r"""`FCOS3D `_ for monocular 3D object detection. 9 | 10 | Currently please refer to our entry on the 11 | `leaderboard `_. 12 | """ # noqa: E501 13 | 14 | def __init__(self, 15 | backbone, 16 | neck, 17 | bbox_head, 18 | train_cfg=None, 19 | test_cfg=None, 20 | pretrained=None): 21 | super(FCOSMono3D, self).__init__(backbone, neck, bbox_head, train_cfg, 22 | test_cfg, pretrained) 23 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/core/hook/sequentialcontrol.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmcv.runner.hooks import HOOKS, Hook 3 | from mmdet3d.core.hook.utils import is_parallel 4 | 5 | __all__ = ['SequentialControlHook'] 6 | 7 | 8 | @HOOKS.register_module() 9 | class SequentialControlHook(Hook): 10 | """ """ 11 | 12 | def __init__(self, temporal_start_epoch=1): 13 | super().__init__() 14 | self.temporal_start_epoch=temporal_start_epoch 15 | 16 | def set_temporal_flag(self, runner, flag): 17 | if is_parallel(runner.model.module): 18 | runner.model.module.module.with_prev=flag 19 | else: 20 | runner.model.module.with_prev = flag 21 | 22 | def before_run(self, runner): 23 | self.set_temporal_flag(runner, False) 24 | 25 | def before_train_epoch(self, runner): 26 | if runner.epoch > self.temporal_start_epoch: 27 | self.set_temporal_flag(runner, True) -------------------------------------------------------------------------------- /configs/regnet/hv_pointpillars_regnet-400mf_fpn_sbn-all_range100_2x8_2x_lyft-3d.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../_base_/models/hv_pointpillars_fpn_range100_lyft.py', 3 | '../_base_/datasets/range100_lyft-3d.py', 4 | '../_base_/schedules/schedule_2x.py', 5 | '../_base_/default_runtime.py', 6 | ] 7 | # model settings 8 | model = dict( 9 | type='MVXFasterRCNN', 10 | pts_backbone=dict( 11 | _delete_=True, 12 | type='NoStemRegNet', 13 | arch=dict(w0=24, wa=24.48, wm=2.54, group_w=16, depth=22, bot_mul=1.0), 14 | init_cfg=dict( 15 | type='Pretrained', checkpoint='open-mmlab://regnetx_400mf'), 16 | out_indices=(1, 2, 3), 17 | frozen_stages=-1, 18 | strides=(1, 2, 2, 2), 19 | base_channels=64, 20 | stem_channels=64, 21 | norm_cfg=dict(type='naiveSyncBN2d', eps=1e-3, momentum=0.01), 22 | norm_eval=False, 23 | style='pytorch'), 24 | pts_neck=dict(in_channels=[64, 160, 384])) 25 | -------------------------------------------------------------------------------- /configs/pointnet2/pointnet2_msg_16x2_cosine_80e_s3dis_seg-3d-13class.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../_base_/datasets/s3dis_seg-3d-13class.py', 3 | '../_base_/models/pointnet2_msg.py', 4 | '../_base_/schedules/seg_cosine_50e.py', '../_base_/default_runtime.py' 5 | ] 6 | 7 | # data settings 8 | data = dict(samples_per_gpu=16) 9 | evaluation = dict(interval=2) 10 | 11 | # model settings 12 | model = dict( 13 | backbone=dict(in_channels=9), # [xyz, rgb, normalized_xyz] 14 | decode_head=dict( 15 | num_classes=13, ignore_index=13, 16 | loss_decode=dict(class_weight=None)), # S3DIS doesn't use class_weight 17 | test_cfg=dict( 18 | num_points=4096, 19 | block_size=1.0, 20 | sample_rate=0.5, 21 | use_normalized_coord=True, 22 | batch_size=24)) 23 | 24 | # runtime settings 25 | checkpoint_config = dict(interval=2) 26 | # PointNet2-MSG needs longer training time than PointNet2-SSG 27 | runner = dict(type='EpochBasedRunner', max_epochs=80) 28 | -------------------------------------------------------------------------------- /configs/nuimages/htc_x101_64x4d_fpn_dconv_c3-c5_coco-20e_16x1_20e_nuim.py: -------------------------------------------------------------------------------- 1 | _base_ = './htc_r50_fpn_1x_nuim.py' 2 | model = dict( 3 | pretrained='open-mmlab://resnext101_64x4d', 4 | backbone=dict( 5 | type='ResNeXt', 6 | depth=101, 7 | groups=64, 8 | base_width=4, 9 | num_stages=4, 10 | out_indices=(0, 1, 2, 3), 11 | frozen_stages=1, 12 | norm_cfg=dict(type='BN', requires_grad=True), 13 | norm_eval=True, 14 | style='pytorch', 15 | dcn=dict(type='DCN', deform_groups=1, fallback_on_stride=False), 16 | stage_with_dcn=(False, True, True, True))) 17 | 18 | data = dict(samples_per_gpu=1, workers_per_gpu=1) 19 | # learning policy 20 | lr_config = dict(step=[16, 19]) 21 | runner = dict(max_epochs=20) 22 | 23 | load_from = 'http://download.openmmlab.com/mmdetection/v2.0/htc/htc_x101_64x4d_fpn_dconv_c3-c5_mstrain_400_1400_16x1_20e_coco/htc_x101_64x4d_fpn_dconv_c3-c5_mstrain_400_1400_16x1_20e_coco_20200312-946fd751.pth' # noqa 24 | -------------------------------------------------------------------------------- /configs/3dssd/metafile.yml: -------------------------------------------------------------------------------- 1 | Collections: 2 | - Name: 3DSSD 3 | Metadata: 4 | Training Data: KITTI 5 | Training Techniques: 6 | - AdamW 7 | Training Resources: 4x TITAN X 8 | Architecture: 9 | - PointNet++ 10 | Paper: 11 | URL: https://arxiv.org/abs/2002.10187 12 | Title: '3DSSD: Point-based 3D Single Stage Object Detector' 13 | README: configs/3dssd/README.md 14 | Code: 15 | URL: https://github.com/open-mmlab/mmdetection3d/blob/master/mmdet3d/models/detectors/ssd3dnet.py#L7 16 | Version: v0.6.0 17 | 18 | Models: 19 | - Name: 3dssd_4x4_kitti-3d-car 20 | In Collection: 3DSSD 21 | Config: configs/3dssd/3dssd_4x4_kitti-3d-car.py 22 | Metadata: 23 | Training Memory (GB): 4.7 24 | Results: 25 | - Task: 3D Object Detection 26 | Dataset: KITTI 27 | Metrics: 28 | mAP: 78.69 29 | Weights: https://download.openmmlab.com/mmdetection3d/v0.1.0_models/3dssd/3dssd_kitti-3d-car_20210602_124438-b4276f56.pth 30 | -------------------------------------------------------------------------------- /mmdet3d/models/detectors/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .base import Base3DDetector 3 | from .centerpoint import CenterPoint 4 | from .dynamic_voxelnet import DynamicVoxelNet 5 | from .fcos_mono3d import FCOSMono3D 6 | from .groupfree3dnet import GroupFree3DNet 7 | from .h3dnet import H3DNet 8 | from .imvotenet import ImVoteNet 9 | from .imvoxelnet import ImVoxelNet 10 | from .mvx_faster_rcnn import DynamicMVXFasterRCNN, MVXFasterRCNN 11 | from .mvx_two_stage import MVXTwoStageDetector 12 | from .parta2 import PartA2 13 | from .single_stage_mono3d import SingleStageMono3DDetector 14 | from .ssd3dnet import SSD3DNet 15 | from .votenet import VoteNet 16 | from .voxelnet import VoxelNet 17 | 18 | __all__ = [ 19 | 'Base3DDetector', 'VoxelNet', 'DynamicVoxelNet', 'MVXTwoStageDetector', 20 | 'DynamicMVXFasterRCNN', 'MVXFasterRCNN', 'PartA2', 'VoteNet', 'H3DNet', 21 | 'CenterPoint', 'SSD3DNet', 'ImVoteNet', 'SingleStageMono3DDetector', 22 | 'FCOSMono3D', 'ImVoxelNet', 'GroupFree3DNet' 23 | ] 24 | -------------------------------------------------------------------------------- /mmdet3d/core/points/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .base_points import BasePoints 3 | from .cam_points import CameraPoints 4 | from .depth_points import DepthPoints 5 | from .lidar_points import LiDARPoints 6 | 7 | __all__ = ['BasePoints', 'CameraPoints', 'DepthPoints', 'LiDARPoints'] 8 | 9 | 10 | def get_points_type(points_type): 11 | """Get the class of points according to coordinate type. 12 | 13 | Args: 14 | points_type (str): The type of points coordinate. 15 | The valid value are "CAMERA", "LIDAR", or "DEPTH". 16 | 17 | Returns: 18 | class: Points type. 19 | """ 20 | if points_type == 'CAMERA': 21 | points_cls = CameraPoints 22 | elif points_type == 'LIDAR': 23 | points_cls = LiDARPoints 24 | elif points_type == 'DEPTH': 25 | points_cls = DepthPoints 26 | else: 27 | raise ValueError('Only "points_type" of "CAMERA", "LIDAR", or "DEPTH"' 28 | f' are supported, got {points_type}') 29 | 30 | return points_cls 31 | -------------------------------------------------------------------------------- /configs/_base_/models/hv_pointpillars_fpn_lyft.py: -------------------------------------------------------------------------------- 1 | _base_ = './hv_pointpillars_fpn_nus.py' 2 | 3 | # model settings (based on nuScenes model settings) 4 | # Voxel size for voxel encoder 5 | # Usually voxel size is changed consistently with the point cloud range 6 | # If point cloud range is modified, do remember to change all related 7 | # keys in the config. 8 | model = dict( 9 | pts_voxel_layer=dict( 10 | max_num_points=20, 11 | point_cloud_range=[-80, -80, -5, 80, 80, 3], 12 | max_voxels=(60000, 60000)), 13 | pts_voxel_encoder=dict( 14 | feat_channels=[64], point_cloud_range=[-80, -80, -5, 80, 80, 3]), 15 | pts_middle_encoder=dict(output_shape=[640, 640]), 16 | pts_bbox_head=dict( 17 | num_classes=9, 18 | anchor_generator=dict( 19 | ranges=[[-80, -80, -1.8, 80, 80, -1.8]], custom_values=[]), 20 | bbox_coder=dict(type='DeltaXYZWLHRBBoxCoder', code_size=7)), 21 | # model training settings (based on nuScenes model settings) 22 | train_cfg=dict(pts=dict(code_weight=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]))) 23 | -------------------------------------------------------------------------------- /configs/_base_/models/hv_pointpillars_fpn_range100_lyft.py: -------------------------------------------------------------------------------- 1 | _base_ = './hv_pointpillars_fpn_nus.py' 2 | 3 | # model settings (based on nuScenes model settings) 4 | # Voxel size for voxel encoder 5 | # Usually voxel size is changed consistently with the point cloud range 6 | # If point cloud range is modified, do remember to change all related 7 | # keys in the config. 8 | model = dict( 9 | pts_voxel_layer=dict( 10 | max_num_points=20, 11 | point_cloud_range=[-100, -100, -5, 100, 100, 3], 12 | max_voxels=(60000, 60000)), 13 | pts_voxel_encoder=dict( 14 | feat_channels=[64], point_cloud_range=[-100, -100, -5, 100, 100, 3]), 15 | pts_middle_encoder=dict(output_shape=[800, 800]), 16 | pts_bbox_head=dict( 17 | num_classes=9, 18 | anchor_generator=dict( 19 | ranges=[[-100, -100, -1.8, 100, 100, -1.8]], custom_values=[]), 20 | bbox_coder=dict(type='DeltaXYZWLHRBBoxCoder', code_size=7)), 21 | # model training settings (based on nuScenes model settings) 22 | train_cfg=dict(pts=dict(code_weight=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]))) 23 | -------------------------------------------------------------------------------- /configs/h3dnet/metafile.yml: -------------------------------------------------------------------------------- 1 | Collections: 2 | - Name: H3DNet 3 | Metadata: 4 | Training Data: ScanNet 5 | Training Techniques: 6 | - AdamW 7 | Training Resources: 8x GeForce GTX 1080 Ti 8 | Architecture: 9 | Paper: 10 | URL: https://arxiv.org/abs/2006.05682 11 | Title: 'H3DNet: 3D Object Detection Using Hybrid Geometric Primitives' 12 | README: configs/h3dnet/README.md 13 | Code: 14 | URL: https://github.com/open-mmlab/mmdetection3d/blob/master/mmdet3d/models/detectors/h3dnet.py#L10 15 | Version: v0.6.0 16 | 17 | Models: 18 | - Name: h3dnet_3x8_scannet-3d-18class 19 | In Collection: H3DNet 20 | Config: configs/h3dnet/h3dnet_3x8_scannet-3d-18class.py 21 | Metadata: 22 | Training Memory (GB): 7.9 23 | Results: 24 | - Task: 3D Object Detection 25 | Dataset: ScanNet 26 | Metrics: 27 | AP@0.25: 66.43 28 | AP@0.5: 48.01 29 | Weights: https://download.openmmlab.com/mmdetection3d/v0.1.0_models/h3dnet/h3dnet_scannet-3d-18class/h3dnet_scannet-3d-18class_20200830_000136-02e36246.pth 30 | -------------------------------------------------------------------------------- /configs/imvoxelnet/metafile.yml: -------------------------------------------------------------------------------- 1 | Collections: 2 | - Name: ImVoxelNet 3 | Metadata: 4 | Training Data: KITTI 5 | Training Techniques: 6 | - AdamW 7 | Training Resources: 8x Tesla P40 8 | Architecture: 9 | - Anchor3DHead 10 | Paper: 11 | URL: https://arxiv.org/abs/2106.01178 12 | Title: 'ImVoxelNet: Image to Voxels Projection for Monocular and Multi-View General-Purpose 3D Object Detection' 13 | README: configs/imvoxelnet/README.md 14 | Code: 15 | URL: https://github.com/open-mmlab/mmdetection3d/blob/master/mmdet3d/models/detectors/imvoxelnet.py#L11 16 | Version: v0.15.0 17 | 18 | Models: 19 | - Name: imvoxelnet_kitti-3d-car 20 | In Collection: ImVoxelNet 21 | Config: configs/imvoxelnet/imvoxelnet_kitti-3d-car.py 22 | Metadata: 23 | Training Memory (GB): 15.0 24 | Results: 25 | - Task: 3D Object Detection 26 | Dataset: KITTI 27 | Metrics: 28 | mAP: 17.4 29 | Weights: https://download.openmmlab.com/mmdetection3d/v0.1.0_models/imvoxelnet/imvoxelnet_kitti-3d-car_20210610_152323-b9abba85.pth 30 | -------------------------------------------------------------------------------- /mmdet3d/apis/train.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmdet.apis import train_detector 3 | from mmseg.apis import train_segmentor 4 | 5 | 6 | def train_model(model, 7 | dataset, 8 | cfg, 9 | distributed=False, 10 | validate=False, 11 | timestamp=None, 12 | meta=None): 13 | """A function wrapper for launching model training according to cfg. 14 | 15 | Because we need different eval_hook in runner. Should be deprecated in the 16 | future. 17 | """ 18 | if cfg.model.type in ['EncoderDecoder3D']: 19 | train_segmentor( 20 | model, 21 | dataset, 22 | cfg, 23 | distributed=distributed, 24 | validate=validate, 25 | timestamp=timestamp, 26 | meta=meta) 27 | else: 28 | train_detector( 29 | model, 30 | dataset, 31 | cfg, 32 | distributed=distributed, 33 | validate=validate, 34 | timestamp=timestamp, 35 | meta=meta) 36 | -------------------------------------------------------------------------------- /configs/second/hv_second_secfpn_6x8_80e_kitti-3d-car.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../_base_/models/hv_second_secfpn_kitti.py', 3 | '../_base_/datasets/kitti-3d-car.py', '../_base_/schedules/cyclic_40e.py', 4 | '../_base_/default_runtime.py' 5 | ] 6 | point_cloud_range = [0, -40, -3, 70.4, 40, 1] 7 | model = dict( 8 | bbox_head=dict( 9 | type='Anchor3DHead', 10 | num_classes=1, 11 | anchor_generator=dict( 12 | _delete_=True, 13 | type='Anchor3DRangeGenerator', 14 | ranges=[[0, -40.0, -1.78, 70.4, 40.0, -1.78]], 15 | sizes=[[1.6, 3.9, 1.56]], 16 | rotations=[0, 1.57], 17 | reshape_out=True)), 18 | # model training and testing settings 19 | train_cfg=dict( 20 | _delete_=True, 21 | assigner=dict( 22 | type='MaxIoUAssigner', 23 | iou_calculator=dict(type='BboxOverlapsNearest3D'), 24 | pos_iou_thr=0.6, 25 | neg_iou_thr=0.45, 26 | min_pos_iou=0.45, 27 | ignore_iof_thr=-1), 28 | allowed_border=0, 29 | pos_weight=-1, 30 | debug=False)) 31 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/core/bbox/match_costs/match_cost.py: -------------------------------------------------------------------------------- 1 | import torch 2 | from mmdet.core.bbox.match_costs.builder import MATCH_COST 3 | from mmdet3d.core.bbox.iou_calculators import BboxOverlaps3D 4 | 5 | 6 | @MATCH_COST.register_module() 7 | class BBox3DL1Cost(object): 8 | """BBox3DL1Cost. 9 | Args: 10 | weight (int | float, optional): loss_weight 11 | """ 12 | 13 | def __init__(self, weight=1.): 14 | self.weight = weight 15 | 16 | def __call__(self, bbox_pred, gt_bboxes): 17 | bbox_cost = torch.cdist(bbox_pred, gt_bboxes, p=1) 18 | return bbox_cost * self.weight 19 | 20 | 21 | @MATCH_COST.register_module() 22 | class BBox3DIoUCost(object): 23 | """BBox3DL1Cost. 24 | Args: 25 | weight (int | float, optional): loss_weight 26 | """ 27 | 28 | def __init__(self, weight=1., coordinate='lidar'): 29 | self.weight = weight 30 | self.iou_calculator = BboxOverlaps3D(coordinate=coordinate) 31 | 32 | def __call__(self, bbox_pred, gt_bboxes): 33 | iou_cost = -self.iou_calculator(bbox_pred, gt_bboxes) 34 | return iou_cost * self.weight 35 | -------------------------------------------------------------------------------- /configs/paconv/metafile.yml: -------------------------------------------------------------------------------- 1 | Collections: 2 | - Name: PAConv 3 | Metadata: 4 | Training Techniques: 5 | - SGD 6 | Training Resources: 8x Titan XP GPUs 7 | Architecture: 8 | - PAConv 9 | Paper: 10 | URL: https://arxiv.org/abs/2103.14635 11 | Title: 'PAConv: Position Adaptive Convolution with Dynamic Kernel Assembling on Point Clouds' 12 | README: configs/paconv/README.md 13 | Code: 14 | URL: https://github.com/open-mmlab/mmdetection3d/blob/master/mmdet3d/ops/paconv/paconv.py#L106 15 | Version: v0.16.0 16 | 17 | Models: 18 | - Name: paconv_ssg_8x8_cosine_150e_s3dis_seg-3d-13class.py 19 | In Collection: PAConv 20 | Config: configs/paconv/paconv_ssg_8x8_cosine_150e_s3dis_seg-3d-13class.py 21 | Metadata: 22 | Training Data: S3DIS 23 | Training Memory (GB): 5.8 24 | Results: 25 | - Task: 3D Semantic Segmentation 26 | Dataset: S3DIS 27 | Metrics: 28 | mIoU: 66.65 29 | Weights: https://download.openmmlab.com/mmdetection3d/v0.1.0_models/paconv/paconv_ssg_8x8_cosine_150e_s3dis_seg-3d-13class/paconv_ssg_8x8_cosine_150e_s3dis_seg-3d-13class_20210729_200615-2147b2d1.pth 30 | -------------------------------------------------------------------------------- /mmdet3d/ops/furthest_point_sample/utils.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | 4 | def calc_square_dist(point_feat_a, point_feat_b, norm=True): 5 | """Calculating square distance between a and b. 6 | 7 | Args: 8 | point_feat_a (Tensor): (B, N, C) Feature vector of each point. 9 | point_feat_b (Tensor): (B, M, C) Feature vector of each point. 10 | norm (Bool): Whether to normalize the distance. 11 | Default: True. 12 | 13 | Returns: 14 | Tensor: (B, N, M) Distance between each pair points. 15 | """ 16 | length_a = point_feat_a.shape[1] 17 | length_b = point_feat_b.shape[1] 18 | num_channel = point_feat_a.shape[-1] 19 | # [bs, n, 1] 20 | a_square = torch.sum(point_feat_a.unsqueeze(dim=2).pow(2), dim=-1) 21 | # [bs, 1, m] 22 | b_square = torch.sum(point_feat_b.unsqueeze(dim=1).pow(2), dim=-1) 23 | a_square = a_square.repeat((1, 1, length_b)) # [bs, n, m] 24 | b_square = b_square.repeat((1, length_a, 1)) # [bs, n, m] 25 | 26 | coor = torch.matmul(point_feat_a, point_feat_b.transpose(1, 2)) 27 | 28 | dist = a_square + b_square - 2 * coor 29 | if norm: 30 | dist = torch.sqrt(dist) / num_channel 31 | return dist 32 | -------------------------------------------------------------------------------- /mmdet3d/utils/logger.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import logging 3 | from mmcv.utils import get_logger 4 | 5 | 6 | def get_root_logger(log_file=None, log_level=logging.INFO, name='mmdet3d'): 7 | """Get root logger and add a keyword filter to it. 8 | 9 | The logger will be initialized if it has not been initialized. By default a 10 | StreamHandler will be added. If `log_file` is specified, a FileHandler will 11 | also be added. The name of the root logger is the top-level package name, 12 | e.g., "mmdet3d". 13 | 14 | Args: 15 | log_file (str, optional): File path of log. Defaults to None. 16 | log_level (int, optional): The level of logger. 17 | Defaults to logging.INFO. 18 | name (str, optional): The name of the root logger, also used as a 19 | filter keyword. Defaults to 'mmdet3d'. 20 | 21 | Returns: 22 | :obj:`logging.Logger`: The obtained logger 23 | """ 24 | logger = get_logger(name=name, log_file=log_file, log_level=log_level) 25 | 26 | # add a logging filter 27 | logging_filter = logging.Filter(name) 28 | logging_filter.filter = lambda record: record.find(name) != -1 29 | 30 | return logger 31 | -------------------------------------------------------------------------------- /configs/mvxnet/metafile.yml: -------------------------------------------------------------------------------- 1 | Collections: 2 | - Name: MVX-Net 3 | Metadata: 4 | Training Data: KITTI 5 | Training Techniques: 6 | - AdamW 7 | Training Resources: 8x V100 GPUs 8 | Architecture: 9 | - Feature Pyramid Network 10 | - Dynamic Voxelization 11 | Paper: 12 | URL: https://arxiv.org/abs/1904.01649 13 | Title: 'MVX-Net: Multimodal VoxelNet for 3D Object Detection' 14 | README: configs/mvxnet/README.md 15 | Code: 16 | URL: https://github.com/open-mmlab/mmdetection3d/blob/master/mmdet3d/models/detectors/mvx_two_stage.py#L20 17 | Version: v0.5.0 18 | 19 | Models: 20 | - Name: dv_mvx-fpn_second_secfpn_adamw_2x8_80e_kitti-3d-3class 21 | In Collection: MVX-Net 22 | Config: configs/mvxnet/dv_mvx-fpn_second_secfpn_adamw_2x8_80e_kitti-3d-3class.py 23 | Metadata: 24 | Training Memory (GB): 6.7 25 | Results: 26 | - Task: 3D Object Detection 27 | Dataset: KITTI 28 | Metrics: 29 | mAP: 63.0 30 | Weights: https://download.openmmlab.com/mmdetection3d/v0.1.0_models/mvxnet/dv_mvx-fpn_second_secfpn_adamw_2x8_80e_kitti-3d-3class/dv_mvx-fpn_second_secfpn_adamw_2x8_80e_kitti-3d-3class_20200621_003904-10140f2d.pth 31 | -------------------------------------------------------------------------------- /tools/model_converters/publish_model.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | import argparse 3 | import subprocess 4 | import torch 5 | 6 | 7 | def parse_args(): 8 | parser = argparse.ArgumentParser( 9 | description='Process a checkpoint to be published') 10 | parser.add_argument('in_file', help='input checkpoint filename') 11 | parser.add_argument('out_file', help='output checkpoint filename') 12 | args = parser.parse_args() 13 | return args 14 | 15 | 16 | def process_checkpoint(in_file, out_file): 17 | checkpoint = torch.load(in_file, map_location='cpu') 18 | # remove optimizer for smaller file size 19 | if 'optimizer' in checkpoint: 20 | del checkpoint['optimizer'] 21 | # if it is necessary to remove some sensitive data in checkpoint['meta'], 22 | # add the code here. 23 | torch.save(checkpoint, out_file) 24 | sha = subprocess.check_output(['sha256sum', out_file]).decode() 25 | final_file = out_file.rstrip('.pth') + '-{}.pth'.format(sha[:8]) 26 | subprocess.Popen(['mv', out_file, final_file]) 27 | 28 | 29 | def main(): 30 | args = parse_args() 31 | process_checkpoint(args.in_file, args.out_file) 32 | 33 | 34 | if __name__ == '__main__': 35 | main() 36 | -------------------------------------------------------------------------------- /mmdet3d/ops/paconv/src/assign_score_withk.cpp: -------------------------------------------------------------------------------- 1 | // Modified from https://github.com/CVMI-Lab/PAConv/tree/main/scene_seg/lib/paconv_lib/src/gpu 2 | 3 | #include 4 | #include 5 | 6 | void assign_score_withk_forward_wrapper( 7 | int B, int N0, int N1, int M, 8 | int K, int O, int aggregate, 9 | const at::Tensor& points, 10 | const at::Tensor& centers, 11 | const at::Tensor& scores, 12 | const at::Tensor& knn_idx, 13 | at::Tensor& output 14 | ); 15 | 16 | void assign_score_withk_backward_wrapper( 17 | int B, int N0, int N1, int M, 18 | int K, int O, int aggregate, 19 | const at::Tensor& grad_out, 20 | const at::Tensor& points, 21 | const at::Tensor& centers, 22 | const at::Tensor& scores, 23 | const at::Tensor& knn_idx, 24 | at::Tensor& grad_points, 25 | at::Tensor& grad_centers, 26 | at::Tensor& grad_scores 27 | ); 28 | 29 | PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { 30 | m.def("assign_score_withk_forward_wrapper", 31 | &assign_score_withk_forward_wrapper, 32 | "Assign score kernel forward (GPU), save memory version"); 33 | m.def("assign_score_withk_backward_wrapper", 34 | &assign_score_withk_backward_wrapper, 35 | "Assign score kernel backward (GPU), save memory version"); 36 | } 37 | -------------------------------------------------------------------------------- /configs/pointpillars/hv_pointpillars_secfpn_sbn_2x16_2x_waymoD5-3d-car.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../_base_/models/hv_pointpillars_secfpn_waymo.py', 3 | '../_base_/datasets/waymoD5-3d-car.py', 4 | '../_base_/schedules/schedule_2x.py', 5 | '../_base_/default_runtime.py', 6 | ] 7 | 8 | # model settings 9 | model = dict( 10 | type='MVXFasterRCNN', 11 | pts_bbox_head=dict( 12 | type='Anchor3DHead', 13 | num_classes=1, 14 | anchor_generator=dict( 15 | type='AlignedAnchor3DRangeGenerator', 16 | ranges=[[-74.88, -74.88, -0.0345, 74.88, 74.88, -0.0345]], 17 | sizes=[[2.08, 4.73, 1.77]], 18 | rotations=[0, 1.57], 19 | reshape_out=True)), 20 | # model training and testing settings 21 | train_cfg=dict( 22 | _delete_=True, 23 | pts=dict( 24 | assigner=dict( 25 | type='MaxIoUAssigner', 26 | iou_calculator=dict(type='BboxOverlapsNearest3D'), 27 | pos_iou_thr=0.55, 28 | neg_iou_thr=0.4, 29 | min_pos_iou=0.4, 30 | ignore_iof_thr=-1), 31 | allowed_border=0, 32 | code_weight=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 33 | pos_weight=-1, 34 | debug=False))) 35 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/core/hook/syncbncontrol.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from mmcv.runner.hooks import HOOKS, Hook 3 | from mmdet3d.core.hook.utils import is_parallel 4 | from torch.nn import SyncBatchNorm 5 | 6 | __all__ = ['SyncbnControlHook'] 7 | 8 | 9 | @HOOKS.register_module() 10 | class SyncbnControlHook(Hook): 11 | """ """ 12 | 13 | def __init__(self, syncbn_start_epoch=1): 14 | super().__init__() 15 | self.is_syncbn=False 16 | self.syncbn_start_epoch = syncbn_start_epoch 17 | 18 | def cvt_syncbn(self, runner): 19 | if is_parallel(runner.model.module): 20 | runner.model.module.module=\ 21 | SyncBatchNorm.convert_sync_batchnorm(runner.model.module.module, 22 | process_group=None) 23 | else: 24 | runner.model.module=\ 25 | SyncBatchNorm.convert_sync_batchnorm(runner.model.module, 26 | process_group=None) 27 | 28 | def before_train_epoch(self, runner): 29 | if runner.epoch>= self.syncbn_start_epoch and not self.is_syncbn: 30 | print('start use syncbn') 31 | self.cvt_syncbn(runner) 32 | self.is_syncbn=True 33 | 34 | -------------------------------------------------------------------------------- /configs/mvxnet/README.md: -------------------------------------------------------------------------------- 1 | # MVX-Net: Multimodal VoxelNet for 3D Object Detection 2 | 3 | ## Introduction 4 | 5 | 6 | 7 | We implement MVX-Net and provide its results and models on KITTI dataset. 8 | 9 | ``` 10 | @inproceedings{sindagi2019mvx, 11 | title={MVX-Net: Multimodal voxelnet for 3D object detection}, 12 | author={Sindagi, Vishwanath A and Zhou, Yin and Tuzel, Oncel}, 13 | booktitle={2019 International Conference on Robotics and Automation (ICRA)}, 14 | pages={7276--7282}, 15 | year={2019}, 16 | organization={IEEE} 17 | } 18 | 19 | ``` 20 | 21 | ## Results 22 | 23 | ### KITTI 24 | 25 | | Backbone |Class| Lr schd | Mem (GB) | Inf time (fps) | mAP | Download | 26 | | :---------: | :-----: | :------: | :------------: | :----: |:----: | :------: | 27 | | [SECFPN](./dv_mvx-fpn_second_secfpn_adamw_2x8_80e_kitti-3d-3class.py)|3 Class|cosine 80e|6.7||63.0|[model](https://download.openmmlab.com/mmdetection3d/v0.1.0_models/mvxnet/dv_mvx-fpn_second_secfpn_adamw_2x8_80e_kitti-3d-3class/dv_mvx-fpn_second_secfpn_adamw_2x8_80e_kitti-3d-3class_20200621_003904-10140f2d.pth) | [log](https://download.openmmlab.com/mmdetection3d/v0.1.0_models/mvxnet/dv_mvx-fpn_second_secfpn_adamw_2x8_80e_kitti-3d-3class/dv_mvx-fpn_second_secfpn_adamw_2x8_80e_kitti-3d-3class_20200621_003904.log.json)| 28 | -------------------------------------------------------------------------------- /configs/imvoxelnet/README.md: -------------------------------------------------------------------------------- 1 | # ImVoxelNet: Image to Voxels Projection for Monocular and Multi-View General-Purpose 3D Object Detection 2 | 3 | ## Introduction 4 | 5 | 6 | 7 | We implement a monocular 3D detector ImVoxelNet and provide its results and checkpoints on KITTI dataset. 8 | Results for SUN RGB-D, ScanNet and nuScenes are currently available in ImVoxelNet authors 9 | [repo](https://github.com/saic-vul/imvoxelnet) (based on mmdetection3d). 10 | 11 | ``` 12 | @article{rukhovich2021imvoxelnet, 13 | title={ImVoxelNet: Image to Voxels Projection for Monocular and Multi-View General-Purpose 3D Object Detection}, 14 | author={Danila Rukhovich, Anna Vorontsova, Anton Konushin}, 15 | journal={arXiv preprint arXiv:2106.01178}, 16 | year={2021} 17 | } 18 | ``` 19 | 20 | ## Results 21 | 22 | ### KITTI 23 | 24 | | Backbone |Class| Lr schd | Mem (GB) | Inf time (fps) | mAP | Download | 25 | | :---------: | :-----: |:-----: | :------: | :------------: | :----: |:----: | 26 | | [ResNet-50](./imvoxelnet_kitti-3d-car.py) | Car | 3x | | |17.4|[model](https://download.openmmlab.com/mmdetection3d/v0.1.0_models/imvoxelnet/imvoxelnet_kitti-3d-car_20210610_152323-b9abba85.pth) | [log](https://download.openmmlab.com/mmdetection3d/v0.1.0_models/imvoxelnet/imvoxelnet_kitti-3d-car_20210610_152323.log.json)| 27 | -------------------------------------------------------------------------------- /mmdet3d/models/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) OpenMMLab. All rights reserved. 2 | from .backbones import * # noqa: F401,F403 3 | from .builder import (FUSION_LAYERS, MIDDLE_ENCODERS, VOXEL_ENCODERS, 4 | build_backbone, build_detector, build_fusion_layer, 5 | build_head, build_loss, build_middle_encoder, 6 | build_model, build_neck, build_roi_extractor, 7 | build_shared_head, build_voxel_encoder) 8 | from .decode_heads import * # noqa: F401,F403 9 | from .dense_heads import * # noqa: F401,F403 10 | from .detectors import * # noqa: F401,F403 11 | from .fusion_layers import * # noqa: F401,F403 12 | from .losses import * # noqa: F401,F403 13 | from .middle_encoders import * # noqa: F401,F403 14 | from .model_utils import * # noqa: F401,F403 15 | from .necks import * # noqa: F401,F403 16 | from .roi_heads import * # noqa: F401,F403 17 | from .segmentors import * # noqa: F401,F403 18 | from .voxel_encoders import * # noqa: F401,F403 19 | 20 | __all__ = [ 21 | 'VOXEL_ENCODERS', 'MIDDLE_ENCODERS', 'FUSION_LAYERS', 'build_backbone', 22 | 'build_neck', 'build_roi_extractor', 'build_shared_head', 'build_head', 23 | 'build_loss', 'build_detector', 'build_fusion_layer', 'build_model', 24 | 'build_middle_encoder', 'build_voxel_encoder' 25 | ] 26 | -------------------------------------------------------------------------------- /configs/_base_/models/pointnet2_msg.py: -------------------------------------------------------------------------------- 1 | _base_ = './pointnet2_ssg.py' 2 | 3 | # model settings 4 | model = dict( 5 | backbone=dict( 6 | _delete_=True, 7 | type='PointNet2SAMSG', 8 | in_channels=6, # [xyz, rgb], should be modified with dataset 9 | num_points=(1024, 256, 64, 16), 10 | radii=((0.05, 0.1), (0.1, 0.2), (0.2, 0.4), (0.4, 0.8)), 11 | num_samples=((16, 32), (16, 32), (16, 32), (16, 32)), 12 | sa_channels=(((16, 16, 32), (32, 32, 64)), ((64, 64, 128), (64, 96, 13 | 128)), 14 | ((128, 196, 256), (128, 196, 256)), ((256, 256, 512), 15 | (256, 384, 512))), 16 | aggregation_channels=(None, None, None, None), 17 | fps_mods=(('D-FPS'), ('D-FPS'), ('D-FPS'), ('D-FPS')), 18 | fps_sample_range_lists=((-1), (-1), (-1), (-1)), 19 | dilated_group=(False, False, False, False), 20 | out_indices=(0, 1, 2, 3), 21 | sa_cfg=dict( 22 | type='PointSAModuleMSG', 23 | pool_mod='max', 24 | use_xyz=True, 25 | normalize_xyz=False)), 26 | decode_head=dict( 27 | fp_channels=((1536, 256, 256), (512, 256, 256), (352, 256, 128), 28 | (128, 128, 128, 128)))) 29 | -------------------------------------------------------------------------------- /configs/pointnet2/pointnet2_ssg_16x2_cosine_200e_scannet_seg-3d-20class.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../_base_/datasets/scannet_seg-3d-20class.py', 3 | '../_base_/models/pointnet2_ssg.py', 4 | '../_base_/schedules/seg_cosine_200e.py', '../_base_/default_runtime.py' 5 | ] 6 | 7 | # data settings 8 | data = dict(samples_per_gpu=16) 9 | evaluation = dict(interval=5) 10 | 11 | # model settings 12 | model = dict( 13 | decode_head=dict( 14 | num_classes=20, 15 | ignore_index=20, 16 | # `class_weight` is generated in data pre-processing, saved in 17 | # `data/scannet/seg_info/train_label_weight.npy` 18 | # you can copy paste the values here, or input the file path as 19 | # `class_weight=data/scannet/seg_info/train_label_weight.npy` 20 | loss_decode=dict(class_weight=[ 21 | 2.389689, 2.7215734, 4.5944676, 4.8543367, 4.096086, 4.907941, 22 | 4.690836, 4.512031, 4.623311, 4.9242644, 5.358117, 5.360071, 23 | 5.019636, 4.967126, 5.3502126, 5.4023647, 5.4027233, 5.4169416, 24 | 5.3954206, 4.6971426 25 | ])), 26 | test_cfg=dict( 27 | num_points=8192, 28 | block_size=1.5, 29 | sample_rate=0.5, 30 | use_normalized_coord=False, 31 | batch_size=24)) 32 | 33 | # runtime settings 34 | checkpoint_config = dict(interval=5) 35 | -------------------------------------------------------------------------------- /configs/pointpillars/hv_pointpillars_secfpn_sbn_2x16_2x_waymo-3d-car.py: -------------------------------------------------------------------------------- 1 | _base_ = [ 2 | '../_base_/models/hv_pointpillars_secfpn_waymo.py', 3 | '../_base_/datasets/waymoD5-3d-car.py', 4 | '../_base_/schedules/schedule_2x.py', 5 | '../_base_/default_runtime.py', 6 | ] 7 | 8 | # data settings 9 | data = dict(train=dict(dataset=dict(load_interval=1))) 10 | 11 | # model settings 12 | model = dict( 13 | type='MVXFasterRCNN', 14 | pts_bbox_head=dict( 15 | type='Anchor3DHead', 16 | num_classes=1, 17 | anchor_generator=dict( 18 | type='AlignedAnchor3DRangeGenerator', 19 | ranges=[[-74.88, -74.88, -0.0345, 74.88, 74.88, -0.0345]], 20 | sizes=[[2.08, 4.73, 1.77]], 21 | rotations=[0, 1.57], 22 | reshape_out=True)), 23 | # model training and testing settings 24 | train_cfg=dict( 25 | _delete_=True, 26 | pts=dict( 27 | assigner=dict( 28 | type='MaxIoUAssigner', 29 | iou_calculator=dict(type='BboxOverlapsNearest3D'), 30 | pos_iou_thr=0.55, 31 | neg_iou_thr=0.4, 32 | min_pos_iou=0.4, 33 | ignore_iof_thr=-1), 34 | allowed_border=0, 35 | code_weight=[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0], 36 | pos_weight=-1, 37 | debug=False))) 38 | -------------------------------------------------------------------------------- /projects/mmdet3d_plugin/ops/point_ops/src/point_ops.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 | void group_inner_inds_launcher(int N, int M, int K, const long *inverse_inds, long *group_inds); 19 | 20 | int group_inner_inds_wrapper(at::Tensor inverse_inds_tensor, at::Tensor group_inds_tensor) { 21 | CHECK_INPUT(inverse_inds_tensor); 22 | CHECK_INPUT(group_inds_tensor); 23 | 24 | int N = inverse_inds_tensor.size(0); 25 | int M = group_inds_tensor.size(0); 26 | int K = group_inds_tensor.size(1); 27 | 28 | const long *inverse_inds = inverse_inds_tensor.data_ptr(); 29 | long *group_inds = group_inds_tensor.data_ptr(); 30 | 31 | group_inner_inds_launcher(N, M, K, inverse_inds, group_inds); 32 | return 1; 33 | } 34 | 35 | PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { 36 | m.def("group_inner_inds_wrapper", &group_inner_inds_wrapper, "group_inner_inds_wrapper"); 37 | } -------------------------------------------------------------------------------- /mmdet3d/ops/spconv/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Yan Yan 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .conv import (SparseConv2d, SparseConv3d, SparseConvTranspose2d, 16 | SparseConvTranspose3d, SparseInverseConv2d, 17 | SparseInverseConv3d, SubMConv2d, SubMConv3d) 18 | from .modules import SparseModule, SparseSequential 19 | from .pool import SparseMaxPool2d, SparseMaxPool3d 20 | from .structure import SparseConvTensor, scatter_nd 21 | 22 | __all__ = [ 23 | 'SparseConv2d', 24 | 'SparseConv3d', 25 | 'SubMConv2d', 26 | 'SubMConv3d', 27 | 'SparseConvTranspose2d', 28 | 'SparseConvTranspose3d', 29 | 'SparseInverseConv2d', 30 | 'SparseInverseConv3d', 31 | 'SparseModule', 32 | 'SparseSequential', 33 | 'SparseMaxPool2d', 34 | 'SparseMaxPool3d', 35 | 'SparseConvTensor', 36 | 'scatter_nd', 37 | ] 38 | -------------------------------------------------------------------------------- /configs/_base_/models/pointnet2_ssg.py: -------------------------------------------------------------------------------- 1 | # model settings 2 | model = dict( 3 | type='EncoderDecoder3D', 4 | backbone=dict( 5 | type='PointNet2SASSG', 6 | in_channels=6, # [xyz, rgb], should be modified with dataset 7 | num_points=(1024, 256, 64, 16), 8 | radius=(0.1, 0.2, 0.4, 0.8), 9 | num_samples=(32, 32, 32, 32), 10 | sa_channels=((32, 32, 64), (64, 64, 128), (128, 128, 256), (256, 256, 11 | 512)), 12 | fp_channels=(), 13 | norm_cfg=dict(type='BN2d'), 14 | sa_cfg=dict( 15 | type='PointSAModule', 16 | pool_mod='max', 17 | use_xyz=True, 18 | normalize_xyz=False)), 19 | decode_head=dict( 20 | type='PointNet2Head', 21 | fp_channels=((768, 256, 256), (384, 256, 256), (320, 256, 128), 22 | (128, 128, 128, 128)), 23 | channels=128, 24 | dropout_ratio=0.5, 25 | conv_cfg=dict(type='Conv1d'), 26 | norm_cfg=dict(type='BN1d'), 27 | act_cfg=dict(type='ReLU'), 28 | loss_decode=dict( 29 | type='CrossEntropyLoss', 30 | use_sigmoid=False, 31 | class_weight=None, # should be modified with dataset 32 | loss_weight=1.0)), 33 | # model training and testing settings 34 | train_cfg=dict(), 35 | test_cfg=dict(mode='slide')) 36 | -------------------------------------------------------------------------------- /mmdet3d/ops/spconv/include/spconv/mp_helper.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_HELPER_H_ 2 | #define MP_HELPER_H_ 3 | #include 4 | #include 5 | 6 | namespace spconv { 7 | template 8 | struct mp_list {}; 9 | 10 | template 11 | using mp_list_c = mp_list...>; 12 | 13 | namespace detail { 14 | 15 | template 16 | constexpr F mp_for_each_impl(mp_list, F &&f) { 17 | return std::initializer_list{(f(T()), 0)...}, std::forward(f); 18 | } 19 | 20 | template 21 | constexpr F mp_for_each_impl(mp_list<>, F &&f) { 22 | return std::forward(f); 23 | } 24 | 25 | } // namespace detail 26 | 27 | namespace detail { 28 | 29 | template class B> 30 | struct mp_rename_impl { 31 | // An error "no type named 'type'" here means that the first argument to 32 | // mp_rename is not a list 33 | }; 34 | 35 | template