8
8
9
9
10
10
class NGSIM_US_101 (InMemoryDataset ):
11
-
12
11
r"""
13
- The NGSIM US-101 dataset from the "NGSIM: Next Generation Simulation"
14
- <https://ops.fhwa.dot.gov/trafficanalysistools/ngsim.htm>`_ project,
15
- containing detailed vehicle trajectory data from the US-101 highway in
16
- Los Angeles, California.
12
+ The NGSIM US-101 dataset from the "NGSIM: Next Generation Simulation"
13
+ <https://ops.fhwa.dot.gov/trafficanalysistools/ngsim.htm>`_ project,
14
+ containing detailed vehicle trajectory data from the US-101 highway in
15
+ Los Angeles, California.
17
16
18
- Parameters
19
- ----------
20
- root: str
21
- Root directory where the dataset should be saved.
22
- name: str, optional
23
- The name of the dataset (:obj:`"train", "val", "test"`).
24
- transform: callable, optional
25
- A function/transform that takes in an
26
- :obj:`gammagl.data.Graph` object and returns a transformed
27
- version. The data object will be transformed before every access.
28
- (default: :obj:`None`)
29
- pre_transform: callable, optional
30
- A function/transform that takes in
31
- an :obj:`gammagl.data.Graph` object and returns a
32
- transformed version. The data object will be transformed before
33
- being saved to disk. (default: :obj:`None`)
34
- force_reload (bool, optional): Whether to re-process the dataset.
35
- (default: :obj:`False`)
17
+ Parameters
18
+ ----------
19
+ root: str
20
+ Root directory where the dataset should be saved.
21
+ name: str, optional
22
+ The name of the dataset (:obj:`"train", "val", "test"`).
23
+ transform: callable, optional
24
+ A function/transform that takes in an
25
+ :obj:`gammagl.data.Graph` object and returns a transformed
26
+ version. The data object will be transformed before every access.
27
+ (default: :obj:`None`)
28
+ pre_transform: callable, optional
29
+ A function/transform that takes in
30
+ an :obj:`gammagl.data.Graph` object and returns a
31
+ transformed version. The data object will be transformed before
32
+ being saved to disk. (default: :obj:`None`)
33
+ force_reload (bool, optional): Whether to re-process the dataset.
34
+ (default: :obj:`False`)
36
35
37
- """
36
+ """
38
37
39
38
url = 'https://github.com/gjy1221/NGSIM-US-101/raw/main/data'
40
39
41
40
def __init__ (self , root : str = None , name : str = None ,
42
41
transform : Optional [Callable ] = None , pre_transform : Optional [Callable ] = None ,
43
42
force_reload : bool = False ):
44
- self .name = name .lower ()
43
+ self .name = osp .join ('ngsim' , name .lower ())
44
+ self .split = name .lower ()
45
45
super ().__init__ (root , transform , pre_transform , force_reload = force_reload )
46
- self .data_path = f' { root } /processed/ { name } '
46
+ self .data_path = osp . join ( self . processed_dir , name )
47
47
self .data_names = os .listdir ('{}' .format (self .data_path ))
48
48
49
49
def __len__ (self ):
@@ -57,23 +57,23 @@ def __getitem__(self, index):
57
57
58
58
@property
59
59
def raw_dir (self ) -> str :
60
- return osp .join (self .root , 'raw' , self .name )
60
+ return osp .join (self .root , 'ngsim' , ' raw' , self .split )
61
61
62
62
@property
63
63
def processed_dir (self ) -> str :
64
- return osp .join (self .root , 'processed' )
64
+ return osp .join (self .root , 'ngsim' , ' processed' )
65
65
66
66
@property
67
67
def raw_file_names (self ) -> List [str ]:
68
- return [f'/ { self .name .lower ()} .zip' ]
68
+ return [f'{ self .split .lower ()} .zip' ]
69
69
70
70
@property
71
71
def processed_file_names (self ) -> str :
72
72
return tlx .BACKEND + '_data.pt'
73
73
74
74
def download (self ):
75
- print (self .root )
76
- path = download_url (self .url + self .raw_file_names [0 ], self .raw_dir )
75
+ # print(self.root)
76
+ path = download_url (f' { self .url } / { self .raw_file_names [0 ]} ' , self .raw_dir )
77
77
with zipfile .ZipFile (path , 'r' ) as zip_ref :
78
78
zip_ref .extractall (self .processed_dir )
79
79
0 commit comments