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

[Refactor] Customize runner type #437

Merged
merged 3 commits into from
Apr 14, 2021
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion configs/3dssd/3dssd_kitti-3d-car.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2))
lr_config = dict(policy='step', warmup=None, step=[80, 120])
# runtime settings
total_epochs = 150
runner = dict(max_epochs=150)

# yapf:disable
log_config = dict(
Expand Down
2 changes: 1 addition & 1 deletion configs/_base_/models/3dssd.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@
optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2))
lr_config = dict(policy='step', warmup=None, step=[80, 120])
# runtime settings
total_epochs = 150
runner = dict(max_epochs=150)
2 changes: 1 addition & 1 deletion configs/_base_/schedules/cyclic_20e.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
)

# runtime settings
total_epochs = 20
runner = dict(type='EpochBasedRunner', max_epochs=20)
6 changes: 3 additions & 3 deletions configs/_base_/schedules/cyclic_40e.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
cyclic_times=1,
step_ratio_up=0.4,
)
# Although the total_epochs is 40, this schedule is usually used we
# RepeatDataset with repeat ratio N, thus the actual total epoch
# Although the max_epochs is 40, this schedule is usually used we
# RepeatDataset with repeat ratio N, thus the actual max epoch
# number could be Nx40
total_epochs = 40
runner = dict(type='EpochBasedRunner', max_epochs=40)
2 changes: 1 addition & 1 deletion configs/_base_/schedules/mmdet_schedule_1x.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
warmup_iters=500,
warmup_ratio=0.001,
step=[8, 11])
total_epochs = 12
runner = dict(type='EpochBasedRunner', max_epochs=12)
2 changes: 1 addition & 1 deletion configs/_base_/schedules/schedule_2x.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
step=[20, 23])
momentum_config = None
# runtime settings
total_epochs = 24
runner = dict(type='EpochBasedRunner', max_epochs=24)
2 changes: 1 addition & 1 deletion configs/_base_/schedules/schedule_3x.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
optimizer_config = dict(grad_clip=dict(max_norm=10, norm_type=2))
lr_config = dict(policy='step', warmup=None, step=[24, 32])
# runtime settings
total_epochs = 36
runner = dict(type='EpochBasedRunner', max_epochs=36)
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
])
# yapf:enable
# runtime settings
total_epochs = 80
runner = dict(max_epochs=80)
dist_params = dict(backend='nccl', port=29506)
log_level = 'INFO'
find_unused_parameters = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
])
# yapf:enable
# runtime settings
total_epochs = 50
runner = dict(max_epochs=50)
dist_params = dict(backend='nccl')
log_level = 'INFO'
work_dir = './work_dirs/pp_secfpn_100e'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
])
# yapf:enable
# runtime settings
total_epochs = 80
runner = dict(max_epochs=80)
dist_params = dict(backend='nccl')
log_level = 'INFO'
work_dir = './work_dirs/pp_secfpn_80e'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
])
# yapf:enable
# runtime settings
total_epochs = 80
runner = dict(max_epochs=80)
dist_params = dict(backend='nccl')
log_level = 'INFO'
work_dir = './work_dirs/sec_secfpn_80e'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@

lr_config = dict(step=[28, 34])
evaluation = dict(interval=36)
total_epochs = 36
runner = dict(max_epochs=36)
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@
data = dict(train=dict(pipeline=train_pipeline))
lr_config = dict(step=[28, 34])
evaluation = dict(interval=36)
total_epochs = 36
runner = dict(max_epochs=36)
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@
warmup_iters=500,
warmup_ratio=0.001,
step=[6])
total_epochs = 8
runner = dict(max_epochs=8)

load_from = 'http://download.openmmlab.com/mmdetection/v2.0/mask_rcnn/mask_rcnn_r50_caffe_fpn_mstrain-poly_3x_coco/mask_rcnn_r50_caffe_fpn_mstrain-poly_3x_coco_bbox_mAP-0.408__segm_mAP-0.37_20200504_163245-42aa3d00.pth' # noqa
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
# yapf:enable
evaluation = dict(interval=1)
# runtime settings
total_epochs = 40
runner = dict(max_epochs=40)
dist_params = dict(backend='nccl')
log_level = 'INFO'
work_dir = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

# learning policy
lr_config = dict(step=[16, 19])
total_epochs = 20
runner = dict(max_epochs=20)

load_from = 'http://download.openmmlab.com/mmdetection/v2.0/cascade_rcnn/cascade_mask_rcnn_r50_fpn_20e_coco/cascade_mask_rcnn_r50_fpn_20e_coco_bbox_mAP-0.419__segm_mAP-0.365_20200504_174711-4af8e66e.pth' # noqa
2 changes: 1 addition & 1 deletion configs/nuimages/htc_r50_fpn_coco-20e_20e_nuim.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
_base_ = './htc_r50_fpn_coco-20e_1x_nuim.py'
# learning policy
lr_config = dict(step=[16, 19])
total_epochs = 20
runner = dict(max_epochs=20)
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
data = dict(samples_per_gpu=1, workers_per_gpu=1)
# learning policy
lr_config = dict(step=[16, 19])
total_epochs = 20
runner = dict(max_epochs=20)

load_from = 'http://download.openmmlab.com/mmdetection/v2.0/htc/htc_x101_64x4d_fpn_dconv_c3-c5_mstrain_400_1400_16x1_20e_coco/htc_x101_64x4d_fpn_dconv_c3-c5_mstrain_400_1400_16x1_20e_coco_20200312-946fd751.pth' # noqa
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@

# learning policy
lr_config = dict(step=[16, 19])
total_epochs = 20
runner = dict(max_epochs=20)

load_from = 'http://download.openmmlab.com/mmdetection/v2.0/mask_rcnn/mask_rcnn_r50_caffe_fpn_mstrain-poly_3x_coco/mask_rcnn_r50_caffe_fpn_mstrain-poly_3x_coco_bbox_mAP-0.408__segm_mAP-0.37_20200504_163245-42aa3d00.pth' # noqa
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@
# PointPillars usually need longer schedule than second, we simply double
# the training schedule. Do remind that since we use RepeatDataset and
# repeat factor is 2, so we actually train 160 epochs.
total_epochs = 80
runner = dict(max_epochs=80)
2 changes: 1 addition & 1 deletion docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The required versions of MMCV and MMDetection for different versions of MMDetect

| MMDetection3D version | MMDetection version | MMCV version |
|:-------------------:|:-------------------:|:-------------------:|
| master | mmdet>=2.5.0 | mmcv-full>=1.2.4, <=1.4|
| master | mmdet>=2.10.0 | mmcv-full>=1.2.4, <=1.4|
| 0.12.0 | mmdet>=2.5.0 | mmcv-full>=1.2.4, <=1.4|
| 0.11.0 | mmdet>=2.5.0 | mmcv-full>=1.2.4, <=1.4|
| 0.10.0 | mmdet>=2.5.0 | mmcv-full>=1.2.4, <=1.4|
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,14 @@ log_config = dict( # config to register logger hook
interval=50, # Interval to print the log
hooks=[dict(type='TextLoggerHook'),
dict(type='TensorboardLoggerHook')]) # The logger used to record the training process.
total_epochs = 36 # Total epochs to train the model
runner = dict(type='EpochBasedRunner', max_epochs=36) # Runner that runs the workflow in total max_epochs
dist_params = dict(backend='nccl') # Parameters to setup distributed training, the port can also be set.
log_level = 'INFO' # The level of logging.
find_unused_parameters = True # Whether to find unused parameters
work_dir = None # Directory to save the model checkpoints and logs for the current experiments.
load_from = None # load models as a pre-trained model from a given path. This will not resume training.
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 36 epochs according to the total_epochs.
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 36 epochs according to the max_epochs.
gpu_ids = range(0, 1) # ids of gpus
```

Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/customize_runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ so that 1 epoch for training and 1 epoch for validation will be run iteratively.
**Note**:

1. The parameters of model will not be updated during val epoch.
2. Keyword `total_epochs` in the config only controls the number of training epochs and will not affect the validation workflow.
2. Keyword `max_epochs` in `runner` in the config only controls the number of training epochs and will not affect the validation workflow.
3. Workflows `[('train', 1), ('val', 1)]` and `[('train', 1)]` will not change the behavior of `EvalHook` because `EvalHook` is called by `after_train_epoch` and validation workflow only affect hooks that are called through `after_val_epoch`. Therefore, the only difference between `[('train', 1), ('val', 1)]` and `[('train', 1)]` is that the runner will calculate losses on validation set after each training epoch.

## Customize hooks
Expand Down
2 changes: 1 addition & 1 deletion mmdet3d/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def digit_version(version_str):
f'MMCV=={mmcv.__version__} is used but incompatible. ' \
f'Please install mmcv>={mmcv_minimum_version}, <={mmcv_maximum_version}.'

mmdet_minimum_version = '2.5.0'
mmdet_minimum_version = '2.10.0'
mmdet_maximum_version = '3.0.0'
mmdet_version = digit_version(mmdet.__version__)
assert (mmdet_version >= digit_version(mmdet_minimum_version)
Expand Down