Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
Save full configuration in output dir (#835)
Browse files Browse the repository at this point in the history
* Merge branch 'master' of /home/braincreator/projects/maskrcnn-benchmark with conflicts.

* update Dockerfile

* save config in output dir

* replace string format with os.path.join
  • Loading branch information
Miguel Varela Ramos authored and fmassa committed May 31, 2019
1 parent d269847 commit 7338be2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions maskrcnn_benchmark/utils/miscellaneous.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import errno
import os
from .comm import is_main_process


def mkdir(path):
Expand All @@ -9,3 +10,9 @@ def mkdir(path):
except OSError as e:
if e.errno != errno.EEXIST:
raise


def save_config(cfg, path):
if is_main_process():
with open(path, 'w') as f:
f.write(cfg.dump())
7 changes: 6 additions & 1 deletion tools/train_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from maskrcnn_benchmark.utils.comm import synchronize, get_rank
from maskrcnn_benchmark.utils.imports import import_file
from maskrcnn_benchmark.utils.logger import setup_logger
from maskrcnn_benchmark.utils.miscellaneous import mkdir
from maskrcnn_benchmark.utils.miscellaneous import mkdir, save_config

# See if we can use apex.DistributedDataParallel instead of the torch default,
# and enable mixed-precision via apex.amp
Expand Down Expand Up @@ -176,6 +176,11 @@ def main():
logger.info(config_str)
logger.info("Running with config:\n{}".format(cfg))

output_config_path = os.path.join(cfg.OUTPUT_DIR, 'config.yml')
logger.info("Saving config into: {}".format(output_config_path))
# save overloaded model config in the output directory
save_config(cfg, output_config_path)

model = train(cfg, args.local_rank, args.distributed)

if not args.skip_test:
Expand Down

0 comments on commit 7338be2

Please sign in to comment.