-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtrain.py
More file actions
42 lines (29 loc) · 889 Bytes
/
train.py
File metadata and controls
42 lines (29 loc) · 889 Bytes
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
import argparse
from pathlib import Path
from mmengine import Config
from mmengine.dist import master_only
from mmengine.runner import Runner
from mmengine.utils import get_git_hash
class TableRunner(Runner):
@master_only
def dump_config(self):
path = Path(self.log_dir)
name = Path(self.cfg.filename)
self.cfg.update(version=get_git_hash())
self.cfg.dump(path.joinpath(name.name))
def options():
args = argparse.ArgumentParser()
args.add_argument("config")
args.add_argument("--work-dir", required=True)
return args.parse_args()
def process(config: str, work_dir: str):
# config
config = Config.fromfile(config)
config.update(work_dir=work_dir)
# runner
runner = TableRunner.from_cfg(config)
# train
runner.train()
runner.test()
if __name__ == "__main__":
process(**vars(options()))