Commit 958b0ad2 authored by Ilija Radosavovic's avatar Ilija Radosavovic Committed by Facebook Github Bot

Make output dir computation dependence on datasets config fields explicit

Reviewed By: rbgirshick

Differential Revision: D7086631

fbshipit-source-id: 8d1a756bdd187eb33cde0dac0dc73c5293ca17eb
parent 2b02a5df
...@@ -1032,12 +1032,15 @@ def cache_cfg_urls(): ...@@ -1032,12 +1032,15 @@ def cache_cfg_urls():
) )
def get_output_dir(training=True): def get_output_dir(datasets, training=True):
"""Get the output directory determined by the current global config.""" """Get the output directory determined by the current global config."""
dataset = ':'.join(__C.TRAIN.DATASETS) if training else __C.TEST.DATASET assert isinstance(datasets, (tuple, list, basestring)), \
'datasets argument must be of type tuple, list or string'
is_string = isinstance(datasets, basestring)
dataset_name = datasets if is_string else ':'.join(datasets)
tag = 'train' if training else 'test' tag = 'train' if training else 'test'
# <output-dir>/<train|test>/<dataset>/<model-type>/ # <output-dir>/<train|test>/<dataset-name>/<model-type>/
outdir = osp.join(__C.OUTPUT_DIR, tag, dataset, __C.MODEL.TYPE) outdir = osp.join(__C.OUTPUT_DIR, tag, dataset_name, __C.MODEL.TYPE)
if not osp.exists(outdir): if not osp.exists(outdir):
os.makedirs(outdir) os.makedirs(outdir)
return outdir return outdir
......
...@@ -81,9 +81,7 @@ def run_inference(ind_range=None, multi_gpu_testing=False, gpu_id=0): ...@@ -81,9 +81,7 @@ def run_inference(ind_range=None, multi_gpu_testing=False, gpu_id=0):
cfg.TEST.DATASET = cfg.TEST.DATASETS[i] cfg.TEST.DATASET = cfg.TEST.DATASETS[i]
if cfg.TEST.PRECOMPUTED_PROPOSALS: if cfg.TEST.PRECOMPUTED_PROPOSALS:
cfg.TEST.PROPOSAL_FILE = cfg.TEST.PROPOSAL_FILES[i] cfg.TEST.PROPOSAL_FILE = cfg.TEST.PROPOSAL_FILES[i]
# Note that output dir computation cannot be moved before the output_dir = get_output_dir(cfg.TEST.DATASET, training=False)
# if statement since it depends on the value of cfg.TEST.DATASET
output_dir = get_output_dir(training=False)
results = parent_func(output_dir, multi_gpu=multi_gpu_testing) results = parent_func(output_dir, multi_gpu=multi_gpu_testing)
all_results.update(results) all_results.update(results)
...@@ -93,7 +91,7 @@ def run_inference(ind_range=None, multi_gpu_testing=False, gpu_id=0): ...@@ -93,7 +91,7 @@ def run_inference(ind_range=None, multi_gpu_testing=False, gpu_id=0):
# In this case test_net was called via subprocess.Popen to execute on a # In this case test_net was called via subprocess.Popen to execute on a
# range of inputs on a single dataset (i.e., use cfg.TEST.DATASET and # range of inputs on a single dataset (i.e., use cfg.TEST.DATASET and
# don't loop over cfg.TEST.DATASETS) # don't loop over cfg.TEST.DATASETS)
output_dir = get_output_dir(training=False) output_dir = get_output_dir(cfg.TEST.DATASET, training=False)
return child_func(output_dir, ind_range=ind_range, gpu_id=gpu_id) return child_func(output_dir, ind_range=ind_range, gpu_id=gpu_id)
......
...@@ -175,7 +175,7 @@ def create_model(): ...@@ -175,7 +175,7 @@ def create_model():
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
start_iter = 0 start_iter = 0
checkpoints = {} checkpoints = {}
output_dir = get_output_dir(training=True) output_dir = get_output_dir(cfg.TRAIN.DATASETS, training=True)
if cfg.TRAIN.AUTO_RESUME: if cfg.TRAIN.AUTO_RESUME:
# Check for the final model (indicates training already finished) # Check for the final model (indicates training already finished)
final_path = os.path.join(output_dir, 'model_final.pkl') final_path = os.path.join(output_dir, 'model_final.pkl')
......
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