-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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 MaskFormer #2789
Merged
Merged
[Feature] Add MaskFormer #2789
Changes from 27 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
4790c5d
scratch_1
shiyutang 41fcd07
scratch_2
shiyutang 35ba0d4
forward_align_finished
shiyutang d2bf25b
update
shiyutang 933b367
backwardaligned_dot2
shiyutang 360f1db
backward_blankin
shiyutang db3a3e2
train_divergy
shiyutang 7a90e9b
fix_optimizer
shiyutang 0abed97
fix_metric
shiyutang 0e466d4
align_train_load+metric467
shiyutang 080bac2
newest
shiyutang 7de03d8
paddle2.2.2
shiyutang cc31da5
update_init_aug
shiyutang 65d36ee
rm_redundant
shiyutang a75a0c3
update
shiyutang ea94836
update
shiyutang e05f390
update
shiyutang 6e25d85
update_init
shiyutang 24f8aed
train_with2.4and new aug
shiyutang 4847dc7
validate_on2.4
shiyutang a3d151a
update_init
shiyutang d6fad22
add_multiple_backbone+initfree
shiyutang 8738173
Merge branch 'develop' into paddle2.2.2
shiyutang 14933b9
fix_format
shiyutang 72c42c2
Merge branch 'develop' of https://github.com/PaddlePaddle/PaddleSeg i…
shiyutang 3d54334
fix_by_comment_test_train_ok_no_acc
shiyutang b86a511
Merge branch 'paddle2.2.2' of https://github.com/shiyutang/PaddleSeg …
shiyutang dbc43c0
valid_47.6
shiyutang d7479be
validate_train_47.93
shiyutang c403cad
valid_train_small_50.4
shiyutang f658d73
fix_by_comment
shiyutang 85c36a3
maskformer_tipc
shiyutang 094d1a2
fix_large_yml
shiyutang f16a816
compact_train_loss
shiyutang fb9668a
Merge branch 'develop' into paddle2.2.2
shiyutang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,6 @@ val_dataset: | |
- type: Normalize | ||
mode: val | ||
|
||
|
||
optimizer: | ||
type: SGD | ||
momentum: 0.9 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Per-Pixel Classification is Not All You Need for Semantic Segmentation | ||
|
||
## Reference | ||
|
||
> Cheng, Bowen, Alex Schwing, and Alexander Kirillov. "Per-pixel classification is not all you need for semantic segmentation." Advances in Neural Information Processing Systems 34 (2021): 17864-17875. | ||
|
||
## Performance | ||
|
||
### ADE20k | ||
|
||
| Model | Backbone | Resolution | Training Iters | mIoU | mIoU (flip) | mIoU (ms+flip) | Links | | ||
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:| | ||
|Maskformer-tiny|SwinTransformer|512x512|160000|47.6|-|-|[model](https://bj.bcebos.com/paddleseg/dygraph/ade20k/maskformer_ade20k_swin_tiny/model.pdparams) \| [log](https://bj.bcebos.com/paddleseg/dygraph/ade20k/maskformer_ade20k_swin_tiny/train.log) \| [vdl](https://www.paddlepaddle.org.cn/paddle/visualdl/service/app/scalar?id=e59773eaad87f677837add5ff110441e)| | ||
|
||
* Maskformer support different backbone including tiny, small, base and large. Due to long training time, the accuracy result is not provided. | ||
|
||
* Maskformer-Base and Maskformer-Large need to be evaled with multi-scale and flip by default. |
76 changes: 76 additions & 0 deletions
76
configs/maskformer/maskformer_swin_base_ade20k_512x512_160k.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
batch_size: 4 | ||
iters: 160000 | ||
|
||
train_dataset: | ||
type: MaskedADE20K | ||
dataset_root: data/ADEChallengeData2016/ | ||
transforms: | ||
- type: ResizeByShort | ||
short_size: [320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024, 1088, 1152, 1216, 1280, 1344] | ||
max_size: 2560 | ||
- type: RandomPaddingCrop | ||
crop_size: [640, 640] | ||
- type: RandomDistort | ||
brightness_range: 0.125 | ||
brightness_prob: 1.0 | ||
contrast_range: 0.5 | ||
contrast_prob: 1.0 | ||
saturation_range: 0.5 | ||
saturation_prob: 1.0 | ||
hue_range: 18 | ||
hue_prob: 1.0 | ||
- type: RandomHorizontalFlip | ||
- type: Padding | ||
target_size: [640, 640] | ||
im_padding_value: 128 | ||
- type: Normalize | ||
mean: [0.485, 0.456, 0.406] | ||
std: [0.229, 0.224, 0.225] | ||
|
||
|
||
val_dataset: | ||
type: MaskedADE20K | ||
dataset_root: data/ADEChallengeData2016/ | ||
transforms: | ||
- type: ResizeByShort | ||
short_size: 512 | ||
- type: Normalize | ||
mean: [0.485, 0.456, 0.406] | ||
std: [0.229, 0.224, 0.225] | ||
mode: val | ||
|
||
model: | ||
type: MaskFormer | ||
num_classes: 150 | ||
backbone: | ||
type: SwinTransformer_base_patch4_window7_384_maskformer | ||
pretrained: https://bj.bcebos.com/paddleseg/paddleseg/dygraph/ade20k/maskformer_ade20k_swin_base/pretrain/model.pdparams | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pretrained还是针对整个maskformer模型,不是针对backbone啊 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 不是,这个是只有swin的模型,训练日志里加载的参数数量也可以看出来 |
||
|
||
optimizer: | ||
type: AdamW | ||
weight_decay: 0.01 | ||
custom_cfg: | ||
- name: backbone | ||
lr_mult: 1.0 | ||
- name: norm | ||
weight_decay_mult: 0.0 | ||
- name: relative_position_bias_table | ||
weight_decay_mult: 0.0 | ||
grad_clip_cfg: | ||
name: ClipGradByNorm | ||
clip_norm: 0.01 | ||
|
||
lr_scheduler: | ||
type: PolynomialDecay | ||
warmup_iters: 1500 | ||
warmup_start_lr: 6.0e-11 | ||
learning_rate: 6.0e-05 | ||
end_lr: 0 | ||
power: 0.9 | ||
|
||
loss: | ||
types: | ||
- type: MaskFormerLoss | ||
num_classes: 150 | ||
eos_coef: 0.1 | ||
coef: [1] |
75 changes: 75 additions & 0 deletions
75
configs/maskformer/maskformer_swin_large_ade20k_512x512_160k.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
batch_size: 4 | ||
iters: 160000 | ||
|
||
train_dataset: | ||
type: MaskedADE20K | ||
dataset_root: data/ADEChallengeData2016/ | ||
transforms: | ||
- type: ResizeByShort | ||
short_size: [320, 384, 448, 512, 576, 640, 704, 768, 832, 896, 960, 1024, 1088, 1152, 1216, 1280, 1344] | ||
max_size: 2560 | ||
- type: RandomPaddingCrop | ||
crop_size: [640, 640] | ||
- type: RandomDistort | ||
brightness_range: 0.125 | ||
brightness_prob: 1.0 | ||
contrast_range: 0.5 | ||
contrast_prob: 1.0 | ||
saturation_range: 0.5 | ||
saturation_prob: 1.0 | ||
hue_range: 18 | ||
hue_prob: 1.0 | ||
- type: RandomHorizontalFlip | ||
- type: Padding | ||
target_size: [640, 640] | ||
im_padding_value: 128 | ||
- type: Normalize | ||
mean: [0.485, 0.456, 0.406] | ||
std: [0.229, 0.224, 0.225] | ||
|
||
val_dataset: | ||
type: MaskedADE20K | ||
dataset_root: data/ADEChallengeData2016/ | ||
transforms: | ||
- type: ResizeByShort | ||
short_size: 512 | ||
- type: Normalize | ||
mean: [0.485, 0.456, 0.406] | ||
std: [0.229, 0.224, 0.225] | ||
mode: val | ||
|
||
model: | ||
type: MaskFormer | ||
num_classes: 150 | ||
backbone: | ||
type: SwinTransformer_large_patch4_window7_384_maskformer | ||
pretrained: https://bj.bcebos.com/paddleseg/paddleseg/dygraph/ade20k/maskformer_ade20k_swin_large/pretrain/model.pdparams | ||
|
||
optimizer: | ||
type: AdamW | ||
weight_decay: 0.01 | ||
custom_cfg: | ||
- name: backbone | ||
lr_mult: 1.0 | ||
- name: norm | ||
weight_decay_mult: 0.0 | ||
- name: relative_position_bias_table | ||
weight_decay_mult: 0.0 | ||
grad_clip_cfg: | ||
name: ClipGradByNorm | ||
clip_norm: 0.01 | ||
|
||
lr_scheduler: | ||
type: PolynomialDecay | ||
warmup_iters: 1500 | ||
warmup_start_lr: 6.0e-11 | ||
learning_rate: 6.0e-05 | ||
end_lr: 0 | ||
power: 0.9 | ||
|
||
loss: | ||
types: | ||
- type: MaskFormerLoss | ||
num_classes: 150 | ||
eos_coef: 0.1 | ||
coef: [1] |
75 changes: 75 additions & 0 deletions
75
configs/maskformer/maskformer_swin_small_ade20k_512x512_160k.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
batch_size: 4 | ||
iters: 160000 | ||
|
||
train_dataset: | ||
type: MaskedADE20K | ||
dataset_root: data/ADEChallengeData2016/ | ||
transforms: | ||
- type: ResizeByShort | ||
short_size: [256, 307, 358, 409, 460, 512, 563, 614, 665, 716, 768, 819, 870, 921, 972, 1024] | ||
max_size: 2048 | ||
- type: RandomPaddingCrop | ||
crop_size: [512, 512] | ||
- type: RandomDistort | ||
brightness_range: 0.125 | ||
brightness_prob: 1.0 | ||
contrast_range: 0.5 | ||
contrast_prob: 1.0 | ||
saturation_range: 0.5 | ||
saturation_prob: 1.0 | ||
hue_range: 18 | ||
hue_prob: 1.0 | ||
- type: RandomHorizontalFlip | ||
- type: Padding | ||
target_size: [512, 512] | ||
im_padding_value: 128 | ||
- type: Normalize | ||
mean: [0.485, 0.456, 0.406] | ||
std: [0.229, 0.224, 0.225] | ||
|
||
val_dataset: | ||
type: MaskedADE20K | ||
dataset_root: data/ADEChallengeData2016/ | ||
transforms: | ||
- type: ResizeByShort | ||
short_size: 512 | ||
- type: Normalize | ||
mean: [0.485, 0.456, 0.406] | ||
std: [0.229, 0.224, 0.225] | ||
mode: val | ||
|
||
model: | ||
type: MaskFormer | ||
num_classes: 150 | ||
backbone: | ||
type: SwinTransformer_small_patch4_window7_224_maskformer | ||
pretrained: https://bj.bcebos.com/paddleseg/paddleseg/dygraph/ade20k/maskformer_ade20k_swin_small/pretrain/model.pdparams | ||
|
||
optimizer: | ||
type: AdamW | ||
weight_decay: 0.01 | ||
custom_cfg: | ||
- name: backbone | ||
lr_mult: 1.0 | ||
- name: norm | ||
weight_decay_mult: 0.0 | ||
- name: relative_position_bias_table | ||
weight_decay_mult: 0.0 | ||
grad_clip_cfg: | ||
name: ClipGradByNorm | ||
clip_norm: 0.01 | ||
|
||
lr_scheduler: | ||
type: PolynomialDecay | ||
warmup_iters: 1500 | ||
warmup_start_lr: 6.0e-11 | ||
learning_rate: 6.0e-05 | ||
end_lr: 0 | ||
power: 0.9 | ||
|
||
loss: | ||
types: | ||
- type: MaskFormerLoss | ||
num_classes: 150 | ||
eos_coef: 0.1 | ||
coef: [1] |
75 changes: 75 additions & 0 deletions
75
configs/maskformer/maskformer_swin_tiny_ade20k_512x512_160k.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
batch_size: 2 | ||
iters: 160000 | ||
|
||
train_dataset: | ||
type: MaskedADE20K | ||
dataset_root: data/ADEChallengeData2016/ | ||
transforms: | ||
- type: ResizeByShort | ||
short_size: [256, 307, 358, 409, 460, 512, 563, 614, 665, 716, 768, 819, 870, 921, 972, 1024] | ||
max_size: 2048 | ||
- type: RandomPaddingCrop | ||
crop_size: [512, 512] | ||
- type: RandomDistort | ||
brightness_range: 0.125 | ||
brightness_prob: 1.0 | ||
contrast_range: 0.5 | ||
contrast_prob: 1.0 | ||
saturation_range: 0.5 | ||
saturation_prob: 1.0 | ||
hue_range: 18 | ||
hue_prob: 1.0 | ||
- type: RandomHorizontalFlip | ||
- type: Padding | ||
target_size: [512, 512] | ||
im_padding_value: 128 | ||
- type: Normalize | ||
mean: [0.485, 0.456, 0.406] | ||
std: [0.229, 0.224, 0.225] | ||
|
||
val_dataset: | ||
type: MaskedADE20K | ||
dataset_root: data/ADEChallengeData2016/ | ||
transforms: | ||
- type: ResizeByShort | ||
short_size: 512 | ||
- type: Normalize | ||
mean: [0.485, 0.456, 0.406] | ||
std: [0.229, 0.224, 0.225] | ||
mode: val | ||
|
||
model: | ||
type: MaskFormer | ||
num_classes: 150 | ||
backbone: | ||
type: SwinTransformer_tiny_patch4_window7_224_maskformer | ||
pretrained: https://bj.bcebos.com/paddleseg/paddleseg/dygraph/ade20k/maskformer_ade20k_swin_tiny/pretrain/model.pdparams | ||
|
||
optimizer: | ||
type: AdamW | ||
weight_decay: 0.01 | ||
custom_cfg: | ||
- name: backbone | ||
lr_mult: 1.0 | ||
- name: norm | ||
weight_decay_mult: 0.0 | ||
- name: relative_position_bias_table | ||
weight_decay_mult: 0.0 | ||
grad_clip_cfg: | ||
name: ClipGradByNorm | ||
clip_norm: 0.01 | ||
|
||
lr_scheduler: | ||
type: PolynomialDecay | ||
warmup_iters: 1500 | ||
warmup_start_lr: 6.0e-11 | ||
learning_rate: 6.0e-05 | ||
end_lr: 0 | ||
power: 0.9 | ||
|
||
loss: | ||
types: | ||
- type: MaskFormerLoss | ||
num_classes: 150 | ||
eos_coef: 0.1 | ||
coef: [1] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
前面已经有RandomPaddingCrop,不需要padding了吧。
如果四个yml文件只是model不一样,一个yml文件作为base,其中三个yml文件可以使__base__包含。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已删除,除了model还有训练数据处理不一样,目前已经修改为最大化继承。