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

Save full configuration in output dir #835

Merged
merged 7 commits into from
May 31, 2019
Merged
Show file tree
Hide file tree
Changes from 6 commits
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
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 = "{}/config.yml".format(cfg.OUTPUT_DIR)
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