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

[Feature] Add segformer decode head and related train config #599

Merged
merged 121 commits into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from 115 commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
b56ceb2
[Feature]Segformer re-implementation
Jun 9, 2021
5a54664
Using act_cfg and norm_cfg to control activation and normalization
Jun 9, 2021
0d60aeb
Split this PR into several little PRs
Jun 10, 2021
c2b0ffd
Fix lint error
Jun 10, 2021
c7e676e
Remove SegFormerHead
Jun 10, 2021
e7ec3da
[Feature] Add segformer decode head and related train config
Jun 11, 2021
d27552f
Add ade20K trainval support for segformer
Jun 11, 2021
e94d6d9
Set arg: find_unused_parameters = True
Jun 11, 2021
237bc9e
Merge Master
Jun 18, 2021
9edbddd
parameters init refactor
Jun 19, 2021
99d7308
1. Refactor segformer backbone parameters init;
Jun 20, 2021
02b09bf
Merge branch 'master' into segformer
Jun 20, 2021
3373827
Remove rebundant codes
Jun 20, 2021
a6b02ee
Replace Linear Layer to 1X1 Conv
Jun 20, 2021
6365d16
Use nn.ModuleList to refactor segformer head.
Jun 20, 2021
f1b6615
Merge Master
Jun 20, 2021
7e12d7c
Remove local to_xtuple
Jun 20, 2021
d967a9f
1. Remove rebundant codes;
Jun 20, 2021
47326de
Refactor the backbone of segformer using mmcv.cnn.bricks.transformer.py
Jun 21, 2021
589af69
Fix some code logic bugs.
Jun 21, 2021
28099de
Add mit_convert.py to match pretrain keys of segformer.
Jun 22, 2021
ebcc3b1
Merge master and Fix name of segformer fusion conv
Jun 23, 2021
0f42462
Merge Master
Jun 23, 2021
e3b7157
Merge Master
Jul 6, 2021
a2110ae
Resolve some comments.
Jul 6, 2021
8b7ca03
1. Add some assert to ensure right params;
Jul 9, 2021
754789a
Merge branch 'master' into segformer
Jul 9, 2021
e137df3
Add pe_index assert and fix unit test.
Jul 9, 2021
b4ae0b5
1. Add doc string for MixVisionTransformer;
Jul 12, 2021
38f7bbe
Use hw_shape to pass shape of feature map.
Jul 14, 2021
443438f
1. Fix doc string of MixVisionTransformer;
Jul 14, 2021
1affeb6
Add more unit tests.
Jul 14, 2021
e969496
Add doc string for shape convertion functions.
Jul 14, 2021
582939b
Add some unit tests to improve code coverage.
Jul 14, 2021
9e06174
Merge segformer backbone.
Jul 15, 2021
e5acfe8
Fix Segformer backbone pretrain weights match bug.
Jul 15, 2021
403db24
Merge branch 'segformer' into segformer_trainval
Jul 15, 2021
af8f309
Modify configs of segformer.
Jul 15, 2021
71df617
resolve the shape convertion functions doc string.
Jul 15, 2021
f591d95
Merge branch 'segformer' into segformer_trainval
Jul 15, 2021
5ac60d4
Merge branch 'master' of github.com:open-mmlab/mmsegmentation into se…
Jul 15, 2021
38b2db8
Add pad_to_patch_size arg.
Jul 16, 2021
f3aaecc
Support progressive test with fewer memory cost.
Jul 16, 2021
e7039ff
Modify default value of pad_to_patch_size arg.
Jul 19, 2021
deafe51
Merge branch 'segformer' into segformer_trainval
Jul 19, 2021
7c944cf
Temp code
Jul 22, 2021
3a97df6
Using processor to refactor evaluation workflow.
Jul 22, 2021
e6be6b4
refactor eval hook.
Jul 22, 2021
fdb6b49
Fix multi gpu bug when index out of len(dataset).
Jul 22, 2021
8653c96
Fix process bar.
Jul 22, 2021
842bdef
Fix middle save argument.
Jul 22, 2021
d389665
Modify some variable name of dataset evaluate api.
Jul 22, 2021
9349970
Modify some viriable name of eval hook.
Jul 22, 2021
3a3b3ec
Fix some priority bugs of eval hook.
Jul 22, 2021
1ec10c7
Merge branch 'segformer_trainval' of github.com:sennnnn/mmsegmentatio…
Jul 24, 2021
d44968a
Merge branch 'segformer' into segformer_trainval
Jul 24, 2021
939bc14
Merge branch 'master' into segformer_trainval
Jul 24, 2021
1475f80
Fix some bugs about model loading and eval hook.
Jul 24, 2021
35503a9
Add ade20k 640x640 dataset.
Jul 24, 2021
ef7b2ca
Fix related segformer configs.
Jul 24, 2021
e03ee57
Depreciated efficient_test.
Jul 24, 2021
c3c491d
Fix training progress blocked by eval hook.
Jul 24, 2021
0cb97f4
Depreciated old test api.
Jul 24, 2021
1d3e271
Merge branch 'progressive_test' into segformer_trainval
Jul 24, 2021
ba6c9ff
Modify error patch size.
Jul 24, 2021
a631e76
Fix pretrain of mit_b0
Jul 24, 2021
543b1ab
Fix the test api error.
Jul 25, 2021
32c67e4
Merge branch 'segformer_trainval' of github.com:sennnnn/mmsegmentatio…
Jul 25, 2021
d5fd29a
Modify dataset base config.
Jul 25, 2021
25943c8
Fix test api error.
Jul 26, 2021
be13436
Modify outer api.
Jul 27, 2021
6bb1c91
Build a sampler test api.
Jul 27, 2021
25a7475
TODO: Refactor format_results.
Jul 27, 2021
25cc8ba
Modify variable names.
Jul 27, 2021
af54432
Fix num_classes bug.
Jul 27, 2021
1b7c976
Fix sampler index bug.
Jul 27, 2021
049b307
Fix grammaly bug.
Jul 27, 2021
9c32a56
Merge new test.
Jul 27, 2021
932d0a4
Add part of benchmark results.
Jul 27, 2021
dc35f6d
Support batch sampler.
Jul 27, 2021
880fbcb
More readable test api.
Jul 27, 2021
f9eda3e
Remove some command arg and fix eval hook bug.
Jul 27, 2021
7be603d
Support format-only arg.
Jul 28, 2021
4243ea2
Modify format_results of datasets.
Jul 28, 2021
ce44bff
Modify tool which use test apis.
Jul 28, 2021
ff9e5f7
Update readme.
Jul 28, 2021
74b8d0e
Merge branch 'progressive_test' into segformer_trainval
Jul 28, 2021
da179df
Update readme of segformer.
Jul 28, 2021
d4fc387
Merge branch 'segformer_trainval' of github.com:sennnnn/mmsegmentatio…
Jul 28, 2021
cb77d5d
Updata readme of segformer.
Jul 28, 2021
378083d
Update segformer readme and fix segformer mit_b4.
Jul 29, 2021
d0a7240
Update readme of segformer.
Jul 29, 2021
77b9850
Clean AlignedResize related config.
Jul 29, 2021
d0d5100
Clean code from pr #709
Jul 29, 2021
9149191
Clean code from pr #709
Jul 29, 2021
37b493d
Add 512x512 segformer_mit-b5.
Jul 29, 2021
5722818
Fix lint.
Jul 29, 2021
98ce9ea
Merge branch 'master' into segformer_trainval
Jul 30, 2021
cd7eecb
Merge branch 'master' into segformer_trainval
Jul 30, 2021
85cae72
Fix some segformer head bugs.
Jul 30, 2021
a1fe725
Add segformer unit tests.
Jul 30, 2021
5f8e7f8
Replace AlignedResize to ResizeToMultiple.
Jul 30, 2021
09c1796
Modify readme of segformer.
Jul 30, 2021
b9af6cf
Fix bug of ResizeToMultiple.
Jul 30, 2021
10c2d7e
Add ResizeToMultiple unit tests.
Jul 30, 2021
cbbda18
Resolve conflict.
Aug 4, 2021
28b35b6
Simplify the implementation of ResizeToMultiple.
Aug 9, 2021
73e09d2
Update test results.
Aug 9, 2021
e44ad02
Fix multi-scale test error when resize_ratio=1.75 and input size=640x…
Aug 9, 2021
029ceb4
Update segformer results.
Aug 9, 2021
dba7167
Update Segformer results.
Aug 9, 2021
08df953
Fix some url bugs and pipelines bug.
Aug 10, 2021
7d40b78
Merge branch 'master' into segformer_trainval
Aug 10, 2021
01b1313
Merge Master.
Aug 10, 2021
8273594
Move ckpt convertion to tools.
Aug 10, 2021
a40205e
Add segformer official pretrain weights usage.
Aug 10, 2021
d650222
Clean redundant codes.
Aug 10, 2021
97a88b0
Remove redundant codes.
Aug 12, 2021
4cbfb9f
Unfied format.
Aug 12, 2021
d1814c1
Add description for segformer converter.
Aug 12, 2021
920feba
Update workers.
Aug 12, 2021
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
34 changes: 34 additions & 0 deletions configs/_base_/models/segformer_mit-b0.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# model settings
norm_cfg = dict(type='SyncBN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained=None,
backbone=dict(
type='MixVisionTransformer',
in_channels=3,
embed_dims=32,
num_stages=4,
num_layers=[2, 2, 2, 2],
num_heads=[1, 2, 5, 8],
patch_sizes=[7, 3, 3, 3],
sr_ratios=[8, 4, 2, 1],
out_indices=(0, 1, 2, 3),
mlp_ratio=4,
qkv_bias=True,
drop_rate=0.0,
attn_drop_rate=0.0,
drop_path_rate=0.1),
decode_head=dict(
type='SegformerHead',
in_channels=[32, 64, 160, 256],
in_index=[0, 1, 2, 3],
channels=256,
dropout_ratio=0.1,
num_classes=19,
norm_cfg=norm_cfg,
align_corners=False,
loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),
# model training and testing settings
train_cfg=dict(),
test_cfg=dict(mode='whole'))
65 changes: 65 additions & 0 deletions configs/segformer/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers

## Introduction

<!-- [ALGORITHM] -->

```latex
@article{xie2021segformer,
title={SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers},
author={Xie, Enze and Wang, Wenhai and Yu, Zhiding and Anandkumar, Anima and Alvarez, Jose M and Luo, Ping},
journal={arXiv preprint arXiv:2105.15203},
year={2021}
}
```

## Results and models

### ADE20k

| Method | Backbone | Crop Size | Lr schd | Mem (GB) | Inf time (fps) | mIoU | mIoU(ms+flip) | config | download |
| ------ | -------- | --------- | ------: | -------: | -------------- | ---: | ------------- | ------ | -------- |
|Segformer | MIT-B0 | 512x512 | 160000 | 2.1 | 51.32 | 37.41 | 38.34 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/segformer/segformer_mit-b0_512x512_160k_ade20k.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/segformer/segformer_mit-b0_512x512_160k_ade20k/segformer_mit-b0_512x512_160k_ade20k_20210726_101530-8ffa8fda.pth) &#124; [log](https://download.openmmlab.com/mmsegmentation/v0.5/segformer/segformer_mit-b0_512x512_160k_ade20k/segformer_mit-b0_512x512_160k_ade20k_20210726_101530.log.json) |
|Segformer | MIT-B1 | 512x512 | 160000 | 2.6 | 47.66 | 40.97 | 42.54 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/segformer/segformer_mit-b1_512x512_160k_ade20k.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/segformer/segformer_mit-b1_512x512_160k_ade20k/segformer_mit-b1_512x512_160k_ade20k_20210726_112106-d70e859d.pth) &#124; [log](https://download.openmmlab.com/mmsegmentation/v0.5/segformer/segformer_mit-b1_512x512_160k_ade20k/segformer_mit-b1_512x512_160k_ade20k_20210726_112106.log.json) |
|Segformer | MIT-B2 | 512x512 | 160000 | 3.6 | 30.88 | 45.58 | 47.03 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/segformer/segformer_mit-b2_512x512_160k_ade20k.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/segformer/segformer_mit-b2_512x512_160k_ade20k/segformer_mit-b2_512x512_160k_ade20k_20210726_112103-cbd414ac.pth) &#124; [log](https://download.openmmlab.com/mmsegmentation/v0.5/segformer/segformer_mit-b2_512x512_160k_ade20k/segformer_mit-b2_512x512_160k_ade20k_20210726_112103.log.json) |
|Segformer | MIT-B3 | 512x512 | 160000 | 4.8 | 22.11 | 47.82 | 48.81 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/segformer/segformer_mit-b3_512x512_160k_ade20k.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/segformer/segformer_mit-b3_512x512_160k_ade20k/segformer_mit-b3_512x512_160k_ade20k_20210726_081410-962b98d2.pth) &#124; [log](https://download.openmmlab.com/mmsegmentation/v0.5/segformer/segformer_mit-b3_512x512_160k_ade20k/segformer_mit-b3_512x512_160k_ade20k_20210726_081410.log.json) |
|Segformer | MIT-B4 | 512x512 | 160000 | 6.1 | 15.45 | 48.46 | 49.76 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/segformer/segformer_mit-b4_512x512_160k_ade20k.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/segformer/segformer_mit-b4_512x512_160k_ade20k/segformer_mit-b4_512x512_160k_ade20k_20210728_183055-7f509d7d.pth) &#124; [log](https://download.openmmlab.com/mmsegmentation/v0.5/segformer/segformer_mit-b4_512x512_160k_ade20k/segformer_mit-b4_512x512_160k_ade20k_20210728_183055.log.json) |
|Segformer | MIT-B5 | 512x512 | 160000 | 7.2 | 11.89 | 49.13 | 50.22 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/segformer/segformer_mit-b5_512x512_160k_ade20k.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/segformer/segformer_mit-b5_512x512_160k_ade20k/segformer_mit-b5_512x512_160k_ade20k_20210726_145235-94cedf59.pth) &#124; [log](https://download.openmmlab.com/mmsegmentation/v0.5/segformer/segformer_mit-b5_512x512_160k_ade20k/segformer_mit-b5_512x512_160k_ade20k_20210726_145235.log.json) |
|Segformer | MIT-B5 | 640x640 | 160000 | 11.5 | 11.30 | 49.62 | 50.36 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/segformer/segformer_mit-b5_640x640_160k_ade20k.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/segformer/segformer_mit-b5_640x640_160k_ade20k/segformer_mit-b5_640x640_160k_ade20k_20210801_121243-41d2845b.pth) &#124; [log](https://download.openmmlab.com/mmsegmentation/v0.5/segformer/segformer_mit-b5_640x640_160k_ade20k/segformer_mit-b5_640x640_160k_ade20k_20210801_121243.log.json) |

Evaluation with AlignedResize:

| Method | Backbone | Crop Size | Lr schd | mIoU | mIoU(ms+flip) |
| ------ | -------- | --------- | ------: | ---: | ------------- |
|Segformer | MIT-B0 | 512x512 | 160000 | 38.1 | 38.57 |
|Segformer | MIT-B1 | 512x512 | 160000 | 41.64 | 42.76 |
|Segformer | MIT-B2 | 512x512 | 160000 | 46.53 | 47.49 |
|Segformer | MIT-B3 | 512x512 | 160000 | 48.46 | 49.14 |
|Segformer | MIT-B4 | 512x512 | 160000 | 49.34 | 50.29 |
|Segformer | MIT-B5 | 512x512 | 160000 | 50.08 | 50.72 |
|Segformer | MIT-B5 | 640x640 | 160000 | 50.58 | 50.8 |

We replace `AlignedResize` in original implementatiuon to `Resize + ResizeToMultiple`. If you want to test by
using `AlignedResize`, you can change the dataset pipeline like this:

```python
test_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale=(2048, 512),
# img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75],
flip=False,
transforms=[
dict(type='Resize', keep_ratio=True),
# resize image to multiple of 32, improve SegFormer by 0.5-1.0 mIoU.
dict(type='ResizeToMultiple', size_divisor=32),
clownrat6 marked this conversation as resolved.
Show resolved Hide resolved
dict(type='RandomFlip'),
dict(type='Normalize', **img_norm_cfg),
dict(type='ImageToTensor', keys=['img']),
dict(type='Collect', keys=['img']),
])
]
```

Because the MixVisionTransformer is not supported by mmcls, we just can get backbone weights from official repo. We provide convert script to convert official weights in `tools/model_converters/mit_convert.py`. After converting, you need to modify `pretrained` of model config.
clownrat6 marked this conversation as resolved.
Show resolved Hide resolved
33 changes: 33 additions & 0 deletions configs/segformer/segformer_mit-b0_512x512_160k_ade20k.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
_base_ = [
'../_base_/models/segformer_mit-b0.py', '../_base_/datasets/ade20k.py',
'../_base_/default_runtime.py', '../_base_/schedules/schedule_160k.py'
]

model = dict(
pretrained='pretrain/mit_b0.pth', decode_head=dict(num_classes=150))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update pretrain path


# optimizer
optimizer = dict(
_delete_=True,
type='AdamW',
lr=0.00006,
betas=(0.9, 0.999),
weight_decay=0.01,
paramwise_cfg=dict(
custom_keys={
'pos_block': dict(decay_mult=0.),
'norm': dict(decay_mult=0.),
'head': dict(lr_mult=10.)
}))

lr_config = dict(
_delete_=True,
policy='poly',
warmup='linear',
warmup_iters=1500,
warmup_ratio=1e-6,
power=1.0,
min_lr=0.0,
by_epoch=False)

data = dict(samples_per_gpu=2)
clownrat6 marked this conversation as resolved.
Show resolved Hide resolved
37 changes: 37 additions & 0 deletions configs/segformer/segformer_mit-b1_512x512_160k_ade20k.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
_base_ = [
'../_base_/models/segformer_mit-b0.py', '../_base_/datasets/ade20k.py',
clownrat6 marked this conversation as resolved.
Show resolved Hide resolved
'../_base_/default_runtime.py', '../_base_/schedules/schedule_160k.py'
]

# model settings
model = dict(
pretrained='pretrain/mit_b1.pth',
backbone=dict(
embed_dims=64, num_heads=[1, 2, 5, 8], num_layers=[2, 2, 2, 2]),
decode_head=dict(in_channels=[64, 128, 320, 512], num_classes=150))
clownrat6 marked this conversation as resolved.
Show resolved Hide resolved

# optimizer
optimizer = dict(
_delete_=True,
type='AdamW',
lr=0.00006,
betas=(0.9, 0.999),
weight_decay=0.01,
paramwise_cfg=dict(
custom_keys={
'pos_block': dict(decay_mult=0.),
'norm': dict(decay_mult=0.),
'head': dict(lr_mult=10.)
}))

lr_config = dict(
_delete_=True,
policy='poly',
warmup='linear',
warmup_iters=1500,
warmup_ratio=1e-6,
power=1.0,
min_lr=0.0,
by_epoch=False)

data = dict(samples_per_gpu=2)
clownrat6 marked this conversation as resolved.
Show resolved Hide resolved
37 changes: 37 additions & 0 deletions configs/segformer/segformer_mit-b2_512x512_160k_ade20k.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
_base_ = [
'../_base_/models/segformer_mit-b0.py', '../_base_/datasets/ade20k.py',
clownrat6 marked this conversation as resolved.
Show resolved Hide resolved
'../_base_/default_runtime.py', '../_base_/schedules/schedule_160k.py'
]

# model settings
model = dict(
pretrained='pretrain/mit_b2.pth',
backbone=dict(
embed_dims=64, num_heads=[1, 2, 5, 8], num_layers=[3, 4, 6, 3]),
decode_head=dict(in_channels=[64, 128, 320, 512], num_classes=150))

# optimizer
optimizer = dict(
_delete_=True,
type='AdamW',
lr=0.00006,
betas=(0.9, 0.999),
weight_decay=0.01,
paramwise_cfg=dict(
custom_keys={
'pos_block': dict(decay_mult=0.),
'norm': dict(decay_mult=0.),
'head': dict(lr_mult=10.)
}))

lr_config = dict(
_delete_=True,
policy='poly',
warmup='linear',
warmup_iters=1500,
warmup_ratio=1e-6,
power=1.0,
min_lr=0.0,
by_epoch=False)

data = dict(samples_per_gpu=2)
37 changes: 37 additions & 0 deletions configs/segformer/segformer_mit-b3_512x512_160k_ade20k.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
_base_ = [
'../_base_/models/segformer_mit-b0.py', '../_base_/datasets/ade20k.py',
clownrat6 marked this conversation as resolved.
Show resolved Hide resolved
'../_base_/default_runtime.py', '../_base_/schedules/schedule_160k.py'
]

# model settings
model = dict(
pretrained='pretrain/mit_b3.pth',
backbone=dict(
embed_dims=64, num_heads=[1, 2, 5, 8], num_layers=[3, 4, 18, 3]),
decode_head=dict(in_channels=[64, 128, 320, 512], num_classes=150))

# optimizer
optimizer = dict(
_delete_=True,
type='AdamW',
lr=0.00006,
betas=(0.9, 0.999),
weight_decay=0.01,
paramwise_cfg=dict(
custom_keys={
'pos_block': dict(decay_mult=0.),
'norm': dict(decay_mult=0.),
'head': dict(lr_mult=10.)
}))

lr_config = dict(
_delete_=True,
policy='poly',
warmup='linear',
warmup_iters=1500,
warmup_ratio=1e-6,
power=1.0,
min_lr=0.0,
by_epoch=False)

data = dict(samples_per_gpu=2)
37 changes: 37 additions & 0 deletions configs/segformer/segformer_mit-b4_512x512_160k_ade20k.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
_base_ = [
'../_base_/models/segformer_mit-b0.py', '../_base_/datasets/ade20k.py',
clownrat6 marked this conversation as resolved.
Show resolved Hide resolved
'../_base_/default_runtime.py', '../_base_/schedules/schedule_160k.py'
]

# model settings
model = dict(
pretrained='pretrain/mit_b4.pth',
backbone=dict(
embed_dims=64, num_heads=[1, 2, 5, 8], num_layers=[3, 8, 27, 3]),
decode_head=dict(in_channels=[64, 128, 320, 512], num_classes=150))

# optimizer
optimizer = dict(
_delete_=True,
type='AdamW',
lr=0.00006,
betas=(0.9, 0.999),
weight_decay=0.01,
paramwise_cfg=dict(
custom_keys={
'pos_block': dict(decay_mult=0.),
'norm': dict(decay_mult=0.),
'head': dict(lr_mult=10.)
}))

lr_config = dict(
_delete_=True,
policy='poly',
warmup='linear',
warmup_iters=1500,
warmup_ratio=1e-6,
power=1.0,
min_lr=0.0,
by_epoch=False)

data = dict(samples_per_gpu=2)
38 changes: 38 additions & 0 deletions configs/segformer/segformer_mit-b5_512x512_160k_ade20k.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
_base_ = [
'../_base_/models/segformer_mit-b0.py', '../_base_/datasets/ade20k.py',
clownrat6 marked this conversation as resolved.
Show resolved Hide resolved
'../_base_/default_runtime.py', '../_base_/schedules/schedule_160k.py'
]

# model settings
model = dict(
pretrained='pretrain/mit_b5.pth',
backbone=dict(
embed_dims=64, num_heads=[1, 2, 5, 8], num_layers=[3, 6, 40, 3]),
decode_head=dict(in_channels=[64, 128, 320, 512], num_classes=150))

# optimizer
optimizer = dict(
_delete_=True,
type='AdamW',
lr=0.00006,
betas=(0.9, 0.999),
weight_decay=0.01,
paramwise_cfg=dict(
custom_keys={
'pos_block': dict(decay_mult=0.),
'norm': dict(decay_mult=0.),
'head': dict(lr_mult=10.)
}))

lr_config = dict(
_delete_=True,
policy='poly',
warmup='linear',
warmup_iters=1500,
warmup_ratio=1e-6,
power=1.0,
min_lr=0.0,
by_epoch=False)

# By default, models are trained on 8 GPUs with 2 images per GPU
data = dict(samples_per_gpu=2)
Loading