(opt)
| 80 | dataset.run_eval(results, opt.save_dir) |
| 81 | |
| 82 | def 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 | |
| 121 | if __name__ == '__main__': |
| 122 | opt = opts().parse() |
no test coverage detected