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.
- openpoints/__init__.py +3 -0
- openpoints/cpp/__init__.py +6 -0
- openpoints/cpp/chamfer_dist/__init__.py +110 -0
- openpoints/cpp/chamfer_dist/setup.py +19 -0
- openpoints/cpp/chamfer_dist/test.py +34 -0
- openpoints/cpp/emd/__init__.py +3 -0
- openpoints/cpp/emd/emd.py +88 -0
- openpoints/cpp/emd/setup.py +27 -0
- openpoints/cpp/emd/test_emd_loss.py +45 -0
- openpoints/cpp/pointnet2_batch/__init__.py +24 -0
- openpoints/cpp/pointnet2_batch/setup.py +23 -0
- openpoints/cpp/pointops/__init__.py +0 -0
- openpoints/cpp/pointops/functions/__init__.py +0 -0
- openpoints/cpp/pointops/functions/pointops.py +314 -0
- openpoints/cpp/pointops/setup.py +37 -0
- openpoints/cpp/pointops/src/__init__.py +0 -0
- openpoints/dataset/__init__.py +10 -0
- openpoints/dataset/atom3d/__init__.py +1 -0
- openpoints/dataset/atom3d/psr.py +38 -0
- openpoints/dataset/build.py +98 -0
- openpoints/dataset/data_util.py +192 -0
- openpoints/dataset/datalist.py +67 -0
- openpoints/dataset/dataset_base.py +96 -0
- openpoints/dataset/graph_dataset/__init__.py +3 -0
- openpoints/dataset/graph_dataset/graph_dataset.py +93 -0
- openpoints/dataset/graph_dataset/stack_with_pad.py +91 -0
- openpoints/dataset/graph_dataset/structural_dataset.py +73 -0
- openpoints/dataset/graph_dataset/svd_encodings_dataset.py +110 -0
- openpoints/dataset/grid_sample.py +21 -0
- openpoints/dataset/matterport3d/__init__.py +1 -0
- openpoints/dataset/matterport3d/category_mapping.tsv +1660 -0
- openpoints/dataset/matterport3d/matterport3d.py +210 -0
- openpoints/dataset/matterport3d/matterport3d_dataprocessing.py +105 -0
- openpoints/dataset/modelnet/__init__.py +3 -0
- openpoints/dataset/modelnet/modelnet40_normal_resampled_loader.py +124 -0
- openpoints/dataset/modelnet/modelnet40_ply_2048_loader.py +160 -0
- openpoints/dataset/molhiv/__init__.py +1 -0
- openpoints/dataset/molhiv/data.py +59 -0
- openpoints/dataset/molpcba/__init__.py +1 -0
- openpoints/dataset/molpcba/data.py +59 -0
- openpoints/dataset/parsers/__init__.py +1 -0
- openpoints/dataset/parsers/class_map.py +19 -0
- openpoints/dataset/parsers/constants.py +1 -0
- openpoints/dataset/parsers/parser.py +17 -0
- openpoints/dataset/parsers/parser_factory.py +29 -0
- openpoints/dataset/parsers/parser_image_folder.py +69 -0
- openpoints/dataset/parsers/parser_image_in_tar.py +222 -0
- openpoints/dataset/parsers/parser_image_tar.py +72 -0
- openpoints/dataset/parsers/parser_tfds.py +297 -0
- openpoints/dataset/pcqm4m/__init__.py +1 -0
- openpoints/dataset/pcqm4m/data.py +62 -0
- openpoints/dataset/pcqm4mv2/__init__.py +1 -0
- openpoints/dataset/pcqm4mv2/data.py +87 -0
- openpoints/dataset/s3dis/__init__.py +2 -0
- openpoints/dataset/s3dis/s3dis.py +156 -0
- openpoints/dataset/s3dis/s3dis_block.py +96 -0
- openpoints/dataset/s3dis/s3dis_sphere.py +349 -0
- openpoints/dataset/scannetv2/__init__.py +1 -0
- openpoints/dataset/scannetv2/scannet.py +176 -0
- openpoints/dataset/scanobjectnn/__init__.py +3 -0
- openpoints/dataset/scanobjectnn/scanobjectnn.py +110 -0
- openpoints/dataset/semantic_kitti/__init__.py +1 -0
- openpoints/dataset/semantic_kitti/helper_tool.py +286 -0
- openpoints/dataset/semantic_kitti/label_mapping.yaml +211 -0
- openpoints/dataset/semantic_kitti/semantickitti.py +229 -0
- openpoints/dataset/semantic_kitti/utils/meta/anno_paths.txt +272 -0
- openpoints/dataset/semantic_kitti/utils/meta/class_names.txt +13 -0
- openpoints/dataset/semantic_kitti/utils/semantic-kitti.yaml +211 -0
- openpoints/dataset/shapenet/__init__.py +1 -0
- openpoints/dataset/shapenet/shapenet55.py +76 -0
- openpoints/dataset/shapenet/shapenetpart.py +121 -0
- openpoints/dataset/shapenetpart/__init__.py +1 -0
- openpoints/dataset/shapenetpart/shapenet55.py +75 -0
- openpoints/dataset/shapenetpart/shapenetpart.py +388 -0
- openpoints/dataset/vis2d.py +17 -0
- openpoints/dataset/vis3d.py +153 -0
- openpoints/loss/__init__.py +3 -0
- openpoints/loss/build.py +281 -0
- openpoints/loss/cross_entropy.py +38 -0
- openpoints/loss/distill_loss.py +76 -0
- openpoints/models/__init__.py +10 -0
- openpoints/models/backbone/Stratified_transformer.py +558 -0
- openpoints/models/backbone/__init__.py +11 -0
- openpoints/models/backbone/baafnet.py +527 -0
- openpoints/models/backbone/ball_dgcnn.py +123 -0
- openpoints/models/backbone/curvenet.py +793 -0
- openpoints/models/backbone/debug_invvit.py +114 -0
- openpoints/models/backbone/deepgcn.py +143 -0
- openpoints/models/backbone/dgcnn.py +119 -0
- openpoints/models/backbone/graphvit3d.py +134 -0
- openpoints/models/backbone/grouppointnet.py +100 -0
- openpoints/models/backbone/pct.py +163 -0
- openpoints/models/backbone/pointmlp.py +417 -0
- openpoints/models/backbone/pointnet.py +199 -0
- openpoints/models/backbone/pointnetv2.py +511 -0
- openpoints/models/backbone/pointnext.py +663 -0
- openpoints/models/backbone/pointnextPyG.py +555 -0
- openpoints/models/backbone/pointtransformer.py +293 -0
- openpoints/models/backbone/pointvector.py +853 -0
- openpoints/models/backbone/pointvit.py +392 -0
- openpoints/models/backbone/pointvit_inv.py +942 -0
- openpoints/models/backbone/pointvit_inv_old.py +784 -0
- openpoints/models/backbone/randlenet.py +318 -0
- openpoints/models/backbone/resnet.py +342 -0
- openpoints/models/backbone/simpleview.py +153 -0
- openpoints/models/backbone/simpleview_util.py +292 -0
- openpoints/models/build.py +13 -0
- openpoints/models/classification/__init__.py +5 -0
- openpoints/models/classification/cls_base.py +136 -0
- openpoints/models/classification/point_bert.py +154 -0
- openpoints/models/layers/__init__.py +14 -0
- openpoints/models/layers/activation.py +57 -0
- openpoints/models/layers/attention.py +103 -0
- openpoints/models/layers/conv.py +167 -0
- openpoints/models/layers/drop.py +164 -0
- openpoints/models/layers/graph_conv.py +122 -0
- openpoints/models/layers/group.py +415 -0
- openpoints/models/layers/group_embed.py +286 -0
- openpoints/models/layers/helpers.py +43 -0
- openpoints/models/layers/kmeans.py +119 -0
- openpoints/models/layers/knn.py +110 -0
- openpoints/models/layers/local_aggregation.py +286 -0
- openpoints/models/layers/mlp.py +129 -0
- openpoints/models/layers/norm.py +106 -0
- openpoints/models/layers/padding.py +56 -0
- openpoints/models/layers/patch_embed.py +37 -0
- openpoints/models/layers/registry.py +168 -0
- openpoints/models/layers/subsample.py +185 -0
- openpoints/models/layers/upsampling.py +106 -0
- openpoints/models/layers/weight_init.py +89 -0
- openpoints/models/reconstruction/__init__.py +8 -0
- openpoints/models/reconstruction/base_recontruct.py +216 -0
- openpoints/models/reconstruction/maskedpoint.py +116 -0
- openpoints/models/reconstruction/maskedpointgroup.py +168 -0
- openpoints/models/reconstruction/maskedpointvit.py +253 -0
- openpoints/models/reconstruction/nodeshuffle.py +11 -0
- openpoints/models/registry.py +149 -0
- openpoints/models/segmentation/__init__.py +6 -0
- openpoints/models/segmentation/base_seg.py +278 -0
- openpoints/models/segmentation/vit_seg.py +126 -0
- openpoints/optim/__init__.py +15 -0
- openpoints/optim/adabelief.py +201 -0
- openpoints/optim/adafactor.py +167 -0
- openpoints/optim/adahessian.py +156 -0
- openpoints/optim/adamp.py +105 -0
- openpoints/optim/adamw.py +122 -0
- openpoints/optim/lamb.py +192 -0
- openpoints/optim/lars.py +135 -0
- openpoints/optim/lookahead.py +61 -0
- openpoints/optim/madgrad.py +184 -0
- openpoints/optim/nadam.py +92 -0
- openpoints/optim/nvnovograd.py +120 -0
- openpoints/optim/optim_factory.py +306 -0
- openpoints/optim/radam.py +89 -0
- openpoints/optim/rmsprop_tf.py +139 -0
- openpoints/optim/sgdp.py +70 -0
- openpoints/scheduler/__init__.py +8 -0
- openpoints/scheduler/cosine_lr.py +124 -0
- openpoints/scheduler/multistep_lr.py +65 -0
- openpoints/scheduler/plateau_lr.py +113 -0
- openpoints/scheduler/poly_lr.py +116 -0
- openpoints/scheduler/scheduler.py +110 -0
- openpoints/scheduler/scheduler_factory.py +118 -0
- openpoints/scheduler/step_lr.py +65 -0
- openpoints/scheduler/tanh_lr.py +117 -0
- openpoints/transforms/__init__.py +7 -0
- openpoints/transforms/point_transform_cpu.py +332 -0
- openpoints/transforms/point_transformer_gpu.py +764 -0
- openpoints/transforms/transforms_factory.py +60 -0
- openpoints/utils/__init__.py +8 -0
- openpoints/utils/ckpt_util.py +438 -0
- openpoints/utils/config.py +113 -0
- openpoints/utils/dist_utils.py +54 -0
- openpoints/utils/logger.py +170 -0
- openpoints/utils/metrics.py +311 -0
- openpoints/utils/random.py +16 -0
- openpoints/utils/registry.py +294 -0
- openpoints/utils/str2bool.py +11 -0
- openpoints/utils/wandb.py +88 -0
- openpoints-0.1.0.dist-info/METADATA +150 -0
- openpoints-0.1.0.dist-info/RECORD +184 -0
- openpoints-0.1.0.dist-info/WHEEL +5 -0
- openpoints-0.1.0.dist-info/licenses/LICENSE +21 -0
- 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
|