Uses the given `dataset_name` argument (instead of the names in cfg), because the standard practice is to evaluate each test set individually (not combining them).
(cfg, dataset_name, mapper=None)
| 154 | |
| 155 | |
| 156 | def _test_loader_from_config(cfg, dataset_name, mapper=None): |
| 157 | """ |
| 158 | Uses the given `dataset_name` argument (instead of the names in cfg), because the |
| 159 | standard practice is to evaluate each test set individually (not combining them). |
| 160 | """ |
| 161 | if isinstance(dataset_name, str): |
| 162 | dataset_name = [dataset_name] |
| 163 | |
| 164 | dataset = get_detection_dataset_dicts( |
| 165 | dataset_name, |
| 166 | filter_empty=False, |
| 167 | proposal_files=None, |
| 168 | ) |
| 169 | # import ipdb;ipdb.set_trace() |
| 170 | if mapper is None: |
| 171 | if isinstance(cfg, (DictConfig)): |
| 172 | cfg = OmegaConf.to_container(copy.deepcopy(cfg)) |
| 173 | mapper_cfg = CfgNode({'INPUT': cfg['INPUT'], 'MODEL': cfg['MODEL'], 'DATASETS': cfg['DATASETS']}) |
| 174 | mapper = DatasetMapper(mapper_cfg, False) |
| 175 | assert cfg['TEST']['BATCH_SIZE_TOTAL'] % get_world_size() == 0, "Evaluation total batchsize is not divisible by gpu number" |
| 176 | batch_size = cfg['TEST']['BATCH_SIZE_TOTAL'] // get_world_size() |
| 177 | |
| 178 | return { |
| 179 | "dataset": dataset, |
| 180 | "mapper": mapper, |
| 181 | "num_workers": cfg['DATALOADER']['NUM_WORKERS'], |
| 182 | "sampler": InferenceSampler(len(dataset)), |
| 183 | "batch_size": batch_size, |
| 184 | } |
| 185 | |
| 186 | |
| 187 | @configurable(from_config=_test_loader_from_config) |
nothing calls this directly
no test coverage detected