MCPcopy
hub / github.com/xingyizhou/CenterNet / test

Function test

src/test.py:82–119  ·  view source on GitHub ↗
(opt)

Source from the content-addressed store, hash-verified

80 dataset.run_eval(results, opt.save_dir)
81
82def test(opt):
83 os.environ['CUDA_VISIBLE_DEVICES'] = opt.gpus_str
84
85 Dataset = dataset_factory[opt.dataset]
86 opt = opts().update_dataset_info_and_set_heads(opt, Dataset)
87 print(opt)
88 Logger(opt)
89 Detector = detector_factory[opt.task]
90
91 split = 'val' if not opt.trainval else 'test'
92 dataset = Dataset(opt, split)
93 detector = Detector(opt)
94
95 results = {}
96 num_iters = len(dataset)
97 bar = Bar('{}'.format(opt.exp_id), max=num_iters)
98 time_stats = ['tot', 'load', 'pre', 'net', 'dec', 'post', 'merge']
99 avg_time_stats = {t: AverageMeter() for t in time_stats}
100 for ind in range(num_iters):
101 img_id = dataset.images[ind]
102 img_info = dataset.coco.loadImgs(ids=[img_id])[0]
103 img_path = os.path.join(dataset.img_dir, img_info['file_name'])
104
105 if opt.task == 'ddd':
106 ret = detector.run(img_path, img_info['calib'])
107 else:
108 ret = detector.run(img_path)
109
110 results[img_id] = ret['results']
111
112 Bar.suffix = '[{0}/{1}]|Tot: {total:} |ETA: {eta:} '.format(
113 ind, num_iters, total=bar.elapsed_td, eta=bar.eta_td)
114 for t in avg_time_stats:
115 avg_time_stats[t].update(ret[t])
116 Bar.suffix = Bar.suffix + '|{} {:.3f} '.format(t, avg_time_stats[t].avg)
117 bar.next()
118 bar.finish()
119 dataset.run_eval(results, opt.save_dir)
120
121if __name__ == '__main__':
122 opt = opts().parse()

Callers 1

test.pyFile · 0.85

Calls 8

optsClass · 0.90
LoggerClass · 0.90
AverageMeterClass · 0.90
DatasetClass · 0.85
runMethod · 0.80
updateMethod · 0.80
run_evalMethod · 0.45

Tested by

no test coverage detected