diff --git a/README_zh-CN.md b/README_zh-CN.md index 858485fd5..f7c3b0b18 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -76,7 +76,7 @@ MMSegmentation 是一个基于 PyTorch 的语义分割开源工具箱。它是 O 同时,我们提供了 Colab 教程。你可以在[这里](demo/MMSegmentation_Tutorial.ipynb)浏览教程,或者直接在 Colab 上[运行](https://colab.research.google.com/github/open-mmlab/mmsegmentation/blob/1.x/demo/MMSegmentation_Tutorial.ipynb)。 -若需要将0.x版本的代码迁移至新版,请参考[迁移文档](docs/zh_cn/migration.md)。 +若需要将0.x版本的代码迁移至新版,请参考[迁移文档](docs/zh_cn/migration)。 ## 基准测试和模型库 diff --git a/docs/en/migration/interface.md b/docs/en/migration/interface.md index d75f8ec3e..3dab125eb 100644 --- a/docs/en/migration/interface.md +++ b/docs/en/migration/interface.md @@ -6,14 +6,17 @@ This guide describes the fundamental differences between MMSegmentation 0.x and ## New dependencies -MMSegmentation 1.x depends on some new packages, you can prepare a new clean environment and install again according to the [installation tutorial](get_started.md). +MMSegmentation 1.x depends on some new packages, you can prepare a new clean environment and install again according to the [installation tutorial](../get_started.md). + Or install the below packages manually. 1. [MMEngine](https://github.com/open-mmlab/mmengine): MMEngine is the core the OpenMMLab 2.0 architecture, and we splited many compentents unrelated to computer vision from MMCV to MMEngine. 2. [MMCV](https://github.com/open-mmlab/mmcv): The computer vision package of OpenMMLab. This is not a new dependency, but you need to upgrade it to above **2.0.0rc1** version. -3. [MMClassification](https://github.com/open-mmlab/mmclassification)(Optional): The image classification toolbox and benchmark of OpenMMLab. This is not a new dependency, but you need to upgrade it to above **1.0.0rc0** version. +3. [MMClassification](https://github.com/open-mmlab/mmclassification)(Optional): The image classification toolbox and benchmark of OpenMMLab. This is not a new dependency, but you need to upgrade it to above **1.0.0rc0** version. + +4. [MMDetection](https://github.com/open-mmlab/mmdetection)(Optional): The object detection toolbox and benchmark of OpenMMLab. This is not a new dependency, but you need to upgrade it to above **3.0.0rc0** version. ## Train launch @@ -86,7 +89,7 @@ Add `model.data_preprocessor` field to configure the `DataPreProcessor`, includi - `bgr_to_rgb` (bool): whether to convert image from BGR to RGB.Defaults to False. -- `rgb_to_bgr` (bool): whether to convert image from RGB to RGB. Defaults to False. +- `rgb_to_bgr` (bool): whether to convert image from RGB to BGR. Defaults to False. **Note:** Please refer [models documentation](../advanced_guides/models.md) for more details. @@ -260,8 +263,7 @@ tta_pipeline = [ Changes in **`evaluation`**: - The **`evaluation`** field is split to `val_evaluator` and `test_evaluator`. And it won't support `interval` and `save_best` arguments. - The `interval` is moved to `train_cfg.val_interval`, and the `save_best` - is moved to `default_hooks.checkpoint.save_best`. `pre_eval` has been removed. + The `interval` is moved to `train_cfg.val_interval`, and the `save_best` is moved to `default_hooks.checkpoint.save_best`. `pre_eval` has been removed. - `'mIoU'` has been changed to `'IoUMetric'`.
功能 | +原版 | +新版 | +
加载预训练模型 | +--load_from=$CHECKPOINT | +--cfg-options load_from=$CHECKPOINT | +
从特定检查点恢复训练 | +--resume-from=$CHECKPOINT | +--resume=$CHECKPOINT | +
从最新的检查点恢复训练 | +--auto-resume | +--resume='auto' | +
培训练期间是否不评估检查点 | +--no-validate | +--cfg-options val_cfg=None val_dataloader=None val_evaluator=None | +
指定训练设备 | +--gpu-id=$DEVICE_ID | +- | +
是否为不同进程设置不同的种子 | +--diff-seed | +--cfg-options randomness.diff_rank_seed=True | +是否为 CUDNN 后端设置确定性选项 | +--deterministic | +--cfg-options randomness.deterministic=True | +
原版 | ++ +```python +data = dict( + samples_per_gpu=4, + workers_per_gpu=4, + train=dict(...), + val=dict(...), + test=dict(...), +) +``` + + | +
新版 | ++ +```python +train_dataloader = dict( + batch_size=4, + num_workers=4, + dataset=dict(...), + sampler=dict(type='DefaultSampler', shuffle=True) # necessary +) + +val_dataloader = dict( + batch_size=4, + num_workers=4, + dataset=dict(...), + sampler=dict(type='DefaultSampler', shuffle=False) # necessary +) + +test_dataloader = val_dataloader +``` + + | +
原版 | ++ +```python +train_pipeline = [ + dict(type='LoadImageFromFile'), + dict(type='LoadAnnotations', reduce_zero_label=True), + dict(type='Resize', img_scale=(2560, 640), ratio_range=(0.5, 2.0)), + dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75), + dict(type='RandomFlip', prob=0.5), + dict(type='PhotoMetricDistortion'), + dict(type='Normalize', **img_norm_cfg), + dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255), + dict(type='DefaultFormatBundle'), + dict(type='Collect', keys=['img', 'gt_semantic_seg']), +] +``` + + | +
新版 | ++ +```python +train_pipeline = [ + dict(type='LoadImageFromFile'), + dict(type='LoadAnnotations', reduce_zero_label=True), + dict( + type='RandomResize', + scale=(2560, 640), + ratio_range=(0.5, 2.0), + keep_ratio=True), + dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75), + dict(type='RandomFlip', prob=0.5), + dict(type='PhotoMetricDistortion'), + dict(type='PackSegInputs') +] +``` + + | +
原版 | ++ +```python +test_pipeline = [ + dict(type='LoadImageFromFile'), + dict( + type='MultiScaleFlipAug', + img_scale=(2560, 640), + # img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75], + flip=False, + transforms=[ + dict(type='Resize', keep_ratio=True), + dict(type='RandomFlip'), + dict(type='Normalize', **img_norm_cfg), + dict(type='ImageToTensor', keys=['img']), + dict(type='Collect', keys=['img']), + ]) +] +``` + + | +
新版 | ++ +```python +test_pipeline = [ + dict(type='LoadImageFromFile'), + dict(type='Resize', scale=(2560, 640), keep_ratio=True), + dict(type='LoadAnnotations', reduce_zero_label=True), + dict(type='PackSegInputs') +] +img_ratios = [0.5, 0.75, 1.0, 1.25, 1.5, 1.75] +tta_pipeline = [ + dict(type='LoadImageFromFile', backend_args=None), + dict( + type='TestTimeAug', + transforms=[ + [ + dict(type='Resize', scale_factor=r, keep_ratio=True) + for r in img_ratios + ], + [ + dict(type='RandomFlip', prob=0., direction='horizontal'), + dict(type='RandomFlip', prob=1., direction='horizontal') + ], [dict(type='LoadAnnotations')], [dict(type='PackSegInputs')] + ]) +] +``` + + | +
原版 | ++ +```python +evaluation = dict(interval=2000, metric='mIoU', pre_eval=True) +``` + + | +
新版 | ++ +```python +val_evaluator = dict(type='IoUMetric', iou_metrics=['mIoU']) +test_evaluator = val_evaluator +``` + + | +
原版 | ++ +```python +optimizer = dict(type='AdamW', lr=0.0001, weight_decay=0.0005) +optimizer_config = dict(grad_clip=dict(max_norm=1, norm_type=2)) +``` + + | +
新版 | ++ +```python +optim_wrapper = dict( + type='OptimWrapper', + optimizer=dict(type='AdamW', lr=0.0001, weight_decay=0.0005), + clip_grad=dict(max_norm=1, norm_type=2)) +``` + + | +
原版 | ++ +```python +lr_config = dict( + policy='poly', + warmup='linear', + warmup_iters=1500, + warmup_ratio=1e-6, + power=1.0, + min_lr=0.0, + by_epoch=False) +``` + + | +
新版 | ++ +```python +param_scheduler = [ + dict( + type='LinearLR', start_factor=1e-6, by_epoch=False, begin=0, end=1500), + dict( + type='PolyLR', + power=1.0, + begin=1500, + end=160000, + eta_min=0.0, + by_epoch=False, + ) +] +``` + + | +
原版 | ++ +```python +runner = dict(type='IterBasedRunner', max_iters=20000) +``` + + | +
新版 | ++ +```python +# The `val_interval` is the original `evaluation.interval`. +train_cfg = dict(type='IterBasedTrainLoop', max_iters=20000, val_interval=2000) +val_cfg = dict(type='ValLoop') # Use the default validation loop. +test_cfg = dict(type='TestLoop') # Use the default test loop. +``` + + | +
原版 | ++ +```python +log_config = dict( + interval=100, + hooks=[ + dict(type='TextLoggerHook'), + dict(type='TensorboardLoggerHook'), + ]) +``` + + | +
新版 | ++ +```python +default_hooks = dict( + ... + logger=dict(type='LoggerHook', interval=100), +) +vis_backends = [dict(type='LocalVisBackend'), + dict(type='TensorboardVisBackend')] +visualizer = dict( + type='SegLocalVisualizer', vis_backends=vis_backends, name='visualizer') +``` + + | +
MMSegmentation 0.x | +MMSegmentation 1.x | +
mmseg.api | +mmseg.api | +
- mmseg.core | ++ mmseg.engine | +
mmseg.datasets | +mmseg.datasets | +
mmseg.models | +mmseg.models | +
- mmseg.ops | ++ mmseg.structure | +
mmseg.utils | +mmseg.utils | +
+ | + mmseg.evaluation | +
+ | + mmseg.registry | +