From e75f2b7c356894dd3943ca936844a0f762c09fdb Mon Sep 17 00:00:00 2001
From: LXXXXR <73265258+LXXXXR@users.noreply.github.com>
Date: Fri, 20 Nov 2020 13:50:28 +0800
Subject: [PATCH] add argument to override configs (#91)

---
 tools/test.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/test.py b/tools/test.py
index 72d08708..0d981891 100644
--- a/tools/test.py
+++ b/tools/test.py
@@ -5,6 +5,7 @@ import warnings
 import mmcv
 import numpy as np
 import torch
+from mmcv import DictAction
 from mmcv.parallel import MMDataParallel, MMDistributedDataParallel
 from mmcv.runner import get_dist_info, init_dist, load_checkpoint
 
@@ -26,6 +27,12 @@ def parse_args():
         action='store_true',
         help='whether to use gpu to collect results')
     parser.add_argument('--tmpdir', help='tmp dir for writing some results')
+    parser.add_argument(
+        '--options',
+        nargs='+',
+        action=DictAction,
+        help='override some settings in the used config, the key-value pair '
+        'in xxx=yyy format will be merged into config file.')
     parser.add_argument(
         '--launcher',
         choices=['none', 'pytorch', 'slurm', 'mpi'],
@@ -42,6 +49,8 @@ def main():
     args = parse_args()
 
     cfg = mmcv.Config.fromfile(args.config)
+    if args.options is not None:
+        cfg.merge_from_dict(args.options)
     # set cudnn_benchmark
     if cfg.get('cudnn_benchmark', False):
         torch.backends.cudnn.benchmark = True