forked from aravindMahadevan/trajectory_prediction_INFER
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNuscenes_dataset_test.py
49 lines (34 loc) · 1.36 KB
/
Nuscenes_dataset_test.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
import os
import pandas as pd
import numpy as np
import torch
import torchvision
import torchvision.transforms.functional as TF
from torch.utils.data import Dataset
from PIL import Image
from torchvision import transforms
class NuscenesDatasetTest(Dataset):
def __init__(self, NuscenesBaseDir, height=256, width=256):
# path to main dataset
self.baseDir = NuscenesBaseDir
self.height, self.width = height, width
# Length of dataset
self.len = 26*9*12
def __len__(self):
return self.len
def __getitem__(self, idx):
sceneNum = np.floor(idx/(26*12)) + 44
seqNum = np.floor(idx / 12) - (sceneNum-44)*26
numFrames = 12
# Get the Current frame
frame_num = idx % 12
file_path = os.path.join(self.baseDir, "scene_" + str(int(sceneNum)), "sequence_" + str(int(seqNum)), "frame_" + str(frame_num) + ".npy")
inpTensor = np.load(file_path)
for i in range(len(inpTensor)):
#import pdb; pdb.set_trace()
inpTensor[i,:,:] = ((inpTensor[i,:,:] / np.max(inpTensor[i,:,:]))*255).astype(int)
inpTensor = torch.from_numpy(inpTensor)
endOfSequence = False
if frame_num == 11:
endOfSequence = True
return inpTensor, sceneNum, seqNum, frame_num, endOfSequence