MCPcopy
hub / github.com/alibaba/EasyCV / quantize_eval

Function quantize_eval

tools/quantize.py:79–105  ·  view source on GitHub ↗
(cfg, model, eval_mode)

Source from the content-addressed store, hash-verified

77
78
79def quantize_eval(cfg, model, eval_mode):
80 for eval_pipe in cfg.eval_pipelines:
81 eval_data = eval_pipe.data
82 # build the dataloader
83 imgs_per_gpu = eval_data.pop('imgs_per_gpu', cfg.data.imgs_per_gpu)
84
85 dataset = build_dataset(eval_data)
86 data_loader = build_dataloader(
87 dataset,
88 imgs_per_gpu=imgs_per_gpu,
89 workers_per_gpu=cfg.data.workers_per_gpu,
90 dist=False,
91 shuffle=False)
92
93 if eval_mode == 'cuda':
94 outputs = single_gpu_test(model, data_loader, mode=eval_pipe.mode)
95 elif eval_mode == 'cpu':
96 outputs = single_cpu_test(model, data_loader, mode=eval_pipe.mode)
97
98 rank, _ = get_dist_info()
99 if rank == 0:
100 for t in eval_pipe.evaluators:
101 if 'metric_type' in t:
102 t.pop('metric_type')
103 evaluators = build_evaluator(eval_pipe.evaluators)
104 eval_result = dataset.evaluate(outputs, evaluators=evaluators)
105 print(f'\n eval_result {eval_result}')
106
107
108def main():

Callers 1

mainFunction · 0.85

Calls 6

build_datasetFunction · 0.90
build_dataloaderFunction · 0.90
single_gpu_testFunction · 0.90
single_cpu_testFunction · 0.90
build_evaluatorFunction · 0.90
evaluateMethod · 0.45

Tested by

no test coverage detected