diff --git a/configs/_base_/datasets/waterpuddles.py b/configs/_base_/datasets/waterpuddles.py new file mode 100644 index 0000000000..7828a5b465 --- /dev/null +++ b/configs/_base_/datasets/waterpuddles.py @@ -0,0 +1,59 @@ +# dataset settings +dataset_type = 'waterpuddlesDataset' +data_root = 'data/puddle-1000_chasedb_NEW' +img_norm_cfg = dict( + mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=False) +img_scale = (360, 640) +crop_size = (128, 128) +train_pipeline = [ + dict(type='LoadImageFromFile'), + dict(type='LoadAnnotations'), + dict(type='Resize', img_scale=img_scale, ratio_range=(0.5, 2.0)), + dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75), + dict(type='RandomFlip', prob=0.5), + dict(type='PhotoMetricDistortion'), + dict(type='Normalize', **img_norm_cfg), + dict(type='Pad', size=crop_size, pad_val=0, seg_pad_val=255), + dict(type='DefaultFormatBundle'), + dict(type='Collect', keys=['img', 'gt_semantic_seg']) +] +test_pipeline = [ + dict(type='LoadImageFromFile'), + dict( + type='MultiScaleFlipAug', + img_scale=img_scale, + # img_ratios=[0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0], + flip=False, + transforms=[ + dict(type='Resize', keep_ratio=True), + dict(type='RandomFlip'), + dict(type='Normalize', **img_norm_cfg), + dict(type='ImageToTensor', keys=['img']), + dict(type='Collect', keys=['img']) + ]) +] + +data = dict( + samples_per_gpu=4, + workers_per_gpu=4, + train=dict( + type='RepeatDataset', + times=40000, + dataset=dict( + type=dataset_type, + data_root=data_root, + img_dir='images/training', + ann_dir='annotations/training', + pipeline=train_pipeline)), + val=dict( + type=dataset_type, + data_root=data_root, + img_dir='images/validation', + ann_dir='annotations/validation', + pipeline=test_pipeline), + test=dict( + type=dataset_type, + data_root=data_root, + img_dir='images/validation', + ann_dir='annotations/validation', + pipeline=test_pipeline)) diff --git a/configs/_base_/models/bisenetv2.py b/configs/_base_/models/bisenetv2.py index f8fffeecad..e244ba0414 100644 --- a/configs/_base_/models/bisenetv2.py +++ b/configs/_base_/models/bisenetv2.py @@ -20,7 +20,7 @@ num_convs=1, concat_input=False, dropout_ratio=0.1, - num_classes=19, + num_classes=2, norm_cfg=norm_cfg, align_corners=False, loss_decode=dict( @@ -31,7 +31,7 @@ in_channels=16, channels=16, num_convs=2, - num_classes=19, + num_classes=2, in_index=1, norm_cfg=norm_cfg, concat_input=False, @@ -43,7 +43,7 @@ in_channels=32, channels=64, num_convs=2, - num_classes=19, + num_classes=2, in_index=2, norm_cfg=norm_cfg, concat_input=False, @@ -55,7 +55,7 @@ in_channels=64, channels=256, num_convs=2, - num_classes=19, + num_classes=2, in_index=3, norm_cfg=norm_cfg, concat_input=False, @@ -67,7 +67,7 @@ in_channels=128, channels=1024, num_convs=2, - num_classes=19, + num_classes=2, in_index=4, norm_cfg=norm_cfg, concat_input=False, diff --git a/configs/_base_/schedules/schedule_40k.py b/configs/_base_/schedules/schedule_40k.py index d2c5023259..251142f484 100644 --- a/configs/_base_/schedules/schedule_40k.py +++ b/configs/_base_/schedules/schedule_40k.py @@ -5,5 +5,5 @@ lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False) # runtime settings runner = dict(type='IterBasedRunner', max_iters=40000) -checkpoint_config = dict(by_epoch=False, interval=4000) -evaluation = dict(interval=4000, metric='mIoU', pre_eval=True) +checkpoint_config = dict(by_epoch=False, interval=2000) +evaluation = dict(interval=2000, metric='mIoU', pre_eval=True) diff --git a/configs/bisenetv2/bisenetv2_fcn_4x4_512x512_40k_waterpuddles.py b/configs/bisenetv2/bisenetv2_fcn_4x4_512x512_40k_waterpuddles.py new file mode 100644 index 0000000000..2e3be52d0b --- /dev/null +++ b/configs/bisenetv2/bisenetv2_fcn_4x4_512x512_40k_waterpuddles.py @@ -0,0 +1,6 @@ +_base_ = [ + '../_base_/models/bisenetv2.py', # model settings + '../_base_/datasets/waterpuddles.py', # dataset settings + '../_base_/schedules/schedule_40k.py', # scheduler settings + '../_base_/default_runtime.py' # other runtime settings +] diff --git a/mmseg/core/evaluation/class_names.py b/mmseg/core/evaluation/class_names.py index e3bff62314..e2e93698b8 100644 --- a/mmseg/core/evaluation/class_names.py +++ b/mmseg/core/evaluation/class_names.py @@ -120,10 +120,11 @@ def isaid_classes(): 'Soccer_ball_field', 'plane', 'Harbor' ] - -def stare_classes(): - """stare class names for external use.""" - return ['background', 'vessel'] +def waterpuddles_classes(): + """waterpuddles class names for external use.""" + return [ + 'background', 'waterpuddle' + ] def cityscapes_palette(): @@ -259,9 +260,8 @@ def isaid_palette(): [0, 0, 191], [0, 0, 255], [0, 191, 127], [0, 127, 191], [0, 127, 255], [0, 100, 155]] - -def stare_palette(): - """STARE palette for external use.""" +def waterpuddles_palette(): + """waterpuddles palette for external use.""" return [[120, 120, 120], [6, 230, 230]] @@ -278,7 +278,7 @@ def stare_palette(): 'coco_stuff164k' ], 'isaid': ['isaid', 'iSAID'], - 'stare': ['stare', 'STARE'] + 'waterpuddles': ['waterpuddles', 'waterpuddle'] } diff --git a/mmseg/datasets/waterpuddles.py b/mmseg/datasets/waterpuddles.py new file mode 100644 index 0000000000..813974cb18 --- /dev/null +++ b/mmseg/datasets/waterpuddles.py @@ -0,0 +1,27 @@ +import os.path as osp + +from .builder import DATASETS +from .custom import CustomDataset + + +@DATASETS.register_module() +class waterpuddlesDataset(CustomDataset): + """water puddles dataset. + + In segmentation map annotation for Chase_db1, 0 stands for background, + which is included in 2 categories. ``reduce_zero_label`` is fixed to False. + The ``img_suffix`` is fixed to '_img.png' and ``seg_map_suffix`` is fixed to + '_anno.png'. + """ + + CLASSES = ('background','waterpuddle') + + PALETTE = [[120, 120, 120], [6, 230, 230]] + + def __init__(self, **kwargs): + super(waterpuddlesDataset, self).__init__( + img_suffix='.png', + seg_map_suffix='.png', + reduce_zero_label=False, + **kwargs) + assert osp.exists(self.img_dir)