Skip to content

Commit

Permalink
[Feature] Provide URLs of Swin Transformer pretrained models (open-mm…
Browse files Browse the repository at this point in the history
…lab#1389)

* [Feature] Provide URLs of Swin Transformer pretrained models

* [Feature] Add multi machine `dist_train`. (open-mmlab#1383)

* Add training startup documentation

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* delete pretrained=None in all six config files

* [Fix] make arguments effective in tools/confusion_matrix.py (open-mmlab#1401)

* add an argument for customizing `title' of the output figure

* fix `color_theme' arguments not passing to plot function

Signed-off-by: code14 <[email protected]>

* colab notebook: fix outdated link for doc (open-mmlab#1392)

* colab notebook: fix outdated link for doc

Fixed outdated link for how to customize your datasets by reorganizing data.

* fix lint

* fix typo (open-mmlab#1405)

* [Fix] Fix windows-style path in `md2yml.py` in Windows pre-commit.  (open-mmlab#1407)

* test

* avoid windows path

* [Fix] fix the config name style description (open-mmlab#1414)

Co-authored-by: FangjianLin <[email protected]>
Co-authored-by: Cody Wong <[email protected]>
Co-authored-by: Nemo Xiong <[email protected]>
Co-authored-by: Xiangxu-0103 <[email protected]>
Co-authored-by: Rockey <[email protected]>
  • Loading branch information
6 people committed Apr 13, 2022
1 parent 11f0610 commit b60891c
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 10 deletions.
Binary file added .DS_Store
Binary file not shown.
15 changes: 13 additions & 2 deletions configs/swin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ This paper presents a new vision Transformer, called Swin Transformer, that capa

## Usage

To use other repositories' pre-trained models, it is necessary to convert keys.
We have provided pretrained models converted from [official repo](https://github.com/microsoft/Swin-Transformer)

We provide a script [`swin2mmseg.py`](../../tools/model_converters/swin2mmseg.py) in the tools directory to convert the key of models from [the official repo](https://github.com/SwinTransformer/Swin-Transformer-Semantic-Segmentation) to MMSegmentation style.
If you want to convert keys on your own to use official repositories' pre-trained models, we also provide a script [`swin2mmseg.py`](../../tools/model_converters/swin2mmseg.py) in the tools directory to convert the key of models from [the official repo](https://github.com/SwinTransformer/Swin-Transformer-Semantic-Segmentation) to MMSegmentation style.

```shell
python tools/model_converters/swin2mmseg.py ${PRETRAIN_PATH} ${STORE_PATH}
Expand All @@ -50,6 +50,17 @@ python tools/model_converters/swin2mmseg.py https://github.com/SwinTransformer/s

This script convert model from `PRETRAIN_PATH` and store the converted model in `STORE_PATH`.

In our default setting, pretrained models and their corresponding [original models](https://github.com/microsoft/Swin-Transforme) models could be defined below:

| pretrained models | original models |
| ------ | -------- |
|pretrain/swin_tiny_patch4_window7_224.pth | [swin_tiny_patch4_window7_224.pth](https://github.com/SwinTransformer/storage/releases/download/v1.0.0/swin_tiny_patch4_window7_224.pth) |
|pretrain/swin_small_patch4_window7_224.pth | [swin_small_patch4_window7_224.pth](https://github.com/SwinTransformer/storage/releases/download/v1.0.0/swin_small_patch4_window7_224.pth) |
|pretrain/swin_base_patch4_window7_224.pth | [swin_base_patch4_window7_224.pth](https://github.com/SwinTransformer/storage/releases/download/v1.0.0/swin_base_patch4_window7_224.pth) |
|pretrain/swin_base_patch4_window7_224_22k.pth | [swin_base_patch4_window7_224_22k.pth](https://github.com/SwinTransformer/storage/releases/download/v1.0.0/swin_base_patch4_window7_224_22k.pth) |
|pretrain/swin_base_patch4_window12_384.pth | [swin_base_patch4_window12_384.pth](https://github.com/SwinTransformer/storage/releases/download/v1.0.0/swin_base_patch4_window12_384.pth) |
|pretrain/swin_base_patch4_window12_384_22k.pth | [swin_base_patch4_window12_384_22k.pth](https://github.com/SwinTransformer/storage/releases/download/v1.0.0/swin_base_patch4_window12_384_22k.pth) |

## Results and models

### ADE20K
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
'upernet_swin_tiny_patch4_window7_512x512_160k_ade20k_'
'pretrain_224x224_1K.py'
]
checkpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/swin/swin_base_patch4_window12_384_20220317-55b0104a.pth' # noqa
model = dict(
pretrained='pretrain/swin_base_patch4_window12_384.pth',
backbone=dict(
init_cfg=dict(type='Pretrained', checkpoint=checkpoint_file),
pretrain_img_size=384,
embed_dims=128,
depths=[2, 2, 18, 2],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
'./upernet_swin_base_patch4_window12_512x512_160k_ade20k_'
'pretrain_384x384_1K.py'
]
model = dict(pretrained='pretrain/swin_base_patch4_window12_384_22k.pth')
checkpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/swin/swin_base_patch4_window12_384_22k_20220317-e5c09f74.pth' # noqa
model = dict(
backbone=dict(
init_cfg=dict(type='Pretrained', checkpoint=checkpoint_file)))
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
'./upernet_swin_tiny_patch4_window7_512x512_160k_ade20k_'
'pretrain_224x224_1K.py'
]
checkpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/swin/swin_base_patch4_window7_224_20220317-e9b98025.pth' # noqa
model = dict(
pretrained='pretrain/swin_base_patch4_window7_224.pth',
backbone=dict(
embed_dims=128, depths=[2, 2, 18, 2], num_heads=[4, 8, 16, 32]),
init_cfg=dict(type='Pretrained', checkpoint=checkpoint_file),
embed_dims=128,
depths=[2, 2, 18, 2],
num_heads=[4, 8, 16, 32]),
decode_head=dict(in_channels=[128, 256, 512, 1024], num_classes=150),
auxiliary_head=dict(in_channels=512, num_classes=150))
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
'./upernet_swin_base_patch4_window7_512x512_160k_ade20k_'
'pretrain_224x224_1K.py'
]
model = dict(pretrained='pretrain/swin_base_patch4_window7_224_22k.pth')
checkpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/swin/swin_base_patch4_window7_224_22k_20220317-4f79f7c0.pth' # noqa
model = dict(
backbone=dict(
init_cfg=dict(type='Pretrained', checkpoint=checkpoint_file)))
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
'./upernet_swin_tiny_patch4_window7_512x512_160k_ade20k_'
'pretrain_224x224_1K.py'
]
checkpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/swin/swin_small_patch4_window7_224_20220317-7ba6d6dd.pth' # noqa
model = dict(
pretrained='pretrain/swin_small_patch4_window7_224.pth',
backbone=dict(depths=[2, 2, 18, 2]),
backbone=dict(
init_cfg=dict(type='Pretrained', checkpoint=checkpoint_file),
depths=[2, 2, 18, 2]),
decode_head=dict(in_channels=[96, 192, 384, 768], num_classes=150),
auxiliary_head=dict(in_channels=384, num_classes=150))
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
'../_base_/models/upernet_swin.py', '../_base_/datasets/ade20k.py',
'../_base_/default_runtime.py', '../_base_/schedules/schedule_160k.py'
]
checkpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/swin/swin_tiny_patch4_window7_224_20220317-1cdeb081.pth' # noqa
model = dict(
pretrained='pretrain/swin_tiny_patch4_window7_224.pth',
backbone=dict(
init_cfg=dict(type='Pretrained', checkpoint=checkpoint_file),
embed_dims=96,
depths=[2, 2, 6, 2],
num_heads=[3, 6, 12, 24],
Expand Down

0 comments on commit b60891c

Please sign in to comment.