MCPcopy Create free account
hub / github.com/UX-Decoder/Semantic-SAM / _test_loader_from_config

Function _test_loader_from_config

datasets/build.py:156–184  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

154
155
156def _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)

Callers

nothing calls this directly

Calls 2

CfgNodeClass · 0.85

Tested by

no test coverage detected