Skip to content

Commit

Permalink
[Enhancement] Support flexible runner (#2646)
Browse files Browse the repository at this point in the history
  • Loading branch information
cir7 authored Sep 6, 2023
1 parent 8ff889a commit de82f14
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion tools/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from mmengine.config import Config, DictAction
from mmengine.runner import Runner

from mmaction.registry import RUNNERS


def parse_args():
parser = argparse.ArgumentParser(
Expand Down Expand Up @@ -108,7 +110,13 @@ def main():
cfg.load_from = args.checkpoint

# build the runner from config
runner = Runner.from_cfg(cfg)
if 'runner_type' not in cfg:
# build the default runner
runner = Runner.from_cfg(cfg)
else:
# build customized runner from the registry
# if 'runner_type' is set in the cfg
runner = RUNNERS.build(cfg)

# start testing
runner.test()
Expand Down
10 changes: 9 additions & 1 deletion tools/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
from mmengine.config import Config, DictAction
from mmengine.runner import Runner

from mmaction.registry import RUNNERS


def parse_args():
parser = argparse.ArgumentParser(description='Train a action recognizer')
Expand Down Expand Up @@ -125,7 +127,13 @@ def main():
cfg = merge_args(cfg, args)

# build the runner from config
runner = Runner.from_cfg(cfg)
if 'runner_type' not in cfg:
# build the default runner
runner = Runner.from_cfg(cfg)
else:
# build customized runner from the registry
# if 'runner_type' is set in the cfg
runner = RUNNERS.build(cfg)

# start training
runner.train()
Expand Down

0 comments on commit de82f14

Please sign in to comment.