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

Function prefetch_test

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

Source from the content-addressed store, hash-verified

45 return len(self.images)
46
47def prefetch_test(opt):
48 os.environ['CUDA_VISIBLE_DEVICES'] = opt.gpus_str
49
50 Dataset = dataset_factory[opt.dataset]
51 opt = opts().update_dataset_info_and_set_heads(opt, Dataset)
52 print(opt)
53 Logger(opt)
54 Detector = detector_factory[opt.task]
55
56 split = 'val' if not opt.trainval else 'test'
57 dataset = Dataset(opt, split)
58 detector = Detector(opt)
59
60 data_loader = torch.utils.data.DataLoader(
61 PrefetchDataset(opt, dataset, detector.pre_process),
62 batch_size=1, shuffle=False, num_workers=1, pin_memory=True)
63
64 results = {}
65 num_iters = len(dataset)
66 bar = Bar('{}'.format(opt.exp_id), max=num_iters)
67 time_stats = ['tot', 'load', 'pre', 'net', 'dec', 'post', 'merge']
68 avg_time_stats = {t: AverageMeter() for t in time_stats}
69 for ind, (img_id, pre_processed_images) in enumerate(data_loader):
70 ret = detector.run(pre_processed_images)
71 results[img_id.numpy().astype(np.int32)[0]] = ret['results']
72 Bar.suffix = '[{0}/{1}]|Tot: {total:} |ETA: {eta:} '.format(
73 ind, num_iters, total=bar.elapsed_td, eta=bar.eta_td)
74 for t in avg_time_stats:
75 avg_time_stats[t].update(ret[t])
76 Bar.suffix = Bar.suffix + '|{} {tm.val:.3f}s ({tm.avg:.3f}s) '.format(
77 t, tm = avg_time_stats[t])
78 bar.next()
79 bar.finish()
80 dataset.run_eval(results, opt.save_dir)
81
82def test(opt):
83 os.environ['CUDA_VISIBLE_DEVICES'] = opt.gpus_str

Callers 1

test.pyFile · 0.85

Calls 9

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

Tested by

no test coverage detected