Skip to content

Commit c1f46a6

Browse files
johnzjaxvjiarui
andauthored
Fast-SCNN implemented (open-mmlab#58)
* init commit: fast_scnn * 247917iters * 4x8_80k * configs placed in configs_unify. 4x8_80k exp.running. * mmseg/utils/collect_env.py modified to support Windows * study on lr * bug in configs_unify/***/cityscapes.py fixed. * lr0.08_100k * lr_power changed to 1.2 * log_config by_epoch set to False. * lr1.2 * doc strings added * add fast_scnn backbone test * 80k 0.08,0.12 * add 450k * fast_scnn test: fix BN bug. * Add different config files into configs/ * .gitignore recovered. * configs_unify del * .gitignore recovered. * delete sub-optimal config files of fast-scnn * Code style improved. * add docstrings to component modules of fast-scnn * relevant files modified according to Jerry's instructions * relevant files modified according to Jerry's instructions * lint problems fixed. * fast_scnn config extremely simplified. * InvertedResidual * fixed padding problems * add unit test for inverted_residual * add unit test for inverted_residual: debug 0 * add unit test for inverted_residual: debug 1 * add unit test for inverted_residual: debug 2 * add unit test for inverted_residual: debug 3 * add unit test for sep_fcn_head: debug 0 * add unit test for sep_fcn_head: debug 1 * add unit test for sep_fcn_head: debug 2 * add unit test for sep_fcn_head: debug 3 * add unit test for sep_fcn_head: debug 4 * add unit test for sep_fcn_head: debug 5 * FastSCNN type(dwchannels) changed to tuple. * t changed to expand_ratio. * Spaces fixed. * Update mmseg/models/backbones/fast_scnn.py Co-authored-by: Jerry Jiarui XU <[email protected]> * Update mmseg/models/decode_heads/sep_fcn_head.py Co-authored-by: Jerry Jiarui XU <[email protected]> * Update mmseg/models/decode_heads/sep_fcn_head.py Co-authored-by: Jerry Jiarui XU <[email protected]> * Docstrings fixed. * Docstrings fixed. * Inverted Residual kept coherent with mmcl. * Inverted Residual kept coherent with mmcl. Debug 0 * _make_layer parameters renamed. * final commit * Arg scale_factor deleted. * Expand_ratio docstrings updated. * final commit * Readme for Fast-SCNN added. * model-zoo.md modified. * fast_scnn README updated. * Move InvertedResidual module into mmseg/utils. * test_inverted_residual module corrected. * test_inverted_residual.py moved. * encoder_decoder modified to avoid bugs when running PSPNet. getting_started.md bug fixed. * Revert "encoder_decoder modified to avoid bugs when running PSPNet. " This reverts commit dd0aadf Co-authored-by: Jerry Jiarui XU <[email protected]>
1 parent d948406 commit c1f46a6

File tree

15 files changed

+714
-12
lines changed

15 files changed

+714
-12
lines changed

configs/_base_/models/fast_scnn.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# model settings
2+
norm_cfg = dict(type='SyncBN', requires_grad=True, momentum=0.01)
3+
model = dict(
4+
type='EncoderDecoder',
5+
backbone=dict(
6+
type='FastSCNN',
7+
downsample_dw_channels=(32, 48),
8+
global_in_channels=64,
9+
global_block_channels=(64, 96, 128),
10+
global_block_strides=(2, 2, 1),
11+
global_out_channels=128,
12+
higher_in_channels=64,
13+
lower_in_channels=128,
14+
fusion_out_channels=128,
15+
out_indices=(0, 1, 2),
16+
norm_cfg=norm_cfg,
17+
align_corners=False),
18+
decode_head=dict(
19+
type='DepthwiseSeparableFCNHead',
20+
in_channels=128,
21+
channels=128,
22+
concat_input=False,
23+
num_classes=19,
24+
in_index=-1,
25+
norm_cfg=norm_cfg,
26+
align_corners=False,
27+
loss_decode=dict(
28+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.)),
29+
auxiliary_head=[
30+
dict(
31+
type='FCNHead',
32+
in_channels=128,
33+
channels=32,
34+
num_convs=1,
35+
num_classes=19,
36+
in_index=-2,
37+
norm_cfg=norm_cfg,
38+
concat_input=False,
39+
align_corners=False,
40+
loss_decode=dict(
41+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
42+
dict(
43+
type='FCNHead',
44+
in_channels=64,
45+
channels=32,
46+
num_convs=1,
47+
num_classes=19,
48+
in_index=-3,
49+
norm_cfg=norm_cfg,
50+
concat_input=False,
51+
align_corners=False,
52+
loss_decode=dict(
53+
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
54+
])
55+
56+
# model training and testing settings
57+
train_cfg = dict()
58+
test_cfg = dict(mode='whole')

configs/fastscnn/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Fast-SCNN for Semantic Segmentation
2+
3+
## Introduction
4+
```
5+
@article{poudel2019fast,
6+
title={Fast-scnn: Fast semantic segmentation network},
7+
author={Poudel, Rudra PK and Liwicki, Stephan and Cipolla, Roberto},
8+
journal={arXiv preprint arXiv:1902.04502},
9+
year={2019}
10+
}
11+
```
12+
13+
## Results and models
14+
15+
### Cityscapes
16+
| Method | Backbone | Crop Size | Lr schd | Mem (GB) | Inf time (fps) | mIoU | mIoU(ms+flip) | download |
17+
|------------|-----------|-----------|--------:|----------|----------------|------:|---------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
18+
| Fast-SCNN | Fast-SCNN | 512x1024 | 80000 | 8.4 | 63.61 | 69.06 | - | [model](https://openmmlab.oss-cn-hangzhou.aliyuncs.com/mmsegmentation/v0.5/fast_scnn/fast_scnn_4x8_80k_lr0.12_cityscapes-cae6c46a.pth) &#124; [log](https://openmmlab.oss-cn-hangzhou.aliyuncs.com/mmsegmentation/v0.5/fast_scnn/fast_scnn_4x8_80k_lr0.12_cityscapes-20200807_165744.log.json) |
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
_base_ = [
2+
'../_base_/models/fast_scnn.py', '../_base_/datasets/cityscapes.py',
3+
'../_base_/default_runtime.py', '../_base_/schedules/schedule_80k.py'
4+
]
5+
6+
# Re-config the data sampler.
7+
data = dict(samples_per_gpu=8, workers_per_gpu=4)
8+
9+
# Re-config the optimizer.
10+
optimizer = dict(type='SGD', lr=0.12, momentum=0.9, weight_decay=4e-5)

docs/getting_started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ The final output filename will be `psp_r50_512x1024_40ki_cityscapes-{hash id}.pt
338338
We provide a script to convert model to [ONNX](https://github.com/onnx/onnx) format. The converted model could be visualized by tools like [Netron](https://github.com/lutzroeder/netron). Besides, we also support comparing the output results between Pytorch and ONNX model.
339339
340340
```shell
341-
python tools/pytorch2onnx.py ${CONFIG_FILE} --checkpoint ${CHECKPOINT_FILE} --output_file ${ONNX_FILE} [--shape ${INPUT_SHAPE} --verify]
341+
python tools/pytorch2onnx.py ${CONFIG_FILE} --checkpoint ${CHECKPOINT_FILE} --output-file ${ONNX_FILE} [--shape ${INPUT_SHAPE} --verify]
342342
```
343343
344344
**Note**: This tool is still experimental. Some customized operators are not supported for now.

docs/model_zoo.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,14 @@ Please refer to [ANN](https://github.com/open-mmlab/mmsegmentation/blob/master/c
8181

8282
Please refer to [OCRNet](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/ocrnet) for details.
8383

84+
### Fast-SCNN
85+
86+
Please refer to [Fast-SCNN](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastscnn) for details.
87+
8488
### ResNeSt
8589

8690
Please refer to [ResNeSt](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/resnest) for details.
8791

88-
8992
### Mixed Precision (FP16) Training
9093

9194
Please refer [Mixed Precision (FP16) Training](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fp16/README.md) for details.

mmseg/models/backbones/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
from .fast_scnn import FastSCNN
12
from .hrnet import HRNet
23
from .resnest import ResNeSt
34
from .resnet import ResNet, ResNetV1c, ResNetV1d
45
from .resnext import ResNeXt
56

6-
__all__ = ['ResNet', 'ResNetV1c', 'ResNetV1d', 'ResNeXt', 'HRNet', 'ResNeSt']
7+
__all__ = [
8+
'ResNet', 'ResNetV1c', 'ResNetV1d', 'ResNeXt', 'HRNet', 'FastSCNN',
9+
'ResNeSt'
10+
]

0 commit comments

Comments
 (0)