birth
This commit is contained in:
33
segmentation/configs/ade20k/README.md
Normal file
33
segmentation/configs/ade20k/README.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# ADE20K
|
||||
|
||||
Introduced by Zhou et al. in [Scene Parsing Through ADE20K Dataset](https://paperswithcode.com/paper/scene-parsing-through-ade20k-dataset).
|
||||
|
||||
The ADE20K semantic segmentation dataset contains more than 20K scene-centric images exhaustively annotated with pixel-level objects and object parts labels. There are totally 150 semantic categories, which include stuffs like sky, road, grass, and discrete objects like person, car, bed.
|
||||
|
||||
|
||||
## Model Zoo
|
||||
|
||||
### UperNet + InternImage
|
||||
|
||||
|
||||
| backbone | resolution | mIoU (ss/ms) | Config | Download |
|
||||
|:--------------:|:----------:|:-----------:|:-----------:|:----------:
|
||||
| FlashInternImage-T | 512x512 | 49.3 / 50.3 | [config](./upernet_flash_internimage_t_512_160k_ade20k.py) | [ckpt](https://huggingface.co/OpenGVLab/DCNv4/resolve/main/upernet_flash_internimage_t_512_160k_ade20k.pth) \| [log](https://huggingface.co/OpenGVLab/DCNv4/resolve/main/upernet_flash_internimage_t_512_160k_ade20k.log) |
|
||||
| FlashInternImage-S | 512x512 | 50.6 / 51.6 | [config](./upernet_flash_internimage_s_512_160k_ade20k.py) | [ckpt](https://huggingface.co/OpenGVLab/DCNv4/resolve/main/upernet_flash_internimage_s_512_160k_ade20k.pth) \| [log](https://huggingface.co/OpenGVLab/DCNv4/resolve/main/upernet_flash_internimage_s_512_160k_ade20k.log) |
|
||||
| FlashInternImage-B | 512x512 | 52.0 / 52.6 | [config](./upernet_flash_internimage_b_512_160k_ade20k.py) | [ckpt](https://huggingface.co/OpenGVLab/DCNv4/resolve/main/upernet_flash_internimage_b_512_160k_ade20k.pth) \| [log](https://huggingface.co/OpenGVLab/DCNv4/resolve/main/upernet_flash_internimage_s_512_160k_ade20k.log) |
|
||||
| FlashInternImage-L | 640x640 | 55.6 / 56.0 | [config](./upernet_flash_internimage_l_640_160k_ade20k.py)| [ckpt](https://huggingface.co/OpenGVLab/DCNv4/resolve/main/upernet_flash_internimage_l_640_160k_ade20k.pth) \| [log](https://huggingface.co/OpenGVLab/DCNv4/resolve/main/upernet_flash_internimage_l_640_160k_ade20k.log) |
|
||||
|
||||
- Training speed is measured with A100 GPU.
|
||||
- Please set `with_cp=True` to save memory if you meet `out-of-memory` issues.
|
||||
- The logs are our recent newly trained ones. There are slight differences between the results in logs and our paper.
|
||||
|
||||
|
||||
### Mask2Former + InternImage
|
||||
|
||||
| backbone | resolution | mIoU (ss) | Config | Download |
|
||||
|:--------------:|:----------:|:-----------:|:-----------:|:----------:
|
||||
| FlashInternImage-T | 512x512 | 51.2 | [config](./mask2former_flash_internimage_t_512_160k_ade20k_ss.py) | [ckpt](https://huggingface.co/OpenGVLab/DCNv4/resolve/main/mask2former_flash_internimage_t_512_160k_ade20k_ss.pth) \| [log](https://huggingface.co/OpenGVLab/DCNv4/resolve/main/mask2former_flash_internimage_t_512_160k_ade20k_ss.log) |
|
||||
| FlashInternImage-S | 640x640 | 52.2 | [config](./mask2former_flash_internimage_s_640_160k_ade20k_ss.py) | [ckpt](https://huggingface.co/OpenGVLab/DCNv4/resolve/main/mask2former_flash_internimage_s_640_160k_ade20k_ss.pth) \| [log](https://huggingface.co/OpenGVLab/DCNv4/resolve/main/mask2former_flash_internimage_s_640_160k_ade20k_ss.log) |
|
||||
| FlashInternImage-B | 640x640 | 53.4 | [config](./mask2former_flash_internimage_b_640_160k_ade20k_ss.py) | [ckpt](https://huggingface.co/OpenGVLab/DCNv4/resolve/main/mask2former_flash_internimage_b_640_160k_ade20k_ss.pth) \| [log](https://huggingface.co/OpenGVLab/DCNv4/resolve/main/mask2former_flash_internimage_b_640_160k_ade20k_ss.log) |
|
||||
| FlashInternImage-L | 640x640 | 56.7 | [config](./mask2former_flash_internimage_l_640_160k_ade20k_ss.py)| [ckpt](https://huggingface.co/OpenGVLab/DCNv4/resolve/main/mask2former_flash_internimage_l_640_160k_ade20k_ss.pth) \| [log](https://huggingface.co/OpenGVLab/DCNv4/resolve/main/mask2former_flash_internimage_l_640_160k_ade20k_ss.log) |
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
# --------------------------------------------------------
|
||||
# DCNv4
|
||||
# Copyright (c) 2024 OpenGVLab
|
||||
# Licensed under The MIT License [see LICENSE for details]
|
||||
# --------------------------------------------------------
|
||||
_base_ = [
|
||||
'../_base_/models/mask2former_beit.py', '../_base_/datasets/ade20k.py',
|
||||
'../_base_/default_runtime.py', '../_base_/schedules/schedule_160k.py'
|
||||
]
|
||||
num_classes = 150
|
||||
pretrained = 'https://huggingface.co/OpenGVLab/DCNv4/resolve/main/flash_intern_image_b_1k_224.pth'
|
||||
model = dict(
|
||||
backbone=dict(
|
||||
_delete_=True,
|
||||
type='FlashInternImage',
|
||||
core_op='DCNv4',
|
||||
channels=112,
|
||||
depths=[4, 4, 21, 4],
|
||||
groups=[7, 14, 28, 56],
|
||||
mlp_ratio=4.,
|
||||
drop_path_rate=0.4,
|
||||
norm_layer='LN',
|
||||
layer_scale=1.0,
|
||||
offset_scale=0.5,
|
||||
post_norm=True,
|
||||
with_cp=False,
|
||||
dw_kernel_size=3,
|
||||
out_indices=(0, 1, 2, 3),
|
||||
init_cfg=dict(type='Pretrained', checkpoint=pretrained)),
|
||||
decode_head=dict(
|
||||
in_channels=[112, 224, 448, 896],
|
||||
feat_channels=256,
|
||||
out_channels=256,
|
||||
num_classes=num_classes,
|
||||
num_queries=200,
|
||||
pixel_decoder=dict(
|
||||
type='MSDeformAttnPixelDecoder',
|
||||
num_outs=3,
|
||||
norm_cfg=dict(type='GN', num_groups=32),
|
||||
act_cfg=dict(type='ReLU'),
|
||||
encoder=dict(
|
||||
type='DetrTransformerEncoder',
|
||||
num_layers=6,
|
||||
transformerlayers=dict(
|
||||
type='BaseTransformerLayer',
|
||||
attn_cfgs=dict(
|
||||
type='MultiScaleDeformableAttention',
|
||||
embed_dims=256,
|
||||
num_heads=8,
|
||||
num_levels=3,
|
||||
num_points=4,
|
||||
im2col_step=64,
|
||||
dropout=0.0,
|
||||
batch_first=False,
|
||||
norm_cfg=None,
|
||||
init_cfg=None),
|
||||
ffn_cfgs=dict(
|
||||
type='FFN',
|
||||
embed_dims=256,
|
||||
feedforward_channels=2048,
|
||||
num_fcs=2,
|
||||
ffn_drop=0.0,
|
||||
with_cp=False, # set with_cp=True to save memory
|
||||
act_cfg=dict(type='ReLU', inplace=True)),
|
||||
operation_order=('self_attn', 'norm', 'ffn', 'norm')),
|
||||
init_cfg=None),
|
||||
positional_encoding=dict(
|
||||
type='SinePositionalEncoding', num_feats=128, normalize=True),
|
||||
init_cfg=None),
|
||||
positional_encoding=dict(
|
||||
type='SinePositionalEncoding', num_feats=128, normalize=True),
|
||||
transformer_decoder=dict(
|
||||
type='DetrTransformerDecoder',
|
||||
return_intermediate=True,
|
||||
num_layers=9,
|
||||
transformerlayers=dict(
|
||||
type='DetrTransformerDecoderLayer',
|
||||
attn_cfgs=dict(
|
||||
type='MultiheadAttention',
|
||||
embed_dims=256,
|
||||
num_heads=8,
|
||||
attn_drop=0.0,
|
||||
proj_drop=0.0,
|
||||
dropout_layer=None,
|
||||
batch_first=False),
|
||||
ffn_cfgs=dict(
|
||||
embed_dims=256,
|
||||
feedforward_channels=2048,
|
||||
num_fcs=2,
|
||||
act_cfg=dict(type='ReLU', inplace=True),
|
||||
ffn_drop=0.0,
|
||||
dropout_layer=None,
|
||||
with_cp=False, # set with_cp=True to save memory
|
||||
add_identity=True),
|
||||
feedforward_channels=2048,
|
||||
operation_order=('cross_attn', 'norm', 'self_attn', 'norm',
|
||||
'ffn', 'norm')),
|
||||
init_cfg=None),
|
||||
loss_cls=dict(
|
||||
type='CrossEntropyLoss',
|
||||
use_sigmoid=False,
|
||||
loss_weight=2.0,
|
||||
reduction='mean',
|
||||
class_weight=[1.0] * num_classes + [0.1])
|
||||
),
|
||||
test_cfg=dict(mode='whole'))
|
||||
img_norm_cfg = dict(
|
||||
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
||||
crop_size = (640, 640)
|
||||
train_pipeline = [
|
||||
dict(type='LoadImageFromFile'),
|
||||
dict(type='LoadAnnotations', reduce_zero_label=True),
|
||||
dict(type='Resize', img_scale=(2560, 640), ratio_range=(0.5, 2.0)),
|
||||
dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75),
|
||||
dict(type='RandomFlip', prob=0.5),
|
||||
dict(type='PhotoMetricDistortion'),
|
||||
dict(type='Normalize', **img_norm_cfg),
|
||||
dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255),
|
||||
dict(type='ToMask'),
|
||||
dict(type='DefaultFormatBundle'),
|
||||
dict(type='Collect', keys=['img', 'gt_semantic_seg', 'gt_masks', 'gt_labels'])
|
||||
]
|
||||
test_pipeline = [
|
||||
dict(type='LoadImageFromFile'),
|
||||
dict(
|
||||
type='MultiScaleFlipAug',
|
||||
img_scale=(2560, 640),
|
||||
# img_ratios=[768./896., 832./896., 1.0, 960./896., 1024./896.],
|
||||
flip=False,
|
||||
transforms=[
|
||||
dict(type='Resize', keep_ratio=True),
|
||||
dict(type='ResizeToMultiple', size_divisor=32),
|
||||
dict(type='RandomFlip'),
|
||||
dict(type='Normalize', **img_norm_cfg),
|
||||
dict(type='ImageToTensor', keys=['img']),
|
||||
dict(type='Collect', keys=['img']),
|
||||
])
|
||||
]
|
||||
optimizer = dict(
|
||||
_delete_=True, type='AdamW', lr=0.0001, betas=(0.9, 0.999), weight_decay=0.05,
|
||||
constructor='CustomLayerDecayOptimizerConstructor',
|
||||
paramwise_cfg=dict(num_layers=33, layer_decay_rate=1.0,
|
||||
depths=[4, 4, 21, 4]))
|
||||
|
||||
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,
|
||||
train=dict(pipeline=train_pipeline),
|
||||
val=dict(pipeline=test_pipeline),
|
||||
test=dict(pipeline=test_pipeline))
|
||||
runner = dict(type='IterBasedRunner')
|
||||
optimizer_config = dict(_delete_=True, grad_clip=dict(max_norm=0.1, norm_type=2))
|
||||
checkpoint_config = dict(by_epoch=False, interval=5000, max_keep_ckpts=1)
|
||||
evaluation = dict(interval=5000, metric='mIoU', save_best='mIoU')
|
||||
# fp16 = dict(loss_scale=dict(init_scale=512))
|
||||
@@ -0,0 +1,160 @@
|
||||
# --------------------------------------------------------
|
||||
# DCNv4
|
||||
# Copyright (c) 2024 OpenGVLab
|
||||
# Licensed under The MIT License [see LICENSE for details]
|
||||
# --------------------------------------------------------
|
||||
_base_ = [
|
||||
'../_base_/models/mask2former_beit.py', '../_base_/datasets/ade20k.py',
|
||||
'../_base_/default_runtime.py', '../_base_/schedules/schedule_160k.py'
|
||||
]
|
||||
num_classes = 150
|
||||
pretrained = 'https://huggingface.co/OpenGVLab/DCNv4/resolve/main/flash_intern_image_l_22k_384.pth'
|
||||
model = dict(
|
||||
backbone=dict(
|
||||
_delete_=True,
|
||||
type='FlashInternImage',
|
||||
core_op='DCNv4',
|
||||
channels=160,
|
||||
depths=[5, 5, 22, 5],
|
||||
groups=[10, 20, 40, 80],
|
||||
mlp_ratio=4.,
|
||||
drop_path_rate=0.5,
|
||||
norm_layer='LN',
|
||||
layer_scale=1.0,
|
||||
offset_scale=2.0,
|
||||
post_norm=True,
|
||||
with_cp=True,
|
||||
dcn_output_bias=True,
|
||||
mlp_fc2_bias=True,
|
||||
dw_kernel_size=3,
|
||||
out_indices=(0, 1, 2, 3),
|
||||
init_cfg=dict(type='Pretrained', checkpoint=pretrained)),
|
||||
decode_head=dict(
|
||||
in_channels=[160, 320, 640, 1280],
|
||||
feat_channels=256,
|
||||
out_channels=256,
|
||||
num_classes=num_classes,
|
||||
num_queries=200,
|
||||
pixel_decoder=dict(
|
||||
type='MSDeformAttnPixelDecoder',
|
||||
num_outs=3,
|
||||
norm_cfg=dict(type='GN', num_groups=32),
|
||||
act_cfg=dict(type='ReLU'),
|
||||
encoder=dict(
|
||||
type='DetrTransformerEncoder',
|
||||
num_layers=6,
|
||||
transformerlayers=dict(
|
||||
type='BaseTransformerLayer',
|
||||
attn_cfgs=dict(
|
||||
type='MultiScaleDeformableAttention',
|
||||
embed_dims=256,
|
||||
num_heads=8,
|
||||
num_levels=3,
|
||||
num_points=4,
|
||||
im2col_step=64,
|
||||
dropout=0.0,
|
||||
batch_first=False,
|
||||
norm_cfg=None,
|
||||
init_cfg=None),
|
||||
ffn_cfgs=dict(
|
||||
type='FFN',
|
||||
embed_dims=256,
|
||||
feedforward_channels=2048,
|
||||
num_fcs=2,
|
||||
ffn_drop=0.0,
|
||||
with_cp=False, # set with_cp=True to save memory
|
||||
act_cfg=dict(type='ReLU', inplace=True)),
|
||||
operation_order=('self_attn', 'norm', 'ffn', 'norm')),
|
||||
init_cfg=None),
|
||||
positional_encoding=dict(
|
||||
type='SinePositionalEncoding', num_feats=128, normalize=True),
|
||||
init_cfg=None),
|
||||
positional_encoding=dict(
|
||||
type='SinePositionalEncoding', num_feats=128, normalize=True),
|
||||
transformer_decoder=dict(
|
||||
type='DetrTransformerDecoder',
|
||||
return_intermediate=True,
|
||||
num_layers=9,
|
||||
transformerlayers=dict(
|
||||
type='DetrTransformerDecoderLayer',
|
||||
attn_cfgs=dict(
|
||||
type='MultiheadAttention',
|
||||
embed_dims=256,
|
||||
num_heads=8,
|
||||
attn_drop=0.0,
|
||||
proj_drop=0.0,
|
||||
dropout_layer=None,
|
||||
batch_first=False),
|
||||
ffn_cfgs=dict(
|
||||
embed_dims=256,
|
||||
feedforward_channels=2048,
|
||||
num_fcs=2,
|
||||
act_cfg=dict(type='ReLU', inplace=True),
|
||||
ffn_drop=0.0,
|
||||
dropout_layer=None,
|
||||
with_cp=False, # set with_cp=True to save memory
|
||||
add_identity=True),
|
||||
feedforward_channels=2048,
|
||||
operation_order=('cross_attn', 'norm', 'self_attn', 'norm',
|
||||
'ffn', 'norm')),
|
||||
init_cfg=None),
|
||||
loss_cls=dict(
|
||||
type='CrossEntropyLoss',
|
||||
use_sigmoid=False,
|
||||
loss_weight=2.0,
|
||||
reduction='mean',
|
||||
class_weight=[1.0] * num_classes + [0.1])
|
||||
),
|
||||
test_cfg=dict(mode='whole'))
|
||||
img_norm_cfg = dict(
|
||||
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
||||
crop_size = (640, 640)
|
||||
train_pipeline = [
|
||||
dict(type='LoadImageFromFile'),
|
||||
dict(type='LoadAnnotations', reduce_zero_label=True),
|
||||
dict(type='Resize', img_scale=(2560, 640), ratio_range=(0.5, 2.0)),
|
||||
dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75),
|
||||
dict(type='RandomFlip', prob=0.5),
|
||||
dict(type='PhotoMetricDistortion'),
|
||||
dict(type='Normalize', **img_norm_cfg),
|
||||
dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255),
|
||||
dict(type='ToMask'),
|
||||
dict(type='DefaultFormatBundle'),
|
||||
dict(type='Collect', keys=['img', 'gt_semantic_seg', 'gt_masks', 'gt_labels'])
|
||||
]
|
||||
test_pipeline = [
|
||||
dict(type='LoadImageFromFile'),
|
||||
dict(
|
||||
type='MultiScaleFlipAug',
|
||||
img_scale=(2560, 640),
|
||||
# img_ratios=[768./896., 832./896., 1.0, 960./896., 1024./896.],
|
||||
flip=False,
|
||||
transforms=[
|
||||
dict(type='Resize', keep_ratio=True),
|
||||
dict(type='ResizeToMultiple', size_divisor=32),
|
||||
dict(type='RandomFlip'),
|
||||
dict(type='Normalize', **img_norm_cfg),
|
||||
dict(type='ImageToTensor', keys=['img']),
|
||||
dict(type='Collect', keys=['img']),
|
||||
])
|
||||
]
|
||||
optimizer = dict(
|
||||
_delete_=True, type='AdamW', lr=0.0001, betas=(0.9, 0.999), weight_decay=0.05,
|
||||
constructor='CustomLayerDecayOptimizerConstructor',
|
||||
paramwise_cfg=dict(num_layers=37, layer_decay_rate=0.94,
|
||||
depths=[5, 5, 22, 5], offset_lr_scale=1.0))
|
||||
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,
|
||||
train=dict(pipeline=train_pipeline),
|
||||
val=dict(pipeline=test_pipeline),
|
||||
test=dict(pipeline=test_pipeline))
|
||||
runner = dict(type='IterBasedRunner')
|
||||
optimizer_config = dict(_delete_=True, grad_clip=dict(max_norm=0.1, norm_type=2))
|
||||
checkpoint_config = dict(by_epoch=False, interval=2000, max_keep_ckpts=1)
|
||||
evaluation = dict(interval=2000, metric='mIoU', save_best='mIoU')
|
||||
# fp16 = dict(loss_scale=dict(init_scale=512))
|
||||
@@ -0,0 +1,159 @@
|
||||
# --------------------------------------------------------
|
||||
# DCNv4
|
||||
# Copyright (c) 2024 OpenGVLab
|
||||
# Licensed under The MIT License [see LICENSE for details]
|
||||
# --------------------------------------------------------
|
||||
_base_ = [
|
||||
'../_base_/models/mask2former_beit.py', '../_base_/datasets/ade20k.py',
|
||||
'../_base_/default_runtime.py', '../_base_/schedules/schedule_160k.py'
|
||||
]
|
||||
num_classes = 150
|
||||
pretrained = 'https://huggingface.co/OpenGVLab/DCNv4/resolve/main/flash_intern_image_s_1k_224.pth'
|
||||
model = dict(
|
||||
backbone=dict(
|
||||
_delete_=True,
|
||||
type='FlashInternImage',
|
||||
core_op='DCNv4',
|
||||
channels=80,
|
||||
depths=[4, 4, 21, 4],
|
||||
groups=[5, 10, 20, 40],
|
||||
mlp_ratio=4.,
|
||||
drop_path_rate=0.3,
|
||||
norm_layer='LN',
|
||||
layer_scale=1.0,
|
||||
offset_scale=1.0,
|
||||
post_norm=True,
|
||||
with_cp=False,
|
||||
dw_kernel_size=3,
|
||||
out_indices=(0, 1, 2, 3),
|
||||
init_cfg=dict(type='Pretrained', checkpoint=pretrained)),
|
||||
decode_head=dict(
|
||||
in_channels=[80, 160, 320, 640],
|
||||
feat_channels=256,
|
||||
out_channels=256,
|
||||
num_classes=num_classes,
|
||||
num_queries=200,
|
||||
pixel_decoder=dict(
|
||||
type='MSDeformAttnPixelDecoder',
|
||||
num_outs=3,
|
||||
norm_cfg=dict(type='GN', num_groups=32),
|
||||
act_cfg=dict(type='ReLU'),
|
||||
encoder=dict(
|
||||
type='DetrTransformerEncoder',
|
||||
num_layers=6,
|
||||
transformerlayers=dict(
|
||||
type='BaseTransformerLayer',
|
||||
attn_cfgs=dict(
|
||||
type='MultiScaleDeformableAttention',
|
||||
embed_dims=256,
|
||||
num_heads=8,
|
||||
num_levels=3,
|
||||
num_points=4,
|
||||
im2col_step=64,
|
||||
dropout=0.0,
|
||||
batch_first=False,
|
||||
norm_cfg=None,
|
||||
init_cfg=None),
|
||||
ffn_cfgs=dict(
|
||||
type='FFN',
|
||||
embed_dims=256,
|
||||
feedforward_channels=2048,
|
||||
num_fcs=2,
|
||||
ffn_drop=0.0,
|
||||
with_cp=False, # set with_cp=True to save memory
|
||||
act_cfg=dict(type='ReLU', inplace=True)),
|
||||
operation_order=('self_attn', 'norm', 'ffn', 'norm')),
|
||||
init_cfg=None),
|
||||
positional_encoding=dict(
|
||||
type='SinePositionalEncoding', num_feats=128, normalize=True),
|
||||
init_cfg=None),
|
||||
positional_encoding=dict(
|
||||
type='SinePositionalEncoding', num_feats=128, normalize=True),
|
||||
transformer_decoder=dict(
|
||||
type='DetrTransformerDecoder',
|
||||
return_intermediate=True,
|
||||
num_layers=9,
|
||||
transformerlayers=dict(
|
||||
type='DetrTransformerDecoderLayer',
|
||||
attn_cfgs=dict(
|
||||
type='MultiheadAttention',
|
||||
embed_dims=256,
|
||||
num_heads=8,
|
||||
attn_drop=0.0,
|
||||
proj_drop=0.0,
|
||||
dropout_layer=None,
|
||||
batch_first=False),
|
||||
ffn_cfgs=dict(
|
||||
embed_dims=256,
|
||||
feedforward_channels=2048,
|
||||
num_fcs=2,
|
||||
act_cfg=dict(type='ReLU', inplace=True),
|
||||
ffn_drop=0.0,
|
||||
dropout_layer=None,
|
||||
with_cp=False, # set with_cp=True to save memory
|
||||
add_identity=True),
|
||||
feedforward_channels=2048,
|
||||
operation_order=('cross_attn', 'norm', 'self_attn', 'norm',
|
||||
'ffn', 'norm')),
|
||||
init_cfg=None),
|
||||
loss_cls=dict(
|
||||
type='CrossEntropyLoss',
|
||||
use_sigmoid=False,
|
||||
loss_weight=2.0,
|
||||
reduction='mean',
|
||||
class_weight=[1.0] * num_classes + [0.1])
|
||||
),
|
||||
test_cfg=dict(mode='whole'))
|
||||
img_norm_cfg = dict(
|
||||
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
||||
crop_size = (640, 640)
|
||||
train_pipeline = [
|
||||
dict(type='LoadImageFromFile'),
|
||||
dict(type='LoadAnnotations', reduce_zero_label=True),
|
||||
dict(type='Resize', img_scale=(2560, 640), ratio_range=(0.5, 2.0)),
|
||||
dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75),
|
||||
dict(type='RandomFlip', prob=0.5),
|
||||
dict(type='PhotoMetricDistortion'),
|
||||
dict(type='Normalize', **img_norm_cfg),
|
||||
dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255),
|
||||
dict(type='ToMask'),
|
||||
dict(type='DefaultFormatBundle'),
|
||||
dict(type='Collect', keys=['img', 'gt_semantic_seg', 'gt_masks', 'gt_labels'])
|
||||
]
|
||||
test_pipeline = [
|
||||
dict(type='LoadImageFromFile'),
|
||||
dict(
|
||||
type='MultiScaleFlipAug',
|
||||
img_scale=(2560, 640),
|
||||
# img_ratios=[768./896., 832./896., 1.0, 960./896., 1024./896.],
|
||||
flip=False,
|
||||
transforms=[
|
||||
dict(type='Resize', keep_ratio=True),
|
||||
dict(type='ResizeToMultiple', size_divisor=32),
|
||||
dict(type='RandomFlip'),
|
||||
dict(type='Normalize', **img_norm_cfg),
|
||||
dict(type='ImageToTensor', keys=['img']),
|
||||
dict(type='Collect', keys=['img']),
|
||||
])
|
||||
]
|
||||
optimizer = dict(
|
||||
_delete_=True, type='AdamW', lr=0.0001, betas=(0.9, 0.999), weight_decay=0.05,
|
||||
constructor='CustomLayerDecayOptimizerConstructor',
|
||||
paramwise_cfg=dict(num_layers=33, layer_decay_rate=1.0,
|
||||
depths=[4, 4, 21, 4]))
|
||||
|
||||
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,
|
||||
train=dict(pipeline=train_pipeline),
|
||||
val=dict(pipeline=test_pipeline),
|
||||
test=dict(pipeline=test_pipeline))
|
||||
runner = dict(type='IterBasedRunner')
|
||||
optimizer_config = dict(_delete_=True, grad_clip=dict(max_norm=0.1, norm_type=2))
|
||||
checkpoint_config = dict(by_epoch=False, interval=5000, max_keep_ckpts=1)
|
||||
evaluation = dict(interval=5000, metric='mIoU', save_best='mIoU')
|
||||
# fp16 = dict(loss_scale=dict(init_scale=512))
|
||||
@@ -0,0 +1,160 @@
|
||||
# --------------------------------------------------------
|
||||
# DCNv4
|
||||
# Copyright (c) 2024 OpenGVLab
|
||||
# Licensed under The MIT License [see LICENSE for details]
|
||||
# --------------------------------------------------------
|
||||
_base_ = [
|
||||
'../_base_/models/mask2former_beit.py', '../_base_/datasets/ade20k.py',
|
||||
'../_base_/default_runtime.py', '../_base_/schedules/schedule_160k.py'
|
||||
]
|
||||
num_classes = 150
|
||||
pretrained = 'https://huggingface.co/OpenGVLab/DCNv4/resolve/main/flash_intern_image_s_1k_224.pth'
|
||||
model = dict(
|
||||
backbone=dict(
|
||||
_delete_=True,
|
||||
type='FlashInternImage',
|
||||
core_op='DCNv4',
|
||||
channels=80,
|
||||
depths=[4, 4, 21, 4],
|
||||
groups=[5, 10, 20, 40],
|
||||
mlp_ratio=4.,
|
||||
drop_path_rate=0.3,
|
||||
norm_layer='LN',
|
||||
layer_scale=1.0,
|
||||
offset_scale=1.0,
|
||||
post_norm=True,
|
||||
with_cp=False,
|
||||
dw_kernel_size=3,
|
||||
out_indices=(0, 1, 2, 3),
|
||||
init_cfg=dict(type='Pretrained', checkpoint=pretrained)),
|
||||
decode_head=dict(
|
||||
in_channels=[80, 160, 320, 640],
|
||||
feat_channels=256,
|
||||
out_channels=256,
|
||||
num_classes=num_classes,
|
||||
num_queries=200,
|
||||
pixel_decoder=dict(
|
||||
type='MSDeformAttnPixelDecoder',
|
||||
num_outs=3,
|
||||
norm_cfg=dict(type='GN', num_groups=32),
|
||||
act_cfg=dict(type='ReLU'),
|
||||
encoder=dict(
|
||||
type='DetrTransformerEncoder',
|
||||
num_layers=6,
|
||||
transformerlayers=dict(
|
||||
type='BaseTransformerLayer',
|
||||
attn_cfgs=dict(
|
||||
type='CustomMultiScaleDeformableAttention',
|
||||
use_softmax=False,
|
||||
embed_dims=256,
|
||||
num_heads=8,
|
||||
num_levels=3,
|
||||
num_points=4,
|
||||
im2col_step=64,
|
||||
dropout=0.0,
|
||||
batch_first=False,
|
||||
norm_cfg=None,
|
||||
init_cfg=None),
|
||||
ffn_cfgs=dict(
|
||||
type='FFN',
|
||||
embed_dims=256,
|
||||
feedforward_channels=2048,
|
||||
num_fcs=2,
|
||||
ffn_drop=0.0,
|
||||
with_cp=False, # set with_cp=True to save memory
|
||||
act_cfg=dict(type='ReLU', inplace=True)),
|
||||
operation_order=('self_attn', 'norm', 'ffn', 'norm')),
|
||||
init_cfg=None),
|
||||
positional_encoding=dict(
|
||||
type='SinePositionalEncoding', num_feats=128, normalize=True),
|
||||
init_cfg=None),
|
||||
positional_encoding=dict(
|
||||
type='SinePositionalEncoding', num_feats=128, normalize=True),
|
||||
transformer_decoder=dict(
|
||||
type='DetrTransformerDecoder',
|
||||
return_intermediate=True,
|
||||
num_layers=9,
|
||||
transformerlayers=dict(
|
||||
type='DetrTransformerDecoderLayer',
|
||||
attn_cfgs=dict(
|
||||
type='MultiheadAttention',
|
||||
embed_dims=256,
|
||||
num_heads=8,
|
||||
attn_drop=0.0,
|
||||
proj_drop=0.0,
|
||||
dropout_layer=None,
|
||||
batch_first=False),
|
||||
ffn_cfgs=dict(
|
||||
embed_dims=256,
|
||||
feedforward_channels=2048,
|
||||
num_fcs=2,
|
||||
act_cfg=dict(type='ReLU', inplace=True),
|
||||
ffn_drop=0.0,
|
||||
dropout_layer=None,
|
||||
with_cp=False, # set with_cp=True to save memory
|
||||
add_identity=True),
|
||||
feedforward_channels=2048,
|
||||
operation_order=('cross_attn', 'norm', 'self_attn', 'norm',
|
||||
'ffn', 'norm')),
|
||||
init_cfg=None),
|
||||
loss_cls=dict(
|
||||
type='CrossEntropyLoss',
|
||||
use_sigmoid=False,
|
||||
loss_weight=2.0,
|
||||
reduction='mean',
|
||||
class_weight=[1.0] * num_classes + [0.1])
|
||||
),
|
||||
test_cfg=dict(mode='whole'))
|
||||
img_norm_cfg = dict(
|
||||
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
||||
crop_size = (640, 640)
|
||||
train_pipeline = [
|
||||
dict(type='LoadImageFromFile'),
|
||||
dict(type='LoadAnnotations', reduce_zero_label=True),
|
||||
dict(type='Resize', img_scale=(2560, 640), ratio_range=(0.5, 2.0)),
|
||||
dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75),
|
||||
dict(type='RandomFlip', prob=0.5),
|
||||
dict(type='PhotoMetricDistortion'),
|
||||
dict(type='Normalize', **img_norm_cfg),
|
||||
dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255),
|
||||
dict(type='ToMask'),
|
||||
dict(type='DefaultFormatBundle'),
|
||||
dict(type='Collect', keys=['img', 'gt_semantic_seg', 'gt_masks', 'gt_labels'])
|
||||
]
|
||||
test_pipeline = [
|
||||
dict(type='LoadImageFromFile'),
|
||||
dict(
|
||||
type='MultiScaleFlipAug',
|
||||
img_scale=(2560, 640),
|
||||
# img_ratios=[768./896., 832./896., 1.0, 960./896., 1024./896.],
|
||||
flip=False,
|
||||
transforms=[
|
||||
dict(type='Resize', keep_ratio=True),
|
||||
dict(type='ResizeToMultiple', size_divisor=32),
|
||||
dict(type='RandomFlip'),
|
||||
dict(type='Normalize', **img_norm_cfg),
|
||||
dict(type='ImageToTensor', keys=['img']),
|
||||
dict(type='Collect', keys=['img']),
|
||||
])
|
||||
]
|
||||
optimizer = dict(
|
||||
_delete_=True, type='AdamW', lr=0.0001, betas=(0.9, 0.999), weight_decay=0.05,
|
||||
constructor='CustomLayerDecayOptimizerConstructor',
|
||||
paramwise_cfg=dict(num_layers=33, layer_decay_rate=1.0,
|
||||
depths=[4, 4, 21, 4]))
|
||||
|
||||
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,
|
||||
train=dict(pipeline=train_pipeline),
|
||||
val=dict(pipeline=test_pipeline),
|
||||
test=dict(pipeline=test_pipeline))
|
||||
runner = dict(type='IterBasedRunner')
|
||||
optimizer_config = dict(_delete_=True, grad_clip=dict(max_norm=0.1, norm_type=2))
|
||||
checkpoint_config = dict(by_epoch=False, interval=5000, max_keep_ckpts=1)
|
||||
evaluation = dict(interval=5000, metric='mIoU', save_best='mIoU')
|
||||
# fp16 = dict(loss_scale=dict(init_scale=512))
|
||||
@@ -0,0 +1,157 @@
|
||||
# --------------------------------------------------------
|
||||
# DCNv4
|
||||
# Copyright (c) 2023 OpenGVLab
|
||||
# Licensed under The MIT License [see LICENSE for details]
|
||||
# --------------------------------------------------------
|
||||
_base_ = [
|
||||
'../_base_/models/mask2former_beit.py', '../_base_/datasets/ade20k.py',
|
||||
'../_base_/default_runtime.py', '../_base_/schedules/schedule_160k.py'
|
||||
]
|
||||
num_classes = 150
|
||||
pretrained = 'https://huggingface.co/OpenGVLab/DCNv4/resolve/main/flash_intern_image_t_1k_224.pth'
|
||||
model = dict(
|
||||
backbone=dict(
|
||||
_delete_=True,
|
||||
type='FlashInternImage',
|
||||
core_op='DCNv4',
|
||||
channels=64,
|
||||
depths=[4, 4, 18, 4],
|
||||
groups=[4, 8, 16, 32],
|
||||
mlp_ratio=4.,
|
||||
drop_path_rate=0.2,
|
||||
norm_layer='LN',
|
||||
layer_scale=1.0,
|
||||
offset_scale=1.0,
|
||||
post_norm=False,
|
||||
with_cp=False,
|
||||
out_indices=(0, 1, 2, 3),
|
||||
init_cfg=dict(type='Pretrained', checkpoint=pretrained)),
|
||||
decode_head=dict(
|
||||
in_channels=[64, 128, 256, 512],
|
||||
feat_channels=256,
|
||||
out_channels=256,
|
||||
num_classes=num_classes,
|
||||
num_queries=100,
|
||||
pixel_decoder=dict(
|
||||
type='MSDeformAttnPixelDecoder',
|
||||
num_outs=3,
|
||||
norm_cfg=dict(type='GN', num_groups=32),
|
||||
act_cfg=dict(type='ReLU'),
|
||||
encoder=dict(
|
||||
type='DetrTransformerEncoder',
|
||||
num_layers=6,
|
||||
transformerlayers=dict(
|
||||
type='BaseTransformerLayer',
|
||||
attn_cfgs=dict(
|
||||
type='MultiScaleDeformableAttention',
|
||||
embed_dims=256,
|
||||
num_heads=8,
|
||||
num_levels=3,
|
||||
num_points=4,
|
||||
im2col_step=64,
|
||||
dropout=0.0,
|
||||
batch_first=False,
|
||||
norm_cfg=None,
|
||||
init_cfg=None),
|
||||
ffn_cfgs=dict(
|
||||
type='FFN',
|
||||
embed_dims=256,
|
||||
feedforward_channels=1024,
|
||||
num_fcs=2,
|
||||
ffn_drop=0.0,
|
||||
with_cp=False, # set with_cp=True to save memory
|
||||
act_cfg=dict(type='ReLU', inplace=True)),
|
||||
operation_order=('self_attn', 'norm', 'ffn', 'norm')),
|
||||
init_cfg=None),
|
||||
positional_encoding=dict(
|
||||
type='SinePositionalEncoding', num_feats=128, normalize=True),
|
||||
init_cfg=None),
|
||||
positional_encoding=dict(
|
||||
type='SinePositionalEncoding', num_feats=128, normalize=True),
|
||||
transformer_decoder=dict(
|
||||
type='DetrTransformerDecoder',
|
||||
return_intermediate=True,
|
||||
num_layers=9,
|
||||
transformerlayers=dict(
|
||||
type='DetrTransformerDecoderLayer',
|
||||
attn_cfgs=dict(
|
||||
type='MultiheadAttention',
|
||||
embed_dims=256,
|
||||
num_heads=8,
|
||||
attn_drop=0.0,
|
||||
proj_drop=0.0,
|
||||
dropout_layer=None,
|
||||
batch_first=False),
|
||||
ffn_cfgs=dict(
|
||||
embed_dims=256,
|
||||
feedforward_channels=2048,
|
||||
num_fcs=2,
|
||||
act_cfg=dict(type='ReLU', inplace=True),
|
||||
ffn_drop=0.0,
|
||||
dropout_layer=None,
|
||||
with_cp=False, # set with_cp=True to save memory
|
||||
add_identity=True),
|
||||
feedforward_channels=2048,
|
||||
operation_order=('cross_attn', 'norm', 'self_attn', 'norm',
|
||||
'ffn', 'norm')),
|
||||
init_cfg=None),
|
||||
loss_cls=dict(
|
||||
type='CrossEntropyLoss',
|
||||
use_sigmoid=False,
|
||||
loss_weight=2.0,
|
||||
reduction='mean',
|
||||
class_weight=[1.0] * num_classes + [0.1])
|
||||
),
|
||||
test_cfg=dict(mode='whole'))
|
||||
img_norm_cfg = dict(
|
||||
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
||||
crop_size = (512, 512)
|
||||
train_pipeline = [
|
||||
dict(type='LoadImageFromFile'),
|
||||
dict(type='LoadAnnotations', reduce_zero_label=True),
|
||||
dict(type='Resize', img_scale=(2048, 512), ratio_range=(0.5, 2.0)),
|
||||
dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75),
|
||||
dict(type='RandomFlip', prob=0.5),
|
||||
dict(type='PhotoMetricDistortion'),
|
||||
dict(type='Normalize', **img_norm_cfg),
|
||||
dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255),
|
||||
dict(type='ToMask'),
|
||||
dict(type='DefaultFormatBundle'),
|
||||
dict(type='Collect', keys=['img', 'gt_semantic_seg', 'gt_masks', 'gt_labels'])
|
||||
]
|
||||
test_pipeline = [
|
||||
dict(type='LoadImageFromFile'),
|
||||
dict(
|
||||
type='MultiScaleFlipAug',
|
||||
img_scale=(2048, 512),
|
||||
# img_ratios=[768./896., 832./896., 1.0, 960./896., 1024./896.],
|
||||
flip=False,
|
||||
transforms=[
|
||||
dict(type='Resize', keep_ratio=True),
|
||||
dict(type='ResizeToMultiple', size_divisor=32),
|
||||
dict(type='RandomFlip'),
|
||||
dict(type='Normalize', **img_norm_cfg),
|
||||
dict(type='ImageToTensor', keys=['img']),
|
||||
dict(type='Collect', keys=['img']),
|
||||
])
|
||||
]
|
||||
optimizer = dict(
|
||||
_delete_=True, type='AdamW', lr=0.0001, weight_decay=0.05,
|
||||
constructor='CustomLayerDecayOptimizerConstructor',
|
||||
paramwise_cfg=dict(num_layers=30, layer_decay_rate=0.9,
|
||||
depths=[4, 4, 18, 4]))
|
||||
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,
|
||||
train=dict(pipeline=train_pipeline),
|
||||
val=dict(pipeline=test_pipeline),
|
||||
test=dict(pipeline=test_pipeline))
|
||||
runner = dict(type='IterBasedRunner')
|
||||
optimizer_config = dict(_delete_=True, grad_clip=dict(max_norm=0.01, norm_type=2))
|
||||
checkpoint_config = dict(by_epoch=False, interval=5000, max_keep_ckpts=1)
|
||||
evaluation = dict(interval=5000, metric='mIoU', save_best='mIoU')
|
||||
# fp16 = dict(loss_scale=dict(init_scale=512))
|
||||
@@ -0,0 +1,68 @@
|
||||
# --------------------------------------------------------
|
||||
# DCNv4
|
||||
# Copyright (c) 2024 OpenGVLab
|
||||
# Licensed under The MIT License [see LICENSE for details]
|
||||
# --------------------------------------------------------
|
||||
_base_ = [
|
||||
'../_base_/models/upernet_r50.py', '../_base_/datasets/ade20k.py',
|
||||
'../_base_/default_runtime.py', '../_base_/schedules/schedule_160k.py'
|
||||
]
|
||||
pretrained = 'https://huggingface.co/OpenGVLab/DCNv4/resolve/main/flash_intern_image_b_1k_224.pth'
|
||||
model = dict(
|
||||
backbone=dict(
|
||||
_delete_=True,
|
||||
type='FlashInternImage',
|
||||
core_op='DCNv4',
|
||||
channels=112,
|
||||
depths=[4, 4, 21, 4],
|
||||
groups=[7, 14, 28, 56],
|
||||
mlp_ratio=4.,
|
||||
drop_path_rate=0.3,
|
||||
norm_layer='LN',
|
||||
layer_scale=1.0,
|
||||
offset_scale=0.5,
|
||||
post_norm=True,
|
||||
with_cp=False,
|
||||
dw_kernel_size=3,
|
||||
out_indices=(0, 1, 2, 3),
|
||||
init_cfg=dict(type='Pretrained', checkpoint=pretrained)),
|
||||
decode_head=dict(num_classes=150, in_channels=[112, 224, 448, 896]),
|
||||
auxiliary_head=dict(num_classes=150, in_channels=448),
|
||||
test_cfg=dict(mode='whole')
|
||||
)
|
||||
img_norm_cfg = dict(
|
||||
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
||||
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),
|
||||
dict(type='ResizeToMultiple', size_divisor=32),
|
||||
dict(type='RandomFlip'),
|
||||
dict(type='Normalize', **img_norm_cfg),
|
||||
dict(type='ImageToTensor', keys=['img']),
|
||||
dict(type='Collect', keys=['img']),
|
||||
])
|
||||
]
|
||||
optimizer = dict(
|
||||
_delete_=True, type='AdamW', lr=0.00006, betas=(0.9, 0.999), weight_decay=0.05,
|
||||
constructor='CustomLayerDecayOptimizerConstructor',
|
||||
paramwise_cfg=dict(num_layers=33, layer_decay_rate=1.0,
|
||||
depths=[4, 4, 21, 4]))
|
||||
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,
|
||||
val=dict(pipeline=test_pipeline),
|
||||
test=dict(pipeline=test_pipeline))
|
||||
runner = dict(type='IterBasedRunner')
|
||||
checkpoint_config = dict(by_epoch=False, interval=1000, max_keep_ckpts=1)
|
||||
evaluation = dict(interval=16000, metric='mIoU', save_best='mIoU')
|
||||
# fp16 = dict(loss_scale=dict(init_scale=512))
|
||||
@@ -0,0 +1,84 @@
|
||||
# --------------------------------------------------------
|
||||
# DCNv4
|
||||
# Copyright (c) 2024 OpenGVLab
|
||||
# Licensed under The MIT License [see LICENSE for details]
|
||||
# --------------------------------------------------------
|
||||
_base_ = [
|
||||
'../_base_/models/upernet_r50.py', '../_base_/datasets/ade20k.py',
|
||||
'../_base_/default_runtime.py', '../_base_/schedules/schedule_160k.py'
|
||||
]
|
||||
pretrained = 'https://huggingface.co/OpenGVLab/DCNv4/resolve/main/flash_intern_image_l_22k_384.pth'
|
||||
model = dict(
|
||||
backbone=dict(
|
||||
_delete_=True,
|
||||
type='FlashInternImage',
|
||||
core_op='DCNv4',
|
||||
channels=160,
|
||||
depths=[5, 5, 22, 5],
|
||||
groups=[10, 20, 40, 80],
|
||||
mlp_ratio=4.,
|
||||
drop_path_rate=0.4,
|
||||
norm_layer='LN',
|
||||
layer_scale=1.0,
|
||||
offset_scale=2.0,
|
||||
post_norm=True,
|
||||
with_cp=False,
|
||||
dcn_output_bias=True,
|
||||
mlp_fc2_bias=True,
|
||||
dw_kernel_size=3,
|
||||
out_indices=(0, 1, 2, 3),
|
||||
init_cfg=dict(type='Pretrained', checkpoint=pretrained)),
|
||||
decode_head=dict(num_classes=150, in_channels=[160, 320, 640, 1280]),
|
||||
auxiliary_head=dict(num_classes=150, in_channels=640),
|
||||
test_cfg=dict(mode='whole'))
|
||||
img_norm_cfg = dict(
|
||||
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
||||
crop_size = (640, 640)
|
||||
train_pipeline = [
|
||||
dict(type='LoadImageFromFile'),
|
||||
dict(type='LoadAnnotations', reduce_zero_label=True),
|
||||
dict(type='Resize', img_scale=(2560, 640), ratio_range=(0.5, 2.0)),
|
||||
dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75),
|
||||
dict(type='RandomFlip', prob=0.5),
|
||||
dict(type='PhotoMetricDistortion'),
|
||||
dict(type='Normalize', **img_norm_cfg),
|
||||
dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255),
|
||||
dict(type='DefaultFormatBundle'),
|
||||
dict(type='Collect', keys=['img', 'gt_semantic_seg']),
|
||||
]
|
||||
test_pipeline = [
|
||||
dict(type='LoadImageFromFile'),
|
||||
dict(
|
||||
type='MultiScaleFlipAug',
|
||||
img_scale=(2560, 640),
|
||||
# img_ratios=[0.75, 1.0, 1.25],
|
||||
flip=False,
|
||||
transforms=[
|
||||
dict(type='Resize', keep_ratio=True),
|
||||
dict(type='ResizeToMultiple', size_divisor=32),
|
||||
dict(type='RandomFlip'),
|
||||
dict(type='Normalize', **img_norm_cfg),
|
||||
dict(type='ImageToTensor', keys=['img']),
|
||||
dict(type='Collect', keys=['img']),
|
||||
])
|
||||
]
|
||||
optimizer = dict(
|
||||
_delete_=True, type='AdamW', lr=0.00002, betas=(0.9, 0.999), weight_decay=0.05,
|
||||
constructor='CustomLayerDecayOptimizerConstructor',
|
||||
paramwise_cfg=dict(num_layers=37, layer_decay_rate=0.94,
|
||||
depths=[5, 5, 22, 5], offset_lr_scale=1.0))
|
||||
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,
|
||||
train=dict(pipeline=train_pipeline),
|
||||
val=dict(pipeline=test_pipeline),
|
||||
test=dict(pipeline=test_pipeline))
|
||||
runner = dict(type='IterBasedRunner')
|
||||
optimizer_config = dict(_delete_=True, grad_clip=dict(max_norm=0.1, norm_type=2))
|
||||
checkpoint_config = dict(by_epoch=False, interval=1000, max_keep_ckpts=1)
|
||||
evaluation = dict(interval=16000, metric='mIoU', save_best='mIoU')
|
||||
# fp16 = dict(loss_scale=dict(init_scale=512))
|
||||
@@ -0,0 +1,68 @@
|
||||
# --------------------------------------------------------
|
||||
# DCNv4
|
||||
# Copyright (c) 2024 OpenGVLab
|
||||
# Licensed under The MIT License [see LICENSE for details]
|
||||
# --------------------------------------------------------
|
||||
_base_ = [
|
||||
'../_base_/models/upernet_r50.py', '../_base_/datasets/ade20k.py',
|
||||
'../_base_/default_runtime.py', '../_base_/schedules/schedule_160k.py'
|
||||
]
|
||||
pretrained = 'https://huggingface.co/OpenGVLab/DCNv4/resolve/main/flash_intern_image_s_1k_224.pth'
|
||||
model = dict(
|
||||
backbone=dict(
|
||||
_delete_=True,
|
||||
type='FlashInternImage',
|
||||
core_op='DCNv4',
|
||||
channels=80,
|
||||
depths=[4, 4, 21, 4],
|
||||
groups=[5, 10, 20, 40],
|
||||
mlp_ratio=4.,
|
||||
drop_path_rate=0.3,
|
||||
norm_layer='LN',
|
||||
layer_scale=1.0,
|
||||
offset_scale=1.0,
|
||||
post_norm=True,
|
||||
with_cp=True,
|
||||
dw_kernel_size=3,
|
||||
out_indices=(0, 1, 2, 3),
|
||||
init_cfg=dict(type='Pretrained', checkpoint=pretrained)),
|
||||
decode_head=dict(num_classes=150, in_channels=[80, 160, 320, 640]),
|
||||
auxiliary_head=dict(num_classes=150, in_channels=320),
|
||||
test_cfg=dict(mode='whole')
|
||||
)
|
||||
img_norm_cfg = dict(
|
||||
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
||||
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),
|
||||
dict(type='ResizeToMultiple', size_divisor=32),
|
||||
dict(type='RandomFlip'),
|
||||
dict(type='Normalize', **img_norm_cfg),
|
||||
dict(type='ImageToTensor', keys=['img']),
|
||||
dict(type='Collect', keys=['img']),
|
||||
])
|
||||
]
|
||||
optimizer = dict(
|
||||
_delete_=True, type='AdamW', lr=0.00006, betas=(0.9, 0.999), weight_decay=0.05,
|
||||
constructor='CustomLayerDecayOptimizerConstructor',
|
||||
paramwise_cfg=dict(num_layers=33, layer_decay_rate=1.0,
|
||||
depths=[4, 4, 21, 4]))
|
||||
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,
|
||||
val=dict(pipeline=test_pipeline),
|
||||
test=dict(pipeline=test_pipeline))
|
||||
runner = dict(type='IterBasedRunner')
|
||||
checkpoint_config = dict(by_epoch=False, interval=1000, max_keep_ckpts=1)
|
||||
evaluation = dict(interval=16000, metric='mIoU', save_best='mIoU')
|
||||
# fp16 = dict(loss_scale=dict(init_scale=512))
|
||||
@@ -0,0 +1,68 @@
|
||||
# --------------------------------------------------------
|
||||
# DCNv4
|
||||
# Copyright (c) 2024 OpenGVLab
|
||||
# Licensed under The MIT License [see LICENSE for details]
|
||||
# --------------------------------------------------------
|
||||
_base_ = [
|
||||
'../_base_/models/upernet_r50.py', '../_base_/datasets/ade20k.py',
|
||||
'../_base_/default_runtime.py', '../_base_/schedules/schedule_160k.py'
|
||||
]
|
||||
pretrained = 'https://huggingface.co/OpenGVLab/DCNv4/resolve/main/flash_intern_image_t_1k_224.pth'
|
||||
model = dict(
|
||||
backbone=dict(
|
||||
_delete_=True,
|
||||
type='FlashInternImage',
|
||||
core_op='DCNv4',
|
||||
channels=64,
|
||||
depths=[4, 4, 18, 4],
|
||||
groups=[4, 8, 16, 32],
|
||||
mlp_ratio=4.,
|
||||
drop_path_rate=0.2,
|
||||
norm_layer='LN',
|
||||
layer_scale=1.0,
|
||||
offset_scale=1.0,
|
||||
post_norm=False,
|
||||
with_cp=True,
|
||||
out_indices=(0, 1, 2, 3),
|
||||
init_cfg=dict(type='Pretrained', checkpoint=pretrained)),
|
||||
decode_head=dict(num_classes=150, in_channels=[64, 128, 256, 512]),
|
||||
auxiliary_head=dict(num_classes=150, in_channels=256),
|
||||
test_cfg=dict(mode='whole')
|
||||
)
|
||||
img_norm_cfg = dict(
|
||||
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
||||
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),
|
||||
dict(type='ResizeToMultiple', size_divisor=32),
|
||||
dict(type='RandomFlip'),
|
||||
dict(type='Normalize', **img_norm_cfg),
|
||||
dict(type='ImageToTensor', keys=['img']),
|
||||
dict(type='Collect', keys=['img']),
|
||||
])
|
||||
]
|
||||
optimizer = dict(
|
||||
_delete_=True, type='AdamW', lr=0.00006, betas=(0.9, 0.999), weight_decay=0.05,
|
||||
constructor='CustomLayerDecayOptimizerConstructor',
|
||||
paramwise_cfg=dict(num_layers=30, layer_decay_rate=1.0,
|
||||
depths=[4, 4, 18, 4]))
|
||||
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,
|
||||
# val=dict(pipeline=test_pipeline),
|
||||
# test=dict(pipeline=test_pipeline)
|
||||
)
|
||||
runner = dict(type='IterBasedRunner')
|
||||
checkpoint_config = dict(by_epoch=False, interval=1000, max_keep_ckpts=1)
|
||||
evaluation = dict(interval=16000, metric='mIoU', save_best='mIoU')
|
||||
# fp16 = dict(loss_scale=dict(init_scale=512))
|
||||
Reference in New Issue
Block a user