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

Support importing train.py #11444

Open
wants to merge 1 commit into
base: dev-3.x
Choose a base branch
from
Open
Changes from all 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
11 changes: 7 additions & 4 deletions tools/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from mmdet.utils import setup_cache_size_limit_of_dynamo


def parse_args():
def parse_args(argv=None):
parser = argparse.ArgumentParser(description='Train a detector')
parser.add_argument('config', help='train config file path')
parser.add_argument('--work-dir', help='the dir to save logs and models')
Expand Down Expand Up @@ -50,16 +50,19 @@ def parse_args():
# will pass the `--local-rank` parameter to `tools/train.py` instead
# of `--local_rank`.
parser.add_argument('--local_rank', '--local-rank', type=int, default=0)
args = parser.parse_args()
args = parser.parse_args(argv)
if 'LOCAL_RANK' not in os.environ:
os.environ['LOCAL_RANK'] = str(args.local_rank)

return args


def main():
args = parse_args()
def main(argv=None):
args = parse_args(argv)
return main2(args)


def main2(args):
# Reduce the number of repeated compilations and improve
# training speed.
setup_cache_size_limit_of_dynamo()
Expand Down