Skip to content

Commit 3bdc276

Browse files
yamengxiyamengxi
andauthored
Define blood vessel dataset and fix filename bug (open-mmlab#203)
* fix filename bug * define blood vessel dataset * redo debug * fix small bug * rename dataset Co-authored-by: yamengxi <[email protected]>
1 parent 651da35 commit 3bdc276

File tree

6 files changed

+121
-5
lines changed

6 files changed

+121
-5
lines changed

mmseg/datasets/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
from .ade import ADE20KDataset
22
from .builder import DATASETS, PIPELINES, build_dataloader, build_dataset
3+
from .chase_db1 import ChaseDB1Dataset
34
from .cityscapes import CityscapesDataset
45
from .custom import CustomDataset
56
from .dataset_wrappers import ConcatDataset, RepeatDataset
7+
from .drive import DRIVEDataset
8+
from .hrf import HRFDataset
69
from .pascal_context import PascalContextDataset
10+
from .stare import STAREDataset
711
from .voc import PascalVOCDataset
812

913
__all__ = [
1014
'CustomDataset', 'build_dataloader', 'ConcatDataset', 'RepeatDataset',
1115
'DATASETS', 'build_dataset', 'PIPELINES', 'CityscapesDataset',
12-
'PascalVOCDataset', 'ADE20KDataset', 'PascalContextDataset'
16+
'PascalVOCDataset', 'ADE20KDataset', 'PascalContextDataset',
17+
'ChaseDB1Dataset', 'DRIVEDataset', 'HRFDataset', 'STAREDataset'
1318
]

mmseg/datasets/chase_db1.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import os.path as osp
2+
3+
from .builder import DATASETS
4+
from .custom import CustomDataset
5+
6+
7+
@DATASETS.register_module()
8+
class ChaseDB1Dataset(CustomDataset):
9+
"""Chase_db1 dataset.
10+
11+
In segmentation map annotation for Chase_db1, 0 stands for background,
12+
which is included in 2 categories. ``reduce_zero_label`` is fixed to False.
13+
The ``img_suffix`` is fixed to '.jpg' and ``seg_map_suffix`` is fixed to
14+
'_1stHO.jpg'.
15+
"""
16+
17+
CLASSES = ('background', 'vessel')
18+
19+
PALETTE = [[120, 120, 120], [6, 230, 230]]
20+
21+
def __init__(self, **kwargs):
22+
super(ChaseDB1Dataset, self).__init__(
23+
img_suffix='.jpg',
24+
seg_map_suffix='_1stHO.jpg',
25+
reduce_zero_label=False,
26+
**kwargs)
27+
assert osp.exists(self.img_dir)

mmseg/datasets/drive.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import os.path as osp
2+
3+
from .builder import DATASETS
4+
from .custom import CustomDataset
5+
6+
7+
@DATASETS.register_module()
8+
class DRIVEDataset(CustomDataset):
9+
"""DRIVE dataset.
10+
11+
In segmentation map annotation for DRIVE, 0 stands for background, which is
12+
included in 2 categories. ``reduce_zero_label`` is fixed to False. The
13+
``img_suffix`` is fixed to '.jpg' and ``seg_map_suffix`` is fixed to
14+
'_manual1.jpg'.
15+
"""
16+
17+
CLASSES = ('background', 'vessel')
18+
19+
PALETTE = [[120, 120, 120], [6, 230, 230]]
20+
21+
def __init__(self, **kwargs):
22+
super(DRIVEDataset, self).__init__(
23+
img_suffix='.jpg',
24+
seg_map_suffix='_manual1.jpg',
25+
reduce_zero_label=False,
26+
**kwargs)
27+
assert osp.exists(self.img_dir)

mmseg/datasets/hrf.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import os.path as osp
2+
3+
from .builder import DATASETS
4+
from .custom import CustomDataset
5+
6+
7+
@DATASETS.register_module()
8+
class HRFDataset(CustomDataset):
9+
"""HRF dataset.
10+
11+
In segmentation map annotation for HRF, 0 stands for background, which is
12+
included in 2 categories. ``reduce_zero_label`` is fixed to False. The
13+
``img_suffix`` is fixed to '.jpg' and ``seg_map_suffix`` is fixed to
14+
'.jpg'.
15+
"""
16+
17+
CLASSES = ('background', 'vessel')
18+
19+
PALETTE = [[120, 120, 120], [6, 230, 230]]
20+
21+
def __init__(self, **kwargs):
22+
super(HRFDataset, self).__init__(
23+
img_suffix='.jpg',
24+
seg_map_suffix='.jpg',
25+
reduce_zero_label=False,
26+
**kwargs)
27+
assert osp.exists(self.img_dir)

mmseg/datasets/stare.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import os.path as osp
2+
3+
from .builder import DATASETS
4+
from .custom import CustomDataset
5+
6+
7+
@DATASETS.register_module()
8+
class STAREDataset(CustomDataset):
9+
"""STARE dataset.
10+
11+
In segmentation map annotation for STARE, 0 stands for background, which is
12+
included in 2 categories. ``reduce_zero_label`` is fixed to False. The
13+
``img_suffix`` is fixed to '.jpg' and ``seg_map_suffix`` is fixed to
14+
'.ah.jpg'.
15+
"""
16+
17+
CLASSES = ('background', 'vessel')
18+
19+
PALETTE = [[120, 120, 120], [6, 230, 230]]
20+
21+
def __init__(self, **kwargs):
22+
super(STAREDataset, self).__init__(
23+
img_suffix='.jpg',
24+
seg_map_suffix='.ah.jpg',
25+
reduce_zero_label=False,
26+
**kwargs)
27+
assert osp.exists(self.img_dir)

tools/convert_datasets/drive.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ def main():
5050
img = mmcv.imread(osp.join(now_dir, img_name))
5151
mmcv.imwrite(
5252
img,
53-
osp.join(out_dir, 'images', 'training',
54-
osp.splitext(img_name)[0] + '.jpg'))
53+
osp.join(
54+
out_dir, 'images', 'training',
55+
osp.splitext(img_name)[0].replace('_training', '') +
56+
'.jpg'))
5557

5658
now_dir = osp.join(tmp_dir, 'training', '1st_manual')
5759
for img_name in os.listdir(now_dir):
@@ -72,8 +74,9 @@ def main():
7274
img = mmcv.imread(osp.join(now_dir, img_name))
7375
mmcv.imwrite(
7476
img,
75-
osp.join(out_dir, 'images', 'validation',
76-
osp.splitext(img_name)[0] + '.jpg'))
77+
osp.join(
78+
out_dir, 'images', 'validation',
79+
osp.splitext(img_name)[0].replace('_test', '') + '.jpg'))
7780

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

0 commit comments

Comments
 (0)