From 9c1f2bb110679dc09e5d9a2a5c07878fac5de316 Mon Sep 17 00:00:00 2001 From: MengzhangLI Date: Sat, 18 Sep 2021 15:55:09 +0800 Subject: [PATCH 01/21] FastFCN first commit --- configs/_base_/models/fastfcn_r50-d32.py | 49 ++++++ .../fastfcn_jpu_deeplabv3_4x4_cityscapes.py | 22 +++ .../fastfcn/fastfcn_jpu_enc_4x4_cityscapes.py | 26 ++++ .../fastfcn/fastfcn_jpu_psp_4x4_cityscapes.py | 7 + ...-d32_d1124_jpu_deeplabv3_4x4_cityscapes.py | 26 ++++ ...cn_r50-d32_d1124_jpu_enc_4x4_cityscapes.py | 30 ++++ ...cn_r50-d32_d1124_jpu_psp_4x4_cityscapes.py | 12 ++ ...0-d8_d1124_jpu_deeplabv3_4x4_cityscapes.py | 26 ++++ ...fcn_r50-d8_d1124_jpu_enc_4x4_cityscapes.py | 30 ++++ ...fcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py | 12 ++ mmseg/models/necks/__init__.py | 3 +- mmseg/models/necks/jpu.py | 147 ++++++++++++++++++ tests/test_models/test_necks/test_jpu.py | 25 +++ 13 files changed, 414 insertions(+), 1 deletion(-) create mode 100644 configs/_base_/models/fastfcn_r50-d32.py create mode 100644 configs/fastfcn/fastfcn_jpu_deeplabv3_4x4_cityscapes.py create mode 100644 configs/fastfcn/fastfcn_jpu_enc_4x4_cityscapes.py create mode 100644 configs/fastfcn/fastfcn_jpu_psp_4x4_cityscapes.py create mode 100644 configs/fastfcn/fastfcn_r50-d32_d1124_jpu_deeplabv3_4x4_cityscapes.py create mode 100644 configs/fastfcn/fastfcn_r50-d32_d1124_jpu_enc_4x4_cityscapes.py create mode 100644 configs/fastfcn/fastfcn_r50-d32_d1124_jpu_psp_4x4_cityscapes.py create mode 100644 configs/fastfcn/fastfcn_r50-d8_d1124_jpu_deeplabv3_4x4_cityscapes.py create mode 100644 configs/fastfcn/fastfcn_r50-d8_d1124_jpu_enc_4x4_cityscapes.py create mode 100644 configs/fastfcn/fastfcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py create mode 100644 mmseg/models/necks/jpu.py create mode 100644 tests/test_models/test_necks/test_jpu.py diff --git a/configs/_base_/models/fastfcn_r50-d32.py b/configs/_base_/models/fastfcn_r50-d32.py new file mode 100644 index 0000000000..7f29371885 --- /dev/null +++ b/configs/_base_/models/fastfcn_r50-d32.py @@ -0,0 +1,49 @@ +# model settings +norm_cfg = dict(type='SyncBN', requires_grad=True) +model = dict( + type='EncoderDecoder', + pretrained='open-mmlab://resnet50_v1c', + backbone=dict( + type='ResNetV1c', + depth=50, + num_stages=4, + dilations=(1, 1, 1, 1), + strides=(1, 2, 2, 2), + norm_cfg=norm_cfg, + norm_eval=False, + style='pytorch', + contract_dilation=True), + neck=dict( + type='JPU', + in_channels=(256, 512, 1024, 2048), + out_channels=512, + align_corners=False, + out_indices=(0, 1, 2, 3), + norm_cfg=norm_cfg), + decode_head=dict( + type='PSPHead', + in_channels=2048, + in_index=3, + channels=512, + dropout_ratio=0.1, + num_classes=19, + norm_cfg=norm_cfg, + align_corners=False, + loss_decode=dict( + type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), + auxiliary_head=dict( + type='FCNHead', + in_channels=1024, + in_index=2, + channels=256, + num_convs=1, + concat_input=False, + dropout_ratio=0.1, + num_classes=19, + norm_cfg=norm_cfg, + align_corners=False, + loss_decode=dict( + type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)), + # model training and testing settings + train_cfg=dict(), + test_cfg=dict(mode='whole')) diff --git a/configs/fastfcn/fastfcn_jpu_deeplabv3_4x4_cityscapes.py b/configs/fastfcn/fastfcn_jpu_deeplabv3_4x4_cityscapes.py new file mode 100644 index 0000000000..df5ee56de8 --- /dev/null +++ b/configs/fastfcn/fastfcn_jpu_deeplabv3_4x4_cityscapes.py @@ -0,0 +1,22 @@ +# model settings +_base_ = './fastfcn_jpu_psp_4x4_cityscapes.py' +norm_cfg = dict(type='SyncBN', requires_grad=True) +model = dict( + decode_head=dict( + type='ASPPHead', + in_channels=2048, + in_index=3, + channels=512, + dilations=(1, 12, 24, 36), + dropout_ratio=0.1, + num_classes=19, + norm_cfg=norm_cfg, + align_corners=False, + loss_decode=dict( + type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), + # model training and testing settings + train_cfg=dict(), + test_cfg=dict(mode='whole')) +data = dict( + samples_per_gpu=4, + workers_per_gpu=4,) \ No newline at end of file diff --git a/configs/fastfcn/fastfcn_jpu_enc_4x4_cityscapes.py b/configs/fastfcn/fastfcn_jpu_enc_4x4_cityscapes.py new file mode 100644 index 0000000000..a4fe673793 --- /dev/null +++ b/configs/fastfcn/fastfcn_jpu_enc_4x4_cityscapes.py @@ -0,0 +1,26 @@ +# model settings +_base_ = './fastfcn_jpu_psp_4x4_cityscapes.py' +norm_cfg = dict(type='SyncBN', requires_grad=True) +model = dict( + decode_head=dict( + type='EncHead', + in_channels=[512, 1024, 2048], + in_index=(1, 2, 3), + channels=512, + num_codes=32, + use_se_loss=True, + add_lateral=False, + dropout_ratio=0.1, + num_classes=19, + norm_cfg=norm_cfg, + align_corners=False, + loss_decode=dict( + type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0), + loss_se_decode=dict( + type='CrossEntropyLoss', use_sigmoid=True, loss_weight=0.2)), + # model training and testing settings + train_cfg=dict(), + test_cfg=dict(mode='whole')) +data = dict( + samples_per_gpu=4, + workers_per_gpu=4,) \ No newline at end of file diff --git a/configs/fastfcn/fastfcn_jpu_psp_4x4_cityscapes.py b/configs/fastfcn/fastfcn_jpu_psp_4x4_cityscapes.py new file mode 100644 index 0000000000..919e402ce7 --- /dev/null +++ b/configs/fastfcn/fastfcn_jpu_psp_4x4_cityscapes.py @@ -0,0 +1,7 @@ +_base_ = [ + '../_base_/models/fastfcn_r50-d32.py', '../_base_/datasets/cityscapes.py', + '../_base_/default_runtime.py', '../_base_/schedules/schedule_80k.py' +] +data = dict( + samples_per_gpu=4, + workers_per_gpu=4,) \ No newline at end of file diff --git a/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_deeplabv3_4x4_cityscapes.py b/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_deeplabv3_4x4_cityscapes.py new file mode 100644 index 0000000000..1a72c6a2c4 --- /dev/null +++ b/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_deeplabv3_4x4_cityscapes.py @@ -0,0 +1,26 @@ +# model settings +_base_ = './fastfcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py' +norm_cfg = dict(type='SyncBN', requires_grad=True) +model = dict( + backbone=dict( + dilations=(1, 1, 2, 4), + strides=(1, 2, 2, 2), + ), + decode_head=dict( + type='ASPPHead', + in_channels=2048, + in_index=3, + channels=512, + dilations=(1, 12, 24, 36), + dropout_ratio=0.1, + num_classes=19, + norm_cfg=norm_cfg, + align_corners=False, + loss_decode=dict( + type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), + # model training and testing settings + train_cfg=dict(), + test_cfg=dict(mode='whole')) +data = dict( + samples_per_gpu=4, + workers_per_gpu=4,) \ No newline at end of file diff --git a/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_enc_4x4_cityscapes.py b/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_enc_4x4_cityscapes.py new file mode 100644 index 0000000000..a8c75a1686 --- /dev/null +++ b/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_enc_4x4_cityscapes.py @@ -0,0 +1,30 @@ +# model settings +_base_ = './fastfcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py' +norm_cfg = dict(type='SyncBN', requires_grad=True) +model = dict( + backbone=dict( + dilations=(1, 1, 2, 4), + strides=(1, 2, 2, 2), + ), + decode_head=dict( + type='EncHead', + in_channels=[512, 1024, 2048], + in_index=(1, 2, 3), + channels=512, + num_codes=32, + use_se_loss=True, + add_lateral=False, + dropout_ratio=0.1, + num_classes=19, + norm_cfg=norm_cfg, + align_corners=False, + loss_decode=dict( + type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0), + loss_se_decode=dict( + type='CrossEntropyLoss', use_sigmoid=True, loss_weight=0.2)), + # model training and testing settings + train_cfg=dict(), + test_cfg=dict(mode='whole')) +data = dict( + samples_per_gpu=4, + workers_per_gpu=4,) \ No newline at end of file diff --git a/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_psp_4x4_cityscapes.py b/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_psp_4x4_cityscapes.py new file mode 100644 index 0000000000..21c836462d --- /dev/null +++ b/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_psp_4x4_cityscapes.py @@ -0,0 +1,12 @@ +_base_ = [ + '../_base_/models/fastfcn_r50-d32.py', '../_base_/datasets/cityscapes.py', + '../_base_/default_runtime.py', '../_base_/schedules/schedule_80k.py' +] +model = dict( + backbone=dict( + dilations=(1, 1, 2, 4), + strides=(1, 2, 2, 2), + )) +data = dict( + samples_per_gpu=4, + workers_per_gpu=4,) \ No newline at end of file diff --git a/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_deeplabv3_4x4_cityscapes.py b/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_deeplabv3_4x4_cityscapes.py new file mode 100644 index 0000000000..67c8bf5f9d --- /dev/null +++ b/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_deeplabv3_4x4_cityscapes.py @@ -0,0 +1,26 @@ +# model settings +_base_ = './fastfcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py' +norm_cfg = dict(type='SyncBN', requires_grad=True) +model = dict( + backbone=dict( + dilations=(1, 1, 2, 4), + strides=(1, 2, 1, 1), + ), + decode_head=dict( + type='ASPPHead', + in_channels=2048, + in_index=3, + channels=512, + dilations=(1, 12, 24, 36), + dropout_ratio=0.1, + num_classes=19, + norm_cfg=norm_cfg, + align_corners=False, + loss_decode=dict( + type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), + # model training and testing settings + train_cfg=dict(), + test_cfg=dict(mode='whole')) +data = dict( + samples_per_gpu=4, + workers_per_gpu=4,) \ No newline at end of file diff --git a/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_enc_4x4_cityscapes.py b/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_enc_4x4_cityscapes.py new file mode 100644 index 0000000000..a2c66c9c7d --- /dev/null +++ b/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_enc_4x4_cityscapes.py @@ -0,0 +1,30 @@ +# model settings +_base_ = './fastfcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py' +norm_cfg = dict(type='SyncBN', requires_grad=True) +model = dict( + backbone=dict( + dilations=(1, 1, 2, 4), + strides=(1, 2, 1, 1), + ), + decode_head=dict( + type='EncHead', + in_channels=[512, 1024, 2048], + in_index=(1, 2, 3), + channels=512, + num_codes=32, + use_se_loss=True, + add_lateral=False, + dropout_ratio=0.1, + num_classes=19, + norm_cfg=norm_cfg, + align_corners=False, + loss_decode=dict( + type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0), + loss_se_decode=dict( + type='CrossEntropyLoss', use_sigmoid=True, loss_weight=0.2)), + # model training and testing settings + train_cfg=dict(), + test_cfg=dict(mode='whole')) +data = dict( + samples_per_gpu=4, + workers_per_gpu=4,) \ No newline at end of file diff --git a/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py b/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py new file mode 100644 index 0000000000..a961fa9712 --- /dev/null +++ b/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py @@ -0,0 +1,12 @@ +_base_ = [ + '../_base_/models/fastfcn_r50-d32.py', '../_base_/datasets/cityscapes.py', + '../_base_/default_runtime.py', '../_base_/schedules/schedule_80k.py' +] +model = dict( + backbone=dict( + dilations=(1, 1, 2, 4), + strides=(1, 2, 1, 1), + )) +data = dict( + samples_per_gpu=4, + workers_per_gpu=4,) \ No newline at end of file diff --git a/mmseg/models/necks/__init__.py b/mmseg/models/necks/__init__.py index c496853c83..b4bce5b57a 100644 --- a/mmseg/models/necks/__init__.py +++ b/mmseg/models/necks/__init__.py @@ -1,6 +1,7 @@ # Copyright (c) OpenMMLab. All rights reserved. from .fpn import FPN +from .jpu import JPU from .mla_neck import MLANeck from .multilevel_neck import MultiLevelNeck -__all__ = ['FPN', 'MultiLevelNeck', 'MLANeck'] +__all__ = ['FPN', 'MultiLevelNeck', 'MLANeck', 'JPU'] diff --git a/mmseg/models/necks/jpu.py b/mmseg/models/necks/jpu.py new file mode 100644 index 0000000000..0a39dff75d --- /dev/null +++ b/mmseg/models/necks/jpu.py @@ -0,0 +1,147 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch.nn as nn +from mmcv.cnn import ConvModule, DepthwiseSeparableConvModule +from mmcv.runner import BaseModule +import torch + +from mmseg.ops import resize +from ..builder import NECKS + +@NECKS.register_module() +class JPU(BaseModule): + """FastFCN: Rethinking Dilated Convolution in the Backbone for Semantic Segmentation. + JPU is the + This neck is the implementation of + `FastFCN `_. + + Args: + in_channels (Tuple[int], optional): The number of input channels + for each convolution operations before upsampling. + Default: (256, 512, 1024, 2048). + out_channels (int): The number of output channels. Default: 512. + out_indices (Tuple[int] | int, optional): Output from which stages. + Default: (0, 1, 2, 3). + align_corners (bool, optional): The align_corners argument of + resize operation. Default: False. + conv_cfg (dict | None): Config of conv layers. + Default: None. + norm_cfg (dict | None): Config of norm layers. + Default: dict(type='BN'). + act_cfg (dict): Config of activation layers. + Default: dict(type='ReLU'). + init_cfg (dict or list[dict], optional): Initialization config dict. + Default: None. + """ + + def __init__(self, + in_channels=(256, 512, 1024, 2048), + out_channels=512, + out_indices=(0, 1, 2, 3), + align_corners=False, + conv_cfg=None, + norm_cfg=dict(type='BN'), + act_cfg=dict(type='ReLU'), + init_cfg=None): + super(JPU, self).__init__(init_cfg=init_cfg) + self.in_channels = in_channels + self.out_channels = out_channels + self.align_corners = align_corners + self.out_indices = out_indices + + # Note: Names of operations below are referenced from original paper. + self.conv3 = nn.Sequential(ConvModule( + self.in_channels[-3], + self.out_channels, + kernel_size=3, + padding=1, + bias=False, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg, + act_cfg=act_cfg)) + self.conv4 = nn.Sequential(ConvModule( + self.in_channels[-2], + self.out_channels, + kernel_size=3, + padding=1, + bias=False, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg, + act_cfg=act_cfg)) + self.conv5 = nn.Sequential(ConvModule( + self.in_channels[-1], + self.out_channels, + kernel_size=3, + padding=1, + bias=False, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg, + act_cfg=act_cfg)) + self.dilation1 = nn.Sequential( + DepthwiseSeparableConvModule( + in_channels=3*self.out_channels, + out_channels=self.out_channels, + kernel_size=3, + stride=1, + padding=1, + dilation=1, + dw_norm_cfg=norm_cfg, + dw_act_cfg=None, + pw_norm_cfg=norm_cfg, + pw_act_cfg=act_cfg)) + self.dilation2 = nn.Sequential( + DepthwiseSeparableConvModule( + in_channels=3*self.out_channels, + out_channels=self.out_channels, + kernel_size=3, + stride=1, + padding=2, + dilation=2, + dw_norm_cfg=norm_cfg, + dw_act_cfg=None, + pw_norm_cfg=norm_cfg, + pw_act_cfg=act_cfg)) + self.dilation3 = nn.Sequential( + DepthwiseSeparableConvModule( + in_channels=3*self.out_channels, + out_channels=self.out_channels, + kernel_size=3, + stride=1, + padding=4, + dilation=4, + dw_norm_cfg=norm_cfg, + dw_act_cfg=None, + pw_norm_cfg=norm_cfg, + pw_act_cfg=act_cfg)) + self.dilation4 = nn.Sequential( + DepthwiseSeparableConvModule( + in_channels=3*self.out_channels, + out_channels=self.out_channels, + kernel_size=3, + stride=1, + padding=8, + dilation=8, + dw_norm_cfg=norm_cfg, + dw_act_cfg=None, + pw_norm_cfg=norm_cfg, + pw_act_cfg=act_cfg)) + + def forward(self, inputs): + """Forward function.""" + x_8 = inputs[1] + x_16 = inputs[2] + x_32 = inputs[3] + feats = [self.conv5(x_32), self.conv4(x_16), self.conv3(x_8)] + _, _, h, w = feats[-1].size() + feats[-2] = resize(feats[-2], size= (h, w), mode='bilinear', align_corners=self.align_corners) + feats[-3] = resize(feats[-3], size=(h, w), mode='bilinear', align_corners=self.align_corners) + feat = torch.cat(feats, dim=1) + feat = torch.cat([self.dilation1(feat), + self.dilation2(feat), + self.dilation3(feat), + self.dilation4(feat)], dim=1) + + outs = [inputs[0], inputs[1], inputs[2], feat] + outs = [outs[i] for i in self.out_indices] + return tuple(outs) + + diff --git a/tests/test_models/test_necks/test_jpu.py b/tests/test_models/test_necks/test_jpu.py new file mode 100644 index 0000000000..7539ad7849 --- /dev/null +++ b/tests/test_models/test_necks/test_jpu.py @@ -0,0 +1,25 @@ +# Copyright (c) OpenMMLab. All rights reserved. +import torch + +from mmseg.models.necks import JPU + + +def test_fastfcn_neck(): + # Test FastFCN Standard Forward + model = JPU() + model.init_weights() + model.train() + batch_size = 1 + input = [ + torch.randn(batch_size, 256, 256, 512), + torch.randn(batch_size, 512, 128, 256), + torch.randn(batch_size, 1024, 64, 128), + torch.randn(batch_size, 2048, 32, 64) + ] + feat = model(input) + + assert len(feat) == 4 + assert feat[0].shape == torch.Size([batch_size, 256, 256, 512]) + assert feat[1].shape == torch.Size([batch_size, 512, 128, 256]) + assert feat[2].shape == torch.Size([batch_size, 1024, 64, 128]) + assert feat[3].shape == torch.Size([batch_size, 2048, 128, 256]) From 7f1fae6087f101c1e0b122f3810712fa118490f0 Mon Sep 17 00:00:00 2001 From: MengzhangLI Date: Sat, 18 Sep 2021 16:08:42 +0800 Subject: [PATCH 02/21] FastFCN first commit --- .../fastfcn_jpu_deeplabv3_4x4_cityscapes.py | 3 +- .../fastfcn/fastfcn_jpu_enc_4x4_cityscapes.py | 3 +- .../fastfcn/fastfcn_jpu_psp_4x4_cityscapes.py | 3 +- ...-d32_d1124_jpu_deeplabv3_4x4_cityscapes.py | 3 +- ...cn_r50-d32_d1124_jpu_enc_4x4_cityscapes.py | 3 +- ...cn_r50-d32_d1124_jpu_psp_4x4_cityscapes.py | 12 +- ...0-d8_d1124_jpu_deeplabv3_4x4_cityscapes.py | 3 +- ...fcn_r50-d8_d1124_jpu_enc_4x4_cityscapes.py | 3 +- ...fcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py | 12 +- mmseg/models/necks/jpu.py | 148 ++++++++++-------- 10 files changed, 107 insertions(+), 86 deletions(-) diff --git a/configs/fastfcn/fastfcn_jpu_deeplabv3_4x4_cityscapes.py b/configs/fastfcn/fastfcn_jpu_deeplabv3_4x4_cityscapes.py index df5ee56de8..7edb891a3d 100644 --- a/configs/fastfcn/fastfcn_jpu_deeplabv3_4x4_cityscapes.py +++ b/configs/fastfcn/fastfcn_jpu_deeplabv3_4x4_cityscapes.py @@ -19,4 +19,5 @@ test_cfg=dict(mode='whole')) data = dict( samples_per_gpu=4, - workers_per_gpu=4,) \ No newline at end of file + workers_per_gpu=4, +) diff --git a/configs/fastfcn/fastfcn_jpu_enc_4x4_cityscapes.py b/configs/fastfcn/fastfcn_jpu_enc_4x4_cityscapes.py index a4fe673793..5b0dc40f8a 100644 --- a/configs/fastfcn/fastfcn_jpu_enc_4x4_cityscapes.py +++ b/configs/fastfcn/fastfcn_jpu_enc_4x4_cityscapes.py @@ -23,4 +23,5 @@ test_cfg=dict(mode='whole')) data = dict( samples_per_gpu=4, - workers_per_gpu=4,) \ No newline at end of file + workers_per_gpu=4, +) diff --git a/configs/fastfcn/fastfcn_jpu_psp_4x4_cityscapes.py b/configs/fastfcn/fastfcn_jpu_psp_4x4_cityscapes.py index 919e402ce7..27965b217b 100644 --- a/configs/fastfcn/fastfcn_jpu_psp_4x4_cityscapes.py +++ b/configs/fastfcn/fastfcn_jpu_psp_4x4_cityscapes.py @@ -4,4 +4,5 @@ ] data = dict( samples_per_gpu=4, - workers_per_gpu=4,) \ No newline at end of file + workers_per_gpu=4, +) diff --git a/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_deeplabv3_4x4_cityscapes.py b/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_deeplabv3_4x4_cityscapes.py index 1a72c6a2c4..9b86de0daa 100644 --- a/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_deeplabv3_4x4_cityscapes.py +++ b/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_deeplabv3_4x4_cityscapes.py @@ -23,4 +23,5 @@ test_cfg=dict(mode='whole')) data = dict( samples_per_gpu=4, - workers_per_gpu=4,) \ No newline at end of file + workers_per_gpu=4, +) diff --git a/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_enc_4x4_cityscapes.py b/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_enc_4x4_cityscapes.py index a8c75a1686..6e7ec3e489 100644 --- a/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_enc_4x4_cityscapes.py +++ b/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_enc_4x4_cityscapes.py @@ -27,4 +27,5 @@ test_cfg=dict(mode='whole')) data = dict( samples_per_gpu=4, - workers_per_gpu=4,) \ No newline at end of file + workers_per_gpu=4, +) diff --git a/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_psp_4x4_cityscapes.py b/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_psp_4x4_cityscapes.py index 21c836462d..eaf84ea242 100644 --- a/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_psp_4x4_cityscapes.py +++ b/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_psp_4x4_cityscapes.py @@ -2,11 +2,11 @@ '../_base_/models/fastfcn_r50-d32.py', '../_base_/datasets/cityscapes.py', '../_base_/default_runtime.py', '../_base_/schedules/schedule_80k.py' ] -model = dict( - backbone=dict( - dilations=(1, 1, 2, 4), - strides=(1, 2, 2, 2), - )) +model = dict(backbone=dict( + dilations=(1, 1, 2, 4), + strides=(1, 2, 2, 2), +)) data = dict( samples_per_gpu=4, - workers_per_gpu=4,) \ No newline at end of file + workers_per_gpu=4, +) diff --git a/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_deeplabv3_4x4_cityscapes.py b/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_deeplabv3_4x4_cityscapes.py index 67c8bf5f9d..732f7e4055 100644 --- a/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_deeplabv3_4x4_cityscapes.py +++ b/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_deeplabv3_4x4_cityscapes.py @@ -23,4 +23,5 @@ test_cfg=dict(mode='whole')) data = dict( samples_per_gpu=4, - workers_per_gpu=4,) \ No newline at end of file + workers_per_gpu=4, +) diff --git a/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_enc_4x4_cityscapes.py b/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_enc_4x4_cityscapes.py index a2c66c9c7d..6cf6c74452 100644 --- a/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_enc_4x4_cityscapes.py +++ b/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_enc_4x4_cityscapes.py @@ -27,4 +27,5 @@ test_cfg=dict(mode='whole')) data = dict( samples_per_gpu=4, - workers_per_gpu=4,) \ No newline at end of file + workers_per_gpu=4, +) diff --git a/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py b/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py index a961fa9712..c88ae0acb9 100644 --- a/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py +++ b/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py @@ -2,11 +2,11 @@ '../_base_/models/fastfcn_r50-d32.py', '../_base_/datasets/cityscapes.py', '../_base_/default_runtime.py', '../_base_/schedules/schedule_80k.py' ] -model = dict( - backbone=dict( - dilations=(1, 1, 2, 4), - strides=(1, 2, 1, 1), - )) +model = dict(backbone=dict( + dilations=(1, 1, 2, 4), + strides=(1, 2, 1, 1), +)) data = dict( samples_per_gpu=4, - workers_per_gpu=4,) \ No newline at end of file + workers_per_gpu=4, +) diff --git a/mmseg/models/necks/jpu.py b/mmseg/models/necks/jpu.py index 0a39dff75d..4d95087dba 100644 --- a/mmseg/models/necks/jpu.py +++ b/mmseg/models/necks/jpu.py @@ -1,17 +1,19 @@ # Copyright (c) OpenMMLab. All rights reserved. +import torch import torch.nn as nn from mmcv.cnn import ConvModule, DepthwiseSeparableConvModule from mmcv.runner import BaseModule -import torch from mmseg.ops import resize from ..builder import NECKS + @NECKS.register_module() class JPU(BaseModule): - """FastFCN: Rethinking Dilated Convolution in the Backbone for Semantic Segmentation. - JPU is the - This neck is the implementation of + """FastFCN: Rethinking Dilated Convolution in the Backbone + for Semantic Segmentation. + + This Joint Pyramid Upsampling (JPU) neck is the implementation of `FastFCN `_. Args: @@ -34,14 +36,14 @@ class JPU(BaseModule): """ def __init__(self, - in_channels=(256, 512, 1024, 2048), - out_channels=512, - out_indices=(0, 1, 2, 3), - align_corners=False, - conv_cfg=None, - norm_cfg=dict(type='BN'), - act_cfg=dict(type='ReLU'), - init_cfg=None): + in_channels=(256, 512, 1024, 2048), + out_channels=512, + out_indices=(0, 1, 2, 3), + align_corners=False, + conv_cfg=None, + norm_cfg=dict(type='BN'), + act_cfg=dict(type='ReLU'), + init_cfg=None): super(JPU, self).__init__(init_cfg=init_cfg) self.in_channels = in_channels self.out_channels = out_channels @@ -49,7 +51,8 @@ def __init__(self, self.out_indices = out_indices # Note: Names of operations below are referenced from original paper. - self.conv3 = nn.Sequential(ConvModule( + self.conv3 = nn.Sequential( + ConvModule( self.in_channels[-3], self.out_channels, kernel_size=3, @@ -58,7 +61,8 @@ def __init__(self, conv_cfg=conv_cfg, norm_cfg=norm_cfg, act_cfg=act_cfg)) - self.conv4 = nn.Sequential(ConvModule( + self.conv4 = nn.Sequential( + ConvModule( self.in_channels[-2], self.out_channels, kernel_size=3, @@ -67,7 +71,8 @@ def __init__(self, conv_cfg=conv_cfg, norm_cfg=norm_cfg, act_cfg=act_cfg)) - self.conv5 = nn.Sequential(ConvModule( + self.conv5 = nn.Sequential( + ConvModule( self.in_channels[-1], self.out_channels, kernel_size=3, @@ -77,53 +82,53 @@ def __init__(self, norm_cfg=norm_cfg, act_cfg=act_cfg)) self.dilation1 = nn.Sequential( - DepthwiseSeparableConvModule( - in_channels=3*self.out_channels, - out_channels=self.out_channels, - kernel_size=3, - stride=1, - padding=1, - dilation=1, - dw_norm_cfg=norm_cfg, - dw_act_cfg=None, - pw_norm_cfg=norm_cfg, - pw_act_cfg=act_cfg)) + DepthwiseSeparableConvModule( + in_channels=3 * self.out_channels, + out_channels=self.out_channels, + kernel_size=3, + stride=1, + padding=1, + dilation=1, + dw_norm_cfg=norm_cfg, + dw_act_cfg=None, + pw_norm_cfg=norm_cfg, + pw_act_cfg=act_cfg)) self.dilation2 = nn.Sequential( - DepthwiseSeparableConvModule( - in_channels=3*self.out_channels, - out_channels=self.out_channels, - kernel_size=3, - stride=1, - padding=2, - dilation=2, - dw_norm_cfg=norm_cfg, - dw_act_cfg=None, - pw_norm_cfg=norm_cfg, - pw_act_cfg=act_cfg)) + DepthwiseSeparableConvModule( + in_channels=3 * self.out_channels, + out_channels=self.out_channels, + kernel_size=3, + stride=1, + padding=2, + dilation=2, + dw_norm_cfg=norm_cfg, + dw_act_cfg=None, + pw_norm_cfg=norm_cfg, + pw_act_cfg=act_cfg)) self.dilation3 = nn.Sequential( - DepthwiseSeparableConvModule( - in_channels=3*self.out_channels, - out_channels=self.out_channels, - kernel_size=3, - stride=1, - padding=4, - dilation=4, - dw_norm_cfg=norm_cfg, - dw_act_cfg=None, - pw_norm_cfg=norm_cfg, - pw_act_cfg=act_cfg)) + DepthwiseSeparableConvModule( + in_channels=3 * self.out_channels, + out_channels=self.out_channels, + kernel_size=3, + stride=1, + padding=4, + dilation=4, + dw_norm_cfg=norm_cfg, + dw_act_cfg=None, + pw_norm_cfg=norm_cfg, + pw_act_cfg=act_cfg)) self.dilation4 = nn.Sequential( - DepthwiseSeparableConvModule( - in_channels=3*self.out_channels, - out_channels=self.out_channels, - kernel_size=3, - stride=1, - padding=8, - dilation=8, - dw_norm_cfg=norm_cfg, - dw_act_cfg=None, - pw_norm_cfg=norm_cfg, - pw_act_cfg=act_cfg)) + DepthwiseSeparableConvModule( + in_channels=3 * self.out_channels, + out_channels=self.out_channels, + kernel_size=3, + stride=1, + padding=8, + dilation=8, + dw_norm_cfg=norm_cfg, + dw_act_cfg=None, + pw_norm_cfg=norm_cfg, + pw_act_cfg=act_cfg)) def forward(self, inputs): """Forward function.""" @@ -132,16 +137,25 @@ def forward(self, inputs): x_32 = inputs[3] feats = [self.conv5(x_32), self.conv4(x_16), self.conv3(x_8)] _, _, h, w = feats[-1].size() - feats[-2] = resize(feats[-2], size= (h, w), mode='bilinear', align_corners=self.align_corners) - feats[-3] = resize(feats[-3], size=(h, w), mode='bilinear', align_corners=self.align_corners) + feats[-2] = resize( + feats[-2], + size=(h, w), + mode='bilinear', + align_corners=self.align_corners) + feats[-3] = resize( + feats[-3], + size=(h, w), + mode='bilinear', + align_corners=self.align_corners) feat = torch.cat(feats, dim=1) - feat = torch.cat([self.dilation1(feat), - self.dilation2(feat), - self.dilation3(feat), - self.dilation4(feat)], dim=1) + feat = torch.cat([ + self.dilation1(feat), + self.dilation2(feat), + self.dilation3(feat), + self.dilation4(feat) + ], + dim=1) outs = [inputs[0], inputs[1], inputs[2], feat] outs = [outs[i] for i in self.out_indices] return tuple(outs) - - From d056d80479cdc228b49ae079112567b3a2de55ab Mon Sep 17 00:00:00 2001 From: MengzhangLI Date: Sat, 18 Sep 2021 16:13:51 +0800 Subject: [PATCH 03/21] Fixing lint error --- tests/test_models/test_necks/test_jpu.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/test_models/test_necks/test_jpu.py b/tests/test_models/test_necks/test_jpu.py index 7539ad7849..d7ee4a8af2 100644 --- a/tests/test_models/test_necks/test_jpu.py +++ b/tests/test_models/test_necks/test_jpu.py @@ -11,15 +11,15 @@ def test_fastfcn_neck(): model.train() batch_size = 1 input = [ - torch.randn(batch_size, 256, 256, 512), - torch.randn(batch_size, 512, 128, 256), - torch.randn(batch_size, 1024, 64, 128), - torch.randn(batch_size, 2048, 32, 64) + torch.randn(batch_size, 256, 128, 256), + torch.randn(batch_size, 512, 64, 128), + torch.randn(batch_size, 1024, 32, 64), + torch.randn(batch_size, 2048, 16, 32) ] feat = model(input) assert len(feat) == 4 - assert feat[0].shape == torch.Size([batch_size, 256, 256, 512]) - assert feat[1].shape == torch.Size([batch_size, 512, 128, 256]) - assert feat[2].shape == torch.Size([batch_size, 1024, 64, 128]) - assert feat[3].shape == torch.Size([batch_size, 2048, 128, 256]) + assert feat[0].shape == torch.Size([batch_size, 256, 128, 256]) + assert feat[1].shape == torch.Size([batch_size, 512, 64, 128]) + assert feat[2].shape == torch.Size([batch_size, 1024, 32, 64]) + assert feat[3].shape == torch.Size([batch_size, 2048, 16, 32]) From 2474b7f3b88eaa660c788c4dfd444d7359c2088f Mon Sep 17 00:00:00 2001 From: MengzhangLI Date: Sat, 18 Sep 2021 16:20:42 +0800 Subject: [PATCH 04/21] Fixing lint error --- tests/test_models/test_necks/test_jpu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_models/test_necks/test_jpu.py b/tests/test_models/test_necks/test_jpu.py index d7ee4a8af2..2de38670aa 100644 --- a/tests/test_models/test_necks/test_jpu.py +++ b/tests/test_models/test_necks/test_jpu.py @@ -22,4 +22,4 @@ def test_fastfcn_neck(): assert feat[0].shape == torch.Size([batch_size, 256, 128, 256]) assert feat[1].shape == torch.Size([batch_size, 512, 64, 128]) assert feat[2].shape == torch.Size([batch_size, 1024, 32, 64]) - assert feat[3].shape == torch.Size([batch_size, 2048, 16, 32]) + assert feat[3].shape == torch.Size([batch_size, 2048, 64, 128]) From 67b42a77e56a4bf4e63572e99a1b28953ba97dd8 Mon Sep 17 00:00:00 2001 From: MengzhangLI Date: Wed, 22 Sep 2021 01:37:55 +0800 Subject: [PATCH 05/21] use for loop on JPU --- mmseg/models/necks/jpu.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mmseg/models/necks/jpu.py b/mmseg/models/necks/jpu.py index 4d95087dba..97f0870428 100644 --- a/mmseg/models/necks/jpu.py +++ b/mmseg/models/necks/jpu.py @@ -81,6 +81,21 @@ def __init__(self, conv_cfg=conv_cfg, norm_cfg=norm_cfg, act_cfg=act_cfg)) + + for i in range(3): + conv_name = f'conv{i+3}' + conv_layer = nn.Sequential( + ConvModule( + self.in_channels[i-3], + self.out_channels, + kernel_size=3, + padding=1, + bias=False, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg, + act_cfg=act_cfg)) + self.add_module(conv_name, conv_layer) + self.dilation1 = nn.Sequential( DepthwiseSeparableConvModule( in_channels=3 * self.out_channels, @@ -136,6 +151,7 @@ def forward(self, inputs): x_16 = inputs[2] x_32 = inputs[3] feats = [self.conv5(x_32), self.conv4(x_16), self.conv3(x_8)] + _, _, h, w = feats[-1].size() feats[-2] = resize( feats[-2], From f390399a0bbcdc5a6df18c61e15e9c081d10b73c Mon Sep 17 00:00:00 2001 From: MengzhangLI Date: Wed, 22 Sep 2021 22:34:40 +0800 Subject: [PATCH 06/21] Use For Loop --- configs/_base_/models/fastfcn_r50-d32.py | 1 + mmseg/models/necks/jpu.py | 127 +++++++---------------- 2 files changed, 38 insertions(+), 90 deletions(-) diff --git a/configs/_base_/models/fastfcn_r50-d32.py b/configs/_base_/models/fastfcn_r50-d32.py index 7f29371885..1ce5f84b84 100644 --- a/configs/_base_/models/fastfcn_r50-d32.py +++ b/configs/_base_/models/fastfcn_r50-d32.py @@ -17,6 +17,7 @@ type='JPU', in_channels=(256, 512, 1024, 2048), out_channels=512, + dilations=(1, 2, 4, 8), align_corners=False, out_indices=(0, 1, 2, 3), norm_cfg=norm_cfg), diff --git a/mmseg/models/necks/jpu.py b/mmseg/models/necks/jpu.py index 97f0870428..525c76e48a 100644 --- a/mmseg/models/necks/jpu.py +++ b/mmseg/models/necks/jpu.py @@ -21,6 +21,7 @@ class JPU(BaseModule): for each convolution operations before upsampling. Default: (256, 512, 1024, 2048). out_channels (int): The number of output channels. Default: 512. + dilations (tuple[int]): Dilation rate of each layer. out_indices (Tuple[int] | int, optional): Output from which stages. Default: (0, 1, 2, 3). align_corners (bool, optional): The align_corners argument of @@ -38,6 +39,7 @@ class JPU(BaseModule): def __init__(self, in_channels=(256, 512, 1024, 2048), out_channels=512, + dilations=(1, 2, 4, 8), out_indices=(0, 1, 2, 3), align_corners=False, conv_cfg=None, @@ -45,105 +47,50 @@ def __init__(self, act_cfg=dict(type='ReLU'), init_cfg=None): super(JPU, self).__init__(init_cfg=init_cfg) + assert isinstance(in_channels, tuple) + assert len(in_channels) == 4, 'Length of input channels \ + must be 4!' + + assert len(dilations) == 4, 'Length of dilations \ + must be 4!' + + assert out_channels == in_channels[1], 'Output channels must \ + be the same with in_channels[1]!' + self.in_channels = in_channels self.out_channels = out_channels self.align_corners = align_corners self.out_indices = out_indices # Note: Names of operations below are referenced from original paper. - self.conv3 = nn.Sequential( - ConvModule( - self.in_channels[-3], - self.out_channels, - kernel_size=3, - padding=1, - bias=False, - conv_cfg=conv_cfg, - norm_cfg=norm_cfg, - act_cfg=act_cfg)) - self.conv4 = nn.Sequential( - ConvModule( - self.in_channels[-2], - self.out_channels, - kernel_size=3, - padding=1, - bias=False, - conv_cfg=conv_cfg, - norm_cfg=norm_cfg, - act_cfg=act_cfg)) - self.conv5 = nn.Sequential( - ConvModule( - self.in_channels[-1], - self.out_channels, - kernel_size=3, - padding=1, - bias=False, - conv_cfg=conv_cfg, - norm_cfg=norm_cfg, - act_cfg=act_cfg)) - for i in range(3): conv_name = f'conv{i+3}' conv_layer = nn.Sequential( - ConvModule( - self.in_channels[i-3], - self.out_channels, - kernel_size=3, - padding=1, - bias=False, - conv_cfg=conv_cfg, - norm_cfg=norm_cfg, - act_cfg=act_cfg)) + ConvModule( + self.in_channels[i - 3], + self.out_channels, + kernel_size=3, + padding=1, + bias=False, + conv_cfg=conv_cfg, + norm_cfg=norm_cfg, + act_cfg=act_cfg)) self.add_module(conv_name, conv_layer) - - self.dilation1 = nn.Sequential( - DepthwiseSeparableConvModule( - in_channels=3 * self.out_channels, - out_channels=self.out_channels, - kernel_size=3, - stride=1, - padding=1, - dilation=1, - dw_norm_cfg=norm_cfg, - dw_act_cfg=None, - pw_norm_cfg=norm_cfg, - pw_act_cfg=act_cfg)) - self.dilation2 = nn.Sequential( - DepthwiseSeparableConvModule( - in_channels=3 * self.out_channels, - out_channels=self.out_channels, - kernel_size=3, - stride=1, - padding=2, - dilation=2, - dw_norm_cfg=norm_cfg, - dw_act_cfg=None, - pw_norm_cfg=norm_cfg, - pw_act_cfg=act_cfg)) - self.dilation3 = nn.Sequential( - DepthwiseSeparableConvModule( - in_channels=3 * self.out_channels, - out_channels=self.out_channels, - kernel_size=3, - stride=1, - padding=4, - dilation=4, - dw_norm_cfg=norm_cfg, - dw_act_cfg=None, - pw_norm_cfg=norm_cfg, - pw_act_cfg=act_cfg)) - self.dilation4 = nn.Sequential( - DepthwiseSeparableConvModule( - in_channels=3 * self.out_channels, - out_channels=self.out_channels, - kernel_size=3, - stride=1, - padding=8, - dilation=8, - dw_norm_cfg=norm_cfg, - dw_act_cfg=None, - pw_norm_cfg=norm_cfg, - pw_act_cfg=act_cfg)) + for i in range(4): + dilation_name = f'dilation{i+1}' + dilation_layer = nn.Sequential( + DepthwiseSeparableConvModule( + in_channels=3 * self.out_channels, + out_channels=self.out_channels, + kernel_size=3, + stride=1, + padding=dilations[i], + dilation=dilations[i], + dw_norm_cfg=norm_cfg, + dw_act_cfg=None, + pw_norm_cfg=norm_cfg, + pw_act_cfg=act_cfg)) + self.add_module(dilation_name, dilation_layer) def forward(self, inputs): """Forward function.""" @@ -151,7 +98,7 @@ def forward(self, inputs): x_16 = inputs[2] x_32 = inputs[3] feats = [self.conv5(x_32), self.conv4(x_16), self.conv3(x_8)] - + _, _, h, w = feats[-1].size() feats[-2] = resize( feats[-2], From c35b0cc9cf0dec2e0c26c7e86866a5ba64629881 Mon Sep 17 00:00:00 2001 From: MengzhangLI Date: Thu, 23 Sep 2021 23:45:48 +0800 Subject: [PATCH 07/21] Refactor FastFCN --- configs/_base_/models/fastfcn_r50-d32.py | 3 +- mmseg/models/necks/jpu.py | 91 +++++++++++++----------- tests/test_models/test_necks/test_jpu.py | 5 ++ 3 files changed, 55 insertions(+), 44 deletions(-) diff --git a/configs/_base_/models/fastfcn_r50-d32.py b/configs/_base_/models/fastfcn_r50-d32.py index 1ce5f84b84..6cd2bfd9ef 100644 --- a/configs/_base_/models/fastfcn_r50-d32.py +++ b/configs/_base_/models/fastfcn_r50-d32.py @@ -16,7 +16,8 @@ neck=dict( type='JPU', in_channels=(256, 512, 1024, 2048), - out_channels=512, + start_level=1, + end_level=-1, dilations=(1, 2, 4, 8), align_corners=False, out_indices=(0, 1, 2, 3), diff --git a/mmseg/models/necks/jpu.py b/mmseg/models/necks/jpu.py index 525c76e48a..fa74947505 100644 --- a/mmseg/models/necks/jpu.py +++ b/mmseg/models/necks/jpu.py @@ -20,8 +20,12 @@ class JPU(BaseModule): in_channels (Tuple[int], optional): The number of input channels for each convolution operations before upsampling. Default: (256, 512, 1024, 2048). - out_channels (int): The number of output channels. Default: 512. - dilations (tuple[int]): Dilation rate of each layer. + start_level (int): Index of the start input backbone level used to + build the feature pyramid. Default: 1. + end_level (int): Index of the end input backbone level (exclusive) to + build the feature pyramid. Default: -1, which means the last level. + dilations (tuple[int]): Dilation rate of each Depthwise + Separable ConvModule. out_indices (Tuple[int] | int, optional): Output from which stages. Default: (0, 1, 2, 3). align_corners (bool, optional): The align_corners argument of @@ -38,7 +42,8 @@ class JPU(BaseModule): def __init__(self, in_channels=(256, 512, 1024, 2048), - out_channels=512, + start_level=1, + end_level=-1, dilations=(1, 2, 4, 8), out_indices=(0, 1, 2, 3), align_corners=False, @@ -48,26 +53,27 @@ def __init__(self, init_cfg=None): super(JPU, self).__init__(init_cfg=init_cfg) assert isinstance(in_channels, tuple) - assert len(in_channels) == 4, 'Length of input channels \ - must be 4!' - - assert len(dilations) == 4, 'Length of dilations \ - must be 4!' - - assert out_channels == in_channels[1], 'Output channels must \ - be the same with in_channels[1]!' - + assert isinstance(dilations, tuple) self.in_channels = in_channels - self.out_channels = out_channels + self.out_channels = in_channels[start_level] + self.start_level = start_level + self.num_ins = len(in_channels) + if end_level == -1: + self.backbone_end_level = self.num_ins + else: + self.backbone_end_level = end_level + assert end_level <= len(in_channels) + + self.dilations = dilations self.align_corners = align_corners self.out_indices = out_indices - # Note: Names of operations below are referenced from original paper. - for i in range(3): - conv_name = f'conv{i+3}' + self.conv_layers = nn.ModuleList() + self.dilation_layers = nn.ModuleList() + for i in range(self.start_level, self.backbone_end_level): conv_layer = nn.Sequential( ConvModule( - self.in_channels[i - 3], + self.in_channels[i], self.out_channels, kernel_size=3, padding=1, @@ -75,12 +81,11 @@ def __init__(self, conv_cfg=conv_cfg, norm_cfg=norm_cfg, act_cfg=act_cfg)) - self.add_module(conv_name, conv_layer) - for i in range(4): - dilation_name = f'dilation{i+1}' + self.conv_layers.append(conv_layer) + for i in range(len(dilations)): dilation_layer = nn.Sequential( DepthwiseSeparableConvModule( - in_channels=3 * self.out_channels, + in_channels=(len(in_channels) - 1) * self.out_channels, out_channels=self.out_channels, kernel_size=3, stride=1, @@ -90,35 +95,35 @@ def __init__(self, dw_act_cfg=None, pw_norm_cfg=norm_cfg, pw_act_cfg=act_cfg)) - self.add_module(dilation_name, dilation_layer) + self.dilation_layers.append(dilation_layer) def forward(self, inputs): """Forward function.""" - x_8 = inputs[1] - x_16 = inputs[2] - x_32 = inputs[3] - feats = [self.conv5(x_32), self.conv4(x_16), self.conv3(x_8)] + assert len(inputs) == len(self.in_channels), 'Length of inputs must \ + be the same with self.in_channels!' + + feats = [ + self.conv_layers[i](inputs[i + 1]) + for i in range(len(self.in_channels) - 1) + ] + + _, _, h, w = feats[0].size() + for i in range(len(feats) - 1): + feats[i + 1] = resize( + feats[i + 1], + size=(h, w), + mode='bilinear', + align_corners=self.align_corners) - _, _, h, w = feats[-1].size() - feats[-2] = resize( - feats[-2], - size=(h, w), - mode='bilinear', - align_corners=self.align_corners) - feats[-3] = resize( - feats[-3], - size=(h, w), - mode='bilinear', - align_corners=self.align_corners) - feat = torch.cat(feats, dim=1) + feat = torch.cat(feats[::-1], dim=1) feat = torch.cat([ - self.dilation1(feat), - self.dilation2(feat), - self.dilation3(feat), - self.dilation4(feat) + self.dilation_layers[i](feat) for i in range(len(self.dilations)) ], dim=1) - outs = [inputs[0], inputs[1], inputs[2], feat] + outs = [] + for i in range(len(inputs) - 1): + outs.append(inputs[i]) + outs.append(feat) outs = [outs[i] for i in self.out_indices] return tuple(outs) diff --git a/tests/test_models/test_necks/test_jpu.py b/tests/test_models/test_necks/test_jpu.py index 2de38670aa..92d1f87acb 100644 --- a/tests/test_models/test_necks/test_jpu.py +++ b/tests/test_models/test_necks/test_jpu.py @@ -1,4 +1,5 @@ # Copyright (c) OpenMMLab. All rights reserved. +import pytest import torch from mmseg.models.necks import JPU @@ -23,3 +24,7 @@ def test_fastfcn_neck(): assert feat[1].shape == torch.Size([batch_size, 512, 64, 128]) assert feat[2].shape == torch.Size([batch_size, 1024, 32, 64]) assert feat[3].shape == torch.Size([batch_size, 2048, 64, 128]) + + with pytest.raises(AssertionError): + # FastFCN input and in_channels constraints. + JPU(in_channels=(128, 256, 512, 1024), start_level=1, end_level=5) From 54d3847e348accca4e8cd73ab3c6de5542a4c926 Mon Sep 17 00:00:00 2001 From: MengzhangLI Date: Fri, 24 Sep 2021 01:42:39 +0800 Subject: [PATCH 08/21] FastFCN --- configs/_base_/models/fastfcn_r50-d32.py | 10 +++--- mmseg/models/necks/jpu.py | 39 ++++++++++++------------ tests/test_models/test_necks/test_jpu.py | 12 +++----- 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/configs/_base_/models/fastfcn_r50-d32.py b/configs/_base_/models/fastfcn_r50-d32.py index 6cd2bfd9ef..d54d842fea 100644 --- a/configs/_base_/models/fastfcn_r50-d32.py +++ b/configs/_base_/models/fastfcn_r50-d32.py @@ -9,23 +9,25 @@ num_stages=4, dilations=(1, 1, 1, 1), strides=(1, 2, 2, 2), + out_indices=(1, 2, 3), norm_cfg=norm_cfg, norm_eval=False, style='pytorch', contract_dilation=True), neck=dict( type='JPU', - in_channels=(256, 512, 1024, 2048), + in_channels=(512, 1024, 2048), + mid_channels=512, start_level=1, end_level=-1, dilations=(1, 2, 4, 8), align_corners=False, - out_indices=(0, 1, 2, 3), + out_indices=(0, 1, 2), norm_cfg=norm_cfg), decode_head=dict( type='PSPHead', in_channels=2048, - in_index=3, + in_index=2, channels=512, dropout_ratio=0.1, num_classes=19, @@ -36,7 +38,7 @@ auxiliary_head=dict( type='FCNHead', in_channels=1024, - in_index=2, + in_index=1, channels=256, num_convs=1, concat_input=False, diff --git a/mmseg/models/necks/jpu.py b/mmseg/models/necks/jpu.py index fa74947505..7f4d0ed9f4 100644 --- a/mmseg/models/necks/jpu.py +++ b/mmseg/models/necks/jpu.py @@ -19,15 +19,17 @@ class JPU(BaseModule): Args: in_channels (Tuple[int], optional): The number of input channels for each convolution operations before upsampling. - Default: (256, 512, 1024, 2048). + Default: (512, 1024, 2048). + mid_channels (int): The number of output channels of JPU. + Default: 512. start_level (int): Index of the start input backbone level used to - build the feature pyramid. Default: 1. + build the feature pyramid. Default: 0. end_level (int): Index of the end input backbone level (exclusive) to build the feature pyramid. Default: -1, which means the last level. dilations (tuple[int]): Dilation rate of each Depthwise Separable ConvModule. out_indices (Tuple[int] | int, optional): Output from which stages. - Default: (0, 1, 2, 3). + Default: (0, 1, 2). align_corners (bool, optional): The align_corners argument of resize operation. Default: False. conv_cfg (dict | None): Config of conv layers. @@ -41,11 +43,12 @@ class JPU(BaseModule): """ def __init__(self, - in_channels=(256, 512, 1024, 2048), - start_level=1, + in_channels=(512, 1024, 2048), + mid_channels=512, + start_level=0, end_level=-1, dilations=(1, 2, 4, 8), - out_indices=(0, 1, 2, 3), + out_indices=(0, 1, 2), align_corners=False, conv_cfg=None, norm_cfg=dict(type='BN'), @@ -55,7 +58,7 @@ def __init__(self, assert isinstance(in_channels, tuple) assert isinstance(dilations, tuple) self.in_channels = in_channels - self.out_channels = in_channels[start_level] + self.mid_channels = mid_channels self.start_level = start_level self.num_ins = len(in_channels) if end_level == -1: @@ -70,14 +73,13 @@ def __init__(self, self.conv_layers = nn.ModuleList() self.dilation_layers = nn.ModuleList() - for i in range(self.start_level, self.backbone_end_level): + for i in range(len(in_channels)): conv_layer = nn.Sequential( ConvModule( self.in_channels[i], - self.out_channels, + self.mid_channels, kernel_size=3, padding=1, - bias=False, conv_cfg=conv_cfg, norm_cfg=norm_cfg, act_cfg=act_cfg)) @@ -85,8 +87,8 @@ def __init__(self, for i in range(len(dilations)): dilation_layer = nn.Sequential( DepthwiseSeparableConvModule( - in_channels=(len(in_channels) - 1) * self.out_channels, - out_channels=self.out_channels, + in_channels=len(in_channels) * self.mid_channels, + out_channels=self.mid_channels, kernel_size=3, stride=1, padding=dilations[i], @@ -102,15 +104,12 @@ def forward(self, inputs): assert len(inputs) == len(self.in_channels), 'Length of inputs must \ be the same with self.in_channels!' - feats = [ - self.conv_layers[i](inputs[i + 1]) - for i in range(len(self.in_channels) - 1) - ] + feats = [self.conv_layers[i](inputs[i]) for i in range(len(inputs))] - _, _, h, w = feats[0].size() - for i in range(len(feats) - 1): - feats[i + 1] = resize( - feats[i + 1], + h, w = feats[0].shape[2:] + for i in range(1, len(feats)): + feats[i] = resize( + feats[i], size=(h, w), mode='bilinear', align_corners=self.align_corners) diff --git a/tests/test_models/test_necks/test_jpu.py b/tests/test_models/test_necks/test_jpu.py index 92d1f87acb..f0a0903d9f 100644 --- a/tests/test_models/test_necks/test_jpu.py +++ b/tests/test_models/test_necks/test_jpu.py @@ -12,19 +12,17 @@ def test_fastfcn_neck(): model.train() batch_size = 1 input = [ - torch.randn(batch_size, 256, 128, 256), torch.randn(batch_size, 512, 64, 128), torch.randn(batch_size, 1024, 32, 64), torch.randn(batch_size, 2048, 16, 32) ] feat = model(input) - assert len(feat) == 4 - assert feat[0].shape == torch.Size([batch_size, 256, 128, 256]) - assert feat[1].shape == torch.Size([batch_size, 512, 64, 128]) - assert feat[2].shape == torch.Size([batch_size, 1024, 32, 64]) - assert feat[3].shape == torch.Size([batch_size, 2048, 64, 128]) + assert len(feat) == 3 + assert feat[0].shape == torch.Size([batch_size, 512, 64, 128]) + assert feat[1].shape == torch.Size([batch_size, 1024, 32, 64]) + assert feat[2].shape == torch.Size([batch_size, 2048, 64, 128]) with pytest.raises(AssertionError): # FastFCN input and in_channels constraints. - JPU(in_channels=(128, 256, 512, 1024), start_level=1, end_level=5) + JPU(in_channels=(256, 512, 1024), start_level=0, end_level=5) From c258d40772af71ecb2aa7f1d462ded4e9792cf51 Mon Sep 17 00:00:00 2001 From: MengzhangLI Date: Fri, 24 Sep 2021 01:44:29 +0800 Subject: [PATCH 09/21] FastFCN --- mmseg/models/necks/jpu.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmseg/models/necks/jpu.py b/mmseg/models/necks/jpu.py index 7f4d0ed9f4..492331d73a 100644 --- a/mmseg/models/necks/jpu.py +++ b/mmseg/models/necks/jpu.py @@ -27,7 +27,7 @@ class JPU(BaseModule): end_level (int): Index of the end input backbone level (exclusive) to build the feature pyramid. Default: -1, which means the last level. dilations (tuple[int]): Dilation rate of each Depthwise - Separable ConvModule. + Separable ConvModule. Default: (1, 2, 4, 8). out_indices (Tuple[int] | int, optional): Output from which stages. Default: (0, 1, 2). align_corners (bool, optional): The align_corners argument of From 2f01526d719954acd0cd0ed89b559aea347106a0 Mon Sep 17 00:00:00 2001 From: MengzhangLI Date: Fri, 24 Sep 2021 13:28:47 +0800 Subject: [PATCH 10/21] temp --- configs/fastfcn/fastfcn_jpu_enc_4x4_cityscapes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/fastfcn/fastfcn_jpu_enc_4x4_cityscapes.py b/configs/fastfcn/fastfcn_jpu_enc_4x4_cityscapes.py index 5b0dc40f8a..f51ce260d7 100644 --- a/configs/fastfcn/fastfcn_jpu_enc_4x4_cityscapes.py +++ b/configs/fastfcn/fastfcn_jpu_enc_4x4_cityscapes.py @@ -5,7 +5,7 @@ decode_head=dict( type='EncHead', in_channels=[512, 1024, 2048], - in_index=(1, 2, 3), + in_index=(0, 1, 2), channels=512, num_codes=32, use_se_loss=True, From 218719efc090f22f139fbad990d8b54c7e3bb7ac Mon Sep 17 00:00:00 2001 From: MengzhangLI Date: Mon, 27 Sep 2021 23:11:16 +0800 Subject: [PATCH 11/21] Uploading models & logs (4x4) --- README.md | 1 + README_zh-CN.md | 1 + configs/_base_/models/fastfcn_r50-d32.py | 2 +- configs/fastfcn/README.md | 37 +++++++++++++++++++ ...-jpu_deeplabv3_512x1024_80k_cityscapes.py} | 4 +- ...astfcn-jpu_enc_512x1024_80k_cityscapes.py} | 2 +- ...astfcn-jpu_psp_512x1024_80k_cityscapes.py} | 0 ...-d32_d1124_jpu_deeplabv3_4x4_cityscapes.py | 27 -------------- ...cn_r50-d32_d1124_jpu_enc_4x4_cityscapes.py | 31 ---------------- ...cn_r50-d32_d1124_jpu_psp_4x4_cityscapes.py | 12 ------ ...0-d8_d1124_jpu_deeplabv3_4x4_cityscapes.py | 27 -------------- ...fcn_r50-d8_d1124_jpu_enc_4x4_cityscapes.py | 31 ---------------- ...fcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py | 12 ------ mmseg/models/necks/jpu.py | 2 +- 14 files changed, 44 insertions(+), 145 deletions(-) create mode 100644 configs/fastfcn/README.md rename configs/fastfcn/{fastfcn_jpu_deeplabv3_4x4_cityscapes.py => fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py} (88%) rename configs/fastfcn/{fastfcn_jpu_enc_4x4_cityscapes.py => fastfcn-jpu_enc_512x1024_80k_cityscapes.py} (93%) rename configs/fastfcn/{fastfcn_jpu_psp_4x4_cityscapes.py => fastfcn-jpu_psp_512x1024_80k_cityscapes.py} (100%) delete mode 100644 configs/fastfcn/fastfcn_r50-d32_d1124_jpu_deeplabv3_4x4_cityscapes.py delete mode 100644 configs/fastfcn/fastfcn_r50-d32_d1124_jpu_enc_4x4_cityscapes.py delete mode 100644 configs/fastfcn/fastfcn_r50-d32_d1124_jpu_psp_4x4_cityscapes.py delete mode 100644 configs/fastfcn/fastfcn_r50-d8_d1124_jpu_deeplabv3_4x4_cityscapes.py delete mode 100644 configs/fastfcn/fastfcn_r50-d8_d1124_jpu_enc_4x4_cityscapes.py delete mode 100644 configs/fastfcn/fastfcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py diff --git a/README.md b/README.md index 21c08021ba..f3d837b3a5 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,7 @@ Supported methods: - [x] [DMNet (ICCV'2019)](configs/dmnet) - [x] [ANN (ICCV'2019)](configs/ann) - [x] [GCNet (ICCVW'2019/TPAMI'2020)](configs/gcnet) +- [x] [FastFCN (ArXiv'2019)](configs/fastfcn) - [x] [Fast-SCNN (ArXiv'2019)](configs/fastscnn) - [x] [ISANet (ArXiv'2019/IJCV'2021)](configs/isanet) - [x] [OCRNet (ECCV'2020)](configs/ocrnet) diff --git a/README_zh-CN.md b/README_zh-CN.md index 51e78f7ab1..29d08e8336 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -86,6 +86,7 @@ MMSegmentation 是一个基于 PyTorch 的语义分割开源工具箱。它是 O - [x] [DMNet (ICCV'2019)](configs/dmnet) - [x] [ANN (ICCV'2019)](configs/ann) - [x] [GCNet (ICCVW'2019/TPAMI'2020)](configs/gcnet) +- [x] [FastFCN (ArXiv'2019)](configs/fastfcn) - [x] [Fast-SCNN (ArXiv'2019)](configs/fastscnn) - [x] [ISANet (ArXiv'2019/IJCV'2021)](configs/isanet) - [x] [OCRNet (ECCV'2020)](configs/ocrnet) diff --git a/configs/_base_/models/fastfcn_r50-d32.py b/configs/_base_/models/fastfcn_r50-d32.py index d54d842fea..931a7463ca 100644 --- a/configs/_base_/models/fastfcn_r50-d32.py +++ b/configs/_base_/models/fastfcn_r50-d32.py @@ -7,7 +7,7 @@ type='ResNetV1c', depth=50, num_stages=4, - dilations=(1, 1, 1, 1), + dilations=(1, 1, 2, 4), strides=(1, 2, 2, 2), out_indices=(1, 2, 3), norm_cfg=norm_cfg, diff --git a/configs/fastfcn/README.md b/configs/fastfcn/README.md new file mode 100644 index 0000000000..61bbec24e3 --- /dev/null +++ b/configs/fastfcn/README.md @@ -0,0 +1,37 @@ +# FastFCN: Rethinking Dilated Convolution in the Backbone for Semantic Segmentation + +## Introduction + + + +Official Repo + +Code Snippet + +
+FastFCN (ArXiv'2019) + +```latex +@article{wu2019fastfcn, + title={Fastfcn: Rethinking dilated convolution in the backbone for semantic segmentation}, + author={Wu, Huikai and Zhang, Junge and Huang, Kaiqi and Liang, Kongming and Yu, Yizhou}, + journal={arXiv preprint arXiv:1903.11816}, + year={2019} +} +``` + +## Results and models + +### Cityscapes + +| Method | Backbone | Crop Size | Lr schd | Mem (GB) | Inf time (fps) | mIoU | mIoU(ms+flip) | config | download | +| --------- | --------- | --------- | ------: | -------- | -------------- | ----: | ------------- | --------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [DeepLabV3](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/deeplabv3) | R-50-D8 | 512x1024 | 80000 | 6.1 | 2.57 | 79.32 | 80.57 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/deeplabv3/deeplabv3_r50-d8_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/deeplabv3/deeplabv3_r50-d8_512x1024_80k_cityscapes/deeplabv3_r50-d8_512x1024_80k_cityscapes_20200606_113404-b92cfdd4.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/deeplabv3/deeplabv3_r50-d8_512x1024_80k_cityscapes/deeplabv3_r50-d8_512x1024_80k_cityscapes_20200606_113404.log.json) | +| DeepLabV3 + JPU (4x2) | R-50-D32 | 512x1024 | 80000 | | | | | | | +| DeepLabV3 + JPU (4x4) | R-50-D32 | 512x1024 | 80000 | 9.79 | 2.64 | 79.52 | 80.91 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes_20210924_214357-c2b06737.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes_20210924_214357.log.json) | +| [PSPNet](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/pspnet) | R-50-D8 | 512x1024 | 80000 | 6.1 | 4.07 | 78.55 | 79.79 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/pspnet/pspnet_r50-d8_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/pspnet/pspnet_r50-d8_512x1024_80k_cityscapes/pspnet_r50-d8_512x1024_80k_cityscapes_20200606_112131-2376f12b.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/pspnet/pspnet_r50-d8_512x1024_80k_cityscapes/pspnet_r50-d8_512x1024_80k_cityscapes_20200606_112131.log.json) | +| PSPNet + JPU (4x2) | R-50-D32 | 512x1024 | 80000 | | | | | | | +| PSPNet + JPU (4x2) | R-50-D32 | 512x1024 | 80000 | 9.94 | 4.47 | 78.76 | 80.03 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes/fastfcn-jpu_psp_512x1024_80k_cityscapes_20210925_061841-b07c5e32.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes/fastfcn-jpu_psp_512x1024_80k_cityscapes_20210925_061841.log.json) | +| [encnet](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/encnet) | R-50-D8 | 512x1024 | 80000 | 8.6 | 4.58 | 77.94 | 79.13 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/encnet/encnet_r50-d8_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/encnet/encnet_r50-d8_512x1024_80k_cityscapes/encnet_r50-d8_512x1024_80k_cityscapes_20200622_003554-fc5c5624.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/encnet/encnet_r50-d8_512x1024_80k_cityscapes/encnet_r50-d8_512x1024_80k_cityscapes-20200622_003554.log.json) | +| encnet + JPU (4x2)| R-50-D32 | 512x1024 | 80000 | | | | | | | +| encnet + JPU (4x4)| R-50-D32 | 512x1024 | 80000 | 15.45 | 5.02 | 78.6 | 80.25 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes/fastfcn-jpu_enc_512x1024_80k_cityscapes_20210926_093217-c2e5d0fd.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes/fastfcn-jpu_enc_512x1024_80k_cityscapes_20210926_093217.log.json) | diff --git a/configs/fastfcn/fastfcn_jpu_deeplabv3_4x4_cityscapes.py b/configs/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py similarity index 88% rename from configs/fastfcn/fastfcn_jpu_deeplabv3_4x4_cityscapes.py rename to configs/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py index 7edb891a3d..f4c0416ae3 100644 --- a/configs/fastfcn/fastfcn_jpu_deeplabv3_4x4_cityscapes.py +++ b/configs/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py @@ -1,11 +1,11 @@ # model settings -_base_ = './fastfcn_jpu_psp_4x4_cityscapes.py' +_base_ = './fastfcn-jpu_psp_512x1024_80k_cityscapes.py' norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( decode_head=dict( type='ASPPHead', in_channels=2048, - in_index=3, + in_index=2, channels=512, dilations=(1, 12, 24, 36), dropout_ratio=0.1, diff --git a/configs/fastfcn/fastfcn_jpu_enc_4x4_cityscapes.py b/configs/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes.py similarity index 93% rename from configs/fastfcn/fastfcn_jpu_enc_4x4_cityscapes.py rename to configs/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes.py index f51ce260d7..2f67ee7f2f 100644 --- a/configs/fastfcn/fastfcn_jpu_enc_4x4_cityscapes.py +++ b/configs/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes.py @@ -1,5 +1,5 @@ # model settings -_base_ = './fastfcn_jpu_psp_4x4_cityscapes.py' +_base_ = './fastfcn-jpu_psp_512x1024_80k_cityscapes.py' norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( decode_head=dict( diff --git a/configs/fastfcn/fastfcn_jpu_psp_4x4_cityscapes.py b/configs/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes.py similarity index 100% rename from configs/fastfcn/fastfcn_jpu_psp_4x4_cityscapes.py rename to configs/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes.py diff --git a/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_deeplabv3_4x4_cityscapes.py b/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_deeplabv3_4x4_cityscapes.py deleted file mode 100644 index 9b86de0daa..0000000000 --- a/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_deeplabv3_4x4_cityscapes.py +++ /dev/null @@ -1,27 +0,0 @@ -# model settings -_base_ = './fastfcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py' -norm_cfg = dict(type='SyncBN', requires_grad=True) -model = dict( - backbone=dict( - dilations=(1, 1, 2, 4), - strides=(1, 2, 2, 2), - ), - decode_head=dict( - type='ASPPHead', - in_channels=2048, - in_index=3, - channels=512, - dilations=(1, 12, 24, 36), - dropout_ratio=0.1, - num_classes=19, - norm_cfg=norm_cfg, - align_corners=False, - loss_decode=dict( - type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), - # model training and testing settings - train_cfg=dict(), - test_cfg=dict(mode='whole')) -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, -) diff --git a/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_enc_4x4_cityscapes.py b/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_enc_4x4_cityscapes.py deleted file mode 100644 index 6e7ec3e489..0000000000 --- a/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_enc_4x4_cityscapes.py +++ /dev/null @@ -1,31 +0,0 @@ -# model settings -_base_ = './fastfcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py' -norm_cfg = dict(type='SyncBN', requires_grad=True) -model = dict( - backbone=dict( - dilations=(1, 1, 2, 4), - strides=(1, 2, 2, 2), - ), - decode_head=dict( - type='EncHead', - in_channels=[512, 1024, 2048], - in_index=(1, 2, 3), - channels=512, - num_codes=32, - use_se_loss=True, - add_lateral=False, - dropout_ratio=0.1, - num_classes=19, - norm_cfg=norm_cfg, - align_corners=False, - loss_decode=dict( - type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0), - loss_se_decode=dict( - type='CrossEntropyLoss', use_sigmoid=True, loss_weight=0.2)), - # model training and testing settings - train_cfg=dict(), - test_cfg=dict(mode='whole')) -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, -) diff --git a/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_psp_4x4_cityscapes.py b/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_psp_4x4_cityscapes.py deleted file mode 100644 index eaf84ea242..0000000000 --- a/configs/fastfcn/fastfcn_r50-d32_d1124_jpu_psp_4x4_cityscapes.py +++ /dev/null @@ -1,12 +0,0 @@ -_base_ = [ - '../_base_/models/fastfcn_r50-d32.py', '../_base_/datasets/cityscapes.py', - '../_base_/default_runtime.py', '../_base_/schedules/schedule_80k.py' -] -model = dict(backbone=dict( - dilations=(1, 1, 2, 4), - strides=(1, 2, 2, 2), -)) -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, -) diff --git a/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_deeplabv3_4x4_cityscapes.py b/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_deeplabv3_4x4_cityscapes.py deleted file mode 100644 index 732f7e4055..0000000000 --- a/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_deeplabv3_4x4_cityscapes.py +++ /dev/null @@ -1,27 +0,0 @@ -# model settings -_base_ = './fastfcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py' -norm_cfg = dict(type='SyncBN', requires_grad=True) -model = dict( - backbone=dict( - dilations=(1, 1, 2, 4), - strides=(1, 2, 1, 1), - ), - decode_head=dict( - type='ASPPHead', - in_channels=2048, - in_index=3, - channels=512, - dilations=(1, 12, 24, 36), - dropout_ratio=0.1, - num_classes=19, - norm_cfg=norm_cfg, - align_corners=False, - loss_decode=dict( - type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), - # model training and testing settings - train_cfg=dict(), - test_cfg=dict(mode='whole')) -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, -) diff --git a/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_enc_4x4_cityscapes.py b/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_enc_4x4_cityscapes.py deleted file mode 100644 index 6cf6c74452..0000000000 --- a/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_enc_4x4_cityscapes.py +++ /dev/null @@ -1,31 +0,0 @@ -# model settings -_base_ = './fastfcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py' -norm_cfg = dict(type='SyncBN', requires_grad=True) -model = dict( - backbone=dict( - dilations=(1, 1, 2, 4), - strides=(1, 2, 1, 1), - ), - decode_head=dict( - type='EncHead', - in_channels=[512, 1024, 2048], - in_index=(1, 2, 3), - channels=512, - num_codes=32, - use_se_loss=True, - add_lateral=False, - dropout_ratio=0.1, - num_classes=19, - norm_cfg=norm_cfg, - align_corners=False, - loss_decode=dict( - type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0), - loss_se_decode=dict( - type='CrossEntropyLoss', use_sigmoid=True, loss_weight=0.2)), - # model training and testing settings - train_cfg=dict(), - test_cfg=dict(mode='whole')) -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, -) diff --git a/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py b/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py deleted file mode 100644 index c88ae0acb9..0000000000 --- a/configs/fastfcn/fastfcn_r50-d8_d1124_jpu_psp_4x4_cityscapes.py +++ /dev/null @@ -1,12 +0,0 @@ -_base_ = [ - '../_base_/models/fastfcn_r50-d32.py', '../_base_/datasets/cityscapes.py', - '../_base_/default_runtime.py', '../_base_/schedules/schedule_80k.py' -] -model = dict(backbone=dict( - dilations=(1, 1, 2, 4), - strides=(1, 2, 1, 1), -)) -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, -) diff --git a/mmseg/models/necks/jpu.py b/mmseg/models/necks/jpu.py index 492331d73a..8552fe5713 100644 --- a/mmseg/models/necks/jpu.py +++ b/mmseg/models/necks/jpu.py @@ -114,7 +114,7 @@ def forward(self, inputs): mode='bilinear', align_corners=self.align_corners) - feat = torch.cat(feats[::-1], dim=1) + feat = torch.cat(feats, dim=1) feat = torch.cat([ self.dilation_layers[i](feat) for i in range(len(self.dilations)) ], From 7a849ff23e9fdb8631c7305820598c14928d534e Mon Sep 17 00:00:00 2001 From: MengzhangLI Date: Tue, 28 Sep 2021 23:11:32 +0800 Subject: [PATCH 12/21] Fixing typos --- configs/fastfcn/README.md | 24 +++-- configs/fastfcn/fastfcn.yml | 199 ++++++++++++++++++++++++++++++++++++ model-index.yml | 1 + 3 files changed, 213 insertions(+), 11 deletions(-) create mode 100644 configs/fastfcn/fastfcn.yml diff --git a/configs/fastfcn/README.md b/configs/fastfcn/README.md index 61bbec24e3..99da290312 100644 --- a/configs/fastfcn/README.md +++ b/configs/fastfcn/README.md @@ -9,29 +9,31 @@ Code Snippet
-FastFCN (ArXiv'2019) +FastFCN (ArXiv'2019) ```latex @article{wu2019fastfcn, - title={Fastfcn: Rethinking dilated convolution in the backbone for semantic segmentation}, - author={Wu, Huikai and Zhang, Junge and Huang, Kaiqi and Liang, Kongming and Yu, Yizhou}, - journal={arXiv preprint arXiv:1903.11816}, - year={2019} +title={Fastfcn: Rethinking dilated convolution in the backbone for semantic segmentation}, +author={Wu, Huikai and Zhang, Junge and Huang, Kaiqi and Liang, Kongming and Yu, Yizhou}, +journal={arXiv preprint arXiv:1903.11816}, +year={2019} } ``` +
+ ## Results and models ### Cityscapes | Method | Backbone | Crop Size | Lr schd | Mem (GB) | Inf time (fps) | mIoU | mIoU(ms+flip) | config | download | | --------- | --------- | --------- | ------: | -------- | -------------- | ----: | ------------- | --------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [DeepLabV3](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/deeplabv3) | R-50-D8 | 512x1024 | 80000 | 6.1 | 2.57 | 79.32 | 80.57 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/deeplabv3/deeplabv3_r50-d8_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/deeplabv3/deeplabv3_r50-d8_512x1024_80k_cityscapes/deeplabv3_r50-d8_512x1024_80k_cityscapes_20200606_113404-b92cfdd4.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/deeplabv3/deeplabv3_r50-d8_512x1024_80k_cityscapes/deeplabv3_r50-d8_512x1024_80k_cityscapes_20200606_113404.log.json) | -| DeepLabV3 + JPU (4x2) | R-50-D32 | 512x1024 | 80000 | | | | | | | +| [DeepLabV3](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/deeplabv3) | R-50-D8 | 512x1024 | 80000 | 6.1 | 2.57 | 79.32 | 80.57 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/deeplabv3/deeplabv3_r50-d8_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/deeplabv3/deeplabv3_r50-d8_512x1024_80k_cityscapes/deeplabv3_r50-d8_512x1024_80k_cityscapes_20200606_113404-b92cfdd4.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/deeplabv3/deeplabv3_r50-d8_512x1024_80k_cityscapes/deeplabv3_r50-d8_512x1024_80k_cityscapes_20200606_113404.log.json) | +| DeepLabV3 + JPU (4x2) | R-50-D32 | 512x1024 | 80000 | 999 | 999 | 0 | 0 | 0 |0 | | DeepLabV3 + JPU (4x4) | R-50-D32 | 512x1024 | 80000 | 9.79 | 2.64 | 79.52 | 80.91 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes_20210924_214357-c2b06737.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes_20210924_214357.log.json) | | [PSPNet](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/pspnet) | R-50-D8 | 512x1024 | 80000 | 6.1 | 4.07 | 78.55 | 79.79 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/pspnet/pspnet_r50-d8_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/pspnet/pspnet_r50-d8_512x1024_80k_cityscapes/pspnet_r50-d8_512x1024_80k_cityscapes_20200606_112131-2376f12b.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/pspnet/pspnet_r50-d8_512x1024_80k_cityscapes/pspnet_r50-d8_512x1024_80k_cityscapes_20200606_112131.log.json) | -| PSPNet + JPU (4x2) | R-50-D32 | 512x1024 | 80000 | | | | | | | -| PSPNet + JPU (4x2) | R-50-D32 | 512x1024 | 80000 | 9.94 | 4.47 | 78.76 | 80.03 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes/fastfcn-jpu_psp_512x1024_80k_cityscapes_20210925_061841-b07c5e32.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes/fastfcn-jpu_psp_512x1024_80k_cityscapes_20210925_061841.log.json) | +| PSPNet + JPU (4x2) | R-50-D32 | 512x1024 | 80000 | 5.67 | 4.40 | 79.26 | 80.86 | | | +| PSPNet + JPU (4x2) | R-50-D32 | 512x1024 | 80000 | 9.94 | - | 78.76 | 80.03 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes/fastfcn-jpu_psp_512x1024_80k_cityscapes_20210925_061841-b07c5e32.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes/fastfcn-jpu_psp_512x1024_80k_cityscapes_20210925_061841.log.json) | | [encnet](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/encnet) | R-50-D8 | 512x1024 | 80000 | 8.6 | 4.58 | 77.94 | 79.13 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/encnet/encnet_r50-d8_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/encnet/encnet_r50-d8_512x1024_80k_cityscapes/encnet_r50-d8_512x1024_80k_cityscapes_20200622_003554-fc5c5624.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/encnet/encnet_r50-d8_512x1024_80k_cityscapes/encnet_r50-d8_512x1024_80k_cityscapes-20200622_003554.log.json) | -| encnet + JPU (4x2)| R-50-D32 | 512x1024 | 80000 | | | | | | | -| encnet + JPU (4x4)| R-50-D32 | 512x1024 | 80000 | 15.45 | 5.02 | 78.6 | 80.25 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes/fastfcn-jpu_enc_512x1024_80k_cityscapes_20210926_093217-c2e5d0fd.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes/fastfcn-jpu_enc_512x1024_80k_cityscapes_20210926_093217.log.json) | +| encnet + JPU (4x2)| R-50-D32 | 512x1024 | 80000 | 8.15 | 4.77 | 77.97 |79.92 | | | +| encnet + JPU (4x4)| R-50-D32 | 512x1024 | 80000 | 15.45 | - | 78.6 | 80.25 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes/fastfcn-jpu_enc_512x1024_80k_cityscapes_20210926_093217-c2e5d0fd.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes/fastfcn-jpu_enc_512x1024_80k_cityscapes_20210926_093217.log.json) | diff --git a/configs/fastfcn/fastfcn.yml b/configs/fastfcn/fastfcn.yml new file mode 100644 index 0000000000..77207a6adb --- /dev/null +++ b/configs/fastfcn/fastfcn.yml @@ -0,0 +1,199 @@ +Collections: +- Name: fastfcn + Metadata: + Training Data: + - Cityscapes + Paper: + URL: https://arxiv.org/abs/1903.11816 + Title: 'FastFCN: Rethinking Dilated Convolution in the Backbone for Semantic Segmentation' + README: configs/fastfcn/README.md + Code: + URL: https://github.com/open-mmlab/mmsegmentation/blob/v0.18.0/mmseg/models/necks/jpu.py#L12 + Version: v0.18.0 + Converted From: + Code: https://github.com/wuhuikai/FastFCN +Models: +- Name: '' + In Collection: fastfcn + Metadata: + backbone: R-50-D8 + crop size: (512,1024) + lr schd: 80000 + inference time (ms/im): + - value: 389.11 + hardware: V100 + backend: PyTorch + batch size: 1 + mode: FP32 + resolution: (512,1024) + memory (GB): 6.1 + Results: + - Task: Semantic Segmentation + Dataset: Cityscapes + Metrics: + mIoU: 79.32 + mIoU(ms+flip): 80.57 + Config: '' + Weights: '' +- Name: '' + In Collection: fastfcn + Metadata: + backbone: R-50-D32 + crop size: (512,1024) + lr schd: 80000 + inference time (ms/im): + - value: 1.0 + hardware: V100 + backend: PyTorch + batch size: 1 + mode: FP32 + resolution: (512,1024) + memory (GB): 999.0 + Results: + - Task: Semantic Segmentation + Dataset: Cityscapes + Metrics: + mIoU: 0.0 + mIoU(ms+flip): 0.0 + Config: '' + Weights: '' +- Name: fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes + In Collection: fastfcn + Metadata: + backbone: R-50-D32 + crop size: (512,1024) + lr schd: 80000 + inference time (ms/im): + - value: 378.79 + hardware: V100 + backend: PyTorch + batch size: 1 + mode: FP32 + resolution: (512,1024) + memory (GB): 9.79 + Results: + - Task: Semantic Segmentation + Dataset: Cityscapes + Metrics: + mIoU: 79.52 + mIoU(ms+flip): 80.91 + Config: configs/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py + Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes_20210924_214357-c2b06737.pth +- Name: '' + In Collection: fastfcn + Metadata: + backbone: R-50-D8 + crop size: (512,1024) + lr schd: 80000 + inference time (ms/im): + - value: 245.7 + hardware: V100 + backend: PyTorch + batch size: 1 + mode: FP32 + resolution: (512,1024) + memory (GB): 6.1 + Results: + - Task: Semantic Segmentation + Dataset: Cityscapes + Metrics: + mIoU: 78.55 + mIoU(ms+flip): 79.79 + Config: '' + Weights: '' +- Name: '' + In Collection: fastfcn + Metadata: + backbone: R-50-D32 + crop size: (512,1024) + lr schd: 80000 + inference time (ms/im): + - value: 227.27 + hardware: V100 + backend: PyTorch + batch size: 1 + mode: FP32 + resolution: (512,1024) + memory (GB): 5.67 + Results: + - Task: Semantic Segmentation + Dataset: Cityscapes + Metrics: + mIoU: 79.26 + mIoU(ms+flip): 80.86 + Config: '' + Weights: '' +- Name: fastfcn-jpu_psp_512x1024_80k_cityscapes + In Collection: fastfcn + Metadata: + backbone: R-50-D32 + crop size: (512,1024) + lr schd: 80000 + memory (GB): 9.94 + Results: + - Task: Semantic Segmentation + Dataset: Cityscapes + Metrics: + mIoU: 78.76 + mIoU(ms+flip): 80.03 + Config: configs/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes.py + Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes/fastfcn-jpu_psp_512x1024_80k_cityscapes_20210925_061841-b07c5e32.pth +- Name: '' + In Collection: fastfcn + Metadata: + backbone: R-50-D8 + crop size: (512,1024) + lr schd: 80000 + inference time (ms/im): + - value: 218.34 + hardware: V100 + backend: PyTorch + batch size: 1 + mode: FP32 + resolution: (512,1024) + memory (GB): 8.6 + Results: + - Task: Semantic Segmentation + Dataset: Cityscapes + Metrics: + mIoU: 77.94 + mIoU(ms+flip): 79.13 + Config: '' + Weights: '' +- Name: '' + In Collection: fastfcn + Metadata: + backbone: R-50-D32 + crop size: (512,1024) + lr schd: 80000 + inference time (ms/im): + - value: 209.64 + hardware: V100 + backend: PyTorch + batch size: 1 + mode: FP32 + resolution: (512,1024) + memory (GB): 8.15 + Results: + - Task: Semantic Segmentation + Dataset: Cityscapes + Metrics: + mIoU: 77.97 + mIoU(ms+flip): 79.92 + Config: '' + Weights: '' +- Name: fastfcn-jpu_enc_512x1024_80k_cityscapes + In Collection: fastfcn + Metadata: + backbone: R-50-D32 + crop size: (512,1024) + lr schd: 80000 + memory (GB): 15.45 + Results: + - Task: Semantic Segmentation + Dataset: Cityscapes + Metrics: + mIoU: 78.6 + mIoU(ms+flip): 80.25 + Config: configs/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes.py + Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes/fastfcn-jpu_enc_512x1024_80k_cityscapes_20210926_093217-c2e5d0fd.pth diff --git a/model-index.yml b/model-index.yml index 1fa927ad92..60c7595126 100644 --- a/model-index.yml +++ b/model-index.yml @@ -12,6 +12,7 @@ Import: - configs/dpt/dpt.yml - configs/emanet/emanet.yml - configs/encnet/encnet.yml +- configs/fastfcn/fastfcn.yml - configs/fastscnn/fastscnn.yml - configs/fcn/fcn.yml - configs/fp16/fp16.yml From e3a3637a1d3cbf4800a2c715cde4e0bf1b491db7 Mon Sep 17 00:00:00 2001 From: MengzhangLI Date: Wed, 29 Sep 2021 20:07:37 +0800 Subject: [PATCH 13/21] fix typos --- configs/_base_/models/fastfcn_r50-d32.py | 1 - configs/fastfcn/README.md | 12 ++--- ...u_deeplabv3_4x4_512x1024_80k_cityscapes.py | 6 +++ ...n-jpu_deeplabv3_512x1024_80k_cityscapes.py | 4 -- ...fcn-jpu_enc_4x4_512x1024_80k_cityscapes.py | 6 +++ ...fastfcn-jpu_enc_512x1024_80k_cityscapes.py | 4 -- ...fcn-jpu_psp_4x4_512x1024_80k_cityscapes.py | 8 +++ ...fastfcn-jpu_psp_512x1024_80k_cityscapes.py | 4 -- configs/fastfcn/fastfcn.yml | 51 ++++++++----------- mmseg/models/necks/jpu.py | 15 +++--- 10 files changed, 55 insertions(+), 56 deletions(-) create mode 100644 configs/fastfcn/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes.py create mode 100644 configs/fastfcn/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes.py create mode 100644 configs/fastfcn/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes.py diff --git a/configs/_base_/models/fastfcn_r50-d32.py b/configs/_base_/models/fastfcn_r50-d32.py index 931a7463ca..f4c43afb60 100644 --- a/configs/_base_/models/fastfcn_r50-d32.py +++ b/configs/_base_/models/fastfcn_r50-d32.py @@ -22,7 +22,6 @@ end_level=-1, dilations=(1, 2, 4, 8), align_corners=False, - out_indices=(0, 1, 2), norm_cfg=norm_cfg), decode_head=dict( type='PSPHead', diff --git a/configs/fastfcn/README.md b/configs/fastfcn/README.md index 99da290312..83d410c5fc 100644 --- a/configs/fastfcn/README.md +++ b/configs/fastfcn/README.md @@ -29,11 +29,11 @@ year={2019} | Method | Backbone | Crop Size | Lr schd | Mem (GB) | Inf time (fps) | mIoU | mIoU(ms+flip) | config | download | | --------- | --------- | --------- | ------: | -------- | -------------- | ----: | ------------- | --------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [DeepLabV3](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/deeplabv3) | R-50-D8 | 512x1024 | 80000 | 6.1 | 2.57 | 79.32 | 80.57 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/deeplabv3/deeplabv3_r50-d8_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/deeplabv3/deeplabv3_r50-d8_512x1024_80k_cityscapes/deeplabv3_r50-d8_512x1024_80k_cityscapes_20200606_113404-b92cfdd4.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/deeplabv3/deeplabv3_r50-d8_512x1024_80k_cityscapes/deeplabv3_r50-d8_512x1024_80k_cityscapes_20200606_113404.log.json) | -| DeepLabV3 + JPU (4x2) | R-50-D32 | 512x1024 | 80000 | 999 | 999 | 0 | 0 | 0 |0 | -| DeepLabV3 + JPU (4x4) | R-50-D32 | 512x1024 | 80000 | 9.79 | 2.64 | 79.52 | 80.91 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes_20210924_214357-c2b06737.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes_20210924_214357.log.json) | +| DeepLabV3 + JPU (4x2) | R-50-D32 | 512x1024 | 80000 | 5.67 | 2.64 | 79.12 | 80.58 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes_20210928_053722-a1cd65ef.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes_20210928_053722.log.json) | +| DeepLabV3 + JPU (4x4) | R-50-D32 | 512x1024 | 80000 | 9.79 | - | 79.52 | 80.91 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes_20210924_214357-662842be.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes_20210924_214357.log.json) | | [PSPNet](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/pspnet) | R-50-D8 | 512x1024 | 80000 | 6.1 | 4.07 | 78.55 | 79.79 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/pspnet/pspnet_r50-d8_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/pspnet/pspnet_r50-d8_512x1024_80k_cityscapes/pspnet_r50-d8_512x1024_80k_cityscapes_20200606_112131-2376f12b.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/pspnet/pspnet_r50-d8_512x1024_80k_cityscapes/pspnet_r50-d8_512x1024_80k_cityscapes_20200606_112131.log.json) | -| PSPNet + JPU (4x2) | R-50-D32 | 512x1024 | 80000 | 5.67 | 4.40 | 79.26 | 80.86 | | | -| PSPNet + JPU (4x2) | R-50-D32 | 512x1024 | 80000 | 9.94 | - | 78.76 | 80.03 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes/fastfcn-jpu_psp_512x1024_80k_cityscapes_20210925_061841-b07c5e32.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes/fastfcn-jpu_psp_512x1024_80k_cityscapes_20210925_061841.log.json) | +| PSPNet + JPU (4x2) | R-50-D32 | 512x1024 | 80000 | 5.67 | 4.40 | 79.26 | 80.86 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes/fastfcn-jpu_psp_512x1024_80k_cityscapes_20210928_053722-2b76380f.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes/fastfcn-jpu_psp_512x1024_80k_cityscapes_20210928_053722.log.json) | +| PSPNet + JPU (4x2) | R-50-D32 | 512x1024 | 80000 | 9.94 | - | 78.76 | 80.03 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes_20210925_061841-4a59425c.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes_20210925_061841.log.json) | | [encnet](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/encnet) | R-50-D8 | 512x1024 | 80000 | 8.6 | 4.58 | 77.94 | 79.13 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/encnet/encnet_r50-d8_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/encnet/encnet_r50-d8_512x1024_80k_cityscapes/encnet_r50-d8_512x1024_80k_cityscapes_20200622_003554-fc5c5624.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/encnet/encnet_r50-d8_512x1024_80k_cityscapes/encnet_r50-d8_512x1024_80k_cityscapes-20200622_003554.log.json) | -| encnet + JPU (4x2)| R-50-D32 | 512x1024 | 80000 | 8.15 | 4.77 | 77.97 |79.92 | | | -| encnet + JPU (4x4)| R-50-D32 | 512x1024 | 80000 | 15.45 | - | 78.6 | 80.25 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes/fastfcn-jpu_enc_512x1024_80k_cityscapes_20210926_093217-c2e5d0fd.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes/fastfcn-jpu_enc_512x1024_80k_cityscapes_20210926_093217.log.json) | +| encnet + JPU (4x2)| R-50-D32 | 512x1024 | 80000 | 8.15 | 4.77 | 77.97 |79.92 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes/fastfcn-jpu_enc_512x1024_80k_cityscapes_20210928_030036-f07a8ca0.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes/fastfcn-jpu_enc_512x1024_80k_cityscapes_20210928_030036.log.json) | +| encnet + JPU (4x4)| R-50-D32 | 512x1024 | 80000 | 15.45 | - | 78.6 | 80.25 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes_20210926_093217-47a1e5e6.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes_20210926_093217.log.json) | diff --git a/configs/fastfcn/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes.py b/configs/fastfcn/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes.py new file mode 100644 index 0000000000..31d46c6956 --- /dev/null +++ b/configs/fastfcn/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes.py @@ -0,0 +1,6 @@ +# model settings +_base_ = './fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py' +data = dict( + samples_per_gpu=4, + workers_per_gpu=4, +) diff --git a/configs/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py b/configs/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py index f4c0416ae3..274fc7b045 100644 --- a/configs/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py +++ b/configs/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py @@ -17,7 +17,3 @@ # model training and testing settings train_cfg=dict(), test_cfg=dict(mode='whole')) -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, -) diff --git a/configs/fastfcn/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes.py b/configs/fastfcn/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes.py new file mode 100644 index 0000000000..ae670bc63d --- /dev/null +++ b/configs/fastfcn/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes.py @@ -0,0 +1,6 @@ +# model settings +_base_ = './fastfcn-jpu_enc_512x1024_80k_cityscapes.py' +data = dict( + samples_per_gpu=4, + workers_per_gpu=4, +) diff --git a/configs/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes.py b/configs/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes.py index 2f67ee7f2f..4b067d5f6b 100644 --- a/configs/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes.py +++ b/configs/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes.py @@ -21,7 +21,3 @@ # model training and testing settings train_cfg=dict(), test_cfg=dict(mode='whole')) -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, -) diff --git a/configs/fastfcn/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes.py b/configs/fastfcn/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes.py new file mode 100644 index 0000000000..27965b217b --- /dev/null +++ b/configs/fastfcn/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes.py @@ -0,0 +1,8 @@ +_base_ = [ + '../_base_/models/fastfcn_r50-d32.py', '../_base_/datasets/cityscapes.py', + '../_base_/default_runtime.py', '../_base_/schedules/schedule_80k.py' +] +data = dict( + samples_per_gpu=4, + workers_per_gpu=4, +) diff --git a/configs/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes.py b/configs/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes.py index 27965b217b..cca6ba9fbc 100644 --- a/configs/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes.py +++ b/configs/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes.py @@ -2,7 +2,3 @@ '../_base_/models/fastfcn_r50-d32.py', '../_base_/datasets/cityscapes.py', '../_base_/default_runtime.py', '../_base_/schedules/schedule_80k.py' ] -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, -) diff --git a/configs/fastfcn/fastfcn.yml b/configs/fastfcn/fastfcn.yml index 77207a6adb..3166a9fcb8 100644 --- a/configs/fastfcn/fastfcn.yml +++ b/configs/fastfcn/fastfcn.yml @@ -35,41 +35,34 @@ Models: mIoU(ms+flip): 80.57 Config: '' Weights: '' -- Name: '' +- Name: fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes In Collection: fastfcn Metadata: backbone: R-50-D32 crop size: (512,1024) lr schd: 80000 inference time (ms/im): - - value: 1.0 + - value: 378.79 hardware: V100 backend: PyTorch batch size: 1 mode: FP32 resolution: (512,1024) - memory (GB): 999.0 + memory (GB): 5.67 Results: - Task: Semantic Segmentation Dataset: Cityscapes Metrics: - mIoU: 0.0 - mIoU(ms+flip): 0.0 - Config: '' - Weights: '' -- Name: fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes + mIoU: 79.12 + mIoU(ms+flip): 80.58 + Config: configs/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py + Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes_20210928_053722-a1cd65ef.pth +- Name: fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes In Collection: fastfcn Metadata: backbone: R-50-D32 crop size: (512,1024) lr schd: 80000 - inference time (ms/im): - - value: 378.79 - hardware: V100 - backend: PyTorch - batch size: 1 - mode: FP32 - resolution: (512,1024) memory (GB): 9.79 Results: - Task: Semantic Segmentation @@ -77,8 +70,8 @@ Models: Metrics: mIoU: 79.52 mIoU(ms+flip): 80.91 - Config: configs/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py - Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes_20210924_214357-c2b06737.pth + Config: configs/fastfcn/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes.py + Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes_20210924_214357-662842be.pth - Name: '' In Collection: fastfcn Metadata: @@ -101,7 +94,7 @@ Models: mIoU(ms+flip): 79.79 Config: '' Weights: '' -- Name: '' +- Name: fastfcn-jpu_psp_512x1024_80k_cityscapes In Collection: fastfcn Metadata: backbone: R-50-D32 @@ -121,9 +114,9 @@ Models: Metrics: mIoU: 79.26 mIoU(ms+flip): 80.86 - Config: '' - Weights: '' -- Name: fastfcn-jpu_psp_512x1024_80k_cityscapes + Config: configs/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes.py + Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes/fastfcn-jpu_psp_512x1024_80k_cityscapes_20210928_053722-2b76380f.pth +- Name: fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes In Collection: fastfcn Metadata: backbone: R-50-D32 @@ -136,8 +129,8 @@ Models: Metrics: mIoU: 78.76 mIoU(ms+flip): 80.03 - Config: configs/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes.py - Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes/fastfcn-jpu_psp_512x1024_80k_cityscapes_20210925_061841-b07c5e32.pth + Config: configs/fastfcn/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes.py + Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes_20210925_061841-4a59425c.pth - Name: '' In Collection: fastfcn Metadata: @@ -160,7 +153,7 @@ Models: mIoU(ms+flip): 79.13 Config: '' Weights: '' -- Name: '' +- Name: fastfcn-jpu_enc_512x1024_80k_cityscapes In Collection: fastfcn Metadata: backbone: R-50-D32 @@ -180,9 +173,9 @@ Models: Metrics: mIoU: 77.97 mIoU(ms+flip): 79.92 - Config: '' - Weights: '' -- Name: fastfcn-jpu_enc_512x1024_80k_cityscapes + Config: configs/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes.py + Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes/fastfcn-jpu_enc_512x1024_80k_cityscapes_20210928_030036-f07a8ca0.pth +- Name: fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes In Collection: fastfcn Metadata: backbone: R-50-D32 @@ -195,5 +188,5 @@ Models: Metrics: mIoU: 78.6 mIoU(ms+flip): 80.25 - Config: configs/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes.py - Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes/fastfcn-jpu_enc_512x1024_80k_cityscapes_20210926_093217-c2e5d0fd.pth + Config: configs/fastfcn/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes.py + Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes_20210926_093217-47a1e5e6.pth diff --git a/mmseg/models/necks/jpu.py b/mmseg/models/necks/jpu.py index 8552fe5713..51689fd30c 100644 --- a/mmseg/models/necks/jpu.py +++ b/mmseg/models/necks/jpu.py @@ -28,8 +28,6 @@ class JPU(BaseModule): build the feature pyramid. Default: -1, which means the last level. dilations (tuple[int]): Dilation rate of each Depthwise Separable ConvModule. Default: (1, 2, 4, 8). - out_indices (Tuple[int] | int, optional): Output from which stages. - Default: (0, 1, 2). align_corners (bool, optional): The align_corners argument of resize operation. Default: False. conv_cfg (dict | None): Config of conv layers. @@ -48,7 +46,6 @@ def __init__(self, start_level=0, end_level=-1, dilations=(1, 2, 4, 8), - out_indices=(0, 1, 2), align_corners=False, conv_cfg=None, norm_cfg=dict(type='BN'), @@ -69,7 +66,6 @@ def __init__(self, self.dilations = dilations self.align_corners = align_corners - self.out_indices = out_indices self.conv_layers = nn.ModuleList() self.dilation_layers = nn.ModuleList() @@ -115,14 +111,17 @@ def forward(self, inputs): align_corners=self.align_corners) feat = torch.cat(feats, dim=1) - feat = torch.cat([ + concat_feat = torch.cat([ self.dilation_layers[i](feat) for i in range(len(self.dilations)) ], - dim=1) + dim=1) outs = [] + + # Default: outs[2] is the output of JPU for decoder head, outs[1] is + # the feature map from backbone for auxiliary head. Additionally, + # outs[0] can also be used for auxiliary head. for i in range(len(inputs) - 1): outs.append(inputs[i]) - outs.append(feat) - outs = [outs[i] for i in self.out_indices] + outs.append(concat_feat) return tuple(outs) From 849c6f66c735b384c44f0b0cbb9594f468ac66aa Mon Sep 17 00:00:00 2001 From: MengzhangLI Date: Thu, 30 Sep 2021 14:05:55 +0800 Subject: [PATCH 14/21] rename config --- ..._r50-d32.py => fastfcn_r50-d32_jpu_psp.py} | 0 configs/fastfcn/README.md | 12 +++---- ...fcn-jpu_psp_4x4_512x1024_80k_cityscapes.py | 8 ----- ...fastfcn-jpu_psp_512x1024_80k_cityscapes.py | 4 --- configs/fastfcn/fastfcn.yml | 36 +++++++++---------- ...2_jpu_aspp_4x4_512x1024_80k_cityscapes.py} | 2 +- ...0-d32_jpu_aspp_512x1024_80k_cityscapes.py} | 2 +- ...32_jpu_enc_4x4_512x1024_80k_cityscapes.py} | 2 +- ...50-d32_jpu_enc_512x1024_80k_cityscapes.py} | 2 +- ...d32_jpu_psp_4x4_512x1024_80k_cityscapes.py | 9 +++++ ...r50-d32_jpu_psp_512x1024_80k_cityscapes.py | 5 +++ 11 files changed, 42 insertions(+), 40 deletions(-) rename configs/_base_/models/{fastfcn_r50-d32.py => fastfcn_r50-d32_jpu_psp.py} (100%) delete mode 100644 configs/fastfcn/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes.py delete mode 100644 configs/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes.py rename configs/fastfcn/{fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes.py => fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes.py} (54%) rename configs/fastfcn/{fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py => fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes.py} (89%) rename configs/fastfcn/{fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes.py => fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes.py} (54%) rename configs/fastfcn/{fastfcn-jpu_enc_512x1024_80k_cityscapes.py => fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes.py} (91%) create mode 100644 configs/fastfcn/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes.py create mode 100644 configs/fastfcn/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes.py diff --git a/configs/_base_/models/fastfcn_r50-d32.py b/configs/_base_/models/fastfcn_r50-d32_jpu_psp.py similarity index 100% rename from configs/_base_/models/fastfcn_r50-d32.py rename to configs/_base_/models/fastfcn_r50-d32_jpu_psp.py diff --git a/configs/fastfcn/README.md b/configs/fastfcn/README.md index 83d410c5fc..86cddc621b 100644 --- a/configs/fastfcn/README.md +++ b/configs/fastfcn/README.md @@ -29,11 +29,11 @@ year={2019} | Method | Backbone | Crop Size | Lr schd | Mem (GB) | Inf time (fps) | mIoU | mIoU(ms+flip) | config | download | | --------- | --------- | --------- | ------: | -------- | -------------- | ----: | ------------- | --------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [DeepLabV3](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/deeplabv3) | R-50-D8 | 512x1024 | 80000 | 6.1 | 2.57 | 79.32 | 80.57 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/deeplabv3/deeplabv3_r50-d8_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/deeplabv3/deeplabv3_r50-d8_512x1024_80k_cityscapes/deeplabv3_r50-d8_512x1024_80k_cityscapes_20200606_113404-b92cfdd4.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/deeplabv3/deeplabv3_r50-d8_512x1024_80k_cityscapes/deeplabv3_r50-d8_512x1024_80k_cityscapes_20200606_113404.log.json) | -| DeepLabV3 + JPU (4x2) | R-50-D32 | 512x1024 | 80000 | 5.67 | 2.64 | 79.12 | 80.58 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes_20210928_053722-a1cd65ef.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes_20210928_053722.log.json) | -| DeepLabV3 + JPU (4x4) | R-50-D32 | 512x1024 | 80000 | 9.79 | - | 79.52 | 80.91 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes_20210924_214357-662842be.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes_20210924_214357.log.json) | +| DeepLabV3 + JPU (4x2) | R-50-D32 | 512x1024 | 80000 | 5.67 | 2.64 | 79.12 | 80.58 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes_20210928_053722-5d1a2648.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes_20210928_053722.log.json) | +| DeepLabV3 + JPU (4x4) | R-50-D32 | 512x1024 | 80000 | 9.79 | - | 79.52 | 80.91 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes_20210924_214357-72220849.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes_20210924_214357.log.json) | | [PSPNet](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/pspnet) | R-50-D8 | 512x1024 | 80000 | 6.1 | 4.07 | 78.55 | 79.79 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/pspnet/pspnet_r50-d8_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/pspnet/pspnet_r50-d8_512x1024_80k_cityscapes/pspnet_r50-d8_512x1024_80k_cityscapes_20200606_112131-2376f12b.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/pspnet/pspnet_r50-d8_512x1024_80k_cityscapes/pspnet_r50-d8_512x1024_80k_cityscapes_20200606_112131.log.json) | -| PSPNet + JPU (4x2) | R-50-D32 | 512x1024 | 80000 | 5.67 | 4.40 | 79.26 | 80.86 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes/fastfcn-jpu_psp_512x1024_80k_cityscapes_20210928_053722-2b76380f.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes/fastfcn-jpu_psp_512x1024_80k_cityscapes_20210928_053722.log.json) | -| PSPNet + JPU (4x2) | R-50-D32 | 512x1024 | 80000 | 9.94 | - | 78.76 | 80.03 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes_20210925_061841-4a59425c.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes_20210925_061841.log.json) | +| PSPNet + JPU (4x2) | R-50-D32 | 512x1024 | 80000 | 5.67 | 4.40 | 79.26 | 80.86 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes_20210928_053722-57749bed.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes_20210928_053722.log.json) | +| PSPNet + JPU (4x4) | R-50-D32 | 512x1024 | 80000 | 9.94 | - | 78.76 | 80.03 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes_20210925_061841-77e87b0a.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes_20210925_061841.log.json) | | [encnet](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/encnet) | R-50-D8 | 512x1024 | 80000 | 8.6 | 4.58 | 77.94 | 79.13 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/encnet/encnet_r50-d8_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/encnet/encnet_r50-d8_512x1024_80k_cityscapes/encnet_r50-d8_512x1024_80k_cityscapes_20200622_003554-fc5c5624.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/encnet/encnet_r50-d8_512x1024_80k_cityscapes/encnet_r50-d8_512x1024_80k_cityscapes-20200622_003554.log.json) | -| encnet + JPU (4x2)| R-50-D32 | 512x1024 | 80000 | 8.15 | 4.77 | 77.97 |79.92 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes/fastfcn-jpu_enc_512x1024_80k_cityscapes_20210928_030036-f07a8ca0.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes/fastfcn-jpu_enc_512x1024_80k_cityscapes_20210928_030036.log.json) | -| encnet + JPU (4x4)| R-50-D32 | 512x1024 | 80000 | 15.45 | - | 78.6 | 80.25 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes_20210926_093217-47a1e5e6.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes_20210926_093217.log.json) | +| encnet + JPU (4x2)| R-50-D32 | 512x1024 | 80000 | 8.15 | 4.77 | 77.97 |79.92 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes_20210928_030036-78da5046.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes_20210928_030036.log.json) | +| encnet + JPU (4x4)| R-50-D32 | 512x1024 | 80000 | 15.45 | - | 78.6 | 80.25 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes_20210926_093217-e1eb6dbb.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes_20210926_093217.log.json) | diff --git a/configs/fastfcn/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes.py b/configs/fastfcn/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes.py deleted file mode 100644 index 27965b217b..0000000000 --- a/configs/fastfcn/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes.py +++ /dev/null @@ -1,8 +0,0 @@ -_base_ = [ - '../_base_/models/fastfcn_r50-d32.py', '../_base_/datasets/cityscapes.py', - '../_base_/default_runtime.py', '../_base_/schedules/schedule_80k.py' -] -data = dict( - samples_per_gpu=4, - workers_per_gpu=4, -) diff --git a/configs/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes.py b/configs/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes.py deleted file mode 100644 index cca6ba9fbc..0000000000 --- a/configs/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes.py +++ /dev/null @@ -1,4 +0,0 @@ -_base_ = [ - '../_base_/models/fastfcn_r50-d32.py', '../_base_/datasets/cityscapes.py', - '../_base_/default_runtime.py', '../_base_/schedules/schedule_80k.py' -] diff --git a/configs/fastfcn/fastfcn.yml b/configs/fastfcn/fastfcn.yml index 3166a9fcb8..d6a2e8a400 100644 --- a/configs/fastfcn/fastfcn.yml +++ b/configs/fastfcn/fastfcn.yml @@ -35,7 +35,7 @@ Models: mIoU(ms+flip): 80.57 Config: '' Weights: '' -- Name: fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes +- Name: fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes In Collection: fastfcn Metadata: backbone: R-50-D32 @@ -55,9 +55,9 @@ Models: Metrics: mIoU: 79.12 mIoU(ms+flip): 80.58 - Config: configs/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py - Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes_20210928_053722-a1cd65ef.pth -- Name: fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes + Config: configs/fastfcn/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes.py + Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes_20210928_053722-5d1a2648.pth +- Name: fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes In Collection: fastfcn Metadata: backbone: R-50-D32 @@ -70,8 +70,8 @@ Models: Metrics: mIoU: 79.52 mIoU(ms+flip): 80.91 - Config: configs/fastfcn/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes.py - Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes_20210924_214357-662842be.pth + Config: configs/fastfcn/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes.py + Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes_20210924_214357-72220849.pth - Name: '' In Collection: fastfcn Metadata: @@ -94,7 +94,7 @@ Models: mIoU(ms+flip): 79.79 Config: '' Weights: '' -- Name: fastfcn-jpu_psp_512x1024_80k_cityscapes +- Name: fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes In Collection: fastfcn Metadata: backbone: R-50-D32 @@ -114,9 +114,9 @@ Models: Metrics: mIoU: 79.26 mIoU(ms+flip): 80.86 - Config: configs/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes.py - Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_psp_512x1024_80k_cityscapes/fastfcn-jpu_psp_512x1024_80k_cityscapes_20210928_053722-2b76380f.pth -- Name: fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes + Config: configs/fastfcn/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes.py + Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes_20210928_053722-57749bed.pth +- Name: fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes In Collection: fastfcn Metadata: backbone: R-50-D32 @@ -129,8 +129,8 @@ Models: Metrics: mIoU: 78.76 mIoU(ms+flip): 80.03 - Config: configs/fastfcn/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes.py - Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes/fastfcn-jpu_psp_4x4_512x1024_80k_cityscapes_20210925_061841-4a59425c.pth + Config: configs/fastfcn/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes.py + Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes_20210925_061841-77e87b0a.pth - Name: '' In Collection: fastfcn Metadata: @@ -153,7 +153,7 @@ Models: mIoU(ms+flip): 79.13 Config: '' Weights: '' -- Name: fastfcn-jpu_enc_512x1024_80k_cityscapes +- Name: fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes In Collection: fastfcn Metadata: backbone: R-50-D32 @@ -173,9 +173,9 @@ Models: Metrics: mIoU: 77.97 mIoU(ms+flip): 79.92 - Config: configs/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes.py - Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes/fastfcn-jpu_enc_512x1024_80k_cityscapes_20210928_030036-f07a8ca0.pth -- Name: fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes + Config: configs/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes.py + Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes_20210928_030036-78da5046.pth +- Name: fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes In Collection: fastfcn Metadata: backbone: R-50-D32 @@ -188,5 +188,5 @@ Models: Metrics: mIoU: 78.6 mIoU(ms+flip): 80.25 - Config: configs/fastfcn/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes.py - Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes_20210926_093217-47a1e5e6.pth + Config: configs/fastfcn/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes.py + Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes_20210926_093217-e1eb6dbb.pth diff --git a/configs/fastfcn/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes.py b/configs/fastfcn/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes.py similarity index 54% rename from configs/fastfcn/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes.py rename to configs/fastfcn/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes.py index ae670bc63d..87fc274dc5 100644 --- a/configs/fastfcn/fastfcn-jpu_enc_4x4_512x1024_80k_cityscapes.py +++ b/configs/fastfcn/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes.py @@ -1,5 +1,5 @@ # model settings -_base_ = './fastfcn-jpu_enc_512x1024_80k_cityscapes.py' +_base_ = './fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes.py' data = dict( samples_per_gpu=4, workers_per_gpu=4, diff --git a/configs/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py b/configs/fastfcn/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes.py similarity index 89% rename from configs/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py rename to configs/fastfcn/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes.py index 274fc7b045..f163187f3d 100644 --- a/configs/fastfcn/fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py +++ b/configs/fastfcn/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes.py @@ -1,5 +1,5 @@ # model settings -_base_ = './fastfcn-jpu_psp_512x1024_80k_cityscapes.py' +_base_ = './fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes.py' norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( decode_head=dict( diff --git a/configs/fastfcn/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes.py b/configs/fastfcn/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes.py similarity index 54% rename from configs/fastfcn/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes.py rename to configs/fastfcn/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes.py index 31d46c6956..59d294b5f4 100644 --- a/configs/fastfcn/fastfcn-jpu_deeplabv3_4x4_512x1024_80k_cityscapes.py +++ b/configs/fastfcn/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes.py @@ -1,5 +1,5 @@ # model settings -_base_ = './fastfcn-jpu_deeplabv3_512x1024_80k_cityscapes.py' +_base_ = './fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes.py' data = dict( samples_per_gpu=4, workers_per_gpu=4, diff --git a/configs/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes.py b/configs/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes.py similarity index 91% rename from configs/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes.py rename to configs/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes.py index 4b067d5f6b..2ee6b71537 100644 --- a/configs/fastfcn/fastfcn-jpu_enc_512x1024_80k_cityscapes.py +++ b/configs/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes.py @@ -1,5 +1,5 @@ # model settings -_base_ = './fastfcn-jpu_psp_512x1024_80k_cityscapes.py' +_base_ = './fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes.py' norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( decode_head=dict( diff --git a/configs/fastfcn/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes.py b/configs/fastfcn/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes.py new file mode 100644 index 0000000000..5fe5ca16b1 --- /dev/null +++ b/configs/fastfcn/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes.py @@ -0,0 +1,9 @@ +_base_ = [ + '../_base_/models/fastfcn_r50-d32_jpu_psp.py', + '../_base_/datasets/cityscapes.py', '../_base_/default_runtime.py', + '../_base_/schedules/schedule_80k.py' +] +data = dict( + samples_per_gpu=4, + workers_per_gpu=4, +) diff --git a/configs/fastfcn/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes.py b/configs/fastfcn/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes.py new file mode 100644 index 0000000000..e7637fabed --- /dev/null +++ b/configs/fastfcn/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes.py @@ -0,0 +1,5 @@ +_base_ = [ + '../_base_/models/fastfcn_r50-d32_jpu_psp.py', + '../_base_/datasets/cityscapes.py', '../_base_/default_runtime.py', + '../_base_/schedules/schedule_80k.py' +] From 509a83b34cd2d0b2a885900578237f2f03a2e04e Mon Sep 17 00:00:00 2001 From: MengzhangLI Date: Thu, 30 Sep 2021 16:06:27 +0800 Subject: [PATCH 15/21] change README.md --- configs/fastfcn/README.md | 16 +++++---- configs/fastfcn/fastfcn.yml | 66 ------------------------------------- 2 files changed, 9 insertions(+), 73 deletions(-) diff --git a/configs/fastfcn/README.md b/configs/fastfcn/README.md index 86cddc621b..c0672c04c7 100644 --- a/configs/fastfcn/README.md +++ b/configs/fastfcn/README.md @@ -28,12 +28,14 @@ year={2019} | Method | Backbone | Crop Size | Lr schd | Mem (GB) | Inf time (fps) | mIoU | mIoU(ms+flip) | config | download | | --------- | --------- | --------- | ------: | -------- | -------------- | ----: | ------------- | --------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| [DeepLabV3](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/deeplabv3) | R-50-D8 | 512x1024 | 80000 | 6.1 | 2.57 | 79.32 | 80.57 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/deeplabv3/deeplabv3_r50-d8_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/deeplabv3/deeplabv3_r50-d8_512x1024_80k_cityscapes/deeplabv3_r50-d8_512x1024_80k_cityscapes_20200606_113404-b92cfdd4.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/deeplabv3/deeplabv3_r50-d8_512x1024_80k_cityscapes/deeplabv3_r50-d8_512x1024_80k_cityscapes_20200606_113404.log.json) | -| DeepLabV3 + JPU (4x2) | R-50-D32 | 512x1024 | 80000 | 5.67 | 2.64 | 79.12 | 80.58 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes_20210928_053722-5d1a2648.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes_20210928_053722.log.json) | +| DeepLabV3 + JPU | R-50-D32 | 512x1024 | 80000 | 5.67 | 2.64 | 79.12 | 80.58 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes_20210928_053722-5d1a2648.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes_20210928_053722.log.json) | | DeepLabV3 + JPU (4x4) | R-50-D32 | 512x1024 | 80000 | 9.79 | - | 79.52 | 80.91 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes_20210924_214357-72220849.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes_20210924_214357.log.json) | -| [PSPNet](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/pspnet) | R-50-D8 | 512x1024 | 80000 | 6.1 | 4.07 | 78.55 | 79.79 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/pspnet/pspnet_r50-d8_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/pspnet/pspnet_r50-d8_512x1024_80k_cityscapes/pspnet_r50-d8_512x1024_80k_cityscapes_20200606_112131-2376f12b.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/pspnet/pspnet_r50-d8_512x1024_80k_cityscapes/pspnet_r50-d8_512x1024_80k_cityscapes_20200606_112131.log.json) | -| PSPNet + JPU (4x2) | R-50-D32 | 512x1024 | 80000 | 5.67 | 4.40 | 79.26 | 80.86 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes_20210928_053722-57749bed.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes_20210928_053722.log.json) | +| PSPNet + JPU | R-50-D32 | 512x1024 | 80000 | 5.67 | 4.40 | 79.26 | 80.86 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes_20210928_053722-57749bed.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes_20210928_053722.log.json) | | PSPNet + JPU (4x4) | R-50-D32 | 512x1024 | 80000 | 9.94 | - | 78.76 | 80.03 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes_20210925_061841-77e87b0a.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes_20210925_061841.log.json) | -| [encnet](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/encnet) | R-50-D8 | 512x1024 | 80000 | 8.6 | 4.58 | 77.94 | 79.13 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/encnet/encnet_r50-d8_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/encnet/encnet_r50-d8_512x1024_80k_cityscapes/encnet_r50-d8_512x1024_80k_cityscapes_20200622_003554-fc5c5624.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/encnet/encnet_r50-d8_512x1024_80k_cityscapes/encnet_r50-d8_512x1024_80k_cityscapes-20200622_003554.log.json) | -| encnet + JPU (4x2)| R-50-D32 | 512x1024 | 80000 | 8.15 | 4.77 | 77.97 |79.92 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes_20210928_030036-78da5046.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes_20210928_030036.log.json) | -| encnet + JPU (4x4)| R-50-D32 | 512x1024 | 80000 | 15.45 | - | 78.6 | 80.25 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes_20210926_093217-e1eb6dbb.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes_20210926_093217.log.json) | +| ENCNet + JPU | R-50-D32 | 512x1024 | 80000 | 8.15 | 4.77 | 77.97 |79.92 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes_20210928_030036-78da5046.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes_20210928_030036.log.json) | +| ENCNet + JPU (4x4)| R-50-D32 | 512x1024 | 80000 | 15.45 | - | 78.6 | 80.25 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes_20210926_093217-e1eb6dbb.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes_20210926_093217.log.json) | + +Note: + +- `4x4` means 4 GPUs with 4 samples per GPU in training, default setting is 4 GPUs with 2 samples per GPU in training. +- Results of [DeepLabV3 (mIoU: 79.32)](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/deeplabv3), [PSPNet (mIoU: 78.55)](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/pspnet) and [ENCNet (mIoU: 77.94)](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/encnet) can be found in each original repo. diff --git a/configs/fastfcn/fastfcn.yml b/configs/fastfcn/fastfcn.yml index d6a2e8a400..5af2b64a97 100644 --- a/configs/fastfcn/fastfcn.yml +++ b/configs/fastfcn/fastfcn.yml @@ -13,28 +13,6 @@ Collections: Converted From: Code: https://github.com/wuhuikai/FastFCN Models: -- Name: '' - In Collection: fastfcn - Metadata: - backbone: R-50-D8 - crop size: (512,1024) - lr schd: 80000 - inference time (ms/im): - - value: 389.11 - hardware: V100 - backend: PyTorch - batch size: 1 - mode: FP32 - resolution: (512,1024) - memory (GB): 6.1 - Results: - - Task: Semantic Segmentation - Dataset: Cityscapes - Metrics: - mIoU: 79.32 - mIoU(ms+flip): 80.57 - Config: '' - Weights: '' - Name: fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes In Collection: fastfcn Metadata: @@ -72,28 +50,6 @@ Models: mIoU(ms+flip): 80.91 Config: configs/fastfcn/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes.py Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes_20210924_214357-72220849.pth -- Name: '' - In Collection: fastfcn - Metadata: - backbone: R-50-D8 - crop size: (512,1024) - lr schd: 80000 - inference time (ms/im): - - value: 245.7 - hardware: V100 - backend: PyTorch - batch size: 1 - mode: FP32 - resolution: (512,1024) - memory (GB): 6.1 - Results: - - Task: Semantic Segmentation - Dataset: Cityscapes - Metrics: - mIoU: 78.55 - mIoU(ms+flip): 79.79 - Config: '' - Weights: '' - Name: fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes In Collection: fastfcn Metadata: @@ -131,28 +87,6 @@ Models: mIoU(ms+flip): 80.03 Config: configs/fastfcn/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes.py Weights: https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes_20210925_061841-77e87b0a.pth -- Name: '' - In Collection: fastfcn - Metadata: - backbone: R-50-D8 - crop size: (512,1024) - lr schd: 80000 - inference time (ms/im): - - value: 218.34 - hardware: V100 - backend: PyTorch - batch size: 1 - mode: FP32 - resolution: (512,1024) - memory (GB): 8.6 - Results: - - Task: Semantic Segmentation - Dataset: Cityscapes - Metrics: - mIoU: 77.94 - mIoU(ms+flip): 79.13 - Config: '' - Weights: '' - Name: fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes In Collection: fastfcn Metadata: From c4d7507690f77265e1cf5a470cce4f427496bd06 Mon Sep 17 00:00:00 2001 From: MengzhangLI Date: Thu, 30 Sep 2021 21:01:26 +0800 Subject: [PATCH 16/21] use _delete_=True --- configs/_base_/models/fastfcn_r50-d32_jpu_psp.py | 1 + .../fastfcn/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes.py | 1 + .../fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes.py | 1 + 3 files changed, 3 insertions(+) diff --git a/configs/_base_/models/fastfcn_r50-d32_jpu_psp.py b/configs/_base_/models/fastfcn_r50-d32_jpu_psp.py index f4c43afb60..d3566b46fb 100644 --- a/configs/_base_/models/fastfcn_r50-d32_jpu_psp.py +++ b/configs/_base_/models/fastfcn_r50-d32_jpu_psp.py @@ -28,6 +28,7 @@ in_channels=2048, in_index=2, channels=512, + pool_scales=(1, 2, 3, 6), dropout_ratio=0.1, num_classes=19, norm_cfg=norm_cfg, diff --git a/configs/fastfcn/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes.py b/configs/fastfcn/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes.py index f163187f3d..dc86da3b6f 100644 --- a/configs/fastfcn/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes.py +++ b/configs/fastfcn/fastfcn_r50-d32_jpu_aspp_512x1024_80k_cityscapes.py @@ -3,6 +3,7 @@ norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( decode_head=dict( + _delete_=True, type='ASPPHead', in_channels=2048, in_index=2, diff --git a/configs/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes.py b/configs/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes.py index 2ee6b71537..cc68edfe5b 100644 --- a/configs/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes.py +++ b/configs/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes.py @@ -3,6 +3,7 @@ norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( decode_head=dict( + _delete_=True, type='EncHead', in_channels=[512, 1024, 2048], in_index=(0, 1, 2), From 30ec997e29918a5442d2f8bbb154d00a1e07469a Mon Sep 17 00:00:00 2001 From: MengzhangLI Date: Thu, 30 Sep 2021 21:36:10 +0800 Subject: [PATCH 17/21] change configs --- configs/fastfcn/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configs/fastfcn/README.md b/configs/fastfcn/README.md index c0672c04c7..78ea667d76 100644 --- a/configs/fastfcn/README.md +++ b/configs/fastfcn/README.md @@ -32,8 +32,8 @@ year={2019} | DeepLabV3 + JPU (4x4) | R-50-D32 | 512x1024 | 80000 | 9.79 | - | 79.52 | 80.91 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes_20210924_214357-72220849.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_aspp_4x4_512x1024_80k_cityscapes_20210924_214357.log.json) | | PSPNet + JPU | R-50-D32 | 512x1024 | 80000 | 5.67 | 4.40 | 79.26 | 80.86 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes_20210928_053722-57749bed.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_psp_512x1024_80k_cityscapes_20210928_053722.log.json) | | PSPNet + JPU (4x4) | R-50-D32 | 512x1024 | 80000 | 9.94 | - | 78.76 | 80.03 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes_20210925_061841-77e87b0a.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_psp_4x4_512x1024_80k_cityscapes_20210925_061841.log.json) | -| ENCNet + JPU | R-50-D32 | 512x1024 | 80000 | 8.15 | 4.77 | 77.97 |79.92 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes_20210928_030036-78da5046.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes_20210928_030036.log.json) | -| ENCNet + JPU (4x4)| R-50-D32 | 512x1024 | 80000 | 15.45 | - | 78.6 | 80.25 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes_20210926_093217-e1eb6dbb.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes_20210926_093217.log.json) | +| EncNet + JPU | R-50-D32 | 512x1024 | 80000 | 8.15 | 4.77 | 77.97 |79.92 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes_20210928_030036-78da5046.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_enc_512x1024_80k_cityscapes_20210928_030036.log.json) | +| EncNet + JPU (4x4)| R-50-D32 | 512x1024 | 80000 | 15.45 | - | 78.6 | 80.25 | [config](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastfcn/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes.py) | [model](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes_20210926_093217-e1eb6dbb.pth) | [log](https://download.openmmlab.com/mmsegmentation/v0.5/fastfcn/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes/fastfcn_r50-d32_jpu_enc_4x4_512x1024_80k_cityscapes_20210926_093217.log.json) | Note: From c8d1757348d9e5e6deb1b049558cda1f8c45fe3a Mon Sep 17 00:00:00 2001 From: MengzhangLI Date: Thu, 30 Sep 2021 23:12:04 +0800 Subject: [PATCH 18/21] change start_level to 0 --- configs/_base_/models/fastfcn_r50-d32_jpu_psp.py | 2 +- mmseg/models/necks/jpu.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/configs/_base_/models/fastfcn_r50-d32_jpu_psp.py b/configs/_base_/models/fastfcn_r50-d32_jpu_psp.py index d3566b46fb..9dc8609aeb 100644 --- a/configs/_base_/models/fastfcn_r50-d32_jpu_psp.py +++ b/configs/_base_/models/fastfcn_r50-d32_jpu_psp.py @@ -18,7 +18,7 @@ type='JPU', in_channels=(512, 1024, 2048), mid_channels=512, - start_level=1, + start_level=0, end_level=-1, dilations=(1, 2, 4, 8), align_corners=False, diff --git a/mmseg/models/necks/jpu.py b/mmseg/models/necks/jpu.py index 51689fd30c..36b6980e90 100644 --- a/mmseg/models/necks/jpu.py +++ b/mmseg/models/necks/jpu.py @@ -69,7 +69,7 @@ def __init__(self, self.conv_layers = nn.ModuleList() self.dilation_layers = nn.ModuleList() - for i in range(len(in_channels)): + for i in range(self.start_level, len(in_channels)): conv_layer = nn.Sequential( ConvModule( self.in_channels[i], From a83111c59f8f2ab9eb4bdf07b376e02728a5e538 Mon Sep 17 00:00:00 2001 From: MengzhangLI Date: Thu, 30 Sep 2021 23:16:11 +0800 Subject: [PATCH 19/21] change start_level to 0 --- configs/fastfcn/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configs/fastfcn/README.md b/configs/fastfcn/README.md index 78ea667d76..768502b05f 100644 --- a/configs/fastfcn/README.md +++ b/configs/fastfcn/README.md @@ -38,4 +38,4 @@ year={2019} Note: - `4x4` means 4 GPUs with 4 samples per GPU in training, default setting is 4 GPUs with 2 samples per GPU in training. -- Results of [DeepLabV3 (mIoU: 79.32)](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/deeplabv3), [PSPNet (mIoU: 78.55)](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/pspnet) and [ENCNet (mIoU: 77.94)](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/encnet) can be found in each original repo. +- Results of [DeepLabV3 (mIoU: 79.32)](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/deeplabv3), [PSPNet (mIoU: 78.55)](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/pspnet) and [ENCNet (mIoU: 77.94)](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/encnet) can be found in each original repository. From 59eaceb8a5c6f4139b166bfcf7c39f4757669abb Mon Sep 17 00:00:00 2001 From: MengzhangLI Date: Fri, 1 Oct 2021 00:33:31 +0800 Subject: [PATCH 20/21] jpu --- mmseg/models/necks/jpu.py | 6 +++--- tests/test_models/test_necks/test_jpu.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/mmseg/models/necks/jpu.py b/mmseg/models/necks/jpu.py index 36b6980e90..4025087642 100644 --- a/mmseg/models/necks/jpu.py +++ b/mmseg/models/necks/jpu.py @@ -69,7 +69,7 @@ def __init__(self, self.conv_layers = nn.ModuleList() self.dilation_layers = nn.ModuleList() - for i in range(self.start_level, len(in_channels)): + for i in range(self.start_level, self.backbone_end_level): conv_layer = nn.Sequential( ConvModule( self.in_channels[i], @@ -100,7 +100,7 @@ def forward(self, inputs): assert len(inputs) == len(self.in_channels), 'Length of inputs must \ be the same with self.in_channels!' - feats = [self.conv_layers[i](inputs[i]) for i in range(len(inputs))] + feats = [self.conv_layers[i - self.start_level](inputs[i]) for i in range(self.start_level, self.backbone_end_level)] h, w = feats[0].shape[2:] for i in range(1, len(feats)): @@ -121,7 +121,7 @@ def forward(self, inputs): # Default: outs[2] is the output of JPU for decoder head, outs[1] is # the feature map from backbone for auxiliary head. Additionally, # outs[0] can also be used for auxiliary head. - for i in range(len(inputs) - 1): + for i in range(self.start_level, self.backbone_end_level - 1): outs.append(inputs[i]) outs.append(concat_feat) return tuple(outs) diff --git a/tests/test_models/test_necks/test_jpu.py b/tests/test_models/test_necks/test_jpu.py index f0a0903d9f..221a91d1a0 100644 --- a/tests/test_models/test_necks/test_jpu.py +++ b/tests/test_models/test_necks/test_jpu.py @@ -26,3 +26,17 @@ def test_fastfcn_neck(): with pytest.raises(AssertionError): # FastFCN input and in_channels constraints. JPU(in_channels=(256, 512, 1024), start_level=0, end_level=5) + + # Test not default start_level + model = JPU( + in_channels=(512, 1024, 2048), + start_level=1, + end_level=-1) + input = [ + torch.randn(batch_size, 512, 64, 128), + torch.randn(batch_size, 1024, 32, 64), + torch.randn(batch_size, 2048, 16, 32) + ] + feat = model(input) + assert len(feat) == 2 + From 05f4d07c37c6d1c823acf7041ad86749f8533946 Mon Sep 17 00:00:00 2001 From: MengzhangLI Date: Fri, 1 Oct 2021 01:38:09 +0800 Subject: [PATCH 21/21] add unittest for start_level!=0 --- mmseg/models/necks/jpu.py | 8 ++++++-- tests/test_models/test_necks/test_jpu.py | 8 +++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/mmseg/models/necks/jpu.py b/mmseg/models/necks/jpu.py index 4025087642..3cc6b9f428 100644 --- a/mmseg/models/necks/jpu.py +++ b/mmseg/models/necks/jpu.py @@ -83,7 +83,8 @@ def __init__(self, for i in range(len(dilations)): dilation_layer = nn.Sequential( DepthwiseSeparableConvModule( - in_channels=len(in_channels) * self.mid_channels, + in_channels=(self.backbone_end_level - self.start_level) * + self.mid_channels, out_channels=self.mid_channels, kernel_size=3, stride=1, @@ -100,7 +101,10 @@ def forward(self, inputs): assert len(inputs) == len(self.in_channels), 'Length of inputs must \ be the same with self.in_channels!' - feats = [self.conv_layers[i - self.start_level](inputs[i]) for i in range(self.start_level, self.backbone_end_level)] + feats = [ + self.conv_layers[i - self.start_level](inputs[i]) + for i in range(self.start_level, self.backbone_end_level) + ] h, w = feats[0].shape[2:] for i in range(1, len(feats)): diff --git a/tests/test_models/test_necks/test_jpu.py b/tests/test_models/test_necks/test_jpu.py index 221a91d1a0..88637044c6 100644 --- a/tests/test_models/test_necks/test_jpu.py +++ b/tests/test_models/test_necks/test_jpu.py @@ -28,10 +28,7 @@ def test_fastfcn_neck(): JPU(in_channels=(256, 512, 1024), start_level=0, end_level=5) # Test not default start_level - model = JPU( - in_channels=(512, 1024, 2048), - start_level=1, - end_level=-1) + model = JPU(in_channels=(512, 1024, 2048), start_level=1, end_level=-1) input = [ torch.randn(batch_size, 512, 64, 128), torch.randn(batch_size, 1024, 32, 64), @@ -39,4 +36,5 @@ def test_fastfcn_neck(): ] feat = model(input) assert len(feat) == 2 - + assert feat[0].shape == torch.Size([batch_size, 1024, 32, 64]) + assert feat[1].shape == torch.Size([batch_size, 2048, 32, 64])