first commit
This commit is contained in:
46
Seg_All_In_One_MMSeg/configs/cgnet/README.md
Normal file
46
Seg_All_In_One_MMSeg/configs/cgnet/README.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# CGNet
|
||||
|
||||
> [CGNet: A Light-weight Context Guided Network for Semantic Segmentation](https://arxiv.org/abs/1811.08201)
|
||||
|
||||
## Introduction
|
||||
|
||||
<!-- [ALGORITHM] -->
|
||||
|
||||
<a href="https://github.com/wutianyiRosun/CGNet">Official Repo</a>
|
||||
|
||||
<a href="https://github.com/open-mmlab/mmsegmentation/blob/v0.17.0/mmseg/models/backbones/cgnet.py#L187">Code Snippet</a>
|
||||
|
||||
## Abstract
|
||||
|
||||
<!-- [ABSTRACT] -->
|
||||
|
||||
The demand of applying semantic segmentation model on mobile devices has been increasing rapidly. Current state-of-the-art networks have enormous amount of parameters hence unsuitable for mobile devices, while other small memory footprint models follow the spirit of classification network and ignore the inherent characteristic of semantic segmentation. To tackle this problem, we propose a novel Context Guided Network (CGNet), which is a light-weight and efficient network for semantic segmentation. We first propose the Context Guided (CG) block, which learns the joint feature of both local feature and surrounding context, and further improves the joint feature with the global context. Based on the CG block, we develop CGNet which captures contextual information in all stages of the network and is specially tailored for increasing segmentation accuracy. CGNet is also elaborately designed to reduce the number of parameters and save memory footprint. Under an equivalent number of parameters, the proposed CGNet significantly outperforms existing segmentation networks. Extensive experiments on Cityscapes and CamVid datasets verify the effectiveness of the proposed approach. Specifically, without any post-processing and multi-scale testing, the proposed CGNet achieves 64.8% mean IoU on Cityscapes with less than 0.5 M parameters. The source code for the complete system can be found at [this https URL](https://github.com/wutianyiRosun/CGNet).
|
||||
|
||||
<!-- [IMAGE] -->
|
||||
|
||||
<div align=center>
|
||||
<img src="https://user-images.githubusercontent.com/24582831/142900351-89559574-79cc-4f57-8f69-5d88765ec38d.png" width="80%"/>
|
||||
</div>
|
||||
|
||||
## Results and models
|
||||
|
||||
### Cityscapes
|
||||
|
||||
| Method | Backbone | Crop Size | Lr schd | Mem (GB) | Inf time (fps) | Device | mIoU | mIoU(ms+flip) | config | download |
|
||||
| ------ | -------- | --------- | ------: | -------- | -------------- | ------ | ----: | ------------: | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| CGNet | M3N21 | 680x680 | 60000 | 7.5 | 30.51 | V100 | 65.63 | 68.04 | [config](https://github.com/open-mmlab/mmsegmentation/blob/main/configs/cgnet/cgnet_fcn_4xb4-60k_cityscapes-680x680.py) | [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 | V100 | 68.27 | 70.33 | [config](https://github.com/open-mmlab/mmsegmentation/blob/main/configs/cgnet/cgnet_fcn_4xb8-60k_cityscapes-512x1024.py) | [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) |
|
||||
|
||||
## Citation
|
||||
|
||||
```bibtext
|
||||
@article{wu2020cgnet,
|
||||
title={Cgnet: A light-weight context guided network for semantic segmentation},
|
||||
author={Wu, Tianyi and Tang, Sheng and Zhang, Rui and Cao, Juan and Zhang, Yongdong},
|
||||
journal={IEEE Transactions on Image Processing},
|
||||
volume={30},
|
||||
pages={1169--1179},
|
||||
year={2020},
|
||||
publisher={IEEE}
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,59 @@
|
||||
_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)
|
||||
optim_wrapper = dict(type='OptimWrapper', optimizer=optimizer)
|
||||
# learning policy
|
||||
param_scheduler = [
|
||||
dict(
|
||||
type='PolyLR',
|
||||
eta_min=1e-4,
|
||||
power=0.9,
|
||||
by_epoch=False,
|
||||
begin=0,
|
||||
end=60000)
|
||||
]
|
||||
# runtime settings
|
||||
total_iters = 60000
|
||||
train_cfg = dict(
|
||||
type='IterBasedTrainLoop', max_iters=total_iters, val_interval=4000)
|
||||
val_cfg = dict(type='ValLoop')
|
||||
test_cfg = dict(type='TestLoop')
|
||||
default_hooks = dict(
|
||||
timer=dict(type='IterTimerHook'),
|
||||
logger=dict(type='LoggerHook', interval=50),
|
||||
param_scheduler=dict(type='ParamSchedulerHook'),
|
||||
checkpoint=dict(type='CheckpointHook', by_epoch=False, interval=4000),
|
||||
sampler_seed=dict(type='DistSamplerSeedHook'))
|
||||
|
||||
crop_size = (680, 680)
|
||||
data_preprocessor = dict(size=crop_size)
|
||||
model = dict(data_preprocessor=data_preprocessor)
|
||||
train_pipeline = [
|
||||
dict(type='LoadImageFromFile'),
|
||||
dict(type='LoadAnnotations'),
|
||||
dict(
|
||||
type='RandomResize',
|
||||
scale=(2048, 1024),
|
||||
ratio_range=(0.5, 2.0),
|
||||
keep_ratio=True),
|
||||
dict(type='RandomCrop', crop_size=crop_size),
|
||||
dict(type='RandomFlip', prob=0.5),
|
||||
dict(type='PackSegInputs')
|
||||
]
|
||||
test_pipeline = [
|
||||
dict(type='LoadImageFromFile'),
|
||||
dict(type='Resize', scale=(2048, 1024), keep_ratio=True),
|
||||
# add loading annotation after ``Resize`` because ground truth
|
||||
# does not need to do resize data transform
|
||||
dict(type='LoadAnnotations'),
|
||||
dict(type='PackSegInputs')
|
||||
]
|
||||
train_dataloader = dict(
|
||||
batch_size=8, num_workers=4, dataset=dict(pipeline=train_pipeline))
|
||||
val_dataloader = dict(
|
||||
batch_size=1, num_workers=4, dataset=dict(pipeline=test_pipeline))
|
||||
test_dataloader = val_dataloader
|
||||
@@ -0,0 +1,38 @@
|
||||
_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)
|
||||
optim_wrapper = dict(type='OptimWrapper', optimizer=optimizer)
|
||||
# learning policy
|
||||
param_scheduler = [
|
||||
dict(
|
||||
type='PolyLR',
|
||||
eta_min=1e-4,
|
||||
power=0.9,
|
||||
by_epoch=False,
|
||||
begin=0,
|
||||
end=60000)
|
||||
]
|
||||
# runtime settings
|
||||
total_iters = 60000
|
||||
train_cfg = dict(
|
||||
type='IterBasedTrainLoop', max_iters=total_iters, val_interval=4000)
|
||||
val_cfg = dict(type='ValLoop')
|
||||
test_cfg = dict(type='TestLoop')
|
||||
default_hooks = dict(
|
||||
timer=dict(type='IterTimerHook'),
|
||||
logger=dict(type='LoggerHook', interval=50),
|
||||
param_scheduler=dict(type='ParamSchedulerHook'),
|
||||
checkpoint=dict(type='CheckpointHook', by_epoch=False, interval=4000),
|
||||
sampler_seed=dict(type='DistSamplerSeedHook'))
|
||||
|
||||
crop_size = (512, 1024)
|
||||
data_preprocessor = dict(size=crop_size)
|
||||
model = dict(data_preprocessor=data_preprocessor)
|
||||
|
||||
train_dataloader = dict(batch_size=8)
|
||||
val_dataloader = dict(batch_size=1)
|
||||
test_dataloader = val_dataloader
|
||||
61
Seg_All_In_One_MMSeg/configs/cgnet/metafile.yaml
Normal file
61
Seg_All_In_One_MMSeg/configs/cgnet/metafile.yaml
Normal file
@@ -0,0 +1,61 @@
|
||||
Collections:
|
||||
- Name: CGNet
|
||||
License: Apache License 2.0
|
||||
Metadata:
|
||||
Training Data:
|
||||
- Cityscapes
|
||||
Paper:
|
||||
Title: 'CGNet: A Light-weight Context Guided Network for Semantic Segmentation'
|
||||
URL: https://arxiv.org/abs/1811.08201
|
||||
README: configs/cgnet/README.md
|
||||
Frameworks:
|
||||
- PyTorch
|
||||
Models:
|
||||
- Name: cgnet_fcn_4xb4-60k_cityscapes-680x680
|
||||
In Collection: CGNet
|
||||
Results:
|
||||
Task: Semantic Segmentation
|
||||
Dataset: Cityscapes
|
||||
Metrics:
|
||||
mIoU: 65.63
|
||||
mIoU(ms+flip): 68.04
|
||||
Config: configs/cgnet/cgnet_fcn_4xb4-60k_cityscapes-680x680.py
|
||||
Metadata:
|
||||
Training Data: Cityscapes
|
||||
Batch Size: 16
|
||||
Architecture:
|
||||
- M3N21
|
||||
- CGNet
|
||||
Training Resources: 4x V100 GPUS
|
||||
Memory (GB): 7.5
|
||||
Weights: https://download.openmmlab.com/mmsegmentation/v0.5/cgnet/cgnet_680x680_60k_cityscapes/cgnet_680x680_60k_cityscapes_20201101_110253-4c0b2f2d.pth
|
||||
Training log: https://download.openmmlab.com/mmsegmentation/v0.5/cgnet/cgnet_680x680_60k_cityscapes/cgnet_680x680_60k_cityscapes-20201101_110253.log.json
|
||||
Paper:
|
||||
Title: 'CGNet: A Light-weight Context Guided Network for Semantic Segmentation'
|
||||
URL: https://arxiv.org/abs/1811.08201
|
||||
Code: https://github.com/open-mmlab/mmsegmentation/blob/v0.17.0/mmseg/models/backbones/cgnet.py#L187
|
||||
Framework: PyTorch
|
||||
- Name: cgnet_fcn_4xb8-60k_cityscapes-512x1024
|
||||
In Collection: CGNet
|
||||
Results:
|
||||
Task: Semantic Segmentation
|
||||
Dataset: Cityscapes
|
||||
Metrics:
|
||||
mIoU: 68.27
|
||||
mIoU(ms+flip): 70.33
|
||||
Config: configs/cgnet/cgnet_fcn_4xb8-60k_cityscapes-512x1024.py
|
||||
Metadata:
|
||||
Training Data: Cityscapes
|
||||
Batch Size: 32
|
||||
Architecture:
|
||||
- M3N21
|
||||
- CGNet
|
||||
Training Resources: 4x V100 GPUS
|
||||
Memory (GB): 8.3
|
||||
Weights: https://download.openmmlab.com/mmsegmentation/v0.5/cgnet/cgnet_512x1024_60k_cityscapes/cgnet_512x1024_60k_cityscapes_20201101_110254-124ea03b.pth
|
||||
Training log: https://download.openmmlab.com/mmsegmentation/v0.5/cgnet/cgnet_512x1024_60k_cityscapes/cgnet_512x1024_60k_cityscapes-20201101_110254.log.json
|
||||
Paper:
|
||||
Title: 'CGNet: A Light-weight Context Guided Network for Semantic Segmentation'
|
||||
URL: https://arxiv.org/abs/1811.08201
|
||||
Code: https://github.com/open-mmlab/mmsegmentation/blob/v0.17.0/mmseg/models/backbones/cgnet.py#L187
|
||||
Framework: PyTorch
|
||||
@@ -0,0 +1,99 @@
|
||||
_base_ = [
|
||||
'../_base_/models/cgnet.py',
|
||||
'../_base_/datasets/my_dataset_model.py',
|
||||
'../_base_/default_runtime.py',
|
||||
'../_base_/schedules/schedule_40k_check_4000.py',
|
||||
]
|
||||
|
||||
norm_cfg = dict(
|
||||
type='BN',
|
||||
)
|
||||
|
||||
crop_size = (680, 680)
|
||||
|
||||
data_preprocessor = dict(
|
||||
size=(680, 680),
|
||||
mean=[
|
||||
94.94709810464303,
|
||||
61.72942233949928,
|
||||
75.93763705236906,
|
||||
],
|
||||
std=[
|
||||
44.005506081132594,
|
||||
42.69595666984776,
|
||||
44.99354156225523,
|
||||
],
|
||||
bgr_to_rgb=False,
|
||||
)
|
||||
|
||||
model = dict(
|
||||
data_preprocessor=dict(
|
||||
size=(680, 680),
|
||||
mean=[
|
||||
94.94709810464303,
|
||||
61.72942233949928,
|
||||
75.93763705236906,
|
||||
],
|
||||
std=[
|
||||
44.005506081132594,
|
||||
42.69595666984776,
|
||||
44.99354156225523,
|
||||
],
|
||||
bgr_to_rgb=False,
|
||||
),
|
||||
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=dict(
|
||||
type='SyncBN',
|
||||
eps=0.001,
|
||||
requires_grad=True,
|
||||
),
|
||||
loss_decode=dict(
|
||||
type='DiceLoss',
|
||||
use_sigmoid=False,
|
||||
loss_weight=1.0,
|
||||
),
|
||||
_delete_=True,
|
||||
),
|
||||
)
|
||||
|
||||
optim_wrapper = dict(
|
||||
type='OptimWrapper',
|
||||
_delete_=True,
|
||||
optimizer=dict(
|
||||
type='AdamW',
|
||||
lr=0.0001,
|
||||
weight_decay=0.0005,
|
||||
),
|
||||
clip_grad=dict(
|
||||
max_norm=1,
|
||||
norm_type=2,
|
||||
),
|
||||
)
|
||||
|
||||
param_scheduler = [
|
||||
dict(
|
||||
type='LinearLR',
|
||||
start_factor=1e-06,
|
||||
by_epoch=False,
|
||||
begin=0,
|
||||
end=1500,
|
||||
),
|
||||
dict(
|
||||
type='PolyLR',
|
||||
power=0.9,
|
||||
begin=1500,
|
||||
end=40000,
|
||||
eta_min=1e-05,
|
||||
by_epoch=False,
|
||||
),
|
||||
]
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
_base_ = [
|
||||
'../_base_/models/cgnet.py',
|
||||
'../_base_/datasets/my_dataset_model.py',
|
||||
'../_base_/default_runtime.py',
|
||||
'../_base_/schedules/schedule_40k_check_4000.py',
|
||||
]
|
||||
|
||||
norm_cfg = dict(
|
||||
type='BN',
|
||||
)
|
||||
|
||||
crop_size = (680, 680)
|
||||
|
||||
data_preprocessor = dict(
|
||||
size=(680, 680),
|
||||
mean=[
|
||||
94.94709810464303,
|
||||
61.72942233949928,
|
||||
75.93763705236906,
|
||||
],
|
||||
std=[
|
||||
44.005506081132594,
|
||||
42.69595666984776,
|
||||
44.99354156225523,
|
||||
],
|
||||
bgr_to_rgb=False,
|
||||
)
|
||||
|
||||
model = dict(
|
||||
data_preprocessor=dict(
|
||||
size=(680, 680),
|
||||
mean=[
|
||||
94.94709810464303,
|
||||
61.72942233949928,
|
||||
75.93763705236906,
|
||||
],
|
||||
std=[
|
||||
44.005506081132594,
|
||||
42.69595666984776,
|
||||
44.99354156225523,
|
||||
],
|
||||
bgr_to_rgb=False,
|
||||
),
|
||||
decode_head=dict(
|
||||
loss_decode=dict(
|
||||
type='DiceLoss',
|
||||
use_sigmoid=False,
|
||||
loss_weight=1.0,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
optim_wrapper = dict(
|
||||
type='OptimWrapper',
|
||||
_delete_=True,
|
||||
optimizer=dict(
|
||||
type='AdamW',
|
||||
lr=0.0001,
|
||||
weight_decay=0.0005,
|
||||
),
|
||||
clip_grad=dict(
|
||||
max_norm=1,
|
||||
norm_type=2,
|
||||
),
|
||||
)
|
||||
|
||||
param_scheduler = [
|
||||
dict(
|
||||
type='LinearLR',
|
||||
start_factor=1e-06,
|
||||
by_epoch=False,
|
||||
begin=0,
|
||||
end=1500,
|
||||
),
|
||||
dict(
|
||||
type='PolyLR',
|
||||
power=0.9,
|
||||
begin=1500,
|
||||
end=40000,
|
||||
eta_min=1e-05,
|
||||
by_epoch=False,
|
||||
),
|
||||
]
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
_base_ = [
|
||||
'../_base_/models/cgnet.py',
|
||||
'../_base_/datasets/my_dataset_model.py',
|
||||
'../_base_/default_runtime.py',
|
||||
'../_base_/schedules/schedule_40k_check_4000.py',
|
||||
]
|
||||
|
||||
norm_cfg = dict(
|
||||
type='BN',
|
||||
)
|
||||
|
||||
crop_size = (680, 680)
|
||||
|
||||
data_preprocessor = dict(
|
||||
size=(680, 680),
|
||||
mean=[
|
||||
94.94709810464303,
|
||||
61.72942233949928,
|
||||
75.93763705236906,
|
||||
],
|
||||
std=[
|
||||
44.005506081132594,
|
||||
42.69595666984776,
|
||||
44.99354156225523,
|
||||
],
|
||||
bgr_to_rgb=False,
|
||||
)
|
||||
|
||||
model = dict(
|
||||
pretrained='./My_Local_Model/open_mmlab/resnet50_v1c.pth',
|
||||
backbone=dict(
|
||||
depth=50,
|
||||
),
|
||||
data_preprocessor=dict(
|
||||
size=(680, 680),
|
||||
mean=[
|
||||
94.94709810464303,
|
||||
61.72942233949928,
|
||||
75.93763705236906,
|
||||
],
|
||||
std=[
|
||||
44.005506081132594,
|
||||
42.69595666984776,
|
||||
44.99354156225523,
|
||||
],
|
||||
bgr_to_rgb=False,
|
||||
),
|
||||
decode_head=dict(
|
||||
num_classes=36,
|
||||
loss_decode=dict(
|
||||
_delete_ = True,
|
||||
type='DiceLoss',
|
||||
use_sigmoid=False,
|
||||
loss_weight=1.0,
|
||||
),
|
||||
align_corners=False,
|
||||
),
|
||||
auxiliary_head=dict(
|
||||
num_classes=36,
|
||||
loss_decode=dict(
|
||||
type='DiceLoss',
|
||||
use_sigmoid=False,
|
||||
loss_weight=0.4,
|
||||
),
|
||||
align_corners=False,
|
||||
),
|
||||
)
|
||||
|
||||
optim_wrapper = dict(
|
||||
type='OptimWrapper',
|
||||
_delete_=True,
|
||||
optimizer=dict(
|
||||
type='AdamW',
|
||||
lr=0.0001,
|
||||
weight_decay=0.0005,
|
||||
),
|
||||
clip_grad=dict(
|
||||
max_norm=1,
|
||||
norm_type=2,
|
||||
),
|
||||
)
|
||||
|
||||
param_scheduler = [
|
||||
dict(
|
||||
type='LinearLR',
|
||||
start_factor=1e-06,
|
||||
by_epoch=False,
|
||||
begin=0,
|
||||
end=1500,
|
||||
),
|
||||
dict(
|
||||
type='PolyLR',
|
||||
power=0.9,
|
||||
begin=1500,
|
||||
end=40000,
|
||||
eta_min=1e-05,
|
||||
by_epoch=False,
|
||||
),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user