Skip to content

Commit 048c0ba

Browse files
authored
[Fix] Fix pretrained models of SegNeXt in master branch. (open-mmlab#2653)
## Motivation Transfer keys of each `mscan_x.pth` pretrained models of SegNeXt, and upload them in the website. The reason of transferring keys is we modify original repo [`.dwconv.dwconv.xxx`](https://github.com/Visual-Attention-Network/SegNeXt/blob/main/mmseg/models/backbones/mscan.py#L21) to [`.dwconv.xxx`](https://github.com/open-mmlab/mmsegmentation/blob/master/mmseg/models/backbones/mscan.py#L43).
1 parent 49a5931 commit 048c0ba

5 files changed

+10
-8
lines changed

configs/segnext/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ We present SegNeXt, a simple convolutional network architecture for semantic seg
3131
}
3232
```
3333

34-
## Pretrained model
35-
36-
The pretrained model could be found [here](https://cloud.tsinghua.edu.cn/d/c15b25a6745946618462/) from [original repo](https://github.com/Visual-Attention-Network/SegNeXt). You can download and put them in `./pretrain` folder.
37-
3834
## Results and models
3935

4036
### ADE20K
@@ -48,6 +44,8 @@ The pretrained model could be found [here](https://cloud.tsinghua.edu.cn/d/c15b2
4844

4945
Note:
5046

47+
- When we integrated SegNeXt into MMSegmentation, we modified some layers' names to make them more precise and concise without changing the model architecture. Therefore, the keys of pre-trained weights are different from the [original weights](https://cloud.tsinghua.edu.cn/d/c15b25a6745946618462/), but don't worry about these changes. we have converted them and uploaded the checkpoints, you might find URL of pre-trained checkpoints in config files and can use them directly for training.
48+
5149
- The total batch size is 16. We trained for SegNeXt with a single GPU as the performance degrades significantly when using`SyncBN` (mainly in `OverlapPatchEmbed` modules of `MSCAN`) of PyTorch 1.9.
5250

5351
- There will be subtle differences when model testing as Non-negative Matrix Factorization (NMF) in `LightHamHead` will be initialized randomly. To control this randomness, please set the random seed when model testing. You can modify [`./tools/test.py`](https://github.com/open-mmlab/mmsegmentation/blob/master/tools/test.py) like:

configs/segnext/segnext_mscan-b_1x16_512x512_adamw_160k_ade20k.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
_base_ = './segnext_mscan-t_1x16_512x512_adamw_160k_ade20k.py'
22
# model settings
3+
checkpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/segnext/mscan_b_20230227-3ab7d230.pth' # noqa
34
ham_norm_cfg = dict(type='GN', num_groups=32, requires_grad=True)
45
model = dict(
56
type='EncoderDecoder',
67
backbone=dict(
78
embed_dims=[64, 128, 320, 512],
89
depths=[3, 3, 12, 3],
9-
init_cfg=dict(type='Pretrained', checkpoint='pretrain/mscan_b.pth'),
10+
init_cfg=dict(type='Pretrained', checkpoint=checkpoint_file),
1011
drop_path_rate=0.1,
1112
norm_cfg=dict(type='BN', requires_grad=True)),
1213
decode_head=dict(

configs/segnext/segnext_mscan-l_1x16_512x512_adamw_160k_ade20k.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
_base_ = './segnext_mscan-t_1x16_512x512_adamw_160k_ade20k.py'
22
# model settings
3+
checkpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/segnext/mscan_l_20230227-cef260d4.pth' # noqa
34
ham_norm_cfg = dict(type='GN', num_groups=32, requires_grad=True)
45
model = dict(
56
type='EncoderDecoder',
67
backbone=dict(
78
embed_dims=[64, 128, 320, 512],
89
depths=[3, 5, 27, 3],
9-
init_cfg=dict(type='Pretrained', checkpoint='pretrain/mscan_l.pth'),
10+
init_cfg=dict(type='Pretrained', checkpoint=checkpoint_file),
1011
drop_path_rate=0.3,
1112
norm_cfg=dict(type='BN', requires_grad=True)),
1213
decode_head=dict(

configs/segnext/segnext_mscan-s_1x16_512x512_adamw_160k_ade20k.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
_base_ = './segnext_mscan-t_1x16_512x512_adamw_160k_ade20k.py'
22
# model settings
3+
checkpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/segnext/mscan_s_20230227-f33ccdf2.pth' # noqa
34
ham_norm_cfg = dict(type='GN', num_groups=32, requires_grad=True)
45
model = dict(
56
type='EncoderDecoder',
67
backbone=dict(
78
embed_dims=[64, 128, 320, 512],
89
depths=[2, 2, 4, 2],
9-
init_cfg=dict(type='Pretrained', checkpoint='./pretrain/mscan_s.pth'),
10+
init_cfg=dict(type='Pretrained', checkpoint=checkpoint_file),
1011
norm_cfg=dict(type='BN', requires_grad=True)),
1112
decode_head=dict(
1213
type='LightHamHead',

configs/segnext/segnext_mscan-t_1x16_512x512_adamw_160k_ade20k.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
'../_base_/default_runtime.py', '../_base_/schedules/schedule_160k.py'
33
]
44
# model settings
5+
checkpoint_file = 'https://download.openmmlab.com/mmsegmentation/v0.5/pretrain/segnext/mscan_t_20230227-119e8c9f.pth' # noqa
56
ham_norm_cfg = dict(type='GN', num_groups=32, requires_grad=True)
67
model = dict(
78
type='EncoderDecoder',
89
pretrained=None,
910
backbone=dict(
1011
type='MSCAN',
11-
init_cfg=dict(type='Pretrained', checkpoint='./pretrain/mscan_t.pth'),
12+
init_cfg=dict(type='Pretrained', checkpoint=checkpoint_file),
1213
embed_dims=[32, 64, 160, 256],
1314
mlp_ratios=[8, 8, 4, 4],
1415
drop_rate=0.0,

0 commit comments

Comments
 (0)