Skip to content

Commit 19ed23e

Browse files
committed
add a config for Mask2Former+BEiT-Adapter-L
ade20k 160k iters without coco-stuff
1 parent f19aa7b commit 19ed23e

2 files changed

Lines changed: 173 additions & 11 deletions

File tree

segmentation/configs/ade20k/README.md

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@ The ADE20K semantic segmentation dataset contains more than 20K scene-centric
88

99
## Results and Models
1010

11+
There are two training strategies for the ADE20K dataset:
12+
13+
- `strategy 1`: ADE20K 160k iterations.
14+
15+
- `strategy 2`: COCO-Stuff 80k + ADE20K 80k iterations.
16+
17+
In other words, if the filename contains `80k`, that means `strategy 2`.
18+
1119
**DeiT Pre-train (ImageNet-1K, supervised)**
1220

13-
| Method | Backbone | Pre-train | Batch Size | Lr schd | Crop Size | mIoU (SS) | mIoU (MS) | #Param | Config | Download |
14-
|:-------:|:-------------:|:---------------------------------------------------------------------------------:|:----------:|:-------:|:---------:|:---------:|:---------:|:------:|:---------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
15-
| UperNet | ViT-Adapter-T | [DeiT-T](https://dl.fbaipublicfiles.com/deit/deit_tiny_patch16_224-a1311bcf.pth) | 8x2 | 160k | 512 | 42.6 | 43.6 | 36M | [config](./upernet_deit_adapter_tiny_512_160k_ade20k.py) | [model](https://github.com/czczup/ViT-Adapter/releases/download/v0.3.1/upernet_deit_adapter_tiny_512_160_ade20k.pth.tar) \| [log](https://drive.google.com/file/d/1wG_6iIaVirmqLGDZt_2rtzp_ZtNV2D4O/view?usp=sharing) |
16-
| UperNet | ViT-Adapter-S | [DeiT-S](https://dl.fbaipublicfiles.com/deit/deit_small_patch16_224-cd65a155.pth) | 8x2 | 160k | 512 | 46.2 | 47.1 | 58M | [config](./upernet_deit_adapter_small_512_160k_ade20k.py) | [model](https://github.com/czczup/ViT-Adapter/releases/download/v0.3.1/upernet_deit_adapter_small_512_160k_ade20k.pth) \| [log]() |
17-
| UperNet | ViT-Adapter-B | [DeiT-B](https://dl.fbaipublicfiles.com/deit/deit_base_patch16_224-b5f2ef4d.pth) | 8x2 | 160k | 512 | 48.8 | 49.7 | 134M | [config](./upernet_deit_adapter_base_512_160k_ade20k.py) | [model](https://github.com/czczup/ViT-Adapter/releases/download/v0.3.1/upernet_deit_adapter_base_512_160k_ade20k.pth.tar) \| [log](https://drive.google.com/file/d/12xHSW7_VYnzQSNzGu2EPuh6BBuozWUTn/view?usp=sharing) |
21+
| Method | Backbone | Pre-train | Batch Size | Lr schd | Crop Size | mIoU (SS) | mIoU (MS) | #Param | Config | Download |
22+
|:-------:|:-------------:|:---------------------------------------------------------------------------------:|:----------:|:-------:|:---------:|:---------:|:---------:|:------:|:---------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
23+
| UperNet | ViT-Adapter-T | [DeiT-T](https://dl.fbaipublicfiles.com/deit/deit_tiny_patch16_224-a1311bcf.pth) | 8x2 | 160k | 512 | 42.6 | 43.6 | 36M | [config](./upernet_deit_adapter_tiny_512_160k_ade20k.py) | [model](https://github.com/czczup/ViT-Adapter/releases/download/v0.3.1/upernet_deit_adapter_tiny_512_160_ade20k.pth.tar) \| [log](https://drive.google.com/file/d/1wG_6iIaVirmqLGDZt_2rtzp_ZtNV2D4O/view?usp=sharing) |
24+
| UperNet | ViT-Adapter-S | [DeiT-S](https://dl.fbaipublicfiles.com/deit/deit_small_patch16_224-cd65a155.pth) | 8x2 | 160k | 512 | 46.2 | 47.1 | 58M | [config](./upernet_deit_adapter_small_512_160k_ade20k.py) | [model](https://github.com/czczup/ViT-Adapter/releases/download/v0.3.1/upernet_deit_adapter_small_512_160k_ade20k.pth) \| [log]() |
25+
| UperNet | ViT-Adapter-B | [DeiT-B](https://dl.fbaipublicfiles.com/deit/deit_base_patch16_224-b5f2ef4d.pth) | 8x2 | 160k | 512 | 48.8 | 49.7 | 134M | [config](./upernet_deit_adapter_base_512_160k_ade20k.py) | [model](https://github.com/czczup/ViT-Adapter/releases/download/v0.3.1/upernet_deit_adapter_base_512_160k_ade20k.pth.tar) \| [log](https://drive.google.com/file/d/12xHSW7_VYnzQSNzGu2EPuh6BBuozWUTn/view?usp=sharing) |
1826

1927
**AugReg Pre-train (ImageNet-22K, supervised)**
2028

@@ -26,9 +34,10 @@ The ADE20K semantic segmentation dataset contains more than 20K scene-centric
2634

2735
**BEiT Pre-train (ImageNet-22K, MIM)**
2836

29-
| Method | Backbone | Pre-train | Batch Size | Lr schd | Crop Size | mIoU (SS) | mIoU (MS) | #Param | Config | Download |
30-
|:-----------:|:-------------:|:------------------------------------------------------------------------------------------------------------------------------------------:|:----------:|:-------:|:---------:|:------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------:|:------:|:----------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
31-
| UperNet | ViT-Adapter-L | [BEiT-L](https://conversationhub.blob.core.windows.net/beit-share-public/beit/beit_large_patch16_224_pt22k_ft22k.pth) | 8x2 | 160k | 640 | [58.0](https://drive.google.com/file/d/1KsV4QPfoRi5cj2hjCzy8VfWih8xCTrE3/view?usp=sharing) | [58.4](https://drive.google.com/file/d/1haeTUvQhKCM7hunVdK60yxULbRH7YYBK/view?usp=sharing) | 451M | [config](./upernet_beit_adapter_large_640_160k_ade20k_ss.py) | [model](https://github.com/czczup/ViT-Adapter/releases/download/v0.2.1/upernet_beit_adapter_large_640_160k_ade20k.pth.tar) \| [log](https://github.com/czczup/ViT-Adapter/releases/download/v0.2.1/20220313_233147.log) |
32-
| Mask2Former | ViT-Adapter-L | [BEiT-L](https://conversationhub.blob.core.windows.net/beit-share-public/beit/beit_large_patch16_224_pt22k_ft22k.pth) | 8x2 | 160k | 640 | [58.3](https://drive.google.com/file/d/1jj56lSbc2s4ZNc-Hi-w6o-OSS99oi-_g/view?usp=sharing) | [59.0](https://drive.google.com/file/d/1hgpZB5gsyd7LTS7Aay2CbHmlY10nafCw/view?usp=sharing) | 568M | [config](./mask2former_beit_adapter_large_640_160k_ade20k_ss.py) | [model](https://github.com/czczup/ViT-Adapter/releases/download/v0.2.2/mask2former_beit_adapter_large_640_160k_ade20k.zip) \| [log](https://github.com/czczup/ViT-Adapter/releases/download/v0.2.2/20220426_003454.log) |
33-
| Mask2Former | ViT-Adapter-L | [BEiT-L+COCO-Stuff](https://github.com/czczup/ViT-Adapter/releases/download/v0.2.6/mask2former_beit_adapter_large_896_80k_cocostuff164k.zip) | 16x1 | 80k | 896 | [59.4](https://drive.google.com/file/d/1B_1XSwdnLhjJeUmn1g_nxfvGJpYmYWHa/view?usp=sharing) | [60.5](https://drive.google.com/file/d/1UtjmgcYKR-2h116oQXklUYOVcTw15woM/view?usp=sharing) | 571M | [config](./mask2former_beit_adapter_large_896_80k_ade20k_ss.py) | [model](https://github.com/czczup/ViT-Adapter/releases/download/v0.2.0/mask2former_beit_adapter_large_896_80k_ade20k.zip) \| [log](https://github.com/czczup/ViT-Adapter/releases/download/v0.2.0/20220430_154104.log) |
34-
| Mask2Former | ViT-Adapter-L | [BEiTv2-L+COCO-Stuff](https://github.com/czczup/ViT-Adapter/releases/download/v0.3.1/mask2former_beitv2_adapter_large_896_80k_cocostuff164k.zip) | 16x1 | 80k | 896 | 61.2 | 61.5 | 571M | [config](./mask2former_beitv2_adapter_large_896_80k_ade20k_ss.py) | [model](https://github.com/czczup/ViT-Adapter/releases/download/v0.3.1/mask2former_beitv2_adapter_large_896_80k_ade20k.zip) \| [log](https://github.com/czczup/ViT-Adapter/releases/download/v0.3.1/20220915_112635.log) |
37+
| Method | Backbone | Pre-train | Batch Size | Lr schd | Crop Size | mIoU (SS) | mIoU (MS) | #Param | Config | Download |
38+
|:-----------:|:-------------:|:------------------------------------------------------------------------------------------------------------------------------------------------:|:----------:|:-------:|:---------:|:------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------:|:------:|:------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
39+
| UperNet | ViT-Adapter-L | [BEiT-L](https://conversationhub.blob.core.windows.net/beit-share-public/beit/beit_large_patch16_224_pt22k_ft22k.pth) | 8x2 | 160k | 640 | [58.0](https://drive.google.com/file/d/1KsV4QPfoRi5cj2hjCzy8VfWih8xCTrE3/view?usp=sharing) | [58.4](https://drive.google.com/file/d/1haeTUvQhKCM7hunVdK60yxULbRH7YYBK/view?usp=sharing) | 451M | [config](./upernet_beit_adapter_large_640_160k_ade20k_ss.py) | [model](https://github.com/czczup/ViT-Adapter/releases/download/v0.2.1/upernet_beit_adapter_large_640_160k_ade20k.pth.tar) \| [log](https://github.com/czczup/ViT-Adapter/releases/download/v0.2.1/20220313_233147.log) |
40+
| Mask2Former | ViT-Adapter-L | [BEiT-L](https://conversationhub.blob.core.windows.net/beit-share-public/beit/beit_large_patch16_224_pt22k_ft22k.pth) | 8x2 | 160k | 640 | [58.3](https://drive.google.com/file/d/1jj56lSbc2s4ZNc-Hi-w6o-OSS99oi-_g/view?usp=sharing) | [59.0](https://drive.google.com/file/d/1hgpZB5gsyd7LTS7Aay2CbHmlY10nafCw/view?usp=sharing) | 568M | [config](./mask2former_beit_adapter_large_640_160k_ade20k_ss.py) | [model](https://github.com/czczup/ViT-Adapter/releases/download/v0.2.2/mask2former_beit_adapter_large_640_160k_ade20k.zip) \| [log](https://github.com/czczup/ViT-Adapter/releases/download/v0.2.2/20220426_003454.log) |
41+
| Mask2Former | ViT-Adapter-L | [BEiT-L+COCO-Stuff](https://github.com/czczup/ViT-Adapter/releases/download/v0.2.6/mask2former_beit_adapter_large_896_80k_cocostuff164k.zip) | 16x1 | 80k | 896 | [59.4](https://drive.google.com/file/d/1B_1XSwdnLhjJeUmn1g_nxfvGJpYmYWHa/view?usp=sharing) | [60.5](https://drive.google.com/file/d/1UtjmgcYKR-2h116oQXklUYOVcTw15woM/view?usp=sharing) | 571M | [config](./mask2former_beit_adapter_large_896_80k_ade20k_ss.py) | [model](https://github.com/czczup/ViT-Adapter/releases/download/v0.2.0/mask2former_beit_adapter_large_896_80k_ade20k.zip) \| [log](https://github.com/czczup/ViT-Adapter/releases/download/v0.2.0/20220430_154104.log) |
42+
| Mask2Former | ViT-Adapter-L | BEiTv2 | 16x1 | 160k | 896 | - | - | 571M | [config](./mask2former_beitv2_adapter_large_896_160k_ade20k_ss.py) | - |
43+
| Mask2Former | ViT-Adapter-L | [BEiTv2-L+COCO-Stuff](https://github.com/czczup/ViT-Adapter/releases/download/v0.3.1/mask2former_beitv2_adapter_large_896_80k_cocostuff164k.zip) | 16x1 | 80k | 896 | 61.2 | 61.5 | 571M | [config](./mask2former_beitv2_adapter_large_896_80k_ade20k_ss.py) | [model](https://github.com/czczup/ViT-Adapter/releases/download/v0.3.1/mask2former_beitv2_adapter_large_896_80k_ade20k.zip) \| [log](https://github.com/czczup/ViT-Adapter/releases/download/v0.3.1/20220915_112635.log) |
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
# Copyright (c) Shanghai AI Lab. All rights reserved.
2+
_base_ = [
3+
'../_base_/models/mask2former_beit.py',
4+
'../_base_/datasets/ade20k.py',
5+
'../_base_/default_runtime.py',
6+
'../_base_/schedules/schedule_160k.py'
7+
]
8+
crop_size = (896, 896)
9+
# pretrained = 'https://conversationhub.blob.core.windows.net/beit-share-public/beitv2/beitv2_large_patch16_224_pt1k_ft21k.pth'
10+
pretrained = 'pretrained/beitv2_large_patch16_224_pt1k_ft21k.pth'
11+
model = dict(
12+
type='EncoderDecoderMask2Former',
13+
pretrained=pretrained,
14+
backbone=dict(
15+
type='BEiTAdapter',
16+
img_size=896,
17+
patch_size=16,
18+
embed_dim=1024,
19+
depth=24,
20+
num_heads=16,
21+
mlp_ratio=4,
22+
qkv_bias=True,
23+
use_abs_pos_emb=False,
24+
use_rel_pos_bias=True,
25+
init_values=1e-6,
26+
drop_path_rate=0.3,
27+
conv_inplane=64,
28+
n_points=4,
29+
deform_num_heads=16,
30+
cffn_ratio=0.25,
31+
deform_ratio=0.5,
32+
with_cp=True, # set with_cp=True to save memory
33+
interaction_indexes=[[0, 5], [6, 11], [12, 17], [18, 23]],
34+
),
35+
decode_head=dict(
36+
in_channels=[1024, 1024, 1024, 1024],
37+
feat_channels=1024,
38+
out_channels=1024,
39+
num_queries=200,
40+
pixel_decoder=dict(
41+
type='MSDeformAttnPixelDecoder',
42+
num_outs=3,
43+
norm_cfg=dict(type='GN', num_groups=32),
44+
act_cfg=dict(type='ReLU'),
45+
encoder=dict(
46+
type='DetrTransformerEncoder',
47+
num_layers=6,
48+
transformerlayers=dict(
49+
type='BaseTransformerLayer',
50+
attn_cfgs=dict(
51+
type='MultiScaleDeformableAttention',
52+
embed_dims=1024,
53+
num_heads=32,
54+
num_levels=3,
55+
num_points=4,
56+
im2col_step=64,
57+
dropout=0.0,
58+
batch_first=False,
59+
norm_cfg=None,
60+
init_cfg=None),
61+
ffn_cfgs=dict(
62+
type='FFN',
63+
embed_dims=1024,
64+
feedforward_channels=4096,
65+
num_fcs=2,
66+
ffn_drop=0.0,
67+
with_cp=True, # set with_cp=True to save memory
68+
act_cfg=dict(type='ReLU', inplace=True)),
69+
operation_order=('self_attn', 'norm', 'ffn', 'norm')),
70+
init_cfg=None),
71+
positional_encoding=dict(
72+
type='SinePositionalEncoding', num_feats=512, normalize=True),
73+
init_cfg=None),
74+
positional_encoding=dict(
75+
type='SinePositionalEncoding', num_feats=512, normalize=True),
76+
transformer_decoder=dict(
77+
type='DetrTransformerDecoder',
78+
return_intermediate=True,
79+
num_layers=9,
80+
transformerlayers=dict(
81+
type='DetrTransformerDecoderLayer',
82+
attn_cfgs=dict(
83+
type='MultiheadAttention',
84+
embed_dims=1024,
85+
num_heads=32,
86+
attn_drop=0.0,
87+
proj_drop=0.0,
88+
dropout_layer=None,
89+
batch_first=False),
90+
ffn_cfgs=dict(
91+
embed_dims=1024,
92+
feedforward_channels=4096,
93+
num_fcs=2,
94+
act_cfg=dict(type='ReLU', inplace=True),
95+
ffn_drop=0.0,
96+
dropout_layer=None,
97+
with_cp=True, # set with_cp=True to save memory
98+
add_identity=True),
99+
feedforward_channels=4096,
100+
operation_order=('cross_attn', 'norm', 'self_attn', 'norm',
101+
'ffn', 'norm')),
102+
init_cfg=None)
103+
),
104+
test_cfg=dict(mode='slide', crop_size=crop_size, stride=(512, 512))
105+
)
106+
# dataset settings
107+
img_norm_cfg = dict(
108+
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
109+
train_pipeline = [
110+
dict(type='LoadImageFromFile'),
111+
dict(type='LoadAnnotations', reduce_zero_label=True),
112+
dict(type='Resize', img_scale=(3584, 896), ratio_range=(0.5, 2.0)),
113+
dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75),
114+
dict(type='RandomFlip', prob=0.5),
115+
dict(type='PhotoMetricDistortion'),
116+
dict(type='Normalize', **img_norm_cfg),
117+
dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255),
118+
dict(type='ToMask'),
119+
dict(type='DefaultFormatBundle'),
120+
dict(type='Collect', keys=['img', 'gt_semantic_seg', 'gt_masks', 'gt_labels'])
121+
]
122+
test_pipeline = [
123+
dict(type='LoadImageFromFile'),
124+
dict(
125+
type='MultiScaleFlipAug',
126+
img_scale=(3584, 896),
127+
# img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75],
128+
flip=False,
129+
transforms=[
130+
dict(type='Resize', keep_ratio=True),
131+
dict(type='ResizeToMultiple', size_divisor=32),
132+
dict(type='RandomFlip'),
133+
dict(type='Normalize', **img_norm_cfg),
134+
dict(type='ImageToTensor', keys=['img']),
135+
dict(type='Collect', keys=['img']),
136+
])
137+
]
138+
optimizer = dict(_delete_=True, type='AdamW', lr=2e-5, betas=(0.9, 0.999), weight_decay=0.05,
139+
constructor='LayerDecayOptimizerConstructor',
140+
paramwise_cfg=dict(num_layers=24, layer_decay_rate=0.90))
141+
lr_config = dict(_delete_=True,
142+
policy='poly',
143+
warmup='linear',
144+
warmup_iters=1500,
145+
warmup_ratio=1e-6,
146+
power=1.0, min_lr=0.0, by_epoch=False)
147+
data = dict(samples_per_gpu=1,
148+
train=dict(pipeline=train_pipeline),
149+
val=dict(pipeline=test_pipeline),
150+
test=dict(pipeline=test_pipeline))
151+
runner = dict(type='IterBasedRunner')
152+
checkpoint_config = dict(by_epoch=False, interval=1000, max_keep_ckpts=1)
153+
evaluation = dict(interval=8000, metric='mIoU', save_best='mIoU')

0 commit comments

Comments
 (0)