-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.py
69 lines (51 loc) · 2.17 KB
/
data.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import os, glob
import numpy as np
from torch.utils.data import Dataset
class ArgoverseSceneFlowDataset(Dataset):
def __init__(self, options, partition="val", width=1):
self.options = options
self.partition = partition
self.width = width
self.num_points = options.num_points
if self.partition == "val":
self.datapath = sorted(glob.glob(os.path.join(options.data_path, options.dataset_name, 'val', '*/*.npz')))
print('number of data is {}'.format(len(self.datapath)))
def __len__(self):
return len(self.datapath)
def __getitem__(self, index):
filename = self.datapath[index]
with open(filename, 'rb') as fp:
data = np.load(fp)
pc1 = data['pc1']
pc2 = data['pc2']
flow = data['flow']
if not self.options.use_all_points:
rand_idx = np.random.choice(pc1.shape[0],self.options.num_points)
pc1 = pc1[rand_idx]
pc2 = pc2[rand_idx]
flow = flow[rand_idx]
return pc1, pc2, flow
class WaymoOpenFlowDataset(Dataset):
def __init__(self, options, partition="val", width=1):
self.options = options
self.partition = partition
self.width = width
self.num_points = options.num_points
if self.partition == "val":
self.datapath = sorted(glob.glob(os.path.join(options.data_path, options.dataset_name, '*/*.npz')))
print('number of data is {}'.format(len(self.datapath)))
def __len__(self):
return len(self.datapath)
def __getitem__(self, index):
filename = self.datapath[index]
with open(filename, 'rb') as fp:
data = np.load(fp)
pc1 = data['pc1']
pc2 = data['pc2']
flow = data['flow']
if not self.options.use_all_points:
rand_idx = np.random.choice(pc1.shape[0],self.options.num_points)
pc1 = pc1[rand_idx]
pc2 = pc2[rand_idx]
flow = flow[rand_idx]
return pc1, pc2, flow