-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathextract_ns_maps.py
49 lines (40 loc) · 1.64 KB
/
extract_ns_maps.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
from datasets.ns import NS
from torch.utils.data import DataLoader
import yaml
"""
Script to extract map images for nuscenes. This significantly speeds up training compared to using the predict helper
during training.
"""
config_file = 'configs/ns.yml'
# Read config file
with open(config_file, 'r') as yaml_file:
config = yaml.safe_load(yaml_file)
# Initialize datasets and dataloaders:
batch_size = 64
tr_set = NS(config['dataroot'],
config['train'],
img_size=config['img_size'],
grid_extent=config['grid_extent'],
image_extraction_mode=True)
val_set = NS(config['dataroot'],
config['val'],
img_size=config['img_size'],
grid_extent=config['grid_extent'],
image_extraction_mode=True)
ts_set = NS(config['dataroot'],
config['test'],
img_size=config['img_size'],
grid_extent=config['grid_extent'],
image_extraction_mode=True)
tr_dl = DataLoader(tr_set, batch_size=batch_size, shuffle=False, num_workers=8)
val_dl = DataLoader(val_set, batch_size=batch_size, shuffle=False, num_workers=8)
ts_dl = DataLoader(ts_set, batch_size=batch_size, shuffle=False, num_workers=8)
print('Extracting train set images....')
for k, data in enumerate(tr_dl):
print('Batch ' + str(k) + ' of ' + str(len(tr_set) // batch_size + 1))
print('Extracting val set images....')
for k, data in enumerate(val_dl):
print('Batch ' + str(k) + ' of ' + str(len(val_set) // batch_size + 1))
print('Extracting test set images....')
for k, data in enumerate(ts_dl):
print('Batch ' + str(k) + ' of ' + str(len(ts_set) // batch_size + 1))