pyg-nightly 2.7.0.dev20241009__py3-none-any.whl → 2.8.0.dev20251228__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 (229) hide show
  1. {pyg_nightly-2.7.0.dev20241009.dist-info → pyg_nightly-2.8.0.dev20251228.dist-info}/METADATA +77 -53
  2. {pyg_nightly-2.7.0.dev20241009.dist-info → pyg_nightly-2.8.0.dev20251228.dist-info}/RECORD +227 -190
  3. {pyg_nightly-2.7.0.dev20241009.dist-info → pyg_nightly-2.8.0.dev20251228.dist-info}/WHEEL +1 -1
  4. pyg_nightly-2.8.0.dev20251228.dist-info/licenses/LICENSE +19 -0
  5. torch_geometric/__init__.py +14 -2
  6. torch_geometric/_compile.py +9 -3
  7. torch_geometric/_onnx.py +214 -0
  8. torch_geometric/config_mixin.py +5 -3
  9. torch_geometric/config_store.py +1 -1
  10. torch_geometric/contrib/__init__.py +1 -1
  11. torch_geometric/contrib/explain/pgm_explainer.py +1 -1
  12. torch_geometric/data/batch.py +2 -2
  13. torch_geometric/data/collate.py +1 -3
  14. torch_geometric/data/data.py +109 -5
  15. torch_geometric/data/database.py +4 -0
  16. torch_geometric/data/dataset.py +14 -11
  17. torch_geometric/data/extract.py +1 -1
  18. torch_geometric/data/feature_store.py +17 -22
  19. torch_geometric/data/graph_store.py +3 -2
  20. torch_geometric/data/hetero_data.py +139 -7
  21. torch_geometric/data/hypergraph_data.py +2 -2
  22. torch_geometric/data/in_memory_dataset.py +2 -2
  23. torch_geometric/data/lightning/datamodule.py +42 -28
  24. torch_geometric/data/storage.py +9 -1
  25. torch_geometric/datasets/__init__.py +18 -1
  26. torch_geometric/datasets/actor.py +7 -9
  27. torch_geometric/datasets/airfrans.py +15 -17
  28. torch_geometric/datasets/airports.py +8 -10
  29. torch_geometric/datasets/amazon.py +8 -11
  30. torch_geometric/datasets/amazon_book.py +8 -9
  31. torch_geometric/datasets/amazon_products.py +7 -9
  32. torch_geometric/datasets/aminer.py +8 -9
  33. torch_geometric/datasets/aqsol.py +10 -13
  34. torch_geometric/datasets/attributed_graph_dataset.py +8 -10
  35. torch_geometric/datasets/ba_multi_shapes.py +10 -12
  36. torch_geometric/datasets/ba_shapes.py +5 -6
  37. torch_geometric/datasets/city.py +157 -0
  38. torch_geometric/datasets/dbp15k.py +1 -1
  39. torch_geometric/datasets/git_mol_dataset.py +263 -0
  40. torch_geometric/datasets/hgb_dataset.py +2 -2
  41. torch_geometric/datasets/hm.py +1 -1
  42. torch_geometric/datasets/instruct_mol_dataset.py +134 -0
  43. torch_geometric/datasets/md17.py +3 -3
  44. torch_geometric/datasets/medshapenet.py +145 -0
  45. torch_geometric/datasets/modelnet.py +1 -1
  46. torch_geometric/datasets/molecule_gpt_dataset.py +492 -0
  47. torch_geometric/datasets/molecule_net.py +3 -2
  48. torch_geometric/datasets/ppi.py +2 -1
  49. torch_geometric/datasets/protein_mpnn_dataset.py +451 -0
  50. torch_geometric/datasets/qm7.py +1 -1
  51. torch_geometric/datasets/qm9.py +1 -1
  52. torch_geometric/datasets/snap_dataset.py +8 -4
  53. torch_geometric/datasets/tag_dataset.py +462 -0
  54. torch_geometric/datasets/teeth3ds.py +269 -0
  55. torch_geometric/datasets/web_qsp_dataset.py +310 -209
  56. torch_geometric/datasets/wikics.py +2 -1
  57. torch_geometric/deprecation.py +1 -1
  58. torch_geometric/distributed/__init__.py +13 -0
  59. torch_geometric/distributed/dist_loader.py +2 -2
  60. torch_geometric/distributed/partition.py +2 -2
  61. torch_geometric/distributed/rpc.py +3 -3
  62. torch_geometric/edge_index.py +18 -14
  63. torch_geometric/explain/algorithm/attention_explainer.py +219 -29
  64. torch_geometric/explain/algorithm/base.py +2 -2
  65. torch_geometric/explain/algorithm/captum.py +1 -1
  66. torch_geometric/explain/algorithm/captum_explainer.py +2 -1
  67. torch_geometric/explain/algorithm/gnn_explainer.py +406 -69
  68. torch_geometric/explain/algorithm/graphmask_explainer.py +8 -8
  69. torch_geometric/explain/algorithm/pg_explainer.py +305 -47
  70. torch_geometric/explain/explainer.py +2 -2
  71. torch_geometric/explain/explanation.py +87 -3
  72. torch_geometric/explain/metric/faithfulness.py +1 -1
  73. torch_geometric/graphgym/config.py +3 -2
  74. torch_geometric/graphgym/imports.py +15 -4
  75. torch_geometric/graphgym/logger.py +1 -1
  76. torch_geometric/graphgym/loss.py +1 -1
  77. torch_geometric/graphgym/models/encoder.py +2 -2
  78. torch_geometric/graphgym/models/layer.py +1 -1
  79. torch_geometric/graphgym/utils/comp_budget.py +4 -3
  80. torch_geometric/hash_tensor.py +798 -0
  81. torch_geometric/index.py +14 -5
  82. torch_geometric/inspector.py +4 -0
  83. torch_geometric/io/fs.py +5 -4
  84. torch_geometric/llm/__init__.py +9 -0
  85. torch_geometric/llm/large_graph_indexer.py +741 -0
  86. torch_geometric/llm/models/__init__.py +23 -0
  87. torch_geometric/{nn → llm}/models/g_retriever.py +77 -45
  88. torch_geometric/llm/models/git_mol.py +336 -0
  89. torch_geometric/llm/models/glem.py +397 -0
  90. torch_geometric/{nn/nlp → llm/models}/llm.py +180 -32
  91. torch_geometric/llm/models/llm_judge.py +158 -0
  92. torch_geometric/llm/models/molecule_gpt.py +222 -0
  93. torch_geometric/llm/models/protein_mpnn.py +333 -0
  94. torch_geometric/llm/models/sentence_transformer.py +188 -0
  95. torch_geometric/llm/models/txt2kg.py +353 -0
  96. torch_geometric/llm/models/vision_transformer.py +38 -0
  97. torch_geometric/llm/rag_loader.py +154 -0
  98. torch_geometric/llm/utils/__init__.py +10 -0
  99. torch_geometric/llm/utils/backend_utils.py +443 -0
  100. torch_geometric/llm/utils/feature_store.py +169 -0
  101. torch_geometric/llm/utils/graph_store.py +199 -0
  102. torch_geometric/llm/utils/vectorrag.py +125 -0
  103. torch_geometric/loader/cluster.py +4 -4
  104. torch_geometric/loader/ibmb_loader.py +4 -4
  105. torch_geometric/loader/link_loader.py +1 -1
  106. torch_geometric/loader/link_neighbor_loader.py +2 -1
  107. torch_geometric/loader/mixin.py +6 -5
  108. torch_geometric/loader/neighbor_loader.py +1 -1
  109. torch_geometric/loader/neighbor_sampler.py +2 -2
  110. torch_geometric/loader/prefetch.py +3 -2
  111. torch_geometric/loader/temporal_dataloader.py +2 -2
  112. torch_geometric/loader/utils.py +10 -10
  113. torch_geometric/metrics/__init__.py +14 -0
  114. torch_geometric/metrics/link_pred.py +745 -92
  115. torch_geometric/nn/__init__.py +1 -0
  116. torch_geometric/nn/aggr/base.py +1 -1
  117. torch_geometric/nn/aggr/equilibrium.py +1 -1
  118. torch_geometric/nn/aggr/fused.py +1 -1
  119. torch_geometric/nn/aggr/patch_transformer.py +8 -2
  120. torch_geometric/nn/aggr/set_transformer.py +1 -1
  121. torch_geometric/nn/aggr/utils.py +9 -4
  122. torch_geometric/nn/attention/__init__.py +9 -1
  123. torch_geometric/nn/attention/polynormer.py +107 -0
  124. torch_geometric/nn/attention/qformer.py +71 -0
  125. torch_geometric/nn/attention/sgformer.py +99 -0
  126. torch_geometric/nn/conv/__init__.py +2 -0
  127. torch_geometric/nn/conv/appnp.py +1 -1
  128. torch_geometric/nn/conv/cugraph/gat_conv.py +8 -2
  129. torch_geometric/nn/conv/cugraph/rgcn_conv.py +3 -0
  130. torch_geometric/nn/conv/cugraph/sage_conv.py +3 -0
  131. torch_geometric/nn/conv/dna_conv.py +1 -1
  132. torch_geometric/nn/conv/eg_conv.py +7 -7
  133. torch_geometric/nn/conv/gen_conv.py +1 -1
  134. torch_geometric/nn/conv/gravnet_conv.py +2 -1
  135. torch_geometric/nn/conv/hetero_conv.py +2 -1
  136. torch_geometric/nn/conv/meshcnn_conv.py +487 -0
  137. torch_geometric/nn/conv/message_passing.py +5 -4
  138. torch_geometric/nn/conv/rgcn_conv.py +2 -1
  139. torch_geometric/nn/conv/sg_conv.py +1 -1
  140. torch_geometric/nn/conv/spline_conv.py +2 -1
  141. torch_geometric/nn/conv/ssg_conv.py +1 -1
  142. torch_geometric/nn/conv/transformer_conv.py +5 -3
  143. torch_geometric/nn/data_parallel.py +5 -4
  144. torch_geometric/nn/dense/linear.py +0 -20
  145. torch_geometric/nn/encoding.py +17 -3
  146. torch_geometric/nn/fx.py +14 -12
  147. torch_geometric/nn/model_hub.py +2 -15
  148. torch_geometric/nn/models/__init__.py +11 -2
  149. torch_geometric/nn/models/attentive_fp.py +1 -1
  150. torch_geometric/nn/models/attract_repel.py +148 -0
  151. torch_geometric/nn/models/basic_gnn.py +2 -1
  152. torch_geometric/nn/models/captum.py +1 -1
  153. torch_geometric/nn/models/deep_graph_infomax.py +1 -1
  154. torch_geometric/nn/models/dimenet.py +2 -2
  155. torch_geometric/nn/models/dimenet_utils.py +4 -2
  156. torch_geometric/nn/models/gpse.py +1083 -0
  157. torch_geometric/nn/models/graph_unet.py +13 -4
  158. torch_geometric/nn/models/lpformer.py +783 -0
  159. torch_geometric/nn/models/metapath2vec.py +1 -1
  160. torch_geometric/nn/models/mlp.py +4 -2
  161. torch_geometric/nn/models/node2vec.py +1 -1
  162. torch_geometric/nn/models/polynormer.py +206 -0
  163. torch_geometric/nn/models/rev_gnn.py +3 -3
  164. torch_geometric/nn/models/sgformer.py +219 -0
  165. torch_geometric/nn/models/signed_gcn.py +1 -1
  166. torch_geometric/nn/models/visnet.py +2 -2
  167. torch_geometric/nn/norm/batch_norm.py +17 -7
  168. torch_geometric/nn/norm/diff_group_norm.py +7 -2
  169. torch_geometric/nn/norm/graph_norm.py +9 -4
  170. torch_geometric/nn/norm/instance_norm.py +5 -1
  171. torch_geometric/nn/norm/layer_norm.py +15 -7
  172. torch_geometric/nn/norm/msg_norm.py +8 -2
  173. torch_geometric/nn/pool/__init__.py +8 -4
  174. torch_geometric/nn/pool/cluster_pool.py +3 -4
  175. torch_geometric/nn/pool/connect/base.py +1 -3
  176. torch_geometric/nn/pool/knn.py +13 -10
  177. torch_geometric/nn/pool/select/base.py +1 -4
  178. torch_geometric/nn/to_hetero_module.py +4 -3
  179. torch_geometric/nn/to_hetero_transformer.py +3 -3
  180. torch_geometric/nn/to_hetero_with_bases_transformer.py +4 -4
  181. torch_geometric/profile/__init__.py +2 -0
  182. torch_geometric/profile/nvtx.py +66 -0
  183. torch_geometric/profile/utils.py +20 -5
  184. torch_geometric/sampler/__init__.py +2 -1
  185. torch_geometric/sampler/base.py +336 -7
  186. torch_geometric/sampler/hgt_sampler.py +11 -1
  187. torch_geometric/sampler/neighbor_sampler.py +296 -23
  188. torch_geometric/sampler/utils.py +93 -5
  189. torch_geometric/testing/__init__.py +4 -0
  190. torch_geometric/testing/decorators.py +35 -5
  191. torch_geometric/testing/distributed.py +1 -1
  192. torch_geometric/transforms/__init__.py +2 -0
  193. torch_geometric/transforms/add_gpse.py +49 -0
  194. torch_geometric/transforms/add_metapaths.py +8 -6
  195. torch_geometric/transforms/add_positional_encoding.py +2 -2
  196. torch_geometric/transforms/base_transform.py +2 -1
  197. torch_geometric/transforms/delaunay.py +65 -15
  198. torch_geometric/transforms/face_to_edge.py +32 -3
  199. torch_geometric/transforms/gdc.py +7 -8
  200. torch_geometric/transforms/largest_connected_components.py +1 -1
  201. torch_geometric/transforms/mask.py +5 -1
  202. torch_geometric/transforms/normalize_features.py +3 -3
  203. torch_geometric/transforms/random_link_split.py +1 -1
  204. torch_geometric/transforms/remove_duplicated_edges.py +4 -2
  205. torch_geometric/transforms/rooted_subgraph.py +1 -1
  206. torch_geometric/typing.py +70 -17
  207. torch_geometric/utils/__init__.py +4 -1
  208. torch_geometric/utils/_lexsort.py +0 -9
  209. torch_geometric/utils/_negative_sampling.py +27 -12
  210. torch_geometric/utils/_scatter.py +132 -195
  211. torch_geometric/utils/_sort_edge_index.py +0 -2
  212. torch_geometric/utils/_spmm.py +16 -14
  213. torch_geometric/utils/_subgraph.py +4 -0
  214. torch_geometric/utils/_to_dense_batch.py +2 -2
  215. torch_geometric/utils/_trim_to_layer.py +2 -2
  216. torch_geometric/utils/convert.py +17 -10
  217. torch_geometric/utils/cross_entropy.py +34 -13
  218. torch_geometric/utils/embedding.py +91 -2
  219. torch_geometric/utils/geodesic.py +4 -3
  220. torch_geometric/utils/influence.py +279 -0
  221. torch_geometric/utils/map.py +13 -9
  222. torch_geometric/utils/nested.py +1 -1
  223. torch_geometric/utils/smiles.py +3 -3
  224. torch_geometric/utils/sparse.py +7 -14
  225. torch_geometric/visualization/__init__.py +2 -1
  226. torch_geometric/visualization/graph.py +250 -5
  227. torch_geometric/warnings.py +11 -2
  228. torch_geometric/nn/nlp/__init__.py +0 -7
  229. torch_geometric/nn/nlp/sentence_transformer.py +0 -101
@@ -0,0 +1,269 @@
1
+ import json
2
+ import os
3
+ import os.path as osp
4
+ from glob import glob
5
+ from typing import Callable, Dict, List, Optional
6
+
7
+ import numpy as np
8
+ import torch
9
+ from tqdm import tqdm
10
+
11
+ from torch_geometric.data import (
12
+ Data,
13
+ InMemoryDataset,
14
+ download_url,
15
+ extract_zip,
16
+ )
17
+
18
+
19
+ class Teeth3DS(InMemoryDataset):
20
+ r"""The Teeth3DS+ dataset from the `"An Extended Benchmark for Intra-oral
21
+ 3D Scans Analysis" <https://crns-smartvision.github.io/teeth3ds/>`_ paper.
22
+
23
+ This dataset is the first comprehensive public benchmark designed to
24
+ advance the field of intra-oral 3D scan analysis developed as part of the
25
+ 3DTeethSeg 2022 and 3DTeethLand 2024 MICCAI challenges, aiming to drive
26
+ research in teeth identification, segmentation, labeling, 3D modeling,
27
+ and dental landmark identification.
28
+ The dataset includes at least 1,800 intra-oral scans (containing 23,999
29
+ annotated teeth) collected from 900 patients, covering both upper and lower
30
+ jaws separately.
31
+
32
+ Args:
33
+ root (str): Root directory where the dataset should be saved.
34
+ split (str): The split name (one of :obj:`"Teeth3DS"`,
35
+ :obj:`"3DTeethSeg22_challenge"` or :obj:`"3DTeethLand_challenge"`).
36
+ train (bool, optional): If :obj:`True`, loads the training dataset,
37
+ otherwise the test dataset. (default: :obj:`True`)
38
+ num_samples (int, optional): Number of points to sample from each mesh.
39
+ (default: :obj:`30000`)
40
+ transform (callable, optional): A function/transform that takes in an
41
+ :obj:`torch_geometric.data.Data` object and returns a transformed
42
+ version. The data object will be transformed before every access.
43
+ (default: :obj:`None`)
44
+ pre_transform (callable, optional): A function/transform that takes in
45
+ an :obj:`torch_geometric.data.Data` object and returns a
46
+ transformed version. The data object will be transformed before
47
+ being saved to disk. (default: :obj:`None`)
48
+ force_reload (bool, optional): Whether to re-process the dataset.
49
+ (default: :obj:`False`)
50
+ """
51
+ urls = {
52
+ 'data_part_1.zip':
53
+ 'https://osf.io/download/qhprs/',
54
+ 'data_part_2.zip':
55
+ 'https://osf.io/download/4pwnr/',
56
+ 'data_part_3.zip':
57
+ 'https://osf.io/download/frwdp/',
58
+ 'data_part_4.zip':
59
+ 'https://osf.io/download/2arn4/',
60
+ 'data_part_5.zip':
61
+ 'https://osf.io/download/xrz5f/',
62
+ 'data_part_6.zip':
63
+ 'https://osf.io/download/23hgq/',
64
+ 'data_part_7.zip':
65
+ 'https://osf.io/download/u83ad/',
66
+ 'train_test_split':
67
+ 'https://files.de-1.osf.io/v1/'
68
+ 'resources/xctdy/providers/osfstorage/?zip='
69
+ }
70
+
71
+ sample_url = {
72
+ 'teeth3ds_sample': 'https://osf.io/download/vr38s/',
73
+ }
74
+
75
+ landmarks_urls = {
76
+ '3DTeethLand_landmarks_train.zip': 'https://osf.io/download/k5hbj/',
77
+ '3DTeethLand_landmarks_test.zip': 'https://osf.io/download/sqw5e/',
78
+ }
79
+
80
+ def __init__(
81
+ self,
82
+ root: str,
83
+ split:
84
+ str = 'Teeth3DS', # [3DTeethSeg22_challenge, 3DTeethLand_challenge]
85
+ train: bool = True,
86
+ num_samples: int = 30000,
87
+ transform: Optional[Callable] = None,
88
+ pre_transform: Optional[Callable] = None,
89
+ force_reload: bool = False,
90
+ ) -> None:
91
+
92
+ self.mode = 'training' if train else 'testing'
93
+ self.split = split
94
+ self.num_samples = num_samples
95
+
96
+ super().__init__(root, transform, pre_transform,
97
+ force_reload=force_reload)
98
+
99
+ @property
100
+ def processed_dir(self) -> str:
101
+ return os.path.join(self.root, f'processed_{self.split}_{self.mode}')
102
+
103
+ @property
104
+ def raw_file_names(self) -> List[str]:
105
+ return ['license.txt']
106
+
107
+ @property
108
+ def processed_file_names(self) -> List[str]:
109
+ # Directory containing train/test split files:
110
+ split_subdir = 'teeth3ds_sample' if self.split == 'sample' else ''
111
+ split_dir = osp.join(
112
+ self.raw_dir,
113
+ split_subdir,
114
+ f'{self.split}_train_test_split',
115
+ )
116
+
117
+ split_files = glob(osp.join(split_dir, f'{self.mode}*.txt'))
118
+
119
+ # Collect all file names from the split files:
120
+ combined_list = []
121
+ for file_path in split_files:
122
+ with open(file_path) as file:
123
+ combined_list.extend(file.read().splitlines())
124
+
125
+ # Generate the list of processed file paths:
126
+ return [f'{file_name}.pt' for file_name in combined_list]
127
+
128
+ def download(self) -> None:
129
+ if self.split == 'sample':
130
+ for key, url in self.sample_url.items():
131
+ path = download_url(url, self.root, filename=key)
132
+ extract_zip(path, self.raw_dir)
133
+ os.unlink(path)
134
+ else:
135
+ for key, url in self.urls.items():
136
+ path = download_url(url, self.root, filename=key)
137
+ extract_zip(path, self.raw_dir)
138
+ os.unlink(path)
139
+ for key, url in self.landmarks_urls.items():
140
+ path = download_url(url, self.root, filename=key)
141
+ extract_zip(path, self.raw_dir) # Extract each downloaded part
142
+ os.unlink(path)
143
+
144
+ def process_file(self, file_path: str) -> Optional[Data]:
145
+ """Processes the input file path to load mesh data, annotations,
146
+ and prepare the input features for a graph-based deep learning model.
147
+ """
148
+ import trimesh
149
+ from fpsample import bucket_fps_kdline_sampling
150
+
151
+ mesh = trimesh.load_mesh(file_path)
152
+
153
+ if isinstance(mesh, list):
154
+ # Handle the case where a list of Geometry objects is returned
155
+ mesh = mesh[0]
156
+
157
+ vertices = mesh.vertices
158
+ vertex_normals = mesh.vertex_normals
159
+
160
+ # Perform sampling on mesh vertices:
161
+ if len(vertices) < self.num_samples:
162
+ sampled_indices = np.random.choice(
163
+ len(vertices),
164
+ self.num_samples,
165
+ replace=True,
166
+ )
167
+ else:
168
+ sampled_indices = bucket_fps_kdline_sampling(
169
+ vertices,
170
+ self.num_samples,
171
+ h=5,
172
+ start_idx=0,
173
+ )
174
+
175
+ if len(sampled_indices) != self.num_samples:
176
+ raise RuntimeError(f"Sampled points mismatch, expected "
177
+ f"{self.num_samples} points, but got "
178
+ f"{len(sampled_indices)} for '{file_path}'")
179
+
180
+ # Extract features and annotations for the sampled points:
181
+ pos = torch.tensor(vertices[sampled_indices], dtype=torch.float)
182
+ x = torch.tensor(vertex_normals[sampled_indices], dtype=torch.float)
183
+
184
+ # Load segmentation annotations:
185
+ seg_annotation_path = file_path.replace('.obj', '.json')
186
+ if osp.exists(seg_annotation_path):
187
+ with open(seg_annotation_path) as f:
188
+ seg_annotations = json.load(f)
189
+ y = torch.tensor(
190
+ np.asarray(seg_annotations['labels'])[sampled_indices],
191
+ dtype=torch.float)
192
+ instances = torch.tensor(
193
+ np.asarray(seg_annotations['instances'])[sampled_indices],
194
+ dtype=torch.float)
195
+ else:
196
+ y = torch.empty(0, 3)
197
+ instances = torch.empty(0, 3)
198
+
199
+ # Load landmarks annotations:
200
+ landmarks_annotation_path = file_path.replace('.obj', '__kpt.json')
201
+
202
+ # Parse keypoint annotations into structured tensors:
203
+ keypoints_dict: Dict[str, List] = {
204
+ key: []
205
+ for key in [
206
+ 'Mesial', 'Distal', 'Cusp', 'InnerPoint', 'OuterPoint',
207
+ 'FacialPoint'
208
+ ]
209
+ }
210
+ keypoint_tensors: Dict[str, torch.Tensor] = {
211
+ key: torch.empty(0, 3)
212
+ for key in [
213
+ 'Mesial', 'Distal', 'Cusp', 'InnerPoint', 'OuterPoint',
214
+ 'FacialPoint'
215
+ ]
216
+ }
217
+ if osp.exists(landmarks_annotation_path):
218
+ with open(landmarks_annotation_path) as f:
219
+ landmarks_annotations = json.load(f)
220
+
221
+ for keypoint in landmarks_annotations['objects']:
222
+ keypoints_dict[keypoint['class']].extend(keypoint['coord'])
223
+
224
+ keypoint_tensors = {
225
+ k: torch.tensor(np.asarray(v),
226
+ dtype=torch.float).reshape(-1, 3)
227
+ for k, v in keypoints_dict.items()
228
+ }
229
+
230
+ data = Data(
231
+ pos=pos,
232
+ x=x,
233
+ y=y,
234
+ instances=instances,
235
+ jaw=file_path.split('.obj')[0].split('_')[1],
236
+ mesial=keypoint_tensors['Mesial'],
237
+ distal=keypoint_tensors['Distal'],
238
+ cusp=keypoint_tensors['Cusp'],
239
+ inner_point=keypoint_tensors['InnerPoint'],
240
+ outer_point=keypoint_tensors['OuterPoint'],
241
+ facial_point=keypoint_tensors['FacialPoint'],
242
+ )
243
+
244
+ if self.pre_transform is not None:
245
+ data = self.pre_transform(data)
246
+
247
+ return data
248
+
249
+ def process(self) -> None:
250
+ for file in tqdm(self.processed_file_names):
251
+ name = file.split('.')[0]
252
+ path = osp.join(self.raw_dir, '**', '*', name + '.obj')
253
+ paths = glob(path)
254
+ if len(paths) == 1:
255
+ data = self.process_file(paths[0])
256
+ torch.save(data, osp.join(self.processed_dir, file))
257
+
258
+ def len(self) -> int:
259
+ return len(self.processed_file_names)
260
+
261
+ def get(self, idx: int) -> Data:
262
+ return torch.load(
263
+ osp.join(self.processed_dir, self.processed_file_names[idx]),
264
+ weights_only=False,
265
+ )
266
+
267
+ def __repr__(self) -> str:
268
+ return (f'{self.__class__.__name__}({len(self)}, '
269
+ f'mode={self.mode}, split={self.split})')