Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]Implement dump results #8814

Merged
merged 4 commits into from
Sep 19, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ def parse_args():
parser.add_argument(
'--work-dir',
help='the directory to save the file containing evaluation metrics')
parser.add_argument(
'--dump',
wanghonglie marked this conversation as resolved.
Show resolved Hide resolved
type=str,
help='dump predictions to a pickle file for offline evaluation')
parser.add_argument(
'--show', action='store_true', help='show prediction results')
parser.add_argument(
Expand Down Expand Up @@ -97,6 +101,16 @@ def main():
if args.show or args.show_dir:
cfg = trigger_visualization_hook(cfg, args)

# Dump predictions
if args.dump is not None:
assert args.dump.endswith(('.pkl', '.pickle')), \
wanghonglie marked this conversation as resolved.
Show resolved Hide resolved
'The dump file must be a pkl file.'
dump_metric = dict(type='DumpResults', out_file_path=args.dump)
if isinstance(cfg.test_evaluator, (list, tuple)):
cfg.test_evaluator = list(cfg.test_evaluator).append(dump_metric)
else:
wanghonglie marked this conversation as resolved.
Show resolved Hide resolved
cfg.test_evaluator = [cfg.test_evaluator, dump_metric]

# build the runner from config
if 'runner_type' not in cfg:
# build the default runner
Expand Down