forked from facebookresearch/DetectAndTrack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
launch.py
executable file
·67 lines (57 loc) · 1.97 KB
/
launch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
##############################################################
# Copyright (c) 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
##############################################################
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import argparse
import sys
import subprocess
def parse_args():
parser = argparse.ArgumentParser(description='Launch a config')
parser.add_argument(
'--cfg', '-c', dest='cfg_file', required=True,
help='Config file to run')
parser.add_argument(
'--mode', '-m', dest='mode',
help='Mode to run [train/test/track/eval]',
default='train')
parser.add_argument(
'opts', help='See lib/core/config.py for all options', default=None,
nargs=argparse.REMAINDER)
if len(sys.argv) == 1:
parser.print_help()
sys.exit(1)
return parser.parse_args()
def _run_cmd(tool_file, cfg_file, other_opts):
cmd = '''python tools/{tool_file} \
--cfg {cfg_file} \
{other_opts}
'''.format(tool_file=tool_file,
cfg_file=cfg_file,
other_opts=other_opts)
subprocess.call(cmd, shell=True)
def main():
args = parse_args()
other_opts = ''
if args.mode in ['train', 'test']:
other_opts += '--multi-gpu-testing '
other_opts += 'OUTPUT_DIR outputs/{} '.format(
args.cfg_file)
if args.opts is not None:
other_opts += ' '.join(args.opts)
tool_file = 'train_net.py'
if args.mode == 'test':
tool_file = 'test_net.py'
elif args.mode == 'track':
tool_file = 'compute_tracks.py'
elif args.mode == 'eval':
tool_file = 'eval_mpii.py'
_run_cmd(tool_file, args.cfg_file, other_opts)
if __name__ == '__main__':
main()