openpoints 0.1.0__py3-none-any.whl

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.
Files changed (184) hide show
  1. openpoints/__init__.py +3 -0
  2. openpoints/cpp/__init__.py +6 -0
  3. openpoints/cpp/chamfer_dist/__init__.py +110 -0
  4. openpoints/cpp/chamfer_dist/setup.py +19 -0
  5. openpoints/cpp/chamfer_dist/test.py +34 -0
  6. openpoints/cpp/emd/__init__.py +3 -0
  7. openpoints/cpp/emd/emd.py +88 -0
  8. openpoints/cpp/emd/setup.py +27 -0
  9. openpoints/cpp/emd/test_emd_loss.py +45 -0
  10. openpoints/cpp/pointnet2_batch/__init__.py +24 -0
  11. openpoints/cpp/pointnet2_batch/setup.py +23 -0
  12. openpoints/cpp/pointops/__init__.py +0 -0
  13. openpoints/cpp/pointops/functions/__init__.py +0 -0
  14. openpoints/cpp/pointops/functions/pointops.py +314 -0
  15. openpoints/cpp/pointops/setup.py +37 -0
  16. openpoints/cpp/pointops/src/__init__.py +0 -0
  17. openpoints/dataset/__init__.py +10 -0
  18. openpoints/dataset/atom3d/__init__.py +1 -0
  19. openpoints/dataset/atom3d/psr.py +38 -0
  20. openpoints/dataset/build.py +98 -0
  21. openpoints/dataset/data_util.py +192 -0
  22. openpoints/dataset/datalist.py +67 -0
  23. openpoints/dataset/dataset_base.py +96 -0
  24. openpoints/dataset/graph_dataset/__init__.py +3 -0
  25. openpoints/dataset/graph_dataset/graph_dataset.py +93 -0
  26. openpoints/dataset/graph_dataset/stack_with_pad.py +91 -0
  27. openpoints/dataset/graph_dataset/structural_dataset.py +73 -0
  28. openpoints/dataset/graph_dataset/svd_encodings_dataset.py +110 -0
  29. openpoints/dataset/grid_sample.py +21 -0
  30. openpoints/dataset/matterport3d/__init__.py +1 -0
  31. openpoints/dataset/matterport3d/category_mapping.tsv +1660 -0
  32. openpoints/dataset/matterport3d/matterport3d.py +210 -0
  33. openpoints/dataset/matterport3d/matterport3d_dataprocessing.py +105 -0
  34. openpoints/dataset/modelnet/__init__.py +3 -0
  35. openpoints/dataset/modelnet/modelnet40_normal_resampled_loader.py +124 -0
  36. openpoints/dataset/modelnet/modelnet40_ply_2048_loader.py +160 -0
  37. openpoints/dataset/molhiv/__init__.py +1 -0
  38. openpoints/dataset/molhiv/data.py +59 -0
  39. openpoints/dataset/molpcba/__init__.py +1 -0
  40. openpoints/dataset/molpcba/data.py +59 -0
  41. openpoints/dataset/parsers/__init__.py +1 -0
  42. openpoints/dataset/parsers/class_map.py +19 -0
  43. openpoints/dataset/parsers/constants.py +1 -0
  44. openpoints/dataset/parsers/parser.py +17 -0
  45. openpoints/dataset/parsers/parser_factory.py +29 -0
  46. openpoints/dataset/parsers/parser_image_folder.py +69 -0
  47. openpoints/dataset/parsers/parser_image_in_tar.py +222 -0
  48. openpoints/dataset/parsers/parser_image_tar.py +72 -0
  49. openpoints/dataset/parsers/parser_tfds.py +297 -0
  50. openpoints/dataset/pcqm4m/__init__.py +1 -0
  51. openpoints/dataset/pcqm4m/data.py +62 -0
  52. openpoints/dataset/pcqm4mv2/__init__.py +1 -0
  53. openpoints/dataset/pcqm4mv2/data.py +87 -0
  54. openpoints/dataset/s3dis/__init__.py +2 -0
  55. openpoints/dataset/s3dis/s3dis.py +156 -0
  56. openpoints/dataset/s3dis/s3dis_block.py +96 -0
  57. openpoints/dataset/s3dis/s3dis_sphere.py +349 -0
  58. openpoints/dataset/scannetv2/__init__.py +1 -0
  59. openpoints/dataset/scannetv2/scannet.py +176 -0
  60. openpoints/dataset/scanobjectnn/__init__.py +3 -0
  61. openpoints/dataset/scanobjectnn/scanobjectnn.py +110 -0
  62. openpoints/dataset/semantic_kitti/__init__.py +1 -0
  63. openpoints/dataset/semantic_kitti/helper_tool.py +286 -0
  64. openpoints/dataset/semantic_kitti/label_mapping.yaml +211 -0
  65. openpoints/dataset/semantic_kitti/semantickitti.py +229 -0
  66. openpoints/dataset/semantic_kitti/utils/meta/anno_paths.txt +272 -0
  67. openpoints/dataset/semantic_kitti/utils/meta/class_names.txt +13 -0
  68. openpoints/dataset/semantic_kitti/utils/semantic-kitti.yaml +211 -0
  69. openpoints/dataset/shapenet/__init__.py +1 -0
  70. openpoints/dataset/shapenet/shapenet55.py +76 -0
  71. openpoints/dataset/shapenet/shapenetpart.py +121 -0
  72. openpoints/dataset/shapenetpart/__init__.py +1 -0
  73. openpoints/dataset/shapenetpart/shapenet55.py +75 -0
  74. openpoints/dataset/shapenetpart/shapenetpart.py +388 -0
  75. openpoints/dataset/vis2d.py +17 -0
  76. openpoints/dataset/vis3d.py +153 -0
  77. openpoints/loss/__init__.py +3 -0
  78. openpoints/loss/build.py +281 -0
  79. openpoints/loss/cross_entropy.py +38 -0
  80. openpoints/loss/distill_loss.py +76 -0
  81. openpoints/models/__init__.py +10 -0
  82. openpoints/models/backbone/Stratified_transformer.py +558 -0
  83. openpoints/models/backbone/__init__.py +11 -0
  84. openpoints/models/backbone/baafnet.py +527 -0
  85. openpoints/models/backbone/ball_dgcnn.py +123 -0
  86. openpoints/models/backbone/curvenet.py +793 -0
  87. openpoints/models/backbone/debug_invvit.py +114 -0
  88. openpoints/models/backbone/deepgcn.py +143 -0
  89. openpoints/models/backbone/dgcnn.py +119 -0
  90. openpoints/models/backbone/graphvit3d.py +134 -0
  91. openpoints/models/backbone/grouppointnet.py +100 -0
  92. openpoints/models/backbone/pct.py +163 -0
  93. openpoints/models/backbone/pointmlp.py +417 -0
  94. openpoints/models/backbone/pointnet.py +199 -0
  95. openpoints/models/backbone/pointnetv2.py +511 -0
  96. openpoints/models/backbone/pointnext.py +663 -0
  97. openpoints/models/backbone/pointnextPyG.py +555 -0
  98. openpoints/models/backbone/pointtransformer.py +293 -0
  99. openpoints/models/backbone/pointvector.py +853 -0
  100. openpoints/models/backbone/pointvit.py +392 -0
  101. openpoints/models/backbone/pointvit_inv.py +942 -0
  102. openpoints/models/backbone/pointvit_inv_old.py +784 -0
  103. openpoints/models/backbone/randlenet.py +318 -0
  104. openpoints/models/backbone/resnet.py +342 -0
  105. openpoints/models/backbone/simpleview.py +153 -0
  106. openpoints/models/backbone/simpleview_util.py +292 -0
  107. openpoints/models/build.py +13 -0
  108. openpoints/models/classification/__init__.py +5 -0
  109. openpoints/models/classification/cls_base.py +136 -0
  110. openpoints/models/classification/point_bert.py +154 -0
  111. openpoints/models/layers/__init__.py +14 -0
  112. openpoints/models/layers/activation.py +57 -0
  113. openpoints/models/layers/attention.py +103 -0
  114. openpoints/models/layers/conv.py +167 -0
  115. openpoints/models/layers/drop.py +164 -0
  116. openpoints/models/layers/graph_conv.py +122 -0
  117. openpoints/models/layers/group.py +415 -0
  118. openpoints/models/layers/group_embed.py +286 -0
  119. openpoints/models/layers/helpers.py +43 -0
  120. openpoints/models/layers/kmeans.py +119 -0
  121. openpoints/models/layers/knn.py +110 -0
  122. openpoints/models/layers/local_aggregation.py +286 -0
  123. openpoints/models/layers/mlp.py +129 -0
  124. openpoints/models/layers/norm.py +106 -0
  125. openpoints/models/layers/padding.py +56 -0
  126. openpoints/models/layers/patch_embed.py +37 -0
  127. openpoints/models/layers/registry.py +168 -0
  128. openpoints/models/layers/subsample.py +185 -0
  129. openpoints/models/layers/upsampling.py +106 -0
  130. openpoints/models/layers/weight_init.py +89 -0
  131. openpoints/models/reconstruction/__init__.py +8 -0
  132. openpoints/models/reconstruction/base_recontruct.py +216 -0
  133. openpoints/models/reconstruction/maskedpoint.py +116 -0
  134. openpoints/models/reconstruction/maskedpointgroup.py +168 -0
  135. openpoints/models/reconstruction/maskedpointvit.py +253 -0
  136. openpoints/models/reconstruction/nodeshuffle.py +11 -0
  137. openpoints/models/registry.py +149 -0
  138. openpoints/models/segmentation/__init__.py +6 -0
  139. openpoints/models/segmentation/base_seg.py +278 -0
  140. openpoints/models/segmentation/vit_seg.py +126 -0
  141. openpoints/optim/__init__.py +15 -0
  142. openpoints/optim/adabelief.py +201 -0
  143. openpoints/optim/adafactor.py +167 -0
  144. openpoints/optim/adahessian.py +156 -0
  145. openpoints/optim/adamp.py +105 -0
  146. openpoints/optim/adamw.py +122 -0
  147. openpoints/optim/lamb.py +192 -0
  148. openpoints/optim/lars.py +135 -0
  149. openpoints/optim/lookahead.py +61 -0
  150. openpoints/optim/madgrad.py +184 -0
  151. openpoints/optim/nadam.py +92 -0
  152. openpoints/optim/nvnovograd.py +120 -0
  153. openpoints/optim/optim_factory.py +306 -0
  154. openpoints/optim/radam.py +89 -0
  155. openpoints/optim/rmsprop_tf.py +139 -0
  156. openpoints/optim/sgdp.py +70 -0
  157. openpoints/scheduler/__init__.py +8 -0
  158. openpoints/scheduler/cosine_lr.py +124 -0
  159. openpoints/scheduler/multistep_lr.py +65 -0
  160. openpoints/scheduler/plateau_lr.py +113 -0
  161. openpoints/scheduler/poly_lr.py +116 -0
  162. openpoints/scheduler/scheduler.py +110 -0
  163. openpoints/scheduler/scheduler_factory.py +118 -0
  164. openpoints/scheduler/step_lr.py +65 -0
  165. openpoints/scheduler/tanh_lr.py +117 -0
  166. openpoints/transforms/__init__.py +7 -0
  167. openpoints/transforms/point_transform_cpu.py +332 -0
  168. openpoints/transforms/point_transformer_gpu.py +764 -0
  169. openpoints/transforms/transforms_factory.py +60 -0
  170. openpoints/utils/__init__.py +8 -0
  171. openpoints/utils/ckpt_util.py +438 -0
  172. openpoints/utils/config.py +113 -0
  173. openpoints/utils/dist_utils.py +54 -0
  174. openpoints/utils/logger.py +170 -0
  175. openpoints/utils/metrics.py +311 -0
  176. openpoints/utils/random.py +16 -0
  177. openpoints/utils/registry.py +294 -0
  178. openpoints/utils/str2bool.py +11 -0
  179. openpoints/utils/wandb.py +88 -0
  180. openpoints-0.1.0.dist-info/METADATA +150 -0
  181. openpoints-0.1.0.dist-info/RECORD +184 -0
  182. openpoints-0.1.0.dist-info/WHEEL +5 -0
  183. openpoints-0.1.0.dist-info/licenses/LICENSE +21 -0
  184. openpoints-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,110 @@
1
+
2
+ import numpy as np
3
+ import torch
4
+ from tqdm import trange
5
+ import numba as nb
6
+
7
+ from .graph_dataset import GraphDataset
8
+
9
+ class SVDEncodingsDatasetBase:
10
+ def __init__(self,
11
+ svd_encodings_key = 'svd_encodings',
12
+ calculated_dim = 8,
13
+ output_dim = 8,
14
+ random_neg_splits = ['training'],
15
+ **kwargs):
16
+ if output_dim > calculated_dim:
17
+ raise ValueError('SVD: output_dim > calculated_dim')
18
+ super().__init__(**kwargs)
19
+ self.svd_encodings_key = svd_encodings_key
20
+ self.calculated_dim = calculated_dim
21
+ self.output_dim = output_dim
22
+ self.random_neg_splits = random_neg_splits
23
+
24
+ def calculate_encodings(self, item):
25
+ raise NotImplementedError('SVDEncodingsDatasetBase.calculate_encodings()')
26
+
27
+ def __getitem__(self, index):
28
+ item = super().__getitem__(index)
29
+ token = self.record_tokens[index]
30
+
31
+ try:
32
+ encodings = self._svd_encodings[token]
33
+ except AttributeError:
34
+ encodings = self.calculate_encodings(item)
35
+ self._svd_encodings = {token:encodings}
36
+ except KeyError:
37
+ encodings = self.calculate_encodings(item)
38
+ self._svd_encodings[token] = encodings
39
+
40
+ if self.output_dim < self.calculated_dim:
41
+ encodings = encodings[:,:self.output_dim,:]
42
+
43
+ if self.split in self.random_neg_splits:
44
+ rn_factors = np.random.randint(0, high=2, size=(encodings.shape[1],1))*2-1 #size=(encodings.shape[0],1,1)
45
+ encodings = encodings * rn_factors.astype(encodings.dtype)
46
+
47
+ item[self.svd_encodings_key] = encodings.reshape(encodings.shape[0],-1)
48
+ return item
49
+
50
+ def calculate_all_svd_encodings(self,verbose=1):
51
+ self._svd_encodings = {}
52
+ if verbose:
53
+ print(f'Calculating all {self.split} SVD encodings...', flush=True)
54
+ for index in trange(super().__len__()):
55
+ item = super().__getitem__(index)
56
+ token = self.record_tokens[index]
57
+ self._svd_encodings[token] = self.calculate_encodings(item)
58
+ else:
59
+ for index in range(super().__len__()):
60
+ item = super().__getitem__(index)
61
+ token = self.record_tokens[index]
62
+ self._svd_encodings[token] = self.calculate_encodings(item)
63
+
64
+ def cache_load_and_save(self, base_path, op, verbose):
65
+ super().cache_load_and_save(base_path, op, verbose)
66
+ svd_encodings_path = base_path/'svd_encodings.pt'
67
+
68
+ if op == 'load':
69
+ self._svd_encodings = torch.load(str(svd_encodings_path))
70
+ elif op == 'save':
71
+ if verbose: print(f'{self.split} SVD encodings cache does not exist! Cacheing...', flush=True)
72
+ self.calculate_all_svd_encodings(verbose=verbose)
73
+ torch.save(self._svd_encodings, str(svd_encodings_path))
74
+ if verbose: print(f'Saved {self.split} SVD encodings cache to disk.', flush=True)
75
+ else:
76
+ raise ValueError(f'Unknown operation: {op}')
77
+
78
+
79
+ @nb.njit
80
+ def calculate_svd_encodings(edges, num_nodes, calculated_dim):
81
+ adj = np.zeros((num_nodes,num_nodes),dtype=np.float32)
82
+ for i in range(edges.shape[0]):
83
+ adj[nb.int64(edges[i,0]),nb.int64(edges[i,1])] = 1
84
+
85
+ for i in range(num_nodes):
86
+ adj[i,i] = 1
87
+ u, s, vh = np.linalg.svd(adj)
88
+
89
+ if calculated_dim < num_nodes:
90
+ s = s[:calculated_dim]
91
+ u = u[:,:calculated_dim]
92
+ vh = vh[:calculated_dim,:]
93
+
94
+ encodings = np.stack((u,vh.T),axis=-1) * np.expand_dims(np.sqrt(s), axis=-1)
95
+ elif calculated_dim > num_nodes:
96
+ z = np.zeros((num_nodes,calculated_dim-num_nodes,2),dtype=np.float32)
97
+ encodings = np.concatenate((np.stack((u,vh.T),axis=-1) * np.expand_dims(np.sqrt(s), axis=-1), z), axis=1)
98
+ else:
99
+ encodings = np.stack((u,vh.T),axis=-1) * np.expand_dims(np.sqrt(s), axis=-1)
100
+ return encodings
101
+
102
+
103
+ class SVDEncodingsGraphDataset(SVDEncodingsDatasetBase, GraphDataset):
104
+ def calculate_encodings(self, item):
105
+ num_nodes = int(item[self.num_nodes_key])
106
+ edges = item[self.edges_key]
107
+ encodings = calculate_svd_encodings(edges, num_nodes, self.calculated_dim)
108
+ return encodings
109
+
110
+
@@ -0,0 +1,21 @@
1
+ import openpoints.cpp.subsampling.grid_subsampling as cpp_subsampling
2
+
3
+
4
+ def grid_subsampling(points, features=None, labels=None, sampleDl=0.1, verbose=0):
5
+ """
6
+ CPP wrapper for a grid subsampling (method = barycenter for points and features
7
+ :param points: (N, 3) matrix of input points
8
+ :param features: optional (N, d) matrix of features (floating number)
9
+ :param labels: optional (N,) matrix of integer labels
10
+ :param sampleDl: parameter defining the size of grid voxels
11
+ :param verbose: 1 to display
12
+ :return: subsampled points, with features and/or labels depending of the input
13
+ """
14
+ if (features is None) and (labels is None):
15
+ return cpp_subsampling.compute(points, sampleDl=sampleDl, verbose=verbose)
16
+ elif (labels is None):
17
+ return cpp_subsampling.compute(points, features=features, sampleDl=sampleDl, verbose=verbose)
18
+ elif (features is None):
19
+ return cpp_subsampling.compute(points, classes=labels, sampleDl=sampleDl, verbose=verbose)
20
+ else:
21
+ return cpp_subsampling.compute(points, features=features, classes=labels, sampleDl=sampleDl, verbose=verbose)
@@ -0,0 +1 @@
1
+ from .matterport3d import MP40