Skip to content
59 changes: 59 additions & 0 deletions configs/_base_/datasets/waterpuddles.py
Original file line number Diff line number Diff line change
@@ -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))
10 changes: 5 additions & 5 deletions configs/_base_/models/bisenetv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions configs/_base_/schedules/schedule_40k.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
@@ -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
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too many comment paragraphs. Just keep L4-L9.

16 changes: 8 additions & 8 deletions mmseg/core/evaluation/class_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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]]


Expand All @@ -278,7 +278,7 @@ def stare_palette():
'coco_stuff164k'
],
'isaid': ['isaid', 'iSAID'],
'stare': ['stare', 'STARE']
'waterpuddles': ['waterpuddles', 'waterpuddle']
}


Expand Down
27 changes: 27 additions & 0 deletions mmseg/datasets/waterpuddles.py
Original file line number Diff line number Diff line change
@@ -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)