forked from open-mmlab/mmsegmentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[New model] Support CGNet (open-mmlab#223)
* added cgnet * added testing for cgnet * git test * add cgnet * fix __init__ * rename FGlo with GlobalContextExtractor * add readme.md and rename bn with norm * delete cg_head * fix a language mistake * rename cgnet_m3n21.py to cgnet.py * modify README.md * modify list to tuple * add fcn_head test * add assert to fcn_head * blank * fix fcn_head assert bug * add * add cgnet to README.md and model_zoo.md * modify cgnet README.md Co-authored-by: KID <wps_@mail.nankai.edu.cn>
- Loading branch information
Showing
11 changed files
with
718 additions
and
7 deletions.
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
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,35 @@ | ||
# model settings | ||
norm_cfg = dict(type='SyncBN', eps=1e-03, requires_grad=True) | ||
model = dict( | ||
type='EncoderDecoder', | ||
backbone=dict( | ||
type='CGNet', | ||
norm_cfg=norm_cfg, | ||
in_channels=3, | ||
num_channels=(32, 64, 128), | ||
num_blocks=(3, 21), | ||
dilations=(2, 4), | ||
reductions=(8, 16)), | ||
decode_head=dict( | ||
type='FCNHead', | ||
in_channels=256, | ||
in_index=2, | ||
channels=256, | ||
num_convs=0, | ||
concat_input=False, | ||
dropout_ratio=0, | ||
num_classes=19, | ||
norm_cfg=norm_cfg, | ||
loss_decode=dict( | ||
type='CrossEntropyLoss', | ||
use_sigmoid=False, | ||
loss_weight=1.0, | ||
class_weight=[ | ||
2.5959933, 6.7415504, 3.5354059, 9.8663225, 9.690899, 9.369352, | ||
10.289121, 9.953208, 4.3097677, 9.490387, 7.674431, 9.396905, | ||
10.347791, 6.3927646, 10.226669, 10.241062, 10.280587, | ||
10.396974, 10.055647 | ||
]))) | ||
# model training and testing settings | ||
train_cfg = dict(sampler=None) | ||
test_cfg = dict(mode='whole') |
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,21 @@ | ||
# CGNet: A Light-weight Context Guided Network for Semantic Segmentation | ||
|
||
## Introduction | ||
|
||
```latext | ||
@article{wu2018cgnet, | ||
title={CGNet: A Light-weight Context Guided Network for Semantic Segmentation}, | ||
author={Wu, Tianyi and Tang, Sheng and Zhang, Rui and Zhang, Yongdong}, | ||
journal={arXiv preprint arXiv:1811.08201}, | ||
year={2018} | ||
} | ||
``` | ||
|
||
## Results and models | ||
|
||
### Cityscapes | ||
|
||
| Method | Backbone | Crop Size | Lr schd | Mem (GB) | Inf time (fps) | mIoU | mIoU(ms+flip) | download | | ||
|-----------|----------|-----------|--------:|----------|----------------|------:|--------------:|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| CGNet | M3N21 | 680x680 | 60000 | 7.5 | 30.51 | 65.63 | 68.04 | [model](https://download.openmmlab.com/mmsegmentation/v0.5/cgnet/cgnet_680x680_60k_cityscapes/cgnet_680x680_60k_cityscapes_20201101_110253-4c0b2f2d.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/cgnet/cgnet_680x680_60k_cityscapes/cgnet_680x680_60k_cityscapes-20201101_110253.log.json) | | ||
| CGNet | M3N21 | 512x1024 | 60000 | 8.3 | 31.14 | 68.27 | 70.33 | [model](https://download.openmmlab.com/mmsegmentation/v0.5/cgnet/cgnet_512x1024_60k_cityscapes/cgnet_512x1024_60k_cityscapes_20201101_110254-124ea03b.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/cgnet/cgnet_512x1024_60k_cityscapes/cgnet_512x1024_60k_cityscapes-20201101_110254.log.json) | |
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,66 @@ | ||
_base_ = ['../_base_/models/cgnet.py', '../_base_/default_runtime.py'] | ||
|
||
# optimizer | ||
optimizer = dict(type='Adam', lr=0.001, eps=1e-08, weight_decay=0.0005) | ||
optimizer_config = dict() | ||
# learning policy | ||
lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False) | ||
# runtime settings | ||
total_iters = 60000 | ||
checkpoint_config = dict(by_epoch=False, interval=4000) | ||
evaluation = dict(interval=4000, metric='mIoU') | ||
|
||
# dataset settings | ||
dataset_type = 'CityscapesDataset' | ||
data_root = 'data/cityscapes/' | ||
img_norm_cfg = dict( | ||
mean=[72.39239876, 82.90891754, 73.15835921], std=[1, 1, 1], to_rgb=True) | ||
crop_size = (512, 1024) | ||
train_pipeline = [ | ||
dict(type='LoadImageFromFile'), | ||
dict(type='LoadAnnotations'), | ||
dict(type='Resize', img_scale=(2048, 1024), ratio_range=(0.5, 2.0)), | ||
dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75), | ||
dict(type='RandomFlip', flip_ratio=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=(2048, 1024), | ||
# 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='RandomFlip'), | ||
dict(type='Normalize', **img_norm_cfg), | ||
dict(type='ImageToTensor', keys=['img']), | ||
dict(type='Collect', keys=['img']), | ||
]) | ||
] | ||
data = dict( | ||
samples_per_gpu=8, | ||
workers_per_gpu=8, | ||
train=dict( | ||
type=dataset_type, | ||
data_root=data_root, | ||
img_dir='leftImg8bit/train', | ||
ann_dir='gtFine/train', | ||
pipeline=train_pipeline), | ||
val=dict( | ||
type=dataset_type, | ||
data_root=data_root, | ||
img_dir='leftImg8bit/val', | ||
ann_dir='gtFine/val', | ||
pipeline=test_pipeline), | ||
test=dict( | ||
type=dataset_type, | ||
data_root=data_root, | ||
img_dir='leftImg8bit/val', | ||
ann_dir='gtFine/val', | ||
pipeline=test_pipeline)) |
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,50 @@ | ||
_base_ = [ | ||
'../_base_/models/cgnet.py', '../_base_/datasets/cityscapes.py', | ||
'../_base_/default_runtime.py' | ||
] | ||
|
||
# optimizer | ||
optimizer = dict(type='Adam', lr=0.001, eps=1e-08, weight_decay=0.0005) | ||
optimizer_config = dict() | ||
# learning policy | ||
lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False) | ||
# runtime settings | ||
total_iters = 60000 | ||
checkpoint_config = dict(by_epoch=False, interval=4000) | ||
evaluation = dict(interval=4000, metric='mIoU') | ||
|
||
img_norm_cfg = dict( | ||
mean=[72.39239876, 82.90891754, 73.15835921], std=[1, 1, 1], to_rgb=True) | ||
crop_size = (680, 680) | ||
train_pipeline = [ | ||
dict(type='LoadImageFromFile'), | ||
dict(type='LoadAnnotations'), | ||
dict(type='Resize', img_scale=(2048, 1024), ratio_range=(0.5, 2.0)), | ||
dict(type='RandomCrop', crop_size=crop_size), | ||
dict(type='RandomFlip', flip_ratio=0.5), | ||
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=(2048, 1024), | ||
# 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='RandomFlip'), | ||
dict(type='Normalize', **img_norm_cfg), | ||
dict(type='ImageToTensor', keys=['img']), | ||
dict(type='Collect', keys=['img']), | ||
]) | ||
] | ||
data = dict( | ||
samples_per_gpu=8, | ||
workers_per_gpu=8, | ||
train=dict(pipeline=train_pipeline), | ||
val=dict(pipeline=test_pipeline), | ||
test=dict(pipeline=test_pipeline)) |
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
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
Oops, something went wrong.