Args: config: parameter configurations gpu_ids: gpu indexes for training is_train: training or testing Returns: dataloader(type:class)
(config, gpu_ids, is_train)
| 4 | from utils import log_print |
| 5 | |
| 6 | def make_data_loader(config, gpu_ids, is_train): |
| 7 | ''' |
| 8 | Args: |
| 9 | config: parameter configurations |
| 10 | gpu_ids: gpu indexes for training |
| 11 | is_train: training or testing |
| 12 | Returns: |
| 13 | dataloader(type:class) |
| 14 | ''' |
| 15 | if is_train: |
| 16 | log_print("Using dataset: %s" % config.DATA.DATASET_NAME, "g") |
| 17 | |
| 18 | if config.DATA.DATASET_NAME == "PITT": |
| 19 | from .pittsburgh import PittsburghDataset |
| 20 | dataloader = PittsburghDataset(config, is_train) |
| 21 | else: |
| 22 | raise ValueError(f"Unrecognized Dataset Name {config.DATA.DATASET_NAME}") |
| 23 | |
| 24 | #TODO collate functions |
| 25 | if config.TRAINING.BATCH.BATCH_TRANSFORM: |
| 26 | collate_fn = make_collate_fn(config) |
| 27 | else: |
| 28 | collate_fn = None |
| 29 | # collate_fn=collate_fn, |
| 30 | |
| 31 | loader = DataLoader(dataloader, |
| 32 | batch_size=config.TRAINING.BATCH.BATCH_SIZE*len(gpu_ids), |
| 33 | num_workers=config.TRAINING.NUM_WORKERS if is_train else 4, |
| 34 | pin_memory=True, |
| 35 | shuffle=True if is_train else False, |
| 36 | drop_last=True) |
| 37 | return loader |
no test coverage detected