├── README.md ├── VoxelNet_CVPR_2018_PointCloud ├── .vscode │ └── launch.json ├── LICENSE ├── README.md ├── __pycache__ │ └── config.cpython-38.pyc ├── config.py ├── loader │ ├── __pycache__ │ │ └── kitti.cpython-38.pyc │ └── kitti.py ├── model │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-38.pyc │ │ ├── group_pointcloud.cpython-38.pyc │ │ ├── model.cpython-38.pyc │ │ └── rpn.cpython-38.pyc │ ├── group_pointcloud.py │ ├── model.py │ └── rpn.py ├── notes │ ├── DESCRIPTIONS.md │ ├── QUESTIONS.md │ └── REMARKS.md ├── parse.py ├── parse.sh ├── preproc │ ├── crop.py │ └── split.py ├── test.py ├── test.sh ├── train.py ├── train.sh └── utils │ ├── __init__.py │ ├── __pycache__ │ ├── __init__.cpython-38.pyc │ ├── colorize.cpython-38.pyc │ ├── data_aug.cpython-38.pyc │ ├── nms.cpython-38.pyc │ ├── preprocess.cpython-38.pyc │ └── utils.cpython-38.pyc │ ├── box_overlaps.c │ ├── box_overlaps.cpython-38-x86_64-linux-gnu.so │ ├── box_overlaps.pyx │ ├── colorize.py │ ├── data_aug.py │ ├── nms.py │ ├── preprocess.py │ ├── setup.py │ └── utils.py ├── second.pytorch ├── Dockerfile ├── LICENSE ├── NUSCENES-GUIDE.md ├── README.md ├── RELEASE.md ├── images │ ├── kittibox.png │ ├── simpleguide.png │ └── viewerweb.png ├── second │ ├── .vscode │ │ └── launch.json │ ├── KITTI_DATASET_ROOT │ ├── __init__.py │ ├── __pycache__ │ │ └── __init__.cpython-38.pyc │ ├── builder │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-38.pyc │ │ │ ├── anchor_generator_builder.cpython-38.pyc │ │ │ ├── dataset_builder.cpython-38.pyc │ │ │ ├── dbsampler_builder.cpython-38.pyc │ │ │ ├── preprocess_builder.cpython-38.pyc │ │ │ ├── similarity_calculator_builder.cpython-38.pyc │ │ │ ├── target_assigner_builder.cpython-38.pyc │ │ │ └── voxel_builder.cpython-38.pyc │ │ ├── anchor_generator_builder.py │ │ ├── dataset_builder.py │ │ ├── dbsampler_builder.py │ │ ├── preprocess_builder.py │ │ ├── similarity_calculator_builder.py │ │ ├── target_assigner_builder.py │ │ └── voxel_builder.py │ ├── configs │ │ ├── all.fhd.config │ │ ├── car.fhd.config │ │ ├── car.fhd.onestage.config │ │ ├── car.lite.config │ │ ├── nuscenes │ │ │ ├── all.fhd.config │ │ │ ├── all.pp.deprecated.config │ │ │ ├── all.pp.largea.config │ │ │ ├── all.pp.lowa.config │ │ │ ├── all.pp.mhead.config │ │ │ └── all.pp.mida.config │ │ ├── people.fhd.config │ │ └── pointpillars │ │ │ ├── car │ │ │ ├── xyres_16.config │ │ │ ├── xyres_20.config │ │ │ ├── xyres_24.config │ │ │ └── xyres_28.config │ │ │ ├── ped_cycle │ │ │ ├── xyres_16.config │ │ │ ├── xyres_20.config │ │ │ ├── xyres_24.config │ │ │ └── xyres_28.config │ │ │ └── pp_pretrain.config │ ├── core │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-38.pyc │ │ │ ├── anchor_generator.cpython-38.pyc │ │ │ ├── box_coders.cpython-38.pyc │ │ │ ├── box_np_ops.cpython-38.pyc │ │ │ ├── geometry.cpython-38.pyc │ │ │ ├── preprocess.cpython-38.pyc │ │ │ ├── region_similarity.cpython-38.pyc │ │ │ ├── sample_ops.cpython-38.pyc │ │ │ ├── target_assigner.cpython-38.pyc │ │ │ └── target_ops.cpython-38.pyc │ │ ├── anchor_generator.py │ │ ├── box_coders.py │ │ ├── box_np_ops.py │ │ ├── geometry.py │ │ ├── inference.py │ │ ├── non_max_suppression │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-38.pyc │ │ │ │ ├── nms_cpu.cpython-38.pyc │ │ │ │ └── nms_gpu.cpython-38.pyc │ │ │ ├── nms_cpu.py │ │ │ └── nms_gpu.py │ │ ├── preprocess.py │ │ ├── region_similarity.py │ │ ├── sample_ops.py │ │ ├── target_assigner.py │ │ └── target_ops.py │ ├── create_data.py │ ├── data │ │ ├── ImageSets │ │ │ ├── test.txt │ │ │ ├── train.txt │ │ │ ├── trainval.txt │ │ │ └── val.txt │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-38.pyc │ │ │ ├── dataset.cpython-38.pyc │ │ │ ├── kitti_common.cpython-38.pyc │ │ │ ├── kitti_dataset.cpython-38.pyc │ │ │ ├── nuscenes_dataset.cpython-38.pyc │ │ │ └── preprocess.cpython-38.pyc │ │ ├── all_dataset.py │ │ ├── dataset.py │ │ ├── kitti_common.py │ │ ├── kitti_dataset.py │ │ ├── nusc_eval.py │ │ ├── nuscenes_dataset.py │ │ └── preprocess.py │ ├── framework │ │ ├── __init__.py │ │ └── test.py │ ├── kittiviewer │ │ ├── __init__.py │ │ ├── backend │ │ │ ├── __init__.py │ │ │ └── main.py │ │ ├── control_panel.py │ │ ├── frontend │ │ │ ├── css │ │ │ │ └── main.css │ │ │ ├── index.html │ │ │ ├── js │ │ │ │ ├── KittiViewer.js │ │ │ │ ├── MapControls.js │ │ │ │ ├── SimplePlot.js │ │ │ │ ├── Toast.js │ │ │ │ ├── libs │ │ │ │ │ ├── jquery-3.3.1.min.js │ │ │ │ │ └── js.cookie.min.js │ │ │ │ ├── postprocessing │ │ │ │ │ ├── BloomPass.js │ │ │ │ │ ├── EffectComposer.js │ │ │ │ │ ├── FilmPass.js │ │ │ │ │ ├── MaskPass.js │ │ │ │ │ ├── RenderPass.js │ │ │ │ │ ├── ShaderPass.js │ │ │ │ │ └── UnrealBloomPass.js │ │ │ │ ├── renderers │ │ │ │ │ └── CSS2DRenderer.js │ │ │ │ └── shaders │ │ │ │ │ ├── ConvolutionShader.js │ │ │ │ │ ├── CopyShader.js │ │ │ │ │ ├── FilmShader.js │ │ │ │ │ ├── FocusShader.js │ │ │ │ │ └── LuminosityHighPassShader.js │ │ │ └── textures │ │ │ │ └── sprites │ │ │ │ └── disc.png │ │ ├── glwidget.py │ │ └── viewer.py │ ├── plot_example.py │ ├── protos │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-38.pyc │ │ │ ├── anchors_pb2.cpython-38.pyc │ │ │ ├── box_coder_pb2.cpython-38.pyc │ │ │ ├── input_reader_pb2.cpython-38.pyc │ │ │ ├── losses_pb2.cpython-38.pyc │ │ │ ├── model_pb2.cpython-38.pyc │ │ │ ├── optimizer_pb2.cpython-38.pyc │ │ │ ├── pipeline_pb2.cpython-38.pyc │ │ │ ├── preprocess_pb2.cpython-38.pyc │ │ │ ├── sampler_pb2.cpython-38.pyc │ │ │ ├── second_pb2.cpython-38.pyc │ │ │ ├── similarity_pb2.cpython-38.pyc │ │ │ ├── target_pb2.cpython-38.pyc │ │ │ ├── train_pb2.cpython-38.pyc │ │ │ └── voxel_generator_pb2.cpython-38.pyc │ │ ├── anchors.proto │ │ ├── anchors_pb2.py │ │ ├── box_coder.proto │ │ ├── box_coder_pb2.py │ │ ├── input_reader.proto │ │ ├── input_reader_pb2.py │ │ ├── losses.proto │ │ ├── losses_pb2.py │ │ ├── model.proto │ │ ├── model_pb2.py │ │ ├── optimizer.proto │ │ ├── optimizer_pb2.py │ │ ├── pipeline.proto │ │ ├── pipeline_pb2.py │ │ ├── preprocess.proto │ │ ├── preprocess_pb2.py │ │ ├── sampler.proto │ │ ├── sampler_pb2.py │ │ ├── second.proto │ │ ├── second_pb2.py │ │ ├── similarity.proto │ │ ├── similarity_pb2.py │ │ ├── target.proto │ │ ├── target_pb2.py │ │ ├── train.proto │ │ ├── train_pb2.py │ │ ├── voxel_generator.proto │ │ └── voxel_generator_pb2.py │ ├── pytorch │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-38.pyc │ │ │ └── train.cpython-38.pyc │ │ ├── builder │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-38.pyc │ │ │ │ ├── box_coder_builder.cpython-38.pyc │ │ │ │ ├── input_reader_builder.cpython-38.pyc │ │ │ │ ├── losses_builder.cpython-38.pyc │ │ │ │ ├── lr_scheduler_builder.cpython-38.pyc │ │ │ │ ├── optimizer_builder.cpython-38.pyc │ │ │ │ └── second_builder.cpython-38.pyc │ │ │ ├── box_coder_builder.py │ │ │ ├── input_reader_builder.py │ │ │ ├── losses_builder.py │ │ │ ├── lr_scheduler_builder.py │ │ │ ├── optimizer_builder.py │ │ │ └── second_builder.py │ │ ├── core │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-38.pyc │ │ │ │ ├── box_coders.cpython-38.pyc │ │ │ │ ├── box_torch_ops.cpython-38.pyc │ │ │ │ ├── ghm_loss.cpython-38.pyc │ │ │ │ └── losses.cpython-38.pyc │ │ │ ├── box_coders.py │ │ │ ├── box_torch_ops.py │ │ │ ├── ghm_loss.py │ │ │ └── losses.py │ │ ├── inference.py │ │ ├── models │ │ │ ├── __init__.py │ │ │ ├── __pycache__ │ │ │ │ ├── __init__.cpython-38.pyc │ │ │ │ ├── middle.cpython-38.pyc │ │ │ │ ├── net_multi_head.cpython-38.pyc │ │ │ │ ├── pointpillars.cpython-38.pyc │ │ │ │ ├── resnet.cpython-38.pyc │ │ │ │ ├── rpn.cpython-38.pyc │ │ │ │ ├── voxel_encoder.cpython-38.pyc │ │ │ │ └── voxelnet.cpython-38.pyc │ │ │ ├── middle.py │ │ │ ├── net_multi_head.py │ │ │ ├── pointpillars.py │ │ │ ├── resnet.py │ │ │ ├── rpn.py │ │ │ ├── voxel_encoder.py │ │ │ └── voxelnet.py │ │ ├── train.py │ │ └── utils │ │ │ ├── __init__.py │ │ │ └── __pycache__ │ │ │ └── __init__.cpython-38.pyc │ ├── script.py │ ├── script_server.py │ ├── simple-inference.ipynb │ ├── simple-inference.py │ ├── simple-inference_spconv2.py │ └── utils │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-38.pyc │ │ ├── check.cpython-38.pyc │ │ ├── eval.cpython-38.pyc │ │ ├── log_tool.cpython-38.pyc │ │ ├── progress_bar.cpython-38.pyc │ │ ├── simplevis.cpython-38.pyc │ │ └── timer.cpython-38.pyc │ │ ├── bbox_plot.py │ │ ├── check.py │ │ ├── config_tool.py │ │ ├── config_tool │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ └── __init__.cpython-38.pyc │ │ └── train.py │ │ ├── eval.py │ │ ├── find.py │ │ ├── loader.py │ │ ├── log_tool.py │ │ ├── merge_result.py │ │ ├── model_tool.py │ │ ├── progress_bar.py │ │ ├── simplevis.py │ │ └── timer.py └── torchplus │ ├── __init__.py │ ├── __pycache__ │ ├── __init__.cpython-38.pyc │ ├── metrics.cpython-38.pyc │ └── tools.cpython-38.pyc │ ├── metrics.py │ ├── nn │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-38.pyc │ │ └── functional.cpython-38.pyc │ ├── functional.py │ └── modules │ │ ├── __init__.py │ │ ├── __pycache__ │ │ ├── __init__.cpython-38.pyc │ │ ├── common.cpython-38.pyc │ │ └── normalization.cpython-38.pyc │ │ ├── common.py │ │ └── normalization.py │ ├── ops │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-38.pyc │ │ └── array_ops.cpython-38.pyc │ └── array_ops.py │ ├── tools.py │ └── train │ ├── __init__.py │ ├── __pycache__ │ ├── __init__.cpython-38.pyc │ ├── checkpoint.cpython-38.pyc │ ├── common.cpython-38.pyc │ ├── fastai_optim.cpython-38.pyc │ ├── learning_schedules.cpython-38.pyc │ ├── learning_schedules_fastai.cpython-38.pyc │ └── optim.cpython-38.pyc │ ├── checkpoint.py │ ├── common.py │ ├── fastai_optim.py │ ├── learning_schedules.py │ ├── learning_schedules_fastai.py │ └── optim.py ├── spconv-1.2.1 ├── CHANGELOG.md ├── CMakeLists.txt ├── Dockerfile ├── LICENSE ├── PERFORMANCE_GUIDE.md ├── README.md ├── example │ └── mnist_sparse.py ├── format_all.sh ├── include │ ├── cuhash │ │ ├── cuda_util.h │ │ ├── debugging.h │ │ ├── definitions.h │ │ ├── hash_functions.h │ │ ├── hash_table.cuh │ │ └── hash_table.h │ ├── paramsgrid.h │ ├── spconv │ │ ├── box_iou.h │ │ ├── cublas_gemm.h │ │ ├── fused_spconv_ops.h │ │ ├── geometry.h │ │ ├── indice.cu.h │ │ ├── indice.h │ │ ├── maxpool.h │ │ ├── nms.h │ │ ├── nms_functor.h │ │ ├── nms_gpu.h │ │ ├── nms_ops.h │ │ ├── pillar_scatter_functor.h │ │ ├── pillar_scatter_ops.h │ │ ├── point2voxel.h │ │ ├── pool_ops.h │ │ ├── reordering.cu.h │ │ ├── reordering.h │ │ └── spconv_ops.h │ ├── tensorrt │ │ └── inference.h │ ├── tensorview │ │ ├── common.h │ │ ├── cuda_utils.h │ │ ├── eigen_utils.h │ │ ├── kernel_utils.h │ │ ├── mp_helper.h │ │ ├── prettyprint.h │ │ ├── pybind_utils.h │ │ ├── tensor.h │ │ ├── tensorview.h │ │ ├── tools.h │ │ └── torch_utils.h │ ├── torch_utils.h │ ├── tsl │ │ ├── robin_growth_policy.h │ │ ├── robin_hash.h │ │ └── robin_map.h │ └── utility │ │ └── timer.h ├── setup.py ├── spconv │ ├── __init__.py │ ├── conv.py │ ├── functional.py │ ├── identity.py │ ├── modules.py │ ├── ops.py │ ├── pool.py │ ├── tables.py │ ├── test_utils.py │ └── utils │ │ └── __init__.py ├── src │ ├── cuhash │ │ ├── CMakeLists.txt │ │ ├── debugging.cpp │ │ ├── debugging.cu │ │ ├── hash_functions.cpp │ │ ├── hash_functions.cu │ │ ├── hash_table.cpp │ │ ├── hash_table.cu │ │ └── main.cc │ ├── spconv │ │ ├── CMakeLists.txt │ │ ├── all.cc │ │ ├── cublas_gemm.cc │ │ ├── indice.cc │ │ ├── indice.cu │ │ ├── maxpool.cc │ │ ├── maxpool.cu │ │ ├── nms.cc │ │ ├── nms.cu │ │ ├── pillar_scatter.cu │ │ ├── pool_ops.cc │ │ ├── reordering.cc │ │ ├── reordering.cu │ │ └── spconv_ops.cc │ └── utils │ │ ├── CMakeLists.txt │ │ ├── all.cc │ │ └── nms.cu └── test │ ├── CMakeLists.txt │ ├── fake_dist_train.py │ ├── fake_train.py │ ├── src │ ├── catch_main.cpp │ └── test_conv_rule.cpp │ └── test_conv.py ├── spconv2.1 ├── .vscode │ └── launch.json ├── CHANGELOG.md ├── LICENSE ├── README.md ├── docs │ ├── API.md │ ├── BENCHMARK.md │ ├── FAQ.md │ ├── PERFORMANCE_GUIDE.md │ ├── SPCONV_2_BREAKING_CHANGEs.md │ ├── SPCONV_DEVELOP_PLAN.md │ ├── USAGE.md │ └── spconv2_algo.pdf ├── example │ ├── simple_hash.py │ ├── sparseconvolution.py │ ├── tensorrt │ │ └── README.md │ └── voxel_gen.py ├── format_all.sh ├── pyproject.toml ├── scripts │ └── sort_bench.py ├── setup.py ├── simple-inference.py ├── spconv.egg-info │ ├── PKG-INFO │ ├── SOURCES.txt │ ├── dependency_links.txt │ ├── requires.txt │ └── top_level.txt ├── spconv │ ├── __init__.py │ ├── __pycache__ │ │ ├── __init__.cpython-38.pyc │ │ ├── build.cpython-38.pyc │ │ ├── constants.cpython-38.pyc │ │ └── core.cpython-38.pyc │ ├── __version__.py │ ├── algo.py │ ├── algocore.py │ ├── benchmark │ │ ├── __init__.py │ │ ├── __main__.py │ │ ├── basic.py │ │ └── core.py │ ├── build.py │ ├── constants.py │ ├── core.py │ ├── core_cc │ │ ├── __init__.pyi │ │ ├── csrc │ │ │ ├── __init__.pyi │ │ │ ├── hash │ │ │ │ ├── __init__.pyi │ │ │ │ └── core.pyi │ │ │ ├── sparse │ │ │ │ ├── __init__.pyi │ │ │ │ ├── all │ │ │ │ │ ├── __init__.pyi │ │ │ │ │ ├── ops1d.pyi │ │ │ │ │ ├── ops2d.pyi │ │ │ │ │ ├── ops3d.pyi │ │ │ │ │ ├── ops4d.pyi │ │ │ │ │ ├── ops_cpu1d.pyi │ │ │ │ │ ├── ops_cpu2d.pyi │ │ │ │ │ ├── ops_cpu3d.pyi │ │ │ │ │ └── ops_cpu4d.pyi │ │ │ │ ├── alloc.pyi │ │ │ │ ├── convops │ │ │ │ │ ├── __init__.pyi │ │ │ │ │ ├── convops.pyi │ │ │ │ │ ├── gemmops.pyi │ │ │ │ │ └── spops.pyi │ │ │ │ └── inference.pyi │ │ │ └── utils │ │ │ │ ├── __init__.pyi │ │ │ │ └── boxops.pyi │ │ └── cumm │ │ │ ├── __init__.pyi │ │ │ ├── common.pyi │ │ │ ├── conv │ │ │ ├── __init__.pyi │ │ │ └── main.pyi │ │ │ ├── gemm │ │ │ ├── __init__.pyi │ │ │ └── main.pyi │ │ │ └── tools │ │ │ ├── __init__.pyi │ │ │ └── cuda.pyi │ ├── cppconstants.py │ ├── csrc │ │ ├── __init__.py │ │ ├── hash │ │ │ ├── __init__.py │ │ │ └── core.py │ │ ├── sparse │ │ │ ├── __init__.py │ │ │ ├── all.py │ │ │ ├── alloc.py │ │ │ ├── convops.py │ │ │ ├── cpu_core.py │ │ │ ├── devleop │ │ │ │ └── sort_bench.py │ │ │ ├── gather.py │ │ │ ├── indices.py │ │ │ ├── inference.py │ │ │ ├── maxpool.py │ │ │ └── pointops.py │ │ └── utils │ │ │ ├── __init__.py │ │ │ └── boxops.py │ ├── debug_utils.py │ ├── gencode │ │ ├── __init__.py │ │ └── __main__.py │ ├── pytorch │ │ ├── __init__.py │ │ ├── constants.py │ │ ├── conv.py │ │ ├── core.py │ │ ├── cppcore.py │ │ ├── functional.py │ │ ├── hash.py │ │ ├── identity.py │ │ ├── modules.py │ │ ├── ops.py │ │ ├── pool.py │ │ ├── spatial.py │ │ ├── tables.py │ │ └── utils.py │ ├── test_utils.py │ ├── tools.py │ └── utils │ │ └── __init__.py ├── test │ ├── apps │ │ └── testapp.py │ ├── benchmark.py │ ├── dev.py │ ├── dev2.py │ ├── fake_dist_train.py │ ├── fake_train.py │ ├── test_all_algo.py │ ├── test_conv.py │ └── test_multi_impl.py ├── test_before_push.sh ├── tools │ ├── README.md │ ├── build-wheels.sh │ ├── install_windows_cuda.ps1 │ └── msvc_setup.ps1 └── version.txt └── torchsparse ├── .pre-commit-config.yaml ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── conv.py ├── docs └── FAQ.md ├── examples ├── .vscode │ ├── launch.json │ └── settings.json ├── __pycache__ │ └── gpu_mem_track.cpython-38.pyc ├── backbones.py ├── example.py ├── gpu_mem_track.py ├── modelsize_estimate.py ├── performance.py ├── plot_example.py ├── profile_example.py ├── tem.txt └── tensorboard_example.py ├── setup.cfg ├── setup.py └── torchsparse ├── __init__.py ├── backbones ├── __init__.py ├── modules │ ├── __init__.py │ └── blocks.py ├── resnet.py └── unet.py ├── backend ├── convolution │ ├── convolution_cpu.cpp │ ├── convolution_cpu.h │ ├── convolution_cuda.cu │ └── convolution_cuda.h ├── devoxelize │ ├── devoxelize_cpu.cpp │ ├── devoxelize_cpu.h │ ├── devoxelize_cuda.cu │ └── devoxelize_cuda.h ├── hash │ ├── hash_cpu.cpp │ ├── hash_cpu.h │ ├── hash_cuda.cu │ └── hash_cuda.h ├── hashmap │ ├── hashmap_cpu.cpp │ ├── hashmap_cpu.hpp │ ├── hashmap_cuda.cu │ └── hashmap_cuda.cuh ├── others │ ├── count_cpu.cpp │ ├── count_cpu.h │ ├── count_cuda.cu │ ├── count_cuda.h │ ├── query_cpu.cpp │ ├── query_cpu.h │ ├── query_cuda.cu │ └── query_cuda.h ├── pybind_cpu.cpp ├── pybind_cuda.cpp ├── utils │ └── atomic.cuh └── voxelize │ ├── voxelize_cpu.cpp │ ├── voxelize_cpu.h │ ├── voxelize_cuda.cu │ └── voxelize_cuda.h ├── nn ├── __init__.py ├── functional │ ├── __init__.py │ ├── activation.py │ ├── conv.py │ ├── count.py │ ├── crop.py │ ├── devoxelize.py │ ├── downsample.py │ ├── hash.py │ ├── pooling.py │ ├── query.py │ └── voxelize.py ├── modules │ ├── __init__.py │ ├── activation.py │ ├── bev.py │ ├── conv.py │ ├── crop.py │ ├── norm.py │ └── pooling.py └── utils │ ├── __init__.py │ ├── apply.py │ └── kernel.py ├── operators.py ├── tensor.py ├── utils ├── __init__.py ├── collate.py ├── quantize.py └── utils.py └── version.py /README.md: -------------------------------------------------------------------------------- 1 | # sparse_model 2 | The four major frameworks for 3D point cloud sparse acceleration that are currently popular are specifically divided into **MIT-HAN-LAB's [torchsparse](https://github.com/mit-han-lab/torchsparse)**, **NVIDIA's [MinkowskiEngine](https://github.com/NVIDIA/MinkowskiEngine)**, **TuSimple's [spconv](https://github.com/traveller59/spconv)**, and **Facebook(Meta) Research's [SparseConvNet](https://github.com/facebookresearch/SparseConvNet)**. The experiment started with Torchsparse, but it was found that it only implemented submanifold and its functionality was incomplete (still immature). After conducting in-depth research on spconv, it was discovered that directly modifying and optimizing at the PyTorch level for sparse acceleration is quite limited. Optimization design at the CUDA low level needs to be considered to achieve model sparse acceleration. 3 | 4 | This library mainly configures the sparse frameworks of the above models, eliminates installation errors, and provides solutions for them. 5 | 6 | Experiments were also conducted on [VoxelNet](https://github.com/collector-m/VoxelNet_CVPR_2018_PointCloud) and [Second](https://github.com/traveller59/second.pytorch). 7 | 8 | 目前较为流行的3D点云稀疏加速四大框架,具体分为, **mit-han-lab的[torchsparse](https://github.com/mit-han-lab/torchsparse)**、**NVIDAI的[MinkowskiEngine](https://github.com/NVIDIA/MinkowskiEngine)**、 **Tusimple的[spconv](https://github.com/traveller59/spconv)**、**facebookresearch的[SparseConvNet](https://github.com/facebookresearch/SparseConvNet)**,具体进行实验以Torchsparse为研究起始,但发现其仅仅是完成了submanifold的实现且功能也不完整(还不成熟),随后经过对spconv的深入研究,发现若要直接的在pytorch层进行修改优化以达到模型稀疏加速的目的是非常有限的,需要在CUDA底层的优化设计进行考虑。 9 | 10 | - 该库主要是对上述的模型稀疏框架进行了配置,消除了安装的错误以及如何解决。 11 | 12 | - 也在[VoxelNet](https://github.com/collector-m/VoxelNet_CVPR_2018_PointCloud)与[Second](https://github.com/traveller59/second.pytorch)上进行了试验。 13 | -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "Python: Current File", 9 | "type": "python", 10 | "request": "launch", 11 | "program": "${file}", 12 | "console": "integratedTerminal", 13 | "justMyCode": false, 14 | "purpose": ["debug-in-terminal"] 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 huanghao-code 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/__pycache__/config.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/VoxelNet_CVPR_2018_PointCloud/__pycache__/config.cpython-38.pyc -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/loader/__pycache__/kitti.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/VoxelNet_CVPR_2018_PointCloud/loader/__pycache__/kitti.cpython-38.pyc -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/model/__init__.py: -------------------------------------------------------------------------------- 1 | from model.rpn import * -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/model/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/VoxelNet_CVPR_2018_PointCloud/model/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/model/__pycache__/group_pointcloud.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/VoxelNet_CVPR_2018_PointCloud/model/__pycache__/group_pointcloud.cpython-38.pyc -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/model/__pycache__/model.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/VoxelNet_CVPR_2018_PointCloud/model/__pycache__/model.cpython-38.pyc -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/model/__pycache__/rpn.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/VoxelNet_CVPR_2018_PointCloud/model/__pycache__/rpn.cpython-38.pyc -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/notes/DESCRIPTIONS.md: -------------------------------------------------------------------------------- 1 | # data_object_image_2.zip 2 | Images from the second color camera. 3 | 4 | # data_object_velodyne.zip 5 | Velodyne scanned points. Each file (.bin) corresponds to an image and contains around 12K 3D points. 6 | Each point is stored in the format (x, y, z, r), where r is the reflectance value. 7 | 8 | # data_object_label_2.zip 9 | Label format can be found [here](https://github.com/NVIDIA/DIGITS/blob/v4.0.0-rc.3/digits/extensions/data/objectDetection/README.md#label-format). 10 | The last value is only used for online submission. Original description can be downloaded [here](https://s3.eu-central-1.amazonaws.com/avg-kitti/devkit_object.zip). 11 | 12 | 13 | 14 | # data_object_calib.zip 15 | Pi: projection matrix after rectification, size of 3x4; i is camera index 16 | 17 | R0_rect: rectifying rotation matrix of the reference camera (camera 0) 18 | 19 | Tr_velo_to_cam: rotation and translation matrix from the Velodyne coordinate to the camera coordinate 20 | 21 | To transform a 3D point x in Velodyne coordinates to a point y in i-th camera image using: **y = Pi * R0_rect * Tr_velo_to_cam * x** -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/notes/QUESTIONS.md: -------------------------------------------------------------------------------- 1 | - Some details of functions in [utils\utils.py](..\utils\utils.py) are not fully understood, especially ones pre-processing dataset. 2 | They involve multiple coordinates projection and transformation. 3 | 4 | - The maximum number of non-voxels (K) is different across samples, so it is not strightforward to use multiple GPUs in PyTorch. 5 | Because it is hard to pack a batch of samples into a single tensor. (TensorFlow can assign certain samples to a certain GPU.) -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/parse.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | python parse.py preds -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | python test.py --tag default --resumed_model kitti_Car_best.pth.tar -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/train.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | python train.py --alpha 1.5 --beta 1 -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from utils.box_overlaps import * -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/utils/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/VoxelNet_CVPR_2018_PointCloud/utils/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/utils/__pycache__/colorize.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/VoxelNet_CVPR_2018_PointCloud/utils/__pycache__/colorize.cpython-38.pyc -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/utils/__pycache__/data_aug.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/VoxelNet_CVPR_2018_PointCloud/utils/__pycache__/data_aug.cpython-38.pyc -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/utils/__pycache__/nms.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/VoxelNet_CVPR_2018_PointCloud/utils/__pycache__/nms.cpython-38.pyc -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/utils/__pycache__/preprocess.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/VoxelNet_CVPR_2018_PointCloud/utils/__pycache__/preprocess.cpython-38.pyc -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/utils/__pycache__/utils.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/VoxelNet_CVPR_2018_PointCloud/utils/__pycache__/utils.cpython-38.pyc -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/utils/box_overlaps.cpython-38-x86_64-linux-gnu.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/VoxelNet_CVPR_2018_PointCloud/utils/box_overlaps.cpython-38-x86_64-linux-gnu.so -------------------------------------------------------------------------------- /VoxelNet_CVPR_2018_PointCloud/utils/setup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding:UTF-8 -*- 3 | 4 | # File Name : setup.py 5 | # Purpose : 6 | # Creation Date : 11-12-2017 7 | # Last Modified : Sat 23 Dec 2017 03:19:46 PM CST 8 | # Created By : Jeasine Ma [jeasinema[at]gmail[dot]com] 9 | 10 | 11 | from distutils.core import setup 12 | from Cython.Build import cythonize 13 | import numpy 14 | 15 | setup( 16 | name = 'box overlaps', 17 | ext_modules = cythonize('./utils/box_overlaps.pyx'), 18 | include_dirs = [numpy.get_include()] 19 | ) 20 | -------------------------------------------------------------------------------- /second.pytorch/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /second.pytorch/images/kittibox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/images/kittibox.png -------------------------------------------------------------------------------- /second.pytorch/images/simpleguide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/images/simpleguide.png -------------------------------------------------------------------------------- /second.pytorch/images/viewerweb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/images/viewerweb.png -------------------------------------------------------------------------------- /second.pytorch/second/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "Python: Current File", 9 | "type": "python", 10 | "request": "launch", 11 | "program": "${file}", 12 | "console": "integratedTerminal", 13 | "justMyCode": false, 14 | "purpose": ["debug-in-terminal"] 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /second.pytorch/second/KITTI_DATASET_ROOT: -------------------------------------------------------------------------------- 1 | /root/datasets/KITTI_DATASET_ROOT -------------------------------------------------------------------------------- /second.pytorch/second/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/__init__.py -------------------------------------------------------------------------------- /second.pytorch/second/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/builder/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/builder/__init__.py -------------------------------------------------------------------------------- /second.pytorch/second/builder/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/builder/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/builder/__pycache__/anchor_generator_builder.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/builder/__pycache__/anchor_generator_builder.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/builder/__pycache__/dataset_builder.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/builder/__pycache__/dataset_builder.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/builder/__pycache__/dbsampler_builder.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/builder/__pycache__/dbsampler_builder.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/builder/__pycache__/preprocess_builder.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/builder/__pycache__/preprocess_builder.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/builder/__pycache__/similarity_calculator_builder.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/builder/__pycache__/similarity_calculator_builder.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/builder/__pycache__/target_assigner_builder.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/builder/__pycache__/target_assigner_builder.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/builder/__pycache__/voxel_builder.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/builder/__pycache__/voxel_builder.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/builder/anchor_generator_builder.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from second.protos import box_coder_pb2 4 | from second.core.anchor_generator import (AnchorGeneratorStride, 5 | AnchorGeneratorRange) 6 | 7 | 8 | def build(class_cfg): 9 | """Create optimizer based on config. 10 | 11 | Args: 12 | optimizer_config: A Optimizer proto message. 13 | 14 | Returns: 15 | An optimizer and a list of variables for summary. 16 | 17 | Raises: 18 | ValueError: when using an unsupported input data type. 19 | """ 20 | ag_type = class_cfg.WhichOneof('anchor_generator') 21 | 22 | if ag_type == 'anchor_generator_stride': 23 | config = class_cfg.anchor_generator_stride 24 | ag = AnchorGeneratorStride( 25 | sizes=list(config.sizes), 26 | anchor_strides=list(config.strides), 27 | anchor_offsets=list(config.offsets), 28 | rotations=list(config.rotations), 29 | match_threshold=class_cfg.matched_threshold, 30 | unmatch_threshold=class_cfg.unmatched_threshold, 31 | class_name=class_cfg.class_name, 32 | custom_values=list(config.custom_values)) 33 | return ag 34 | elif ag_type == 'anchor_generator_range': 35 | config = class_cfg.anchor_generator_range 36 | ag = AnchorGeneratorRange( 37 | sizes=list(config.sizes), 38 | anchor_ranges=list(config.anchor_ranges), 39 | rotations=list(config.rotations), 40 | match_threshold=class_cfg.matched_threshold, 41 | unmatch_threshold=class_cfg.unmatched_threshold, 42 | class_name=class_cfg.class_name, 43 | custom_values=list(config.custom_values)) 44 | return ag 45 | elif ag_type == 'no_anchor': 46 | return None 47 | else: 48 | raise ValueError(" unknown anchor generator type") -------------------------------------------------------------------------------- /second.pytorch/second/builder/dbsampler_builder.py: -------------------------------------------------------------------------------- 1 | import pickle 2 | 3 | import second.core.preprocess as prep 4 | from second.builder import preprocess_builder 5 | from second.core.preprocess import DataBasePreprocessor 6 | from second.core.sample_ops import DataBaseSamplerV2 7 | 8 | 9 | def build(sampler_config): 10 | cfg = sampler_config 11 | groups = list(cfg.sample_groups) 12 | prepors = [ 13 | preprocess_builder.build_db_preprocess(c) 14 | for c in cfg.database_prep_steps 15 | ] 16 | db_prepor = DataBasePreprocessor(prepors) 17 | rate = cfg.rate 18 | grot_range = cfg.global_random_rotation_range_per_object 19 | groups = [dict(g.name_to_max_num) for g in groups] 20 | info_path = cfg.database_info_path 21 | with open(info_path, 'rb') as f: 22 | db_infos = pickle.load(f) 23 | grot_range = list(grot_range) 24 | if len(grot_range) == 0: 25 | grot_range = None 26 | sampler = DataBaseSamplerV2(db_infos, groups, db_prepor, rate, grot_range) 27 | return sampler 28 | -------------------------------------------------------------------------------- /second.pytorch/second/builder/preprocess_builder.py: -------------------------------------------------------------------------------- 1 | import second.core.preprocess as prep 2 | 3 | def build_db_preprocess(db_prep_config): 4 | prep_type = db_prep_config.WhichOneof('database_preprocessing_step') 5 | 6 | if prep_type == 'filter_by_difficulty': 7 | cfg = db_prep_config.filter_by_difficulty 8 | return prep.DBFilterByDifficulty(list(cfg.removed_difficulties)) 9 | elif prep_type == 'filter_by_min_num_points': 10 | cfg = db_prep_config.filter_by_min_num_points 11 | return prep.DBFilterByMinNumPoint(dict(cfg.min_num_point_pairs)) 12 | else: 13 | raise ValueError("unknown database prep type") 14 | 15 | -------------------------------------------------------------------------------- /second.pytorch/second/builder/similarity_calculator_builder.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from second.core import region_similarity 4 | from second.protos import similarity_pb2 5 | 6 | 7 | def build(similarity_config): 8 | """Create optimizer based on config. 9 | 10 | Args: 11 | optimizer_config: A Optimizer proto message. 12 | 13 | Returns: 14 | An optimizer and a list of variables for summary. 15 | 16 | Raises: 17 | ValueError: when using an unsupported input data type. 18 | """ 19 | similarity_type = similarity_config.WhichOneof('region_similarity') 20 | if similarity_type == 'rotate_iou_similarity': 21 | return region_similarity.RotateIouSimilarity() 22 | elif similarity_type == 'nearest_iou_similarity': 23 | return region_similarity.NearestIouSimilarity() 24 | elif similarity_type == 'distance_similarity': 25 | cfg = similarity_config.distance_similarity 26 | return region_similarity.DistanceSimilarity( 27 | distance_norm=cfg.distance_norm, 28 | with_rotation=cfg.with_rotation, 29 | rotation_alpha=cfg.rotation_alpha) 30 | else: 31 | raise ValueError("unknown similarity type") 32 | -------------------------------------------------------------------------------- /second.pytorch/second/builder/voxel_builder.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | # from spconv.utils import VoxelGeneratorV2 #spconv1.2.1 4 | from spconv.pytorch.utils import PointToVoxel as VoxelGeneratorV2 #spconv2.1 5 | 6 | from second.protos import voxel_generator_pb2 7 | 8 | 9 | # def build(voxel_config): #spconv1.2.1 10 | def build(voxel_config, num_point_features): #spconv2.1 11 | """Builds a tensor dictionary based on the InputReader config. 12 | 13 | Args: 14 | input_reader_config: A input_reader_pb2.InputReader object. 15 | 16 | Returns: 17 | A tensor dict based on the input_reader_config. 18 | 19 | Raises: 20 | ValueError: On invalid input reader proto. 21 | ValueError: If no input paths are specified. 22 | """ 23 | if not isinstance(voxel_config, (voxel_generator_pb2.VoxelGenerator)): 24 | raise ValueError('input_reader_config not of type ' 25 | 'input_reader_pb2.InputReader.') 26 | # voxel_generator = VoxelGeneratorV2( 27 | # voxel_size=list(voxel_config.voxel_size), 28 | # point_cloud_range=list(voxel_config.point_cloud_range), 29 | # max_num_points=voxel_config.max_number_of_points_per_voxel, 30 | # max_voxels=20000, 31 | # full_mean=voxel_config.full_empty_part_with_mean, 32 | # block_filtering=voxel_config.block_filtering, 33 | # block_factor=voxel_config.block_factor, 34 | # block_size=voxel_config.block_size, 35 | # height_threshold=voxel_config.height_threshold) #spconv1.2.1 36 | 37 | voxel_generator = VoxelGeneratorV2( 38 | vsize_xyz=list(voxel_config.voxel_size), 39 | coors_range_xyz=list(voxel_config.point_cloud_range), 40 | num_point_features = num_point_features, 41 | max_num_points_per_voxel=voxel_config.max_number_of_points_per_voxel, 42 | max_num_voxels=20000) #spconv2.1 43 | return voxel_generator -------------------------------------------------------------------------------- /second.pytorch/second/core/__init__.py: -------------------------------------------------------------------------------- 1 | # from . import box_np_ops, box_tf_ops, geometry, preprocess, non_max_suppression -------------------------------------------------------------------------------- /second.pytorch/second/core/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/core/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/core/__pycache__/anchor_generator.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/core/__pycache__/anchor_generator.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/core/__pycache__/box_coders.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/core/__pycache__/box_coders.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/core/__pycache__/box_np_ops.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/core/__pycache__/box_np_ops.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/core/__pycache__/geometry.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/core/__pycache__/geometry.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/core/__pycache__/preprocess.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/core/__pycache__/preprocess.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/core/__pycache__/region_similarity.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/core/__pycache__/region_similarity.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/core/__pycache__/sample_ops.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/core/__pycache__/sample_ops.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/core/__pycache__/target_assigner.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/core/__pycache__/target_assigner.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/core/__pycache__/target_ops.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/core/__pycache__/target_ops.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/core/non_max_suppression/__init__.py: -------------------------------------------------------------------------------- 1 | from second.core.non_max_suppression.nms_cpu import nms_jit, soft_nms_jit 2 | from second.core.non_max_suppression.nms_gpu import (nms_gpu, rotate_iou_gpu, 3 | rotate_nms_gpu) 4 | -------------------------------------------------------------------------------- /second.pytorch/second/core/non_max_suppression/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/core/non_max_suppression/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/core/non_max_suppression/__pycache__/nms_cpu.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/core/non_max_suppression/__pycache__/nms_cpu.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/core/non_max_suppression/__pycache__/nms_gpu.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/core/non_max_suppression/__pycache__/nms_gpu.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/create_data.py: -------------------------------------------------------------------------------- 1 | import copy 2 | from pathlib import Path 3 | import pickle 4 | 5 | import fire 6 | 7 | import second.data.kitti_dataset as kitti_ds 8 | import second.data.nuscenes_dataset as nu_ds 9 | from second.data.all_dataset import create_groundtruth_database 10 | 11 | def kitti_data_prep(root_path): 12 | kitti_ds.create_kitti_info_file(root_path) 13 | kitti_ds.create_reduced_point_cloud(root_path) 14 | create_groundtruth_database("KittiDataset", root_path, Path(root_path) / "kitti_infos_train.pkl") 15 | 16 | def nuscenes_data_prep(root_path, version, dataset_name, max_sweeps=10): 17 | nu_ds.create_nuscenes_infos(root_path, version=version, max_sweeps=max_sweeps) 18 | name = "infos_train.pkl" 19 | if version == "v1.0-test": 20 | name = "infos_test.pkl" 21 | create_groundtruth_database(dataset_name, root_path, Path(root_path) / name) 22 | 23 | if __name__ == '__main__': 24 | fire.Fire() 25 | -------------------------------------------------------------------------------- /second.pytorch/second/data/__init__.py: -------------------------------------------------------------------------------- 1 | from . import kitti_dataset 2 | from . import nuscenes_dataset -------------------------------------------------------------------------------- /second.pytorch/second/data/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/data/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/data/__pycache__/dataset.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/data/__pycache__/dataset.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/data/__pycache__/kitti_common.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/data/__pycache__/kitti_common.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/data/__pycache__/kitti_dataset.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/data/__pycache__/kitti_dataset.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/data/__pycache__/nuscenes_dataset.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/data/__pycache__/nuscenes_dataset.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/data/__pycache__/preprocess.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/data/__pycache__/preprocess.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/data/nusc_eval.py: -------------------------------------------------------------------------------- 1 | import fire 2 | 3 | from nuscenes import NuScenes 4 | from nuscenes.eval.detection.config import config_factory 5 | from nuscenes.eval.detection.evaluate import NuScenesEval 6 | 7 | def eval_main(root_path, version, eval_version, res_path, eval_set, output_dir): 8 | nusc = NuScenes( 9 | version=version, dataroot=str(root_path), verbose=False) 10 | 11 | cfg = config_factory(eval_version) 12 | nusc_eval = NuScenesEval(nusc, config=cfg, result_path=res_path, eval_set=eval_set, 13 | output_dir=output_dir, 14 | verbose=False) 15 | nusc_eval.main(render_curves=False) 16 | 17 | if __name__ == "__main__": 18 | fire.Fire(eval_main) -------------------------------------------------------------------------------- /second.pytorch/second/framework/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/framework/__init__.py -------------------------------------------------------------------------------- /second.pytorch/second/kittiviewer/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/kittiviewer/__init__.py -------------------------------------------------------------------------------- /second.pytorch/second/kittiviewer/backend/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/kittiviewer/backend/__init__.py -------------------------------------------------------------------------------- /second.pytorch/second/kittiviewer/frontend/css/main.css: -------------------------------------------------------------------------------- 1 | .btn { 2 | /*height: 100%;*/ 3 | text-align: center; 4 | position: absolute; 5 | top: 90%; 6 | left: 40%; 7 | z-index: 2; 8 | font-size: 40pt; 9 | color:#bbb; 10 | } 11 | 12 | .prev { 13 | left: 38%; 14 | /*transform: scale(3, 1);*/ 15 | } 16 | .imgidx { 17 | background: transparent; 18 | width: 120px; 19 | height: 40px; 20 | font-size: 12pt; 21 | left: 47%; 22 | 23 | border: 2px solid blue; 24 | border-radius: 5px; 25 | 26 | } 27 | 28 | .next { 29 | left: 58%; 30 | /*transform: scale(3, 1);*/ 31 | } 32 | 33 | 34 | .toasts { 35 | position: fixed; 36 | max-width: 100%; 37 | width: 250px; 38 | right: 0; 39 | bottom: 0; 40 | padding: 0 10px; 41 | box-sizing: border-box; 42 | transition: height 1s; 43 | z-index: 100; 44 | } 45 | 46 | .toasts li { 47 | width: 100%; 48 | list-style-type: none; 49 | box-sizing: border-box; 50 | font-family: sans-serif; 51 | padding: 15px 20px; 52 | background: #222; 53 | color: white; 54 | border-radius: 2px; 55 | margin: 10px 0; 56 | } 57 | 58 | .toasts li.message { 59 | background: #358; 60 | } 61 | 62 | .toasts li.error { 63 | background: brown; 64 | } 65 | 66 | .toasts li.warning { 67 | background: chocolate; 68 | } 69 | 70 | .toasts li.success { 71 | background: seagreen; 72 | } -------------------------------------------------------------------------------- /second.pytorch/second/kittiviewer/frontend/js/Toast.js: -------------------------------------------------------------------------------- 1 | var Toast = function(toasts, timeout = 3000){ 2 | this.toasts = toasts; 3 | this.type = ['error', 'message', 'warning', 'success']; 4 | this.timeout = timeout; 5 | } 6 | 7 | Toast.prototype = { 8 | _addToast : function(type, text){ 9 | var toast; 10 | toast = document.createElement('li'); 11 | toast.classList.add(type); 12 | setTimeout(function(){ 13 | toast.remove(); 14 | }, this.timeout); 15 | this.toasts.appendChild(toast); 16 | return toast.innerHTML = `${type}: ${text}`; 17 | }, 18 | 19 | message : function(text){ 20 | return this._addToast("message", text); 21 | }, 22 | warning : function(text){ 23 | return this._addToast("warning", text); 24 | }, 25 | error : function(text){ 26 | return this._addToast("error", text); 27 | }, 28 | success : function(text){ 29 | return this._addToast("success", text); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /second.pytorch/second/kittiviewer/frontend/js/postprocessing/RenderPass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.RenderPass = function ( scene, camera, overrideMaterial, clearColor, clearAlpha ) { 6 | 7 | THREE.Pass.call( this ); 8 | 9 | this.scene = scene; 10 | this.camera = camera; 11 | 12 | this.overrideMaterial = overrideMaterial; 13 | 14 | this.clearColor = clearColor; 15 | this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0; 16 | 17 | this.clear = true; 18 | this.clearDepth = false; 19 | this.needsSwap = false; 20 | 21 | }; 22 | 23 | THREE.RenderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { 24 | 25 | constructor: THREE.RenderPass, 26 | 27 | render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) { 28 | 29 | var oldAutoClear = renderer.autoClear; 30 | renderer.autoClear = false; 31 | 32 | this.scene.overrideMaterial = this.overrideMaterial; 33 | 34 | var oldClearColor, oldClearAlpha; 35 | 36 | if ( this.clearColor ) { 37 | 38 | oldClearColor = renderer.getClearColor().getHex(); 39 | oldClearAlpha = renderer.getClearAlpha(); 40 | 41 | renderer.setClearColor( this.clearColor, this.clearAlpha ); 42 | 43 | } 44 | 45 | if ( this.clearDepth ) { 46 | 47 | renderer.clearDepth(); 48 | 49 | } 50 | 51 | renderer.render( this.scene, this.camera, this.renderToScreen ? null : readBuffer, this.clear ); 52 | 53 | if ( this.clearColor ) { 54 | 55 | renderer.setClearColor( oldClearColor, oldClearAlpha ); 56 | 57 | } 58 | 59 | this.scene.overrideMaterial = null; 60 | renderer.autoClear = oldAutoClear; 61 | } 62 | 63 | } ); 64 | -------------------------------------------------------------------------------- /second.pytorch/second/kittiviewer/frontend/js/postprocessing/ShaderPass.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | THREE.ShaderPass = function ( shader, textureID ) { 6 | 7 | THREE.Pass.call( this ); 8 | 9 | this.textureID = ( textureID !== undefined ) ? textureID : "tDiffuse"; 10 | 11 | if ( shader instanceof THREE.ShaderMaterial ) { 12 | 13 | this.uniforms = shader.uniforms; 14 | 15 | this.material = shader; 16 | 17 | } else if ( shader ) { 18 | 19 | this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); 20 | 21 | this.material = new THREE.ShaderMaterial( { 22 | 23 | defines: Object.assign( {}, shader.defines ), 24 | uniforms: this.uniforms, 25 | vertexShader: shader.vertexShader, 26 | fragmentShader: shader.fragmentShader 27 | 28 | } ); 29 | 30 | } 31 | 32 | this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); 33 | this.scene = new THREE.Scene(); 34 | 35 | this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), null ); 36 | this.quad.frustumCulled = false; // Avoid getting clipped 37 | this.scene.add( this.quad ); 38 | 39 | }; 40 | 41 | THREE.ShaderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), { 42 | 43 | constructor: THREE.ShaderPass, 44 | 45 | render: function( renderer, writeBuffer, readBuffer, delta, maskActive ) { 46 | 47 | if ( this.uniforms[ this.textureID ] ) { 48 | 49 | this.uniforms[ this.textureID ].value = readBuffer.texture; 50 | 51 | } 52 | 53 | this.quad.material = this.material; 54 | 55 | if ( this.renderToScreen ) { 56 | 57 | renderer.render( this.scene, this.camera ); 58 | 59 | } else { 60 | 61 | renderer.render( this.scene, this.camera, writeBuffer, this.clear ); 62 | 63 | } 64 | 65 | } 66 | 67 | } ); 68 | -------------------------------------------------------------------------------- /second.pytorch/second/kittiviewer/frontend/js/shaders/CopyShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * Full-screen textured quad shader 5 | */ 6 | 7 | THREE.CopyShader = { 8 | 9 | uniforms: { 10 | 11 | "tDiffuse": { value: null }, 12 | "opacity": { value: 1.0 } 13 | 14 | }, 15 | 16 | vertexShader: [ 17 | 18 | "varying vec2 vUv;", 19 | 20 | "void main() {", 21 | 22 | "vUv = uv;", 23 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 24 | 25 | "}" 26 | 27 | ].join( "\n" ), 28 | 29 | fragmentShader: [ 30 | 31 | "uniform float opacity;", 32 | 33 | "uniform sampler2D tDiffuse;", 34 | 35 | "varying vec2 vUv;", 36 | 37 | "void main() {", 38 | 39 | "vec4 texel = texture2D( tDiffuse, vUv );", 40 | "gl_FragColor = opacity * texel;", 41 | 42 | "}" 43 | 44 | ].join( "\n" ) 45 | 46 | }; 47 | -------------------------------------------------------------------------------- /second.pytorch/second/kittiviewer/frontend/js/shaders/LuminosityHighPassShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author bhouston / http://clara.io/ 3 | * 4 | * Luminosity 5 | * http://en.wikipedia.org/wiki/Luminosity 6 | */ 7 | 8 | THREE.LuminosityHighPassShader = { 9 | 10 | shaderID: "luminosityHighPass", 11 | 12 | uniforms: { 13 | 14 | "tDiffuse": { type: "t", value: null }, 15 | "luminosityThreshold": { type: "f", value: 1.0 }, 16 | "smoothWidth": { type: "f", value: 1.0 }, 17 | "defaultColor": { type: "c", value: new THREE.Color( 0x000000 ) }, 18 | "defaultOpacity": { type: "f", value: 0.0 } 19 | 20 | }, 21 | 22 | vertexShader: [ 23 | 24 | "varying vec2 vUv;", 25 | 26 | "void main() {", 27 | 28 | "vUv = uv;", 29 | 30 | "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", 31 | 32 | "}" 33 | 34 | ].join("\n"), 35 | 36 | fragmentShader: [ 37 | 38 | "uniform sampler2D tDiffuse;", 39 | "uniform vec3 defaultColor;", 40 | "uniform float defaultOpacity;", 41 | "uniform float luminosityThreshold;", 42 | "uniform float smoothWidth;", 43 | 44 | "varying vec2 vUv;", 45 | 46 | "void main() {", 47 | 48 | "vec4 texel = texture2D( tDiffuse, vUv );", 49 | 50 | "vec3 luma = vec3( 0.299, 0.587, 0.114 );", 51 | 52 | "float v = dot( texel.xyz, luma );", 53 | 54 | "vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );", 55 | 56 | "float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );", 57 | 58 | "gl_FragColor = mix( outputColor, texel, alpha );", 59 | 60 | "}" 61 | 62 | ].join("\n") 63 | 64 | }; 65 | -------------------------------------------------------------------------------- /second.pytorch/second/kittiviewer/frontend/textures/sprites/disc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/kittiviewer/frontend/textures/sprites/disc.png -------------------------------------------------------------------------------- /second.pytorch/second/protos/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/protos/__init__.py -------------------------------------------------------------------------------- /second.pytorch/second/protos/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/protos/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/protos/__pycache__/anchors_pb2.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/protos/__pycache__/anchors_pb2.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/protos/__pycache__/box_coder_pb2.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/protos/__pycache__/box_coder_pb2.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/protos/__pycache__/input_reader_pb2.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/protos/__pycache__/input_reader_pb2.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/protos/__pycache__/losses_pb2.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/protos/__pycache__/losses_pb2.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/protos/__pycache__/model_pb2.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/protos/__pycache__/model_pb2.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/protos/__pycache__/optimizer_pb2.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/protos/__pycache__/optimizer_pb2.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/protos/__pycache__/pipeline_pb2.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/protos/__pycache__/pipeline_pb2.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/protos/__pycache__/preprocess_pb2.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/protos/__pycache__/preprocess_pb2.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/protos/__pycache__/sampler_pb2.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/protos/__pycache__/sampler_pb2.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/protos/__pycache__/second_pb2.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/protos/__pycache__/second_pb2.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/protos/__pycache__/similarity_pb2.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/protos/__pycache__/similarity_pb2.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/protos/__pycache__/target_pb2.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/protos/__pycache__/target_pb2.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/protos/__pycache__/train_pb2.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/protos/__pycache__/train_pb2.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/protos/__pycache__/voxel_generator_pb2.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/protos/__pycache__/voxel_generator_pb2.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/protos/anchors.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package second.protos; 4 | 5 | message AnchorGeneratorStride { 6 | repeated float sizes = 1; 7 | repeated float strides = 2; 8 | repeated float offsets = 3; 9 | repeated float rotations = 4; 10 | repeated float custom_values = 5; 11 | } 12 | 13 | message AnchorGeneratorRange { 14 | repeated float sizes = 1; 15 | repeated float anchor_ranges = 2; 16 | repeated float rotations = 3; 17 | repeated float custom_values = 4; 18 | } 19 | 20 | message NoAnchor { 21 | } 22 | 23 | -------------------------------------------------------------------------------- /second.pytorch/second/protos/box_coder.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package second.protos; 4 | 5 | // Configuration proto for the box coder to be used in the object detection 6 | // pipeline. See core/box_coder.py for details. 7 | message BoxCoder { 8 | oneof box_coder { 9 | GroundBox3dCoder ground_box3d_coder = 1; 10 | BevBoxCoder bev_box_coder = 2; 11 | } 12 | } 13 | 14 | message GroundBox3dCoder { 15 | bool linear_dim = 1; 16 | bool encode_angle_vector = 2; 17 | } 18 | 19 | message BevBoxCoder { 20 | bool linear_dim = 1; 21 | bool encode_angle_vector = 2; 22 | float z_fixed = 3; 23 | float h_fixed = 4; 24 | } 25 | -------------------------------------------------------------------------------- /second.pytorch/second/protos/input_reader.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package second.protos; 4 | import "second/protos/preprocess.proto"; 5 | import "second/protos/sampler.proto"; 6 | 7 | message InputReader { 8 | uint32 batch_size = 1; 9 | message Dataset { 10 | string kitti_info_path = 1; 11 | string kitti_root_path = 2; 12 | string dataset_class_name = 3; // support KittiDataset and NuScenesDataset 13 | } 14 | Dataset dataset = 2; 15 | message Preprocess { 16 | bool shuffle_points = 1; 17 | uint32 max_number_of_voxels = 2; 18 | repeated float groundtruth_localization_noise_std = 3; 19 | repeated float groundtruth_rotation_uniform_noise = 4; 20 | repeated float global_rotation_uniform_noise = 5; 21 | repeated float global_scaling_uniform_noise = 6; 22 | repeated float global_translate_noise_std = 7; 23 | bool remove_unknown_examples = 8; 24 | uint32 num_workers = 9; 25 | float anchor_area_threshold = 10; 26 | bool remove_points_after_sample = 11; 27 | float groundtruth_points_drop_percentage = 12; 28 | uint32 groundtruth_drop_max_keep_points = 13; 29 | bool remove_environment = 14; 30 | repeated float global_random_rotation_range_per_object = 15; 31 | repeated DatabasePreprocessingStep database_prep_steps = 16; 32 | Sampler database_sampler = 17; 33 | bool use_group_id = 18; // this will enable group sample and noise 34 | int64 min_num_of_points_in_gt = 19; // gt boxes contains less than this will be ignored. 35 | bool random_flip_x = 20; 36 | bool random_flip_y = 21; 37 | float sample_importance = 22; 38 | } 39 | Preprocess preprocess = 3; 40 | uint32 max_num_epochs = 4; // deprecated 41 | uint32 prefetch_size = 5; // deprecated 42 | } 43 | -------------------------------------------------------------------------------- /second.pytorch/second/protos/model.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package second.protos; 4 | import "second/protos/second.proto"; 5 | message DetectionModel{ 6 | oneof model { 7 | VoxelNet second = 1; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /second.pytorch/second/protos/pipeline.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package second.protos; 4 | 5 | import "second/protos/input_reader.proto"; 6 | import "second/protos/model.proto"; 7 | import "second/protos/train.proto"; 8 | // Convenience message for configuring a training and eval pipeline. Allows all 9 | // of the pipeline parameters to be configured from one file. 10 | message TrainEvalPipelineConfig { 11 | DetectionModel model = 1; 12 | InputReader train_input_reader = 2; 13 | TrainConfig train_config = 3; 14 | InputReader eval_input_reader = 4; 15 | } 16 | 17 | -------------------------------------------------------------------------------- /second.pytorch/second/protos/preprocess.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package second.protos; 4 | 5 | message DatabasePreprocessingStep { 6 | oneof database_preprocessing_step { 7 | DBFilterByDifficulty filter_by_difficulty = 1; 8 | DBFilterByMinNumPointInGroundTruth filter_by_min_num_points = 2; 9 | } 10 | } 11 | 12 | message DBFilterByDifficulty{ 13 | repeated int32 removed_difficulties = 1; 14 | } 15 | 16 | message DBFilterByMinNumPointInGroundTruth{ 17 | map min_num_point_pairs = 1; 18 | } 19 | -------------------------------------------------------------------------------- /second.pytorch/second/protos/sampler.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package second.protos; 4 | import "second/protos/preprocess.proto"; 5 | 6 | message Group{ 7 | map name_to_max_num = 1; 8 | } 9 | 10 | message Sampler{ 11 | string database_info_path = 1; 12 | repeated Group sample_groups = 2; 13 | repeated DatabasePreprocessingStep database_prep_steps = 3; 14 | repeated float global_random_rotation_range_per_object = 4; 15 | float rate = 5; 16 | } 17 | -------------------------------------------------------------------------------- /second.pytorch/second/protos/similarity.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package second.protos; 4 | 5 | // Configuration proto for region similarity calculators. See 6 | // core/region_similarity_calculator.py for details. 7 | message RegionSimilarityCalculator { 8 | oneof region_similarity { 9 | RotateIouSimilarity rotate_iou_similarity = 1; 10 | NearestIouSimilarity nearest_iou_similarity = 2; 11 | DistanceSimilarity distance_similarity = 3; 12 | } 13 | } 14 | 15 | // Configuration for intersection-over-union (IOU) similarity calculator. 16 | message RotateIouSimilarity { 17 | } 18 | 19 | // Configuration for intersection-over-union (IOU) similarity calculator. 20 | message NearestIouSimilarity { 21 | } 22 | 23 | // Configuration for intersection-over-union (IOU) similarity calculator. 24 | message DistanceSimilarity { 25 | float distance_norm = 1; 26 | bool with_rotation = 2; 27 | float rotation_alpha = 3; 28 | } -------------------------------------------------------------------------------- /second.pytorch/second/protos/target.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package second.protos; 4 | import "second/protos/anchors.proto"; 5 | import "second/protos/similarity.proto"; 6 | 7 | message ClassSetting { 8 | oneof anchor_generator { 9 | AnchorGeneratorStride anchor_generator_stride = 1; 10 | AnchorGeneratorRange anchor_generator_range = 2; 11 | NoAnchor no_anchor = 3; 12 | } 13 | RegionSimilarityCalculator region_similarity_calculator = 4; 14 | bool use_multi_class_nms = 5; 15 | bool use_rotate_nms = 6; 16 | int32 nms_pre_max_size = 7; 17 | int32 nms_post_max_size = 8; 18 | float nms_score_threshold = 9; 19 | float nms_iou_threshold = 10; 20 | float matched_threshold = 11; 21 | float unmatched_threshold = 12; 22 | string class_name = 13; 23 | repeated int64 feature_map_size = 14; // 3D zyx (DHW) size 24 | } 25 | 26 | message TargetAssigner { 27 | repeated ClassSetting class_settings = 1; 28 | float sample_positive_fraction = 2; 29 | uint32 sample_size = 3; 30 | bool assign_per_class = 4; 31 | repeated int64 nms_pre_max_sizes = 5; // this will override setting in ClassSettings if provide. 32 | repeated int64 nms_post_max_sizes = 6; // this will override setting in ClassSettings if provide. 33 | repeated int64 nms_score_thresholds = 7; // this will override setting in ClassSettings if provide. 34 | repeated int64 nms_iou_thresholds = 8; // this will override setting in ClassSettings if provide. 35 | } -------------------------------------------------------------------------------- /second.pytorch/second/protos/train.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package second.protos; 4 | 5 | import "second/protos/optimizer.proto"; 6 | import "second/protos/preprocess.proto"; 7 | 8 | message TrainConfig{ 9 | Optimizer optimizer = 1; 10 | uint32 steps = 2; 11 | uint32 steps_per_eval = 3; 12 | uint32 save_checkpoints_secs = 4; 13 | uint32 save_summary_steps = 5; 14 | bool enable_mixed_precision = 6; 15 | float loss_scale_factor = 7; 16 | bool clear_metrics_every_epoch = 8; 17 | } -------------------------------------------------------------------------------- /second.pytorch/second/protos/voxel_generator.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package second.protos; 4 | 5 | message VoxelGenerator{ 6 | repeated float voxel_size = 1; 7 | repeated float point_cloud_range = 2; 8 | uint32 max_number_of_points_per_voxel = 3; 9 | bool full_empty_part_with_mean = 4; 10 | bool block_filtering = 5; 11 | int64 block_factor = 6; 12 | int64 block_size = 7; 13 | float height_threshold = 8; 14 | } 15 | -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/__init__.py -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/__pycache__/train.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/__pycache__/train.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/builder/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/builder/__init__.py -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/builder/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/builder/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/builder/__pycache__/box_coder_builder.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/builder/__pycache__/box_coder_builder.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/builder/__pycache__/input_reader_builder.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/builder/__pycache__/input_reader_builder.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/builder/__pycache__/losses_builder.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/builder/__pycache__/losses_builder.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/builder/__pycache__/lr_scheduler_builder.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/builder/__pycache__/lr_scheduler_builder.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/builder/__pycache__/optimizer_builder.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/builder/__pycache__/optimizer_builder.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/builder/__pycache__/second_builder.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/builder/__pycache__/second_builder.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/builder/box_coder_builder.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from second.protos import box_coder_pb2 4 | from second.pytorch.core.box_coders import (BevBoxCoderTorch, 5 | GroundBox3dCoderTorch) 6 | 7 | 8 | def build(box_coder_config): 9 | """Create optimizer based on config. 10 | 11 | Args: 12 | optimizer_config: A Optimizer proto message. 13 | 14 | Returns: 15 | An optimizer and a list of variables for summary. 16 | 17 | Raises: 18 | ValueError: when using an unsupported input data type. 19 | """ 20 | box_coder_type = box_coder_config.WhichOneof('box_coder') 21 | if box_coder_type == 'ground_box3d_coder': 22 | cfg = box_coder_config.ground_box3d_coder 23 | return GroundBox3dCoderTorch(cfg.linear_dim, cfg.encode_angle_vector) 24 | elif box_coder_type == 'bev_box_coder': 25 | cfg = box_coder_config.bev_box_coder 26 | return BevBoxCoderTorch(cfg.linear_dim, cfg.encode_angle_vector, cfg.z_fixed, cfg.h_fixed) 27 | else: 28 | raise ValueError("unknown box_coder type") 29 | -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/core/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/core/__init__.py -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/core/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/core/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/core/__pycache__/box_coders.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/core/__pycache__/box_coders.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/core/__pycache__/box_torch_ops.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/core/__pycache__/box_torch_ops.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/core/__pycache__/ghm_loss.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/core/__pycache__/ghm_loss.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/core/__pycache__/losses.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/core/__pycache__/losses.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/core/box_coders.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | from second.core.box_coders import BevBoxCoder, GroundBox3dCoder 4 | from second.pytorch.core import box_torch_ops 5 | 6 | 7 | class GroundBox3dCoderTorch(GroundBox3dCoder): 8 | def encode_torch(self, boxes, anchors): 9 | return box_torch_ops.second_box_encode(boxes, anchors, self.vec_encode, 10 | self.linear_dim) 11 | 12 | def decode_torch(self, boxes, anchors): 13 | return box_torch_ops.second_box_decode(boxes, anchors, self.vec_encode, 14 | self.linear_dim) 15 | 16 | 17 | class BevBoxCoderTorch(BevBoxCoder): 18 | def encode_torch(self, boxes, anchors): 19 | anchors = anchors[..., [0, 1, 3, 4, 6]] 20 | boxes = boxes[..., [0, 1, 3, 4, 6]] 21 | return box_torch_ops.bev_box_encode(boxes, anchors, self.vec_encode, 22 | self.linear_dim) 23 | 24 | def decode_torch(self, encodings, anchors): 25 | anchors = anchors[..., [0, 1, 3, 4, 6]] 26 | ret = box_torch_ops.bev_box_decode(encodings, anchors, self.vec_encode, 27 | self.linear_dim) 28 | z_fixed = torch.full([*ret.shape[:-1], 1], 29 | self.z_fixed, 30 | dtype=ret.dtype, 31 | device=ret.device) 32 | h_fixed = torch.full([*ret.shape[:-1], 1], 33 | self.h_fixed, 34 | dtype=ret.dtype, 35 | device=ret.device) 36 | return torch.cat( 37 | [ret[..., :2], z_fixed, ret[..., 2:4], h_fixed, ret[..., 4:]], 38 | dim=-1) 39 | -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/models/__init__.py: -------------------------------------------------------------------------------- 1 | from . import net_multi_head -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/models/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/models/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/models/__pycache__/middle.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/models/__pycache__/middle.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/models/__pycache__/net_multi_head.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/models/__pycache__/net_multi_head.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/models/__pycache__/pointpillars.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/models/__pycache__/pointpillars.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/models/__pycache__/resnet.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/models/__pycache__/resnet.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/models/__pycache__/rpn.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/models/__pycache__/rpn.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/models/__pycache__/voxel_encoder.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/models/__pycache__/voxel_encoder.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/models/__pycache__/voxelnet.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/models/__pycache__/voxelnet.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/utils/__init__.py: -------------------------------------------------------------------------------- 1 | import time 2 | import contextlib 3 | import torch 4 | 5 | @contextlib.contextmanager 6 | def torch_timer(name=''): 7 | torch.cuda.synchronize() 8 | t = time.time() 9 | yield 10 | torch.cuda.synchronize() 11 | print(name, "time:", time.time() - t) -------------------------------------------------------------------------------- /second.pytorch/second/pytorch/utils/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/pytorch/utils/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/script.py: -------------------------------------------------------------------------------- 1 | from second.pytorch.train import train, evaluate 2 | from google.protobuf import text_format 3 | from second.protos import pipeline_pb2 4 | from pathlib import Path 5 | from second.utils import config_tool 6 | 7 | 8 | def train_multi_rpn_layer_num(): 9 | config_path = "./configs/car.lite.config" 10 | model_root = Path.home() / "second_test" # don't forget to change this. 11 | config = pipeline_pb2.TrainEvalPipelineConfig() 12 | with open(config_path, "r") as f: 13 | proto_str = f.read() 14 | text_format.Merge(proto_str, config) 15 | input_cfg = config.eval_input_reader 16 | model_cfg = config.model.second 17 | layer_nums = [2, 4, 7, 9] 18 | for l in layer_nums: 19 | model_dir = str(model_root / f"car_lite_L{l}") 20 | model_cfg.rpn.layer_nums[:] = [l] 21 | train(config, model_dir) 22 | 23 | 24 | def eval_multi_threshold(): 25 | config_path = "./configs/car.fhd.config" 26 | ckpt_name = "/path/to/your/model_ckpt" # don't forget to change this. 27 | assert "/path/to/your" not in ckpt_name 28 | config = pipeline_pb2.TrainEvalPipelineConfig() 29 | with open(config_path, "r") as f: 30 | proto_str = f.read() 31 | text_format.Merge(proto_str, config) 32 | model_cfg = config.model.second 33 | threshs = [0.3] 34 | for thresh in threshs: 35 | model_cfg.nms_score_threshold = thresh 36 | # don't forget to change this. 37 | result_path = Path.home() / f"second_test_eval_{thresh:.2f}" 38 | evaluate( 39 | config, 40 | result_path=result_path, 41 | ckpt_path=str(ckpt_name), 42 | batch_size=1, 43 | measure_time=True) 44 | 45 | 46 | if __name__ == "__main__": 47 | eval_multi_threshold() -------------------------------------------------------------------------------- /second.pytorch/second/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/utils/__init__.py -------------------------------------------------------------------------------- /second.pytorch/second/utils/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/utils/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/utils/__pycache__/check.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/utils/__pycache__/check.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/utils/__pycache__/eval.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/utils/__pycache__/eval.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/utils/__pycache__/log_tool.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/utils/__pycache__/log_tool.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/utils/__pycache__/progress_bar.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/utils/__pycache__/progress_bar.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/utils/__pycache__/simplevis.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/utils/__pycache__/simplevis.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/utils/__pycache__/timer.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/utils/__pycache__/timer.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/utils/check.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | def is_array_like(x): 4 | return isinstance(x, (list, tuple, np.ndarray)) 5 | 6 | def shape_mergeable(x, expected_shape): 7 | mergeable = True 8 | if is_array_like(x) and is_array_like(expected_shape): 9 | x = np.array(x) 10 | if len(x.shape) == len(expected_shape): 11 | for s, s_ex in zip(x.shape, expected_shape): 12 | if s_ex is not None and s != s_ex: 13 | mergeable = False 14 | break 15 | return mergeable -------------------------------------------------------------------------------- /second.pytorch/second/utils/config_tool/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/second/utils/config_tool/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/second/utils/merge_result.py: -------------------------------------------------------------------------------- 1 | import fire 2 | from pathlib import Path 3 | import re 4 | 5 | def merge(path1, path2, output_path): 6 | filepaths1 = Path(path1).glob('*.txt') 7 | prog = re.compile(r'^\d{6}.txt$') 8 | filepaths1 = filter(lambda f: prog.match(f.name), filepaths1) 9 | for fp1 in list(filepaths1): 10 | with open(fp1) as f1: 11 | contents = f1.readlines() 12 | if len(contents) != 0: 13 | contents += "\n" 14 | with open(Path(path2) / f"{fp1.stem}.txt", 'r') as f2: 15 | contents += f2.readlines() 16 | with open(Path(output_path) / f"{fp1.stem}.txt", 'w') as f: 17 | f.writelines(contents) 18 | 19 | if __name__ == '__main__': 20 | fire.Fire() 21 | 22 | -------------------------------------------------------------------------------- /second.pytorch/second/utils/model_tool.py: -------------------------------------------------------------------------------- 1 | from pathlib import Path 2 | import re 3 | import shutil 4 | 5 | def rm_invalid_model_dir(directory, step_thresh=200): 6 | directory = Path(directory).resolve() 7 | ckpt_re = r"[a-zA-Z0-9_]+\-([0-9]+)\.tckpt" 8 | ckpt_re = re.compile(ckpt_re) 9 | for path in directory.rglob("*"): 10 | if path.is_dir(): 11 | pipeline_path = (path / "pipeline.config") 12 | log_path = (path / "log.txt") 13 | summary_path = (path / "summary") 14 | must_exists = [pipeline_path, log_path, summary_path] 15 | if not all([e.exists() for e in must_exists]): 16 | continue 17 | ckpts = [] 18 | for subpath in path.iterdir(): 19 | match = ckpt_re.search(subpath.name) 20 | if match is not None: 21 | ckpts.append(int(match.group(1))) 22 | if len(ckpts) == 0 or all([e < step_thresh for e in ckpts]): 23 | shutil.rmtree(str(path)) 24 | -------------------------------------------------------------------------------- /second.pytorch/second/utils/timer.py: -------------------------------------------------------------------------------- 1 | import time 2 | from contextlib import contextmanager 3 | 4 | @contextmanager 5 | def simple_timer(name=''): 6 | t = time.time() 7 | yield 8 | print(f"{name} exec time: {time.time() - t}") -------------------------------------------------------------------------------- /second.pytorch/torchplus/__init__.py: -------------------------------------------------------------------------------- 1 | from . import train 2 | from . import nn 3 | from . import metrics 4 | from . import tools 5 | 6 | from .tools import change_default_args 7 | from torchplus.ops.array_ops import scatter_nd, gather_nd 8 | -------------------------------------------------------------------------------- /second.pytorch/torchplus/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/torchplus/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/torchplus/__pycache__/metrics.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/torchplus/__pycache__/metrics.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/torchplus/__pycache__/tools.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/torchplus/__pycache__/tools.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/torchplus/nn/__init__.py: -------------------------------------------------------------------------------- 1 | from torchplus.nn.functional import one_hot 2 | from torchplus.nn.modules.common import Empty, Sequential 3 | from torchplus.nn.modules.normalization import GroupNorm 4 | -------------------------------------------------------------------------------- /second.pytorch/torchplus/nn/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/torchplus/nn/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/torchplus/nn/__pycache__/functional.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/torchplus/nn/__pycache__/functional.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/torchplus/nn/functional.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | def one_hot(tensor, depth, dim=-1, on_value=1.0, dtype=torch.float32): 4 | tensor_onehot = torch.zeros( 5 | *list(tensor.shape), depth, dtype=dtype, device=tensor.device) 6 | tensor_onehot.scatter_(dim, tensor.unsqueeze(dim).long(), on_value) 7 | return tensor_onehot 8 | -------------------------------------------------------------------------------- /second.pytorch/torchplus/nn/modules/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/torchplus/nn/modules/__init__.py -------------------------------------------------------------------------------- /second.pytorch/torchplus/nn/modules/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/torchplus/nn/modules/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/torchplus/nn/modules/__pycache__/common.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/torchplus/nn/modules/__pycache__/common.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/torchplus/nn/modules/__pycache__/normalization.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/torchplus/nn/modules/__pycache__/normalization.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/torchplus/nn/modules/normalization.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | 4 | class GroupNorm(torch.nn.GroupNorm): 5 | def __init__(self, num_channels, num_groups, eps=1e-5, affine=True): 6 | super().__init__( 7 | num_groups=num_groups, 8 | num_channels=num_channels, 9 | eps=eps, 10 | affine=affine) 11 | -------------------------------------------------------------------------------- /second.pytorch/torchplus/ops/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/torchplus/ops/__init__.py -------------------------------------------------------------------------------- /second.pytorch/torchplus/ops/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/torchplus/ops/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/torchplus/ops/__pycache__/array_ops.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/torchplus/ops/__pycache__/array_ops.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/torchplus/ops/array_ops.py: -------------------------------------------------------------------------------- 1 | import ctypes 2 | import math 3 | import time 4 | import torch 5 | 6 | 7 | def scatter_nd(indices, updates, shape): 8 | """pytorch edition of tensorflow scatter_nd. 9 | this function don't contain except handle code. so use this carefully 10 | when indice repeats, don't support repeat add which is supported 11 | in tensorflow. 12 | """ 13 | ret = torch.zeros(*shape, dtype=updates.dtype, device=updates.device) 14 | ndim = indices.shape[-1] 15 | output_shape = list(indices.shape[:-1]) + shape[indices.shape[-1]:] 16 | flatted_indices = indices.view(-1, ndim) 17 | slices = [flatted_indices[:, i] for i in range(ndim)] 18 | slices += [Ellipsis] 19 | ret[slices] = updates.view(*output_shape) 20 | return ret 21 | 22 | 23 | def gather_nd(params, indices): 24 | # this function has a limit that MAX_ADVINDEX_CALC_DIMS=5 25 | ndim = indices.shape[-1] 26 | output_shape = list(indices.shape[:-1]) + list(params.shape[indices.shape[-1]:]) 27 | flatted_indices = indices.view(-1, ndim) 28 | slices = [flatted_indices[:, i] for i in range(ndim)] 29 | slices += [Ellipsis] 30 | return params[slices].view(*output_shape) 31 | -------------------------------------------------------------------------------- /second.pytorch/torchplus/tools.py: -------------------------------------------------------------------------------- 1 | import functools 2 | import inspect 3 | import sys 4 | from collections import OrderedDict 5 | 6 | import numba 7 | import numpy as np 8 | import torch 9 | 10 | 11 | def get_pos_to_kw_map(func): 12 | pos_to_kw = {} 13 | fsig = inspect.signature(func) 14 | pos = 0 15 | for name, info in fsig.parameters.items(): 16 | if info.kind is info.POSITIONAL_OR_KEYWORD: 17 | pos_to_kw[pos] = name 18 | pos += 1 19 | return pos_to_kw 20 | 21 | 22 | def get_kw_to_default_map(func): 23 | kw_to_default = {} 24 | fsig = inspect.signature(func) 25 | for name, info in fsig.parameters.items(): 26 | if info.kind is info.POSITIONAL_OR_KEYWORD: 27 | if info.default is not info.empty: 28 | kw_to_default[name] = info.default 29 | return kw_to_default 30 | 31 | 32 | def change_default_args(**kwargs): 33 | def layer_wrapper(layer_class): 34 | class DefaultArgLayer(layer_class): 35 | def __init__(self, *args, **kw): 36 | pos_to_kw = get_pos_to_kw_map(layer_class.__init__) 37 | kw_to_pos = {kw: pos for pos, kw in pos_to_kw.items()} 38 | for key, val in kwargs.items(): 39 | if key not in kw and kw_to_pos[key] > len(args): 40 | kw[key] = val 41 | super().__init__(*args, **kw) 42 | 43 | return DefaultArgLayer 44 | 45 | return layer_wrapper 46 | 47 | def torch_to_np_dtype(ttype): 48 | type_map = { 49 | torch.float16: np.dtype(np.float16), 50 | torch.float32: np.dtype(np.float32), 51 | torch.float16: np.dtype(np.float64), 52 | torch.int32: np.dtype(np.int32), 53 | torch.int64: np.dtype(np.int64), 54 | torch.uint8: np.dtype(np.uint8), 55 | } 56 | return type_map[ttype] 57 | -------------------------------------------------------------------------------- /second.pytorch/torchplus/train/__init__.py: -------------------------------------------------------------------------------- 1 | from torchplus.train.checkpoint import (latest_checkpoint, restore, 2 | restore_latest_checkpoints, 3 | restore_models, save, save_models, 4 | try_restore_latest_checkpoints) 5 | from torchplus.train.common import create_folder 6 | from torchplus.train.optim import MixedPrecisionWrapper 7 | -------------------------------------------------------------------------------- /second.pytorch/torchplus/train/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/torchplus/train/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/torchplus/train/__pycache__/checkpoint.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/torchplus/train/__pycache__/checkpoint.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/torchplus/train/__pycache__/common.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/torchplus/train/__pycache__/common.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/torchplus/train/__pycache__/fastai_optim.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/torchplus/train/__pycache__/fastai_optim.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/torchplus/train/__pycache__/learning_schedules.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/torchplus/train/__pycache__/learning_schedules.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/torchplus/train/__pycache__/learning_schedules_fastai.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/torchplus/train/__pycache__/learning_schedules_fastai.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/torchplus/train/__pycache__/optim.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/haiduo/sparse_model/1bf0cc251f608b46a27bf93a9dd52412b6e3459f/second.pytorch/torchplus/train/__pycache__/optim.cpython-38.pyc -------------------------------------------------------------------------------- /second.pytorch/torchplus/train/common.py: -------------------------------------------------------------------------------- 1 | import datetime 2 | import os 3 | import shutil 4 | 5 | def create_folder(prefix, add_time=True, add_str=None, delete=False): 6 | additional_str = '' 7 | if delete is True: 8 | if os.path.exists(prefix): 9 | shutil.rmtree(prefix) 10 | os.makedirs(prefix) 11 | folder = prefix 12 | if add_time is True: 13 | # additional_str has a form such as '170903_220351' 14 | additional_str += datetime.datetime.now().strftime("%y%m%d_%H%M%S") 15 | if add_str is not None: 16 | folder += '/' + additional_str + '_' + add_str 17 | else: 18 | folder += '/' + additional_str 19 | if delete is True: 20 | if os.path.exists(folder): 21 | shutil.rmtree(folder) 22 | os.makedirs(folder) 23 | return folder -------------------------------------------------------------------------------- /spconv-1.2.1/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [1.2.1] - 2020-06-04 4 | ### Changed 5 | - The subm indice pair generation speed is greatly increased by two tricks: 1. most subm conv use only kernelsize=3, so we can unroll loops to get 100% performance increase. 2. subm indice pairs have a property: indicePairs[0, i] = indicePairs[1, kernelVolume - i - 1], so we can get another 100% performance increase. 6 | 7 | 8 | ## [1.2.0] - 2020-05-28 9 | ### Added 10 | - add batch gemm support. small performance increasement but more gpu memory usage. you can use algo=spconv.ConvAlgo.Batch to use it. 11 | 12 | ### Changed 13 | - replace most of 'functor' with c++14 dispatch in c++ code. 14 | 15 | ### Fixed 16 | - change gather/scatterAdd kernel parameter to support large points. 17 | -------------------------------------------------------------------------------- /spconv-1.2.1/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM scrin/dev:latest 2 | 3 | RUN PROBLEM_FILE=/usr/local/lib/python3.8/dist-packages/torch/share/cmake/Caffe2/Caffe2Targets.cmake && \ 4 | sed -i 's/-Wall;-Wextra;-Wno-unused-parameter;-Wno-missing-field-initializers;-Wno-write-strings;-Wno-unknown-pragmas;-Wno-missing-braces;-fopenmp//g' $PROBLEM_FILE && \ 5 | sed -i 's/-Wall;-Wextra;-Wno-unused-parameter;-Wno-missing-field-initializers;-Wno-write-strings;-Wno-unknown-pragmas;-Wno-missing-braces//g' $PROBLEM_FILE && \ 6 | cd /root && \ 7 | git clone --depth 1 --recursive https://www.github.com/traveller59/spconv.git && \ 8 | cd ./spconv && \ 9 | SPCONV_FORCE_BUILD_CUDA=1 python setup.py install 10 | -------------------------------------------------------------------------------- /spconv-1.2.1/PERFORMANCE_GUIDE.md: -------------------------------------------------------------------------------- 1 | ## Performance Guide 2 | 3 | ### 1. Regular sparse conv is very slow 4 | 5 | Regular sparse convolution will greatly increase the number of active points. for 3x3x3 3D convolution, we can get at most 27x active points, which means next convolution will perform 27x slower! 6 | 7 | This problem can be solved by using submanifold convolution (SubMConv3d). This kind of sparse convolution doesn't generate new active points. 8 | 9 | **NEVER** use SparseConv3d except downsample data, **NEVER** use SparseConv3dTranspose, use SparseInverseConv3d instead. 10 | 11 | ### 2. Large Spatial Shape cost too much GPU memory 12 | 13 | Our implementation use dense map to generate indices in GPU for sparse convolution, which means if your spatial shape is ```[batchSize=4, 1600, 1600, 40]```, it will cost ~2GB GPU memory. 14 | 15 | To solve this problem, you can use CPU algorithm (hash map) for first layer that has large shape, then convert generated indices to GPU and use GPU algorithm for downsampled data. 16 | 17 | Another way is use cuda hash. Unfortunately this library isn't stable enough, it should only be used when the spatial shape is very large. 18 | 19 | ### 3. Stacked submanifold convolution can share same indice data 20 | 21 | When you using stacked subm convolution, there is no need to generate indice data again, but this can't be done automatically. you need to specify a unique key ```indice_key="c0"``` and use it for all stacked subm convolution. 22 | 23 | ### 4. Different convolution algorithm may lead to different performance 24 | 25 | There are three kind of algorithm: ```Native```, ```Batch```, ```BatchGemmGather```. 26 | 27 | * ```Native```: should be used for all submanifold convolutions. should be used when there are too much active points. 28 | 29 | * ```Batch```: **cost more GPU memory** should be used when number of active points is small. 30 | 31 | * ```BatchGemmGather```: **cost more GPU memory** can be used for regular convolution. -------------------------------------------------------------------------------- /spconv-1.2.1/format_all.sh: -------------------------------------------------------------------------------- 1 | isort -rc --atomic ./spconv && \ 2 | isort -rc --atomic ./test && \ 3 | yapf -i --recursive -vv ./spconv ./test 4 | find ./src -regex '.*\.\(cpp\|hpp\|cc\|cxx\|cu\|cuh\|h\)' | xargs clang-format -i 5 | find ./include -regex '.*\.\(cpp\|hpp\|cc\|cxx\|cu\|cuh\|h\)' | xargs clang-format -i -------------------------------------------------------------------------------- /spconv-1.2.1/include/spconv/maxpool.h: -------------------------------------------------------------------------------- 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 | #ifndef SPARSE_MAXPOOL_FUNCTOR_H_ 16 | #define SPARSE_MAXPOOL_FUNCTOR_H_ 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | namespace spconv { 23 | 24 | void maxpool_bwd_cpu(torch::Tensor outFeatures, torch::Tensor inFeatures, 25 | torch::Tensor dout, torch::Tensor din, 26 | torch::Tensor indicesIn, torch::Tensor indicesOut, 27 | int size); 28 | 29 | void maxpool_fwd_cpu(torch::Tensor outFeatures, torch::Tensor inFeatures, 30 | torch::Tensor indicesIn, torch::Tensor indicesOut, 31 | int size); 32 | 33 | void maxpool_bwd_cuda(torch::Tensor outFeatures, torch::Tensor inFeatures, 34 | torch::Tensor dout, torch::Tensor din, 35 | torch::Tensor indicesIn, torch::Tensor indicesOut, 36 | int size); 37 | 38 | void maxpool_fwd_cuda(torch::Tensor outFeatures, torch::Tensor inFeatures, 39 | torch::Tensor indicesIn, torch::Tensor indicesOut, 40 | int size); 41 | 42 | } // namespace spconv 43 | 44 | #endif -------------------------------------------------------------------------------- /spconv-1.2.1/include/spconv/nms_functor.h: -------------------------------------------------------------------------------- 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 | #ifndef NMS_FUNCTOR_H_ 16 | #define NMS_FUNCTOR_H_ 17 | #include 18 | 19 | namespace spconv { 20 | namespace functor { 21 | template 22 | struct NonMaxSupressionFunctor { 23 | Index operator()(const Device &d, tv::TensorView keep, 24 | tv::TensorView boxes, T threshold, T eps); 25 | }; 26 | 27 | template 28 | struct rotateNonMaxSupressionFunctor { 29 | Index operator()(const Device &d, tv::TensorView keep, 30 | tv::TensorView boxCorners, 31 | tv::TensorView standupIoU, T threshold); 32 | }; 33 | 34 | } // namespace functor 35 | } // namespace spconv 36 | 37 | #endif -------------------------------------------------------------------------------- /spconv-1.2.1/include/spconv/nms_gpu.h: -------------------------------------------------------------------------------- 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 | #pragma once 16 | template 17 | int _nms_gpu(int *keep_out, const DType *boxes_host, int boxes_num, 18 | int boxes_dim, DType nms_overlap_thresh, int device_id); 19 | -------------------------------------------------------------------------------- /spconv-1.2.1/include/spconv/pillar_scatter_functor.h: -------------------------------------------------------------------------------- 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 | #ifndef POINTPILLARS_SCATTER_FUNCTOR_H_ 16 | #define POINTPILLARS_SCATTER_FUNCTOR_H_ 17 | #include 18 | 19 | namespace spconv { 20 | namespace functor { 21 | template 22 | struct PointPillarScatter { 23 | void operator()(const Device &d, tv::TensorView canvas, 24 | tv::TensorView features, 25 | tv::TensorView coors); 26 | }; 27 | 28 | } // namespace functor 29 | } // namespace spconv 30 | 31 | #endif -------------------------------------------------------------------------------- /spconv-1.2.1/include/spconv/pool_ops.h: -------------------------------------------------------------------------------- 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 | #ifndef SPARSE_POOL_OP_H_ 16 | #define SPARSE_POOL_OP_H_ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | namespace spconv { 24 | torch::Tensor indiceMaxPool(torch::Tensor features, torch::Tensor indicePairs, 25 | torch::Tensor indiceNum, int64_t numAct); 26 | 27 | torch::Tensor indiceMaxPoolBackward(torch::Tensor features, 28 | torch::Tensor outFeatures, 29 | torch::Tensor outGrad, 30 | torch::Tensor indicePairs, 31 | torch::Tensor indiceNum); 32 | 33 | } // namespace spconv 34 | 35 | #endif -------------------------------------------------------------------------------- /spconv-1.2.1/include/spconv/reordering.h: -------------------------------------------------------------------------------- 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 | #ifndef SPARSE_REORDERING_FUNCTOR_H_ 16 | #define SPARSE_REORDERING_FUNCTOR_H_ 17 | #include 18 | #include 19 | 20 | namespace spconv { 21 | 22 | void batch_sparse_gather_cuda(torch::Tensor buffer, torch::Tensor features, 23 | torch::Tensor indices, int size); 24 | void batch_sparse_scatter_add_cuda(torch::Tensor buffer, 25 | torch::Tensor outFeatures, 26 | torch::Tensor indices, int size); 27 | 28 | void sparse_gather_cuda(torch::Tensor buffer, torch::Tensor features, 29 | torch::Tensor indices, int size); 30 | void sparse_scatter_add_cuda(torch::Tensor buffer, torch::Tensor outFeatures, 31 | torch::Tensor indices, int size); 32 | 33 | void sparse_gather_cpu(torch::Tensor buffer, torch::Tensor features, 34 | torch::Tensor indices, int size); 35 | void sparse_scatter_add_cpu(torch::Tensor buffer, torch::Tensor outFeatures, 36 | torch::Tensor indices, int size); 37 | 38 | } // namespace spconv 39 | 40 | #endif -------------------------------------------------------------------------------- /spconv-1.2.1/include/tensorview/cuda_utils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | // from pytorch.aten 3 | #include "tensorview.h" 4 | #include 5 | namespace tv { 6 | namespace cuda { 7 | 8 | template inline int DivUp(const T1 a, const T2 b) { 9 | return (a + b - 1) / b; 10 | } 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 | 16 | inline int getNumThreads(const int N) { 17 | if (N > CUDA_NUM_THREADS) { 18 | return CUDA_NUM_THREADS; 19 | } 20 | return DivUp(N, 32) * 32; 21 | } 22 | 23 | inline int getBlocks(const int N) { 24 | TV_ASSERT_RT_ERR(N > 0, 25 | "CUDA kernel launch blocks must be positive, but got N=", N); 26 | return DivUp(N, getNumThreads(N)); 27 | } 28 | 29 | } // namespace cuda 30 | 31 | } // namespace tv -------------------------------------------------------------------------------- /spconv-1.2.1/include/tensorview/eigen_utils.h: -------------------------------------------------------------------------------- 1 | // Copyright 2019-2020 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 | #pragma once 16 | #include "tensor.h" 17 | #include "tensorview.h" 18 | #include 19 | 20 | namespace tv { 21 | 22 | template 23 | Eigen::Map> 24 | tv2eigen(TensorView view) { 25 | TV_ASSERT_INVALID_ARG(view.ndim() <= 2 && view.ndim() > 0, "error"); 26 | if (Row != Eigen::Dynamic) { 27 | TV_ASSERT_INVALID_ARG(view.dim(0) == Row, "error"); 28 | } 29 | if (Col != Eigen::Dynamic) { 30 | TV_ASSERT_INVALID_ARG(view.dim(1) == Col, "error"); 31 | } 32 | int row = 1; 33 | if (view.ndim() == 2) { 34 | row = view.dim(0); 35 | } 36 | Eigen::Map> eigen_map( 37 | view.data(), row, view.dim(1)); 38 | return eigen_map; 39 | } 40 | 41 | } // namespace tv 42 | -------------------------------------------------------------------------------- /spconv-1.2.1/include/tensorview/mp_helper.h: -------------------------------------------------------------------------------- 1 | #ifndef MP_HELPER_H_ 2 | #define MP_HELPER_H_ 3 | #include 4 | #include 5 | 6 | namespace tv { 7 | template struct mp_list {}; 8 | 9 | template 10 | using mp_list_c = mp_list...>; 11 | 12 | namespace detail { 13 | 14 | template 15 | constexpr F mp_for_each_impl(mp_list, F &&f) { 16 | return (void)(std::initializer_list{(f(Ts()), 0)...}), 17 | std::forward(f); 18 | } 19 | 20 | template constexpr F mp_for_each_impl(mp_list<>, F &&f) { 21 | return std::forward(f); 22 | } 23 | 24 | } // namespace detail 25 | 26 | template 27 | using mp_length = std::integral_constant; 28 | 29 | namespace detail { 30 | 31 | template class B> struct mp_rename_impl { 32 | // An error "no type named 'type'" here means that the first argument to 33 | // mp_rename is not a list 34 | }; 35 | 36 | template