Skip to content

Commit ecd2dc4

Browse files
MengzhangLIlinfangjian01mob5566xiongnemoXiangxu-0103
authored
[Feature] Provide URLs of Swin Transformer pretrained models (open-mmlab#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]>
1 parent c9f507e commit ecd2dc4

8 files changed

+34
-10
lines changed

.DS_Store

10 KB
Binary file not shown.

configs/swin/README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ This paper presents a new vision Transformer, called Swin Transformer, that capa
3434

3535
## Usage
3636

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

39-
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.
39+
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.
4040

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

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

53+
In our default setting, pretrained models and their corresponding [original models](https://github.com/microsoft/Swin-Transforme) models could be defined below:
54+
55+
| pretrained models | original models |
56+
| ------ | -------- |
57+
|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) |
58+
|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) |
59+
|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) |
60+
|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) |
61+
|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) |
62+
|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) |
63+
5364
## Results and models
5465

5566
### ADE20K

configs/swin/upernet_swin_base_patch4_window12_512x512_160k_ade20k_pretrain_384x384_1K.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
'upernet_swin_tiny_patch4_window7_512x512_160k_ade20k_'
33
'pretrain_224x224_1K.py'
44
]
5+
checkpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/swin/swin_base_patch4_window12_384_20220317-55b0104a.pth' # noqa
56
model = dict(
6-
pretrained='pretrain/swin_base_patch4_window12_384.pth',
77
backbone=dict(
8+
init_cfg=dict(type='Pretrained', checkpoint=checkpoint_file),
89
pretrain_img_size=384,
910
embed_dims=128,
1011
depths=[2, 2, 18, 2],

configs/swin/upernet_swin_base_patch4_window12_512x512_160k_ade20k_pretrain_384x384_22K.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
'./upernet_swin_base_patch4_window12_512x512_160k_ade20k_'
33
'pretrain_384x384_1K.py'
44
]
5-
model = dict(pretrained='pretrain/swin_base_patch4_window12_384_22k.pth')
5+
checkpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/swin/swin_base_patch4_window12_384_22k_20220317-e5c09f74.pth' # noqa
6+
model = dict(
7+
backbone=dict(
8+
init_cfg=dict(type='Pretrained', checkpoint=checkpoint_file)))

configs/swin/upernet_swin_base_patch4_window7_512x512_160k_ade20k_pretrain_224x224_1K.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
'./upernet_swin_tiny_patch4_window7_512x512_160k_ade20k_'
33
'pretrain_224x224_1K.py'
44
]
5+
checkpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/swin/swin_base_patch4_window7_224_20220317-e9b98025.pth' # noqa
56
model = dict(
6-
pretrained='pretrain/swin_base_patch4_window7_224.pth',
77
backbone=dict(
8-
embed_dims=128, depths=[2, 2, 18, 2], num_heads=[4, 8, 16, 32]),
8+
init_cfg=dict(type='Pretrained', checkpoint=checkpoint_file),
9+
embed_dims=128,
10+
depths=[2, 2, 18, 2],
11+
num_heads=[4, 8, 16, 32]),
912
decode_head=dict(in_channels=[128, 256, 512, 1024], num_classes=150),
1013
auxiliary_head=dict(in_channels=512, num_classes=150))

configs/swin/upernet_swin_base_patch4_window7_512x512_160k_ade20k_pretrain_224x224_22K.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
'./upernet_swin_base_patch4_window7_512x512_160k_ade20k_'
33
'pretrain_224x224_1K.py'
44
]
5-
model = dict(pretrained='pretrain/swin_base_patch4_window7_224_22k.pth')
5+
checkpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/swin/swin_base_patch4_window7_224_22k_20220317-4f79f7c0.pth' # noqa
6+
model = dict(
7+
backbone=dict(
8+
init_cfg=dict(type='Pretrained', checkpoint=checkpoint_file)))

configs/swin/upernet_swin_small_patch4_window7_512x512_160k_ade20k_pretrain_224x224_1K.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
'./upernet_swin_tiny_patch4_window7_512x512_160k_ade20k_'
33
'pretrain_224x224_1K.py'
44
]
5+
checkpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/swin/swin_small_patch4_window7_224_20220317-7ba6d6dd.pth' # noqa
56
model = dict(
6-
pretrained='pretrain/swin_small_patch4_window7_224.pth',
7-
backbone=dict(depths=[2, 2, 18, 2]),
7+
backbone=dict(
8+
init_cfg=dict(type='Pretrained', checkpoint=checkpoint_file),
9+
depths=[2, 2, 18, 2]),
810
decode_head=dict(in_channels=[96, 192, 384, 768], num_classes=150),
911
auxiliary_head=dict(in_channels=384, num_classes=150))

configs/swin/upernet_swin_tiny_patch4_window7_512x512_160k_ade20k_pretrain_224x224_1K.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
'../_base_/models/upernet_swin.py', '../_base_/datasets/ade20k.py',
33
'../_base_/default_runtime.py', '../_base_/schedules/schedule_160k.py'
44
]
5+
checkpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/swin/swin_tiny_patch4_window7_224_20220317-1cdeb081.pth' # noqa
56
model = dict(
6-
pretrained='pretrain/swin_tiny_patch4_window7_224.pth',
77
backbone=dict(
8+
init_cfg=dict(type='Pretrained', checkpoint=checkpoint_file),
89
embed_dims=96,
910
depths=[2, 2, 6, 2],
1011
num_heads=[3, 6, 12, 24],

0 commit comments

Comments
 (0)