Commit 20762ce9 authored by Kai Chen's avatar Kai Chen
Browse files

bug fix for proposal evaluation

parent a6adf8f0
...@@ -16,8 +16,8 @@ def coco_eval(result_file, result_types, coco, max_dets=(100, 300, 1000)): ...@@ -16,8 +16,8 @@ def coco_eval(result_file, result_types, coco, max_dets=(100, 300, 1000)):
coco = COCO(coco) coco = COCO(coco)
assert isinstance(coco, COCO) assert isinstance(coco, COCO)
if res_type == 'proposal_fast': if result_types == ['proposal_fast']:
ar = fast_eval_recall(result_file, coco, max_dets) ar = fast_eval_recall(result_file, coco, np.array(max_dets))
for i, num in enumerate(max_dets): for i, num in enumerate(max_dets):
print('AR@{}\t= {:.4f}'.format(num, ar[i])) print('AR@{}\t= {:.4f}'.format(num, ar[i]))
return return
......
...@@ -55,6 +55,9 @@ def parse_args(): ...@@ -55,6 +55,9 @@ def parse_args():
def main(): def main():
args = parse_args() args = parse_args()
if args.out is not None and not args.out.endswith(('.pkl', '.pickle')):
raise ValueError('The output file must be a pkl file.')
cfg = mmcv.Config.fromfile(args.config) cfg = mmcv.Config.fromfile(args.config)
cfg.model.pretrained = None cfg.model.pretrained = None
cfg.data.test.test_mode = True cfg.data.test.test_mode = True
...@@ -82,11 +85,17 @@ def main(): ...@@ -82,11 +85,17 @@ def main():
dataset, _data_func, range(args.gpus)) dataset, _data_func, range(args.gpus))
if args.out: if args.out:
print('writing results to {}'.format(args.out))
mmcv.dump(outputs, args.out) mmcv.dump(outputs, args.out)
if args.eval: eval_types = args.eval
json_file = args.out + '.json' if eval_types:
results2json(dataset, outputs, json_file) print('Starting evaluate {}'.format(' and '.join(eval_types)))
coco_eval(json_file, args.eval, dataset.coco) if eval_types == ['proposal_fast']:
result_file = args.out
else:
result_file = args.out + '.json'
results2json(dataset, outputs, result_file)
coco_eval(result_file, eval_types, dataset.coco)
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment