Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define blood vessel dataset and fix filename bug #203

Merged
merged 5 commits into from Oct 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion mmseg/datasets/__init__.py
@@ -1,13 +1,18 @@
from .ade import ADE20KDataset
from .builder import DATASETS, PIPELINES, build_dataloader, build_dataset
from .chase_db1 import ChaseDB1Dataset
from .cityscapes import CityscapesDataset
from .custom import CustomDataset
from .dataset_wrappers import ConcatDataset, RepeatDataset
from .drive import DRIVEDataset
from .hrf import HRFDataset
from .pascal_context import PascalContextDataset
from .stare import STAREDataset
from .voc import PascalVOCDataset

__all__ = [
'CustomDataset', 'build_dataloader', 'ConcatDataset', 'RepeatDataset',
'DATASETS', 'build_dataset', 'PIPELINES', 'CityscapesDataset',
'PascalVOCDataset', 'ADE20KDataset', 'PascalContextDataset'
'PascalVOCDataset', 'ADE20KDataset', 'PascalContextDataset',
'ChaseDB1Dataset', 'DRIVEDataset', 'HRFDataset', 'STAREDataset'
]
27 changes: 27 additions & 0 deletions mmseg/datasets/chase_db1.py
@@ -0,0 +1,27 @@
import os.path as osp

from .builder import DATASETS
from .custom import CustomDataset


@DATASETS.register_module()
class ChaseDB1Dataset(CustomDataset):
"""Chase_db1 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 '.jpg' and ``seg_map_suffix`` is fixed to
'_1stHO.jpg'.
"""

CLASSES = ('background', 'vessel')

PALETTE = [[120, 120, 120], [6, 230, 230]]

def __init__(self, **kwargs):
super(ChaseDB1Dataset, self).__init__(
img_suffix='.jpg',
seg_map_suffix='_1stHO.jpg',
reduce_zero_label=False,
**kwargs)
assert osp.exists(self.img_dir)
27 changes: 27 additions & 0 deletions mmseg/datasets/drive.py
@@ -0,0 +1,27 @@
import os.path as osp

from .builder import DATASETS
from .custom import CustomDataset


@DATASETS.register_module()
class DRIVEDataset(CustomDataset):
"""DRIVE dataset.

In segmentation map annotation for DRIVE, 0 stands for background, which is
included in 2 categories. ``reduce_zero_label`` is fixed to False. The
``img_suffix`` is fixed to '.jpg' and ``seg_map_suffix`` is fixed to
'_manual1.jpg'.
"""

CLASSES = ('background', 'vessel')

PALETTE = [[120, 120, 120], [6, 230, 230]]

def __init__(self, **kwargs):
super(DRIVEDataset, self).__init__(
img_suffix='.jpg',
seg_map_suffix='_manual1.jpg',
reduce_zero_label=False,
**kwargs)
assert osp.exists(self.img_dir)
27 changes: 27 additions & 0 deletions mmseg/datasets/hrf.py
@@ -0,0 +1,27 @@
import os.path as osp

from .builder import DATASETS
from .custom import CustomDataset


@DATASETS.register_module()
class HRFDataset(CustomDataset):
"""HRF dataset.

In segmentation map annotation for HRF, 0 stands for background, which is
included in 2 categories. ``reduce_zero_label`` is fixed to False. The
``img_suffix`` is fixed to '.jpg' and ``seg_map_suffix`` is fixed to
'.jpg'.
"""

CLASSES = ('background', 'vessel')

PALETTE = [[120, 120, 120], [6, 230, 230]]

def __init__(self, **kwargs):
super(HRFDataset, self).__init__(
img_suffix='.jpg',
seg_map_suffix='.jpg',
reduce_zero_label=False,
**kwargs)
assert osp.exists(self.img_dir)
27 changes: 27 additions & 0 deletions mmseg/datasets/stare.py
@@ -0,0 +1,27 @@
import os.path as osp

from .builder import DATASETS
from .custom import CustomDataset


@DATASETS.register_module()
class STAREDataset(CustomDataset):
"""STARE dataset.

In segmentation map annotation for STARE, 0 stands for background, which is
included in 2 categories. ``reduce_zero_label`` is fixed to False. The
``img_suffix`` is fixed to '.jpg' and ``seg_map_suffix`` is fixed to
'.ah.jpg'.
"""

CLASSES = ('background', 'vessel')

PALETTE = [[120, 120, 120], [6, 230, 230]]

def __init__(self, **kwargs):
super(STAREDataset, self).__init__(
img_suffix='.jpg',
seg_map_suffix='.ah.jpg',
reduce_zero_label=False,
**kwargs)
assert osp.exists(self.img_dir)
11 changes: 7 additions & 4 deletions tools/convert_datasets/drive.py
Expand Up @@ -50,8 +50,10 @@ def main():
img = mmcv.imread(osp.join(now_dir, img_name))
mmcv.imwrite(
img,
osp.join(out_dir, 'images', 'training',
osp.splitext(img_name)[0] + '.jpg'))
osp.join(
out_dir, 'images', 'training',
osp.splitext(img_name)[0].replace('_training', '') +
'.jpg'))

now_dir = osp.join(tmp_dir, 'training', '1st_manual')
for img_name in os.listdir(now_dir):
Expand All @@ -72,8 +74,9 @@ def main():
img = mmcv.imread(osp.join(now_dir, img_name))
mmcv.imwrite(
img,
osp.join(out_dir, 'images', 'validation',
osp.splitext(img_name)[0] + '.jpg'))
osp.join(
out_dir, 'images', 'validation',
osp.splitext(img_name)[0].replace('_test', '') + '.jpg'))

now_dir = osp.join(tmp_dir, 'test', '1st_manual')
if osp.exists(now_dir):
Expand Down