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

Customize runner type #4570

Merged
merged 9 commits into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions configs/_base_/default_runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
load_from = None
resume_from = None
workflow = [('train', 1)]
runner = 'EpochBasedRunner'
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
_base_ = 'faster_rcnn_r50_caffe_fpn_mstrain_1x_coco.py'
ZwwWayne marked this conversation as resolved.
Show resolved Hide resolved

# learning policy
lr_config = dict(
policy='step',
warmup='linear',
warmup_iters=500,
warmup_ratio=0.001,
step=[60000, 80000])
total_epochs = 90000

# Runner type
runner = 'IterBasedRunner'

checkpoint_config = dict(interval=10000)
evaluation = dict(interval=10000, metric='bbox')
ZwwWayne marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
_base_ = '../_base_/default_runtime.py'

# model settings
model = dict(
type='RetinaNet',
Expand Down Expand Up @@ -163,9 +165,3 @@
# yapf:enable
# runtime settings
total_epochs = 24
dist_params = dict(backend='nccl')
log_level = 'INFO'
work_dir = './work_dirs/ga_retinanet_r101_caffe_fpn_mstrain_2x'
load_from = None
resume_from = None
workflow = [('train', 1)]
5 changes: 0 additions & 5 deletions configs/vfnet/vfnet_r50_fpn_1x_coco.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,3 @@
warmup_ratio=0.1,
step=[8, 11])
total_epochs = 12

# runtime
load_from = None
resume_from = None
workflow = [('train', 1)]
1 change: 1 addition & 0 deletions docs/tutorials/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ load_from = None # load models as a pre-trained model from a given path. This w
resume_from = None # Resume checkpoints from a given path, the training will be resumed from the epoch when the checkpoint's is saved.
workflow = [('train', 1)] # Workflow for runner. [('train', 1)] means there is only one workflow and the workflow named 'train' is executed once. The workflow trains the model by 12 epochs according to the total_epochs.
work_dir = 'work_dir' # Directory to save the model checkpoints and logs for the current experiments.
runner = 'EpochBasedRunner' # Type of the runner that runs the workflow, can be either 'EpochBasedRunner' or 'IterBasedRunner'.

```

Expand Down
7 changes: 5 additions & 2 deletions mmdet/apis/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ def train_detector(model,

# build runner
optimizer = build_optimizer(model, cfg.optimizer)
runner = EpochBasedRunner(
assert cfg.runner in ('IterBasedRunner', 'EpochBasedRunner'), \
'Currently only support IterBasedRunner and EpochBasedRunner'
runner = eval(cfg.runner)(
model,
optimizer=optimizer,
work_dir=cfg.work_dir,
Expand All @@ -108,7 +110,8 @@ def train_detector(model,
cfg.checkpoint_config, cfg.log_config,
cfg.get('momentum_config', None))
if distributed:
runner.register_hook(DistSamplerSeedHook())
if isinstance(runner, EpochBasedRunner):
runner.register_hook(DistSamplerSeedHook())

# register eval hooks
if validate:
Expand Down