(cfg, dataset_name, mapper, *, dataset=None, sampler=None)
| 251 | |
| 252 | |
| 253 | def _train_loader_from_config(cfg, dataset_name, mapper, *, dataset=None, sampler=None): |
| 254 | cfg_datasets = cfg['DATASETS'] |
| 255 | cfg_dataloader = cfg['DATALOADER'] |
| 256 | |
| 257 | if dataset is None: |
| 258 | dataset = get_detection_dataset_dicts( |
| 259 | dataset_name, |
| 260 | filter_empty=cfg_dataloader['FILTER_EMPTY_ANNOTATIONS'], |
| 261 | proposal_files=cfg_datasets['PROPOSAL_FILES_TRAIN'] if cfg_dataloader['LOAD_PROPOSALS'] else None, |
| 262 | ) |
| 263 | |
| 264 | if mapper is None: |
| 265 | mapper = DatasetMapper(cfg, True) |
| 266 | |
| 267 | if sampler is None: |
| 268 | sampler_name = cfg_dataloader['SAMPLER_TRAIN'] |
| 269 | logger = logging.getLogger(__name__) |
| 270 | logger.info("Using training sampler {}".format(sampler_name)) |
| 271 | sampler = TrainingSampler(len(dataset)) |
| 272 | |
| 273 | return { |
| 274 | "dataset": dataset, |
| 275 | "sampler": sampler, |
| 276 | "mapper": mapper, |
| 277 | "total_batch_size": cfg['TRAIN']['BATCH_SIZE_TOTAL'], |
| 278 | "aspect_ratio_grouping": cfg_dataloader['ASPECT_RATIO_GROUPING'], |
| 279 | "num_workers": cfg_dataloader['NUM_WORKERS'], |
| 280 | } |
| 281 | |
| 282 | |
| 283 | @configurable(from_config=_train_loader_from_config) |
nothing calls this directly
no test coverage detected