openpoints 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openpoints-0.1.0/LICENSE +21 -0
- openpoints-0.1.0/MANIFEST.in +6 -0
- openpoints-0.1.0/PKG-INFO +150 -0
- openpoints-0.1.0/README.md +74 -0
- openpoints-0.1.0/__init__.py +3 -0
- openpoints-0.1.0/cpp/__init__.py +6 -0
- openpoints-0.1.0/cpp/chamfer_dist/__init__.py +110 -0
- openpoints-0.1.0/cpp/chamfer_dist/chamfer.cu +229 -0
- openpoints-0.1.0/cpp/chamfer_dist/chamfer_cuda.cpp +39 -0
- openpoints-0.1.0/cpp/chamfer_dist/setup.py +19 -0
- openpoints-0.1.0/cpp/chamfer_dist/test.py +34 -0
- openpoints-0.1.0/cpp/emd/README.md +31 -0
- openpoints-0.1.0/cpp/emd/__init__.py +3 -0
- openpoints-0.1.0/cpp/emd/cuda/emd.cpp +29 -0
- openpoints-0.1.0/cpp/emd/cuda/emd_kernel.cu +403 -0
- openpoints-0.1.0/cpp/emd/emd.py +88 -0
- openpoints-0.1.0/cpp/emd/setup.py +27 -0
- openpoints-0.1.0/cpp/emd/test_emd_loss.py +45 -0
- openpoints-0.1.0/cpp/pointnet2_batch/__init__.py +24 -0
- openpoints-0.1.0/cpp/pointnet2_batch/setup.py +23 -0
- openpoints-0.1.0/cpp/pointnet2_batch/src/ball_query.cpp +39 -0
- openpoints-0.1.0/cpp/pointnet2_batch/src/ball_query_gpu.cu +73 -0
- openpoints-0.1.0/cpp/pointnet2_batch/src/ball_query_gpu.h +15 -0
- openpoints-0.1.0/cpp/pointnet2_batch/src/cuda_utils.h +15 -0
- openpoints-0.1.0/cpp/pointnet2_batch/src/group_points.cpp +35 -0
- openpoints-0.1.0/cpp/pointnet2_batch/src/group_points_gpu.cu +92 -0
- openpoints-0.1.0/cpp/pointnet2_batch/src/group_points_gpu.h +22 -0
- openpoints-0.1.0/cpp/pointnet2_batch/src/interpolate.cpp +57 -0
- openpoints-0.1.0/cpp/pointnet2_batch/src/interpolate_gpu.cu +168 -0
- openpoints-0.1.0/cpp/pointnet2_batch/src/interpolate_gpu.h +30 -0
- openpoints-0.1.0/cpp/pointnet2_batch/src/pointnet2_api.cpp +24 -0
- openpoints-0.1.0/cpp/pointnet2_batch/src/sampling.cpp +48 -0
- openpoints-0.1.0/cpp/pointnet2_batch/src/sampling_gpu.cu +260 -0
- openpoints-0.1.0/cpp/pointnet2_batch/src/sampling_gpu.h +29 -0
- openpoints-0.1.0/cpp/pointops/__init__.py +0 -0
- openpoints-0.1.0/cpp/pointops/functions/__init__.py +0 -0
- openpoints-0.1.0/cpp/pointops/functions/pointops.py +314 -0
- openpoints-0.1.0/cpp/pointops/setup.py +37 -0
- openpoints-0.1.0/cpp/pointops/src/__init__.py +0 -0
- openpoints-0.1.0/cpp/pointops/src/aggregation/aggregation_cuda.cpp +28 -0
- openpoints-0.1.0/cpp/pointops/src/aggregation/aggregation_cuda_kernel.cu +53 -0
- openpoints-0.1.0/cpp/pointops/src/aggregation/aggregation_cuda_kernel.h +20 -0
- openpoints-0.1.0/cpp/pointops/src/ballquery/ballquery_cuda.cpp +50 -0
- openpoints-0.1.0/cpp/pointops/src/ballquery/ballquery_cuda_kernel.cu +100 -0
- openpoints-0.1.0/cpp/pointops/src/ballquery/ballquery_cuda_kernel.h +17 -0
- openpoints-0.1.0/cpp/pointops/src/cuda_utils.h +23 -0
- openpoints-0.1.0/cpp/pointops/src/grouping/grouping_cuda.cpp +21 -0
- openpoints-0.1.0/cpp/pointops/src/grouping/grouping_cuda_kernel.cu +40 -0
- openpoints-0.1.0/cpp/pointops/src/grouping/grouping_cuda_kernel.h +20 -0
- openpoints-0.1.0/cpp/pointops/src/interpolation/interpolation_cuda.cpp +23 -0
- openpoints-0.1.0/cpp/pointops/src/interpolation/interpolation_cuda_kernel.cu +47 -0
- openpoints-0.1.0/cpp/pointops/src/interpolation/interpolation_cuda_kernel.h +20 -0
- openpoints-0.1.0/cpp/pointops/src/knnquery/knnquery_cuda.cpp +16 -0
- openpoints-0.1.0/cpp/pointops/src/knnquery/knnquery_cuda_kernel.cu +116 -0
- openpoints-0.1.0/cpp/pointops/src/knnquery/knnquery_cuda_kernel.h +18 -0
- openpoints-0.1.0/cpp/pointops/src/pointops_api.cpp +25 -0
- openpoints-0.1.0/cpp/pointops/src/sampling/sampling_cuda.cpp +15 -0
- openpoints-0.1.0/cpp/pointops/src/sampling/sampling_cuda_kernel.cu +171 -0
- openpoints-0.1.0/cpp/pointops/src/sampling/sampling_cuda_kernel.h +18 -0
- openpoints-0.1.0/cpp/pointops/src/subtraction/subtraction_cuda.cpp +23 -0
- openpoints-0.1.0/cpp/pointops/src/subtraction/subtraction_cuda_kernel.cu +44 -0
- openpoints-0.1.0/cpp/pointops/src/subtraction/subtraction_cuda_kernel.h +20 -0
- openpoints-0.1.0/cpp/subsampling/cpp_utils/cloud/cloud.cpp +67 -0
- openpoints-0.1.0/cpp/subsampling/cpp_utils/cloud/cloud.h +184 -0
- openpoints-0.1.0/cpp/subsampling/cpp_utils/nanoflann/nanoflann.hpp +2043 -0
- openpoints-0.1.0/cpp/subsampling/grid_subsampling/grid_subsampling.cpp +106 -0
- openpoints-0.1.0/cpp/subsampling/grid_subsampling/grid_subsampling.h +92 -0
- openpoints-0.1.0/cpp/subsampling/setup.py +29 -0
- openpoints-0.1.0/cpp/subsampling/wrapper.cpp +286 -0
- openpoints-0.1.0/dataset/__init__.py +10 -0
- openpoints-0.1.0/dataset/atom3d/__init__.py +1 -0
- openpoints-0.1.0/dataset/atom3d/psr.py +38 -0
- openpoints-0.1.0/dataset/build.py +98 -0
- openpoints-0.1.0/dataset/data_util.py +192 -0
- openpoints-0.1.0/dataset/datalist.py +67 -0
- openpoints-0.1.0/dataset/dataset_base.py +96 -0
- openpoints-0.1.0/dataset/graph_dataset/__init__.py +3 -0
- openpoints-0.1.0/dataset/graph_dataset/graph_dataset.py +93 -0
- openpoints-0.1.0/dataset/graph_dataset/stack_with_pad.py +91 -0
- openpoints-0.1.0/dataset/graph_dataset/structural_dataset.py +73 -0
- openpoints-0.1.0/dataset/graph_dataset/svd_encodings_dataset.py +110 -0
- openpoints-0.1.0/dataset/grid_sample.py +21 -0
- openpoints-0.1.0/dataset/matterport3d/__init__.py +1 -0
- openpoints-0.1.0/dataset/matterport3d/category_mapping.tsv +1660 -0
- openpoints-0.1.0/dataset/matterport3d/matterport3d.py +210 -0
- openpoints-0.1.0/dataset/matterport3d/matterport3d_dataprocessing.py +105 -0
- openpoints-0.1.0/dataset/modelnet/__init__.py +3 -0
- openpoints-0.1.0/dataset/modelnet/modelnet40_normal_resampled_loader.py +124 -0
- openpoints-0.1.0/dataset/modelnet/modelnet40_ply_2048_loader.py +160 -0
- openpoints-0.1.0/dataset/molhiv/__init__.py +1 -0
- openpoints-0.1.0/dataset/molhiv/data.py +59 -0
- openpoints-0.1.0/dataset/molpcba/__init__.py +1 -0
- openpoints-0.1.0/dataset/molpcba/data.py +59 -0
- openpoints-0.1.0/dataset/parsers/__init__.py +1 -0
- openpoints-0.1.0/dataset/parsers/class_map.py +19 -0
- openpoints-0.1.0/dataset/parsers/constants.py +1 -0
- openpoints-0.1.0/dataset/parsers/parser.py +17 -0
- openpoints-0.1.0/dataset/parsers/parser_factory.py +29 -0
- openpoints-0.1.0/dataset/parsers/parser_image_folder.py +69 -0
- openpoints-0.1.0/dataset/parsers/parser_image_in_tar.py +222 -0
- openpoints-0.1.0/dataset/parsers/parser_image_tar.py +72 -0
- openpoints-0.1.0/dataset/parsers/parser_tfds.py +297 -0
- openpoints-0.1.0/dataset/pcqm4m/__init__.py +1 -0
- openpoints-0.1.0/dataset/pcqm4m/data.py +62 -0
- openpoints-0.1.0/dataset/pcqm4mv2/__init__.py +1 -0
- openpoints-0.1.0/dataset/pcqm4mv2/data.py +87 -0
- openpoints-0.1.0/dataset/s3dis/__init__.py +2 -0
- openpoints-0.1.0/dataset/s3dis/s3dis.py +156 -0
- openpoints-0.1.0/dataset/s3dis/s3dis_block.py +96 -0
- openpoints-0.1.0/dataset/s3dis/s3dis_sphere.py +349 -0
- openpoints-0.1.0/dataset/scannetv2/__init__.py +1 -0
- openpoints-0.1.0/dataset/scannetv2/scannet.py +176 -0
- openpoints-0.1.0/dataset/scanobjectnn/__init__.py +3 -0
- openpoints-0.1.0/dataset/scanobjectnn/scanobjectnn.py +110 -0
- openpoints-0.1.0/dataset/semantic_kitti/__init__.py +1 -0
- openpoints-0.1.0/dataset/semantic_kitti/compile_op.sh +7 -0
- openpoints-0.1.0/dataset/semantic_kitti/helper_tool.py +286 -0
- openpoints-0.1.0/dataset/semantic_kitti/label_mapping.yaml +211 -0
- openpoints-0.1.0/dataset/semantic_kitti/semantickitti.py +229 -0
- openpoints-0.1.0/dataset/semantic_kitti/utils/cpp_wrappers/compile_wrappers.sh +7 -0
- openpoints-0.1.0/dataset/semantic_kitti/utils/cpp_wrappers/cpp_subsampling/grid_subsampling/grid_subsampling.cpp +106 -0
- openpoints-0.1.0/dataset/semantic_kitti/utils/cpp_wrappers/cpp_subsampling/grid_subsampling/grid_subsampling.h +92 -0
- openpoints-0.1.0/dataset/semantic_kitti/utils/cpp_wrappers/cpp_subsampling/wrapper.cpp +286 -0
- openpoints-0.1.0/dataset/semantic_kitti/utils/cpp_wrappers/cpp_utils/cloud/cloud.cpp +67 -0
- openpoints-0.1.0/dataset/semantic_kitti/utils/cpp_wrappers/cpp_utils/cloud/cloud.h +158 -0
- openpoints-0.1.0/dataset/semantic_kitti/utils/cpp_wrappers/cpp_utils/nanoflann/nanoflann.hpp +2043 -0
- openpoints-0.1.0/dataset/semantic_kitti/utils/download_semantic3d.sh +57 -0
- openpoints-0.1.0/dataset/semantic_kitti/utils/meta/anno_paths.txt +272 -0
- openpoints-0.1.0/dataset/semantic_kitti/utils/meta/class_names.txt +13 -0
- openpoints-0.1.0/dataset/semantic_kitti/utils/nearest_neighbors/KDTreeTableAdaptor.h +189 -0
- openpoints-0.1.0/dataset/semantic_kitti/utils/nearest_neighbors/knn.cpp +9641 -0
- openpoints-0.1.0/dataset/semantic_kitti/utils/nearest_neighbors/knn.pyx +149 -0
- openpoints-0.1.0/dataset/semantic_kitti/utils/nearest_neighbors/knn_.cxx +271 -0
- openpoints-0.1.0/dataset/semantic_kitti/utils/nearest_neighbors/knn_.h +27 -0
- openpoints-0.1.0/dataset/semantic_kitti/utils/nearest_neighbors/nanoflann.hpp +1990 -0
- openpoints-0.1.0/dataset/semantic_kitti/utils/semantic-kitti.yaml +211 -0
- openpoints-0.1.0/dataset/shapenet/__init__.py +1 -0
- openpoints-0.1.0/dataset/shapenet/shapenet55.py +76 -0
- openpoints-0.1.0/dataset/shapenet/shapenetpart.py +121 -0
- openpoints-0.1.0/dataset/shapenetpart/__init__.py +1 -0
- openpoints-0.1.0/dataset/shapenetpart/shapenet55.py +75 -0
- openpoints-0.1.0/dataset/shapenetpart/shapenetpart.py +388 -0
- openpoints-0.1.0/dataset/vis2d.py +17 -0
- openpoints-0.1.0/dataset/vis3d.py +153 -0
- openpoints-0.1.0/loss/__init__.py +3 -0
- openpoints-0.1.0/loss/build.py +281 -0
- openpoints-0.1.0/loss/cross_entropy.py +38 -0
- openpoints-0.1.0/loss/distill_loss.py +76 -0
- openpoints-0.1.0/models/__init__.py +10 -0
- openpoints-0.1.0/models/backbone/Stratified_transformer.py +558 -0
- openpoints-0.1.0/models/backbone/__init__.py +11 -0
- openpoints-0.1.0/models/backbone/baafnet.py +527 -0
- openpoints-0.1.0/models/backbone/ball_dgcnn.py +123 -0
- openpoints-0.1.0/models/backbone/curvenet.py +793 -0
- openpoints-0.1.0/models/backbone/debug_invvit.py +114 -0
- openpoints-0.1.0/models/backbone/deepgcn.py +143 -0
- openpoints-0.1.0/models/backbone/dgcnn.py +119 -0
- openpoints-0.1.0/models/backbone/graphvit3d.py +134 -0
- openpoints-0.1.0/models/backbone/grouppointnet.py +100 -0
- openpoints-0.1.0/models/backbone/pct.py +163 -0
- openpoints-0.1.0/models/backbone/pointmlp.py +417 -0
- openpoints-0.1.0/models/backbone/pointnet.py +199 -0
- openpoints-0.1.0/models/backbone/pointnetv2.py +511 -0
- openpoints-0.1.0/models/backbone/pointnext.py +663 -0
- openpoints-0.1.0/models/backbone/pointnextPyG.py +555 -0
- openpoints-0.1.0/models/backbone/pointtransformer.py +293 -0
- openpoints-0.1.0/models/backbone/pointvector.py +853 -0
- openpoints-0.1.0/models/backbone/pointvit.py +392 -0
- openpoints-0.1.0/models/backbone/pointvit_inv.py +942 -0
- openpoints-0.1.0/models/backbone/pointvit_inv_old.py +784 -0
- openpoints-0.1.0/models/backbone/randlenet.py +318 -0
- openpoints-0.1.0/models/backbone/resnet.py +342 -0
- openpoints-0.1.0/models/backbone/simpleview.py +153 -0
- openpoints-0.1.0/models/backbone/simpleview_util.py +292 -0
- openpoints-0.1.0/models/build.py +13 -0
- openpoints-0.1.0/models/classification/__init__.py +5 -0
- openpoints-0.1.0/models/classification/cls_base.py +136 -0
- openpoints-0.1.0/models/classification/point_bert.py +154 -0
- openpoints-0.1.0/models/layers/__init__.py +14 -0
- openpoints-0.1.0/models/layers/activation.py +57 -0
- openpoints-0.1.0/models/layers/attention.py +103 -0
- openpoints-0.1.0/models/layers/conv.py +167 -0
- openpoints-0.1.0/models/layers/drop.py +164 -0
- openpoints-0.1.0/models/layers/graph_conv.py +122 -0
- openpoints-0.1.0/models/layers/group.py +415 -0
- openpoints-0.1.0/models/layers/group_embed.py +286 -0
- openpoints-0.1.0/models/layers/helpers.py +43 -0
- openpoints-0.1.0/models/layers/kmeans.py +119 -0
- openpoints-0.1.0/models/layers/knn.py +110 -0
- openpoints-0.1.0/models/layers/local_aggregation.py +286 -0
- openpoints-0.1.0/models/layers/mlp.py +129 -0
- openpoints-0.1.0/models/layers/norm.py +106 -0
- openpoints-0.1.0/models/layers/padding.py +56 -0
- openpoints-0.1.0/models/layers/patch_embed.py +37 -0
- openpoints-0.1.0/models/layers/registry.py +168 -0
- openpoints-0.1.0/models/layers/subsample.py +185 -0
- openpoints-0.1.0/models/layers/upsampling.py +106 -0
- openpoints-0.1.0/models/layers/weight_init.py +89 -0
- openpoints-0.1.0/models/reconstruction/__init__.py +8 -0
- openpoints-0.1.0/models/reconstruction/base_recontruct.py +216 -0
- openpoints-0.1.0/models/reconstruction/maskedpoint.py +116 -0
- openpoints-0.1.0/models/reconstruction/maskedpointgroup.py +168 -0
- openpoints-0.1.0/models/reconstruction/maskedpointvit.py +253 -0
- openpoints-0.1.0/models/reconstruction/nodeshuffle.py +11 -0
- openpoints-0.1.0/models/registry.py +149 -0
- openpoints-0.1.0/models/segmentation/__init__.py +6 -0
- openpoints-0.1.0/models/segmentation/base_seg.py +278 -0
- openpoints-0.1.0/models/segmentation/vit_seg.py +126 -0
- openpoints-0.1.0/openpoints.egg-info/PKG-INFO +150 -0
- openpoints-0.1.0/openpoints.egg-info/SOURCES.txt +435 -0
- openpoints-0.1.0/openpoints.egg-info/dependency_links.txt +1 -0
- openpoints-0.1.0/openpoints.egg-info/not-zip-safe +1 -0
- openpoints-0.1.0/openpoints.egg-info/requires.txt +58 -0
- openpoints-0.1.0/openpoints.egg-info/top_level.txt +1 -0
- openpoints-0.1.0/optim/__init__.py +15 -0
- openpoints-0.1.0/optim/adabelief.py +201 -0
- openpoints-0.1.0/optim/adafactor.py +167 -0
- openpoints-0.1.0/optim/adahessian.py +156 -0
- openpoints-0.1.0/optim/adamp.py +105 -0
- openpoints-0.1.0/optim/adamw.py +122 -0
- openpoints-0.1.0/optim/lamb.py +192 -0
- openpoints-0.1.0/optim/lars.py +135 -0
- openpoints-0.1.0/optim/lookahead.py +61 -0
- openpoints-0.1.0/optim/madgrad.py +184 -0
- openpoints-0.1.0/optim/nadam.py +92 -0
- openpoints-0.1.0/optim/nvnovograd.py +120 -0
- openpoints-0.1.0/optim/optim_factory.py +306 -0
- openpoints-0.1.0/optim/radam.py +89 -0
- openpoints-0.1.0/optim/rmsprop_tf.py +139 -0
- openpoints-0.1.0/optim/sgdp.py +70 -0
- openpoints-0.1.0/pyproject.toml +146 -0
- openpoints-0.1.0/scheduler/__init__.py +8 -0
- openpoints-0.1.0/scheduler/cosine_lr.py +124 -0
- openpoints-0.1.0/scheduler/multistep_lr.py +65 -0
- openpoints-0.1.0/scheduler/plateau_lr.py +113 -0
- openpoints-0.1.0/scheduler/poly_lr.py +116 -0
- openpoints-0.1.0/scheduler/scheduler.py +110 -0
- openpoints-0.1.0/scheduler/scheduler_factory.py +118 -0
- openpoints-0.1.0/scheduler/step_lr.py +65 -0
- openpoints-0.1.0/scheduler/tanh_lr.py +117 -0
- openpoints-0.1.0/setup.cfg +4 -0
- openpoints-0.1.0/tests/test_data_util.py +36 -0
- openpoints-0.1.0/tests/test_optional_cuda_imports.py +65 -0
- openpoints-0.1.0/tests/test_pointmlp_hooks.py +10 -0
- openpoints-0.1.0/transforms/__init__.py +7 -0
- openpoints-0.1.0/transforms/point_transform_cpu.py +332 -0
- openpoints-0.1.0/transforms/point_transformer_gpu.py +764 -0
- openpoints-0.1.0/transforms/transforms_factory.py +60 -0
- openpoints-0.1.0/utils/__init__.py +8 -0
- openpoints-0.1.0/utils/ckpt_util.py +438 -0
- openpoints-0.1.0/utils/config.py +113 -0
- openpoints-0.1.0/utils/dist_utils.py +54 -0
- openpoints-0.1.0/utils/logger.py +170 -0
- openpoints-0.1.0/utils/metrics.py +311 -0
- openpoints-0.1.0/utils/random.py +16 -0
- openpoints-0.1.0/utils/registry.py +294 -0
- openpoints-0.1.0/utils/str2bool.py +11 -0
- openpoints-0.1.0/utils/wandb.py +88 -0
openpoints-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Guocheng Qian.
|
|
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.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
include README.md
|
|
2
|
+
include LICENSE
|
|
3
|
+
recursive-include cpp *.cpp *.cu *.cxx *.h *.hpp *.pyx *.md *.py
|
|
4
|
+
recursive-include dataset/semantic_kitti *.yaml *.txt *.cpp *.cxx *.h *.hpp *.pyx *.sh
|
|
5
|
+
include dataset/matterport3d/category_mapping.tsv
|
|
6
|
+
global-exclude *.py[cod] __pycache__/* *.so .DS_Store
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: openpoints
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: OpenPoints: point cloud understanding models, layers, datasets, transforms, optimizers, and training utilities.
|
|
5
|
+
Author: Guocheng Qian
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/guochengqian/openpoints
|
|
8
|
+
Project-URL: Repository, https://github.com/guochengqian/openpoints
|
|
9
|
+
Project-URL: Issues, https://github.com/guochengqian/PointNeXt/issues
|
|
10
|
+
Keywords: point cloud,deep learning,pytorch,3d vision,PointNeXt
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
|
+
Requires-Python: >=3.8
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: torch>=1.10
|
|
25
|
+
Requires-Dist: numpy>=1.20
|
|
26
|
+
Requires-Dist: scipy>=1.7
|
|
27
|
+
Requires-Dist: PyYAML>=5.4
|
|
28
|
+
Requires-Dist: multimethod>=1.8
|
|
29
|
+
Requires-Dist: termcolor>=1.1
|
|
30
|
+
Requires-Dist: shortuuid>=1.0
|
|
31
|
+
Requires-Dist: scikit-learn>=1.0
|
|
32
|
+
Requires-Dist: tqdm>=4
|
|
33
|
+
Requires-Dist: easydict>=1.9
|
|
34
|
+
Requires-Dist: h5py>=3
|
|
35
|
+
Requires-Dist: pandas>=1.3
|
|
36
|
+
Requires-Dist: torchvision>=0.11
|
|
37
|
+
Provides-Extra: data
|
|
38
|
+
Requires-Dist: easydict>=1.9; extra == "data"
|
|
39
|
+
Requires-Dist: h5py>=3; extra == "data"
|
|
40
|
+
Requires-Dist: pandas>=1.3; extra == "data"
|
|
41
|
+
Requires-Dist: torchvision>=0.11; extra == "data"
|
|
42
|
+
Provides-Extra: viz
|
|
43
|
+
Requires-Dist: matplotlib>=3.5; extra == "viz"
|
|
44
|
+
Requires-Dist: pyvista>=0.38; extra == "viz"
|
|
45
|
+
Provides-Extra: graph
|
|
46
|
+
Requires-Dist: numba>=0.56; extra == "graph"
|
|
47
|
+
Requires-Dist: ogb>=1.3; extra == "graph"
|
|
48
|
+
Requires-Dist: atom3d>=0.2; extra == "graph"
|
|
49
|
+
Requires-Dist: fast-pytorch-kmeans>=0.1; extra == "graph"
|
|
50
|
+
Provides-Extra: tfds
|
|
51
|
+
Requires-Dist: Pillow>=8; extra == "tfds"
|
|
52
|
+
Requires-Dist: tensorflow>=2; extra == "tfds"
|
|
53
|
+
Requires-Dist: tensorflow-datasets>=4; extra == "tfds"
|
|
54
|
+
Provides-Extra: wandb
|
|
55
|
+
Requires-Dist: wandb>=0.13; extra == "wandb"
|
|
56
|
+
Provides-Extra: dev
|
|
57
|
+
Requires-Dist: build>=1; extra == "dev"
|
|
58
|
+
Requires-Dist: twine>=4; extra == "dev"
|
|
59
|
+
Requires-Dist: pytest>=7; extra == "dev"
|
|
60
|
+
Provides-Extra: all
|
|
61
|
+
Requires-Dist: easydict>=1.9; extra == "all"
|
|
62
|
+
Requires-Dist: h5py>=3; extra == "all"
|
|
63
|
+
Requires-Dist: pandas>=1.3; extra == "all"
|
|
64
|
+
Requires-Dist: torchvision>=0.11; extra == "all"
|
|
65
|
+
Requires-Dist: matplotlib>=3.5; extra == "all"
|
|
66
|
+
Requires-Dist: pyvista>=0.38; extra == "all"
|
|
67
|
+
Requires-Dist: numba>=0.56; extra == "all"
|
|
68
|
+
Requires-Dist: ogb>=1.3; extra == "all"
|
|
69
|
+
Requires-Dist: atom3d>=0.2; extra == "all"
|
|
70
|
+
Requires-Dist: fast-pytorch-kmeans>=0.1; extra == "all"
|
|
71
|
+
Requires-Dist: Pillow>=8; extra == "all"
|
|
72
|
+
Requires-Dist: tensorflow>=2; extra == "all"
|
|
73
|
+
Requires-Dist: tensorflow-datasets>=4; extra == "all"
|
|
74
|
+
Requires-Dist: wandb>=0.13; extra == "all"
|
|
75
|
+
Dynamic: license-file
|
|
76
|
+
|
|
77
|
+
# OpenPoints
|
|
78
|
+
|
|
79
|
+
OpenPoints is a library built for fairly benchmarking and easily reproducing point-based methods for point cloud understanding. It is born in the course of [PointNeXt](https://github.com/guochengqian/PointNeXt) project and is used as an engine therein.
|
|
80
|
+
|
|
81
|
+
**For any question related to OpenPoints, please open an issue in [PointNeXt](https://github.com/guochengqian/PointNeXt) repo.**
|
|
82
|
+
|
|
83
|
+
OpenPoints currently supports reproducing the following models:
|
|
84
|
+
- PointNet
|
|
85
|
+
- DGCNN
|
|
86
|
+
- DeepGCN
|
|
87
|
+
- PointNet++
|
|
88
|
+
- ASSANet
|
|
89
|
+
- PointMLP
|
|
90
|
+
- PointNeXt
|
|
91
|
+
- Pix4Point
|
|
92
|
+
- PointVector
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
## Features
|
|
97
|
+
|
|
98
|
+
1. **Extensibility**: supports many representative networks for point cloud understanding, such as *PointNet, DGCNN, DeepGCN, PointNet++, ASSANet, PointMLP*, and our ***PointNeXt***. More networks can be built easily based on our framework since **OpenPoints support a wide range of basic operations including graph convolutions, self-attention, farthest point sampling, ball query, *e.t.c***.
|
|
99
|
+
|
|
100
|
+
2. **Ease of Use**: *Build* model, optimizer, scheduler, loss function, and data loader *easily from cfg*. Train and validate different models on various tasks by simply changing the `cfg\*\*.yaml` file.
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
model = build_model_from_cfg(cfg.model)
|
|
104
|
+
criterion = build_criterion_from_cfg(cfg.criterion_args)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
## Installation
|
|
110
|
+
|
|
111
|
+
OpenPoints can be installed as the `openpoints` Python package:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
pip install openpoints
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The PyPI package installs the Python library (`import openpoints`) and the files needed by the datasets and configs. CUDA/C++ operators such as `pointnet2_batch_cuda`, `pointops_cuda`, `chamfer`, and `emd_cuda` are still built from a source checkout or source distribution for now because PyTorch/CUDA wheels must match the user's Python, PyTorch, CUDA, and platform versions.
|
|
118
|
+
|
|
119
|
+
For full training/evaluation with CUDA ops, install from source after installing PyTorch:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
git clone --recursive https://github.com/guochengqian/openpoints.git
|
|
123
|
+
cd openpoints
|
|
124
|
+
pip install -e .[data,viz,wandb]
|
|
125
|
+
cd cpp/pointnet2_batch && python setup.py install && cd ../..
|
|
126
|
+
cd cpp/pointops && python setup.py install && cd ../..
|
|
127
|
+
cd cpp/chamfer_dist && python setup.py install && cd ../..
|
|
128
|
+
cd cpp/emd && python setup.py install && cd ../..
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
If the `openpoints` name is unavailable on a package index mirror, the same code can be published as `openpoints-torch`; the import name remains `openpoints`.
|
|
132
|
+
|
|
133
|
+
## Usage
|
|
134
|
+
|
|
135
|
+
OpenPoints serves as the engine for PointNeXt. Please refer to [PointNeXt](https://github.com/guochengqian/PointNeXt) for complete training, evaluation, and model-zoo examples.
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
## Citation
|
|
140
|
+
|
|
141
|
+
If you use this library, please kindly acknowledge our work:
|
|
142
|
+
```tex
|
|
143
|
+
@Article{qian2022pointnext,
|
|
144
|
+
author = {Qian, Guocheng and Li, Yuchen and Peng, Houwen and Mai, Jinjie and Hammoud, Hasan and Elhoseiny, Mohamed and Ghanem, Bernard},
|
|
145
|
+
title = {PointNeXt: Revisiting PointNet++ with Improved Training and Scaling Strategies},
|
|
146
|
+
journal = {arXiv:2206.04670},
|
|
147
|
+
year = {2022},
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# OpenPoints
|
|
2
|
+
|
|
3
|
+
OpenPoints is a library built for fairly benchmarking and easily reproducing point-based methods for point cloud understanding. It is born in the course of [PointNeXt](https://github.com/guochengqian/PointNeXt) project and is used as an engine therein.
|
|
4
|
+
|
|
5
|
+
**For any question related to OpenPoints, please open an issue in [PointNeXt](https://github.com/guochengqian/PointNeXt) repo.**
|
|
6
|
+
|
|
7
|
+
OpenPoints currently supports reproducing the following models:
|
|
8
|
+
- PointNet
|
|
9
|
+
- DGCNN
|
|
10
|
+
- DeepGCN
|
|
11
|
+
- PointNet++
|
|
12
|
+
- ASSANet
|
|
13
|
+
- PointMLP
|
|
14
|
+
- PointNeXt
|
|
15
|
+
- Pix4Point
|
|
16
|
+
- PointVector
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
1. **Extensibility**: supports many representative networks for point cloud understanding, such as *PointNet, DGCNN, DeepGCN, PointNet++, ASSANet, PointMLP*, and our ***PointNeXt***. More networks can be built easily based on our framework since **OpenPoints support a wide range of basic operations including graph convolutions, self-attention, farthest point sampling, ball query, *e.t.c***.
|
|
23
|
+
|
|
24
|
+
2. **Ease of Use**: *Build* model, optimizer, scheduler, loss function, and data loader *easily from cfg*. Train and validate different models on various tasks by simply changing the `cfg\*\*.yaml` file.
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
model = build_model_from_cfg(cfg.model)
|
|
28
|
+
criterion = build_criterion_from_cfg(cfg.criterion_args)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
OpenPoints can be installed as the `openpoints` Python package:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install openpoints
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The PyPI package installs the Python library (`import openpoints`) and the files needed by the datasets and configs. CUDA/C++ operators such as `pointnet2_batch_cuda`, `pointops_cuda`, `chamfer`, and `emd_cuda` are still built from a source checkout or source distribution for now because PyTorch/CUDA wheels must match the user's Python, PyTorch, CUDA, and platform versions.
|
|
42
|
+
|
|
43
|
+
For full training/evaluation with CUDA ops, install from source after installing PyTorch:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
git clone --recursive https://github.com/guochengqian/openpoints.git
|
|
47
|
+
cd openpoints
|
|
48
|
+
pip install -e .[data,viz,wandb]
|
|
49
|
+
cd cpp/pointnet2_batch && python setup.py install && cd ../..
|
|
50
|
+
cd cpp/pointops && python setup.py install && cd ../..
|
|
51
|
+
cd cpp/chamfer_dist && python setup.py install && cd ../..
|
|
52
|
+
cd cpp/emd && python setup.py install && cd ../..
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
If the `openpoints` name is unavailable on a package index mirror, the same code can be published as `openpoints-torch`; the import name remains `openpoints`.
|
|
56
|
+
|
|
57
|
+
## Usage
|
|
58
|
+
|
|
59
|
+
OpenPoints serves as the engine for PointNeXt. Please refer to [PointNeXt](https://github.com/guochengqian/PointNeXt) for complete training, evaluation, and model-zoo examples.
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
## Citation
|
|
64
|
+
|
|
65
|
+
If you use this library, please kindly acknowledge our work:
|
|
66
|
+
```tex
|
|
67
|
+
@Article{qian2022pointnext,
|
|
68
|
+
author = {Qian, Guocheng and Li, Yuchen and Peng, Houwen and Mai, Jinjie and Hammoud, Hasan and Elhoseiny, Mohamed and Ghanem, Bernard},
|
|
69
|
+
title = {PointNeXt: Revisiting PointNet++ with Improved Training and Scaling Strategies},
|
|
70
|
+
journal = {arXiv:2206.04670},
|
|
71
|
+
year = {2022},
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# @Author: Thibault GROUEIX
|
|
3
|
+
# @Date: 2019-08-07 20:54:24
|
|
4
|
+
# @Last Modified by: Haozhe Xie
|
|
5
|
+
# @Last Modified time: 2019-12-18 15:06:25
|
|
6
|
+
# @Email: cshzxie@gmail.com
|
|
7
|
+
"""Chamfer distance CUDA extension loader.
|
|
8
|
+
|
|
9
|
+
The PyPI package ships Python sources and keeps compiled CUDA extensions
|
|
10
|
+
optional. Importing this module should not fail on machines where the
|
|
11
|
+
``chamfer`` extension has not been built yet; users only need the extension
|
|
12
|
+
when they instantiate/use Chamfer distance losses.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import torch
|
|
16
|
+
|
|
17
|
+
try:
|
|
18
|
+
import chamfer as _chamfer
|
|
19
|
+
except ImportError as exc:
|
|
20
|
+
_chamfer = None
|
|
21
|
+
_chamfer_import_error = exc
|
|
22
|
+
else:
|
|
23
|
+
_chamfer_import_error = None
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _require_chamfer():
|
|
27
|
+
if _chamfer is None:
|
|
28
|
+
raise ImportError(
|
|
29
|
+
"The `chamfer` CUDA extension is not installed. Build OpenPoints "
|
|
30
|
+
"CUDA ops from source first, e.g. `cd cpp/chamfer_dist && "
|
|
31
|
+
"python setup.py install`, or install a wheel that includes the "
|
|
32
|
+
"compiled extension."
|
|
33
|
+
) from _chamfer_import_error
|
|
34
|
+
return _chamfer
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class ChamferFunction(torch.autograd.Function):
|
|
38
|
+
@staticmethod
|
|
39
|
+
def forward(ctx, xyz1, xyz2):
|
|
40
|
+
chamfer = _require_chamfer()
|
|
41
|
+
dist1, dist2, idx1, idx2 = chamfer.forward(xyz1, xyz2)
|
|
42
|
+
ctx.save_for_backward(xyz1, xyz2, idx1, idx2)
|
|
43
|
+
|
|
44
|
+
return dist1, dist2
|
|
45
|
+
|
|
46
|
+
@staticmethod
|
|
47
|
+
def backward(ctx, grad_dist1, grad_dist2):
|
|
48
|
+
chamfer = _require_chamfer()
|
|
49
|
+
xyz1, xyz2, idx1, idx2 = ctx.saved_tensors
|
|
50
|
+
grad_xyz1, grad_xyz2 = chamfer.backward(xyz1, xyz2, idx1, idx2, grad_dist1, grad_dist2)
|
|
51
|
+
return grad_xyz1, grad_xyz2
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class ChamferDistanceL2(torch.nn.Module):
|
|
55
|
+
f''' Chamder Distance L2
|
|
56
|
+
'''
|
|
57
|
+
def __init__(self, ignore_zeros=False):
|
|
58
|
+
super().__init__()
|
|
59
|
+
self.ignore_zeros = ignore_zeros
|
|
60
|
+
|
|
61
|
+
def forward(self, xyz1, xyz2):
|
|
62
|
+
batch_size = xyz1.size(0)
|
|
63
|
+
if batch_size == 1 and self.ignore_zeros:
|
|
64
|
+
non_zeros1 = torch.sum(xyz1, dim=2).ne(0)
|
|
65
|
+
non_zeros2 = torch.sum(xyz2, dim=2).ne(0)
|
|
66
|
+
xyz1 = xyz1[non_zeros1].unsqueeze(dim=0)
|
|
67
|
+
xyz2 = xyz2[non_zeros2].unsqueeze(dim=0)
|
|
68
|
+
|
|
69
|
+
dist1, dist2 = ChamferFunction.apply(xyz1, xyz2)
|
|
70
|
+
return torch.mean(dist1) + torch.mean(dist2)
|
|
71
|
+
|
|
72
|
+
class ChamferDistanceL2_split(torch.nn.Module):
|
|
73
|
+
f''' Chamder Distance L2
|
|
74
|
+
'''
|
|
75
|
+
def __init__(self, ignore_zeros=False):
|
|
76
|
+
super().__init__()
|
|
77
|
+
self.ignore_zeros = ignore_zeros
|
|
78
|
+
|
|
79
|
+
def forward(self, xyz1, xyz2):
|
|
80
|
+
batch_size = xyz1.size(0)
|
|
81
|
+
if batch_size == 1 and self.ignore_zeros:
|
|
82
|
+
non_zeros1 = torch.sum(xyz1, dim=2).ne(0)
|
|
83
|
+
non_zeros2 = torch.sum(xyz2, dim=2).ne(0)
|
|
84
|
+
xyz1 = xyz1[non_zeros1].unsqueeze(dim=0)
|
|
85
|
+
xyz2 = xyz2[non_zeros2].unsqueeze(dim=0)
|
|
86
|
+
|
|
87
|
+
dist1, dist2 = ChamferFunction.apply(xyz1, xyz2)
|
|
88
|
+
return torch.mean(dist1), torch.mean(dist2)
|
|
89
|
+
|
|
90
|
+
class ChamferDistanceL1(torch.nn.Module):
|
|
91
|
+
f''' Chamder Distance L1
|
|
92
|
+
'''
|
|
93
|
+
def __init__(self, ignore_zeros=False):
|
|
94
|
+
super().__init__()
|
|
95
|
+
self.ignore_zeros = ignore_zeros
|
|
96
|
+
|
|
97
|
+
def forward(self, xyz1, xyz2):
|
|
98
|
+
batch_size = xyz1.size(0)
|
|
99
|
+
if batch_size == 1 and self.ignore_zeros:
|
|
100
|
+
non_zeros1 = torch.sum(xyz1, dim=2).ne(0)
|
|
101
|
+
non_zeros2 = torch.sum(xyz2, dim=2).ne(0)
|
|
102
|
+
xyz1 = xyz1[non_zeros1].unsqueeze(dim=0)
|
|
103
|
+
xyz2 = xyz2[non_zeros2].unsqueeze(dim=0)
|
|
104
|
+
|
|
105
|
+
dist1, dist2 = ChamferFunction.apply(xyz1, xyz2)
|
|
106
|
+
# import pdb
|
|
107
|
+
# pdb.set_trace()
|
|
108
|
+
dist1 = torch.sqrt(dist1)
|
|
109
|
+
dist2 = torch.sqrt(dist2)
|
|
110
|
+
return (torch.mean(dist1) + torch.mean(dist2))/2
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: Haozhe Xie
|
|
3
|
+
* @Date: 2019-08-07 20:54:24
|
|
4
|
+
* @Last Modified by: Haozhe Xie
|
|
5
|
+
* @Last Modified time: 2020-06-17 14:58:55
|
|
6
|
+
* @Email: cshzxie@gmail.com
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#include <cuda.h>
|
|
10
|
+
#include <cuda_runtime.h>
|
|
11
|
+
#include <torch/extension.h>
|
|
12
|
+
|
|
13
|
+
#include <vector>
|
|
14
|
+
|
|
15
|
+
__global__ void chamfer_dist_kernel(int batch_size,
|
|
16
|
+
int n,
|
|
17
|
+
const float* xyz1,
|
|
18
|
+
int m,
|
|
19
|
+
const float* xyz2,
|
|
20
|
+
float* dist,
|
|
21
|
+
int* indexes) {
|
|
22
|
+
const int batch = 512;
|
|
23
|
+
__shared__ float buf[batch * 3];
|
|
24
|
+
for (int i = blockIdx.x; i < batch_size; i += gridDim.x) {
|
|
25
|
+
for (int k2 = 0; k2 < m; k2 += batch) {
|
|
26
|
+
int end_k = min(m, k2 + batch) - k2;
|
|
27
|
+
for (int j = threadIdx.x; j < end_k * 3; j += blockDim.x) {
|
|
28
|
+
buf[j] = xyz2[(i * m + k2) * 3 + j];
|
|
29
|
+
}
|
|
30
|
+
__syncthreads();
|
|
31
|
+
for (int j = threadIdx.x + blockIdx.y * blockDim.x; j < n;
|
|
32
|
+
j += blockDim.x * gridDim.y) {
|
|
33
|
+
float x1 = xyz1[(i * n + j) * 3 + 0];
|
|
34
|
+
float y1 = xyz1[(i * n + j) * 3 + 1];
|
|
35
|
+
float z1 = xyz1[(i * n + j) * 3 + 2];
|
|
36
|
+
float best_dist = 0;
|
|
37
|
+
int best_dist_index = 0;
|
|
38
|
+
int end_ka = end_k - (end_k & 3);
|
|
39
|
+
if (end_ka == batch) {
|
|
40
|
+
for (int k = 0; k < batch; k += 4) {
|
|
41
|
+
{
|
|
42
|
+
float x2 = buf[k * 3 + 0] - x1;
|
|
43
|
+
float y2 = buf[k * 3 + 1] - y1;
|
|
44
|
+
float z2 = buf[k * 3 + 2] - z1;
|
|
45
|
+
float dist = x2 * x2 + y2 * y2 + z2 * z2;
|
|
46
|
+
|
|
47
|
+
if (k == 0 || dist < best_dist) {
|
|
48
|
+
best_dist = dist;
|
|
49
|
+
best_dist_index = k + k2;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
{
|
|
53
|
+
float x2 = buf[k * 3 + 3] - x1;
|
|
54
|
+
float y2 = buf[k * 3 + 4] - y1;
|
|
55
|
+
float z2 = buf[k * 3 + 5] - z1;
|
|
56
|
+
float dist = x2 * x2 + y2 * y2 + z2 * z2;
|
|
57
|
+
if (dist < best_dist) {
|
|
58
|
+
best_dist = dist;
|
|
59
|
+
best_dist_index = k + k2 + 1;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
{
|
|
63
|
+
float x2 = buf[k * 3 + 6] - x1;
|
|
64
|
+
float y2 = buf[k * 3 + 7] - y1;
|
|
65
|
+
float z2 = buf[k * 3 + 8] - z1;
|
|
66
|
+
float dist = x2 * x2 + y2 * y2 + z2 * z2;
|
|
67
|
+
if (dist < best_dist) {
|
|
68
|
+
best_dist = dist;
|
|
69
|
+
best_dist_index = k + k2 + 2;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
{
|
|
73
|
+
float x2 = buf[k * 3 + 9] - x1;
|
|
74
|
+
float y2 = buf[k * 3 + 10] - y1;
|
|
75
|
+
float z2 = buf[k * 3 + 11] - z1;
|
|
76
|
+
float dist = x2 * x2 + y2 * y2 + z2 * z2;
|
|
77
|
+
if (dist < best_dist) {
|
|
78
|
+
best_dist = dist;
|
|
79
|
+
best_dist_index = k + k2 + 3;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
for (int k = 0; k < end_ka; k += 4) {
|
|
85
|
+
{
|
|
86
|
+
float x2 = buf[k * 3 + 0] - x1;
|
|
87
|
+
float y2 = buf[k * 3 + 1] - y1;
|
|
88
|
+
float z2 = buf[k * 3 + 2] - z1;
|
|
89
|
+
float dist = x2 * x2 + y2 * y2 + z2 * z2;
|
|
90
|
+
if (k == 0 || dist < best_dist) {
|
|
91
|
+
best_dist = dist;
|
|
92
|
+
best_dist_index = k + k2;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
{
|
|
96
|
+
float x2 = buf[k * 3 + 3] - x1;
|
|
97
|
+
float y2 = buf[k * 3 + 4] - y1;
|
|
98
|
+
float z2 = buf[k * 3 + 5] - z1;
|
|
99
|
+
float dist = x2 * x2 + y2 * y2 + z2 * z2;
|
|
100
|
+
if (dist < best_dist) {
|
|
101
|
+
best_dist = dist;
|
|
102
|
+
best_dist_index = k + k2 + 1;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
{
|
|
106
|
+
float x2 = buf[k * 3 + 6] - x1;
|
|
107
|
+
float y2 = buf[k * 3 + 7] - y1;
|
|
108
|
+
float z2 = buf[k * 3 + 8] - z1;
|
|
109
|
+
float dist = x2 * x2 + y2 * y2 + z2 * z2;
|
|
110
|
+
if (dist < best_dist) {
|
|
111
|
+
best_dist = dist;
|
|
112
|
+
best_dist_index = k + k2 + 2;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
{
|
|
116
|
+
float x2 = buf[k * 3 + 9] - x1;
|
|
117
|
+
float y2 = buf[k * 3 + 10] - y1;
|
|
118
|
+
float z2 = buf[k * 3 + 11] - z1;
|
|
119
|
+
float dist = x2 * x2 + y2 * y2 + z2 * z2;
|
|
120
|
+
if (dist < best_dist) {
|
|
121
|
+
best_dist = dist;
|
|
122
|
+
best_dist_index = k + k2 + 3;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
for (int k = end_ka; k < end_k; k++) {
|
|
128
|
+
float x2 = buf[k * 3 + 0] - x1;
|
|
129
|
+
float y2 = buf[k * 3 + 1] - y1;
|
|
130
|
+
float z2 = buf[k * 3 + 2] - z1;
|
|
131
|
+
float dist = x2 * x2 + y2 * y2 + z2 * z2;
|
|
132
|
+
if (k == 0 || dist < best_dist) {
|
|
133
|
+
best_dist = dist;
|
|
134
|
+
best_dist_index = k + k2;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (k2 == 0 || dist[(i * n + j)] > best_dist) {
|
|
138
|
+
dist[(i * n + j)] = best_dist;
|
|
139
|
+
indexes[(i * n + j)] = best_dist_index;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
__syncthreads();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
std::vector<torch::Tensor> chamfer_cuda_forward(torch::Tensor xyz1,
|
|
148
|
+
torch::Tensor xyz2) {
|
|
149
|
+
const int batch_size = xyz1.size(0);
|
|
150
|
+
const int n = xyz1.size(1); // num_points point cloud A
|
|
151
|
+
const int m = xyz2.size(1); // num_points point cloud B
|
|
152
|
+
torch::Tensor dist1 =
|
|
153
|
+
torch::zeros({batch_size, n}, torch::CUDA(torch::kFloat));
|
|
154
|
+
torch::Tensor dist2 =
|
|
155
|
+
torch::zeros({batch_size, m}, torch::CUDA(torch::kFloat));
|
|
156
|
+
torch::Tensor idx1 = torch::zeros({batch_size, n}, torch::CUDA(torch::kInt));
|
|
157
|
+
torch::Tensor idx2 = torch::zeros({batch_size, m}, torch::CUDA(torch::kInt));
|
|
158
|
+
|
|
159
|
+
chamfer_dist_kernel<<<dim3(32, 16, 1), 512>>>(
|
|
160
|
+
batch_size, n, xyz1.data_ptr<float>(), m, xyz2.data_ptr<float>(),
|
|
161
|
+
dist1.data_ptr<float>(), idx1.data_ptr<int>());
|
|
162
|
+
chamfer_dist_kernel<<<dim3(32, 16, 1), 512>>>(
|
|
163
|
+
batch_size, m, xyz2.data_ptr<float>(), n, xyz1.data_ptr<float>(),
|
|
164
|
+
dist2.data_ptr<float>(), idx2.data_ptr<int>());
|
|
165
|
+
|
|
166
|
+
cudaError_t err = cudaGetLastError();
|
|
167
|
+
if (err != cudaSuccess) {
|
|
168
|
+
printf("Error in chamfer_cuda_forward: %s\n", cudaGetErrorString(err));
|
|
169
|
+
}
|
|
170
|
+
return {dist1, dist2, idx1, idx2};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
__global__ void chamfer_dist_grad_kernel(int b,
|
|
174
|
+
int n,
|
|
175
|
+
const float* xyz1,
|
|
176
|
+
int m,
|
|
177
|
+
const float* xyz2,
|
|
178
|
+
const float* grad_dist1,
|
|
179
|
+
const int* idx1,
|
|
180
|
+
float* grad_xyz1,
|
|
181
|
+
float* grad_xyz2) {
|
|
182
|
+
for (int i = blockIdx.x; i < b; i += gridDim.x) {
|
|
183
|
+
for (int j = threadIdx.x + blockIdx.y * blockDim.x; j < n;
|
|
184
|
+
j += blockDim.x * gridDim.y) {
|
|
185
|
+
float x1 = xyz1[(i * n + j) * 3 + 0];
|
|
186
|
+
float y1 = xyz1[(i * n + j) * 3 + 1];
|
|
187
|
+
float z1 = xyz1[(i * n + j) * 3 + 2];
|
|
188
|
+
int j2 = idx1[i * n + j];
|
|
189
|
+
float x2 = xyz2[(i * m + j2) * 3 + 0];
|
|
190
|
+
float y2 = xyz2[(i * m + j2) * 3 + 1];
|
|
191
|
+
float z2 = xyz2[(i * m + j2) * 3 + 2];
|
|
192
|
+
float g = grad_dist1[i * n + j] * 2;
|
|
193
|
+
atomicAdd(&(grad_xyz1[(i * n + j) * 3 + 0]), g * (x1 - x2));
|
|
194
|
+
atomicAdd(&(grad_xyz1[(i * n + j) * 3 + 1]), g * (y1 - y2));
|
|
195
|
+
atomicAdd(&(grad_xyz1[(i * n + j) * 3 + 2]), g * (z1 - z2));
|
|
196
|
+
atomicAdd(&(grad_xyz2[(i * m + j2) * 3 + 0]), -(g * (x1 - x2)));
|
|
197
|
+
atomicAdd(&(grad_xyz2[(i * m + j2) * 3 + 1]), -(g * (y1 - y2)));
|
|
198
|
+
atomicAdd(&(grad_xyz2[(i * m + j2) * 3 + 2]), -(g * (z1 - z2)));
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
std::vector<torch::Tensor> chamfer_cuda_backward(torch::Tensor xyz1,
|
|
204
|
+
torch::Tensor xyz2,
|
|
205
|
+
torch::Tensor idx1,
|
|
206
|
+
torch::Tensor idx2,
|
|
207
|
+
torch::Tensor grad_dist1,
|
|
208
|
+
torch::Tensor grad_dist2) {
|
|
209
|
+
const int batch_size = xyz1.size(0);
|
|
210
|
+
const int n = xyz1.size(1); // num_points point cloud A
|
|
211
|
+
const int m = xyz2.size(1); // num_points point cloud B
|
|
212
|
+
torch::Tensor grad_xyz1 = torch::zeros_like(xyz1, torch::CUDA(torch::kFloat));
|
|
213
|
+
torch::Tensor grad_xyz2 = torch::zeros_like(xyz2, torch::CUDA(torch::kFloat));
|
|
214
|
+
|
|
215
|
+
chamfer_dist_grad_kernel<<<dim3(1, 16, 1), 256>>>(
|
|
216
|
+
batch_size, n, xyz1.data_ptr<float>(), m, xyz2.data_ptr<float>(),
|
|
217
|
+
grad_dist1.data_ptr<float>(), idx1.data_ptr<int>(),
|
|
218
|
+
grad_xyz1.data_ptr<float>(), grad_xyz2.data_ptr<float>());
|
|
219
|
+
chamfer_dist_grad_kernel<<<dim3(1, 16, 1), 256>>>(
|
|
220
|
+
batch_size, m, xyz2.data_ptr<float>(), n, xyz1.data_ptr<float>(),
|
|
221
|
+
grad_dist2.data_ptr<float>(), idx2.data_ptr<int>(),
|
|
222
|
+
grad_xyz2.data_ptr<float>(), grad_xyz1.data_ptr<float>());
|
|
223
|
+
|
|
224
|
+
cudaError_t err = cudaGetLastError();
|
|
225
|
+
if (err != cudaSuccess) {
|
|
226
|
+
printf("Error in chamfer_cuda_backward: %s\n", cudaGetErrorString(err));
|
|
227
|
+
}
|
|
228
|
+
return {grad_xyz1, grad_xyz2};
|
|
229
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: Haozhe Xie
|
|
3
|
+
* @Date: 2019-08-07 20:54:24
|
|
4
|
+
* @Last Modified by: Haozhe Xie
|
|
5
|
+
* @Last Modified time: 2019-12-10 10:33:50
|
|
6
|
+
* @Email: cshzxie@gmail.com
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#include <torch/extension.h>
|
|
10
|
+
#include <vector>
|
|
11
|
+
|
|
12
|
+
std::vector<torch::Tensor> chamfer_cuda_forward(torch::Tensor xyz1,
|
|
13
|
+
torch::Tensor xyz2);
|
|
14
|
+
|
|
15
|
+
std::vector<torch::Tensor> chamfer_cuda_backward(torch::Tensor xyz1,
|
|
16
|
+
torch::Tensor xyz2,
|
|
17
|
+
torch::Tensor idx1,
|
|
18
|
+
torch::Tensor idx2,
|
|
19
|
+
torch::Tensor grad_dist1,
|
|
20
|
+
torch::Tensor grad_dist2);
|
|
21
|
+
|
|
22
|
+
std::vector<torch::Tensor> chamfer_forward(torch::Tensor xyz1,
|
|
23
|
+
torch::Tensor xyz2) {
|
|
24
|
+
return chamfer_cuda_forward(xyz1, xyz2);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
std::vector<torch::Tensor> chamfer_backward(torch::Tensor xyz1,
|
|
28
|
+
torch::Tensor xyz2,
|
|
29
|
+
torch::Tensor idx1,
|
|
30
|
+
torch::Tensor idx2,
|
|
31
|
+
torch::Tensor grad_dist1,
|
|
32
|
+
torch::Tensor grad_dist2) {
|
|
33
|
+
return chamfer_cuda_backward(xyz1, xyz2, idx1, idx2, grad_dist1, grad_dist2);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
|
|
37
|
+
m.def("forward", &chamfer_forward, "Chamfer forward (CUDA)");
|
|
38
|
+
m.def("backward", &chamfer_backward, "Chamfer backward (CUDA)");
|
|
39
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# @Author: Haozhe Xie
|
|
3
|
+
# @Date: 2019-08-07 20:54:24
|
|
4
|
+
# @Last Modified by: Haozhe Xie
|
|
5
|
+
# @Last Modified time: 2019-12-10 10:04:25
|
|
6
|
+
# @Email: cshzxie@gmail.com
|
|
7
|
+
|
|
8
|
+
from setuptools import setup
|
|
9
|
+
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
|
|
10
|
+
|
|
11
|
+
setup(name='chamfer',
|
|
12
|
+
version='2.0.0',
|
|
13
|
+
ext_modules=[
|
|
14
|
+
CUDAExtension('chamfer', [
|
|
15
|
+
'chamfer_cuda.cpp',
|
|
16
|
+
'chamfer.cu',
|
|
17
|
+
]),
|
|
18
|
+
],
|
|
19
|
+
cmdclass={'build_ext': BuildExtension})
|