forked from DarthIV02/HyperLiDAR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloader.py
More file actions
44 lines (34 loc) · 1.52 KB
/
loader.py
File metadata and controls
44 lines (34 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from auxiliary.ply_utils import read_ply, write_ply
import random
import torch
class Loader_Data():
def __init__(self, cfg, device) -> None:
self.cfg = cfg
self.device = device
if cfg.target == "paris":
self.load = self.load_ply
def load_ply(self, path):
scan = read_ply('/root/main/dataset/training_10_classes/Lille1_1.ply')
data = scan[['x', 'y', 'z']]
label = scan['class']
print("The min and max labels are: ", min(label), max(label))
print("Number of points:", len(data))
sample_size = int(len(data) * 0.5)
# Randomly sample 75% of the tuple
data_train = data[:sample_size]
labels_train = label[:sample_size]
data_test = data[sample_size:]
labels_test = label[sample_size:]
data_train_x = torch.FloatTensor([data_train['x'], data_train['y'], data_train['z']])
data_train_x.to(self.device)
labels_train_x = torch.FloatTensor([labels_train])
labels_train_x.to(self.device)
labels_train_x = labels_train_x[0]
data_train_xt = torch.transpose(data_train_x, 0, 1)
data_test_x = torch.FloatTensor([data_test['x'], data_test['y'], data_test['z']])
data_test_x.to(self.device)
labels_test_x = torch.FloatTensor([labels_test])
labels_test_x.to(self.device)
labels_test_x = labels_test_x[0]
data_test_xt = torch.transpose(data_test_x, 0, 1)
return data_train_xt, labels_train_x, data_test_xt, labels_test_x