Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions demo/MMSegmentation_Tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,10 @@
"outputs": [],
"source": [
"from mmseg.datasets.builder import DATASETS\n",
"from mmseg.datasets.custom import CustomDataset\n",
"from mmseg.datasets.custom import BaseSegDataset\n",
"\n",
"@DATASETS.register_module()\n",
"class StanfordBackgroundDataset(CustomDataset):\n",
"class StanfordBackgroundDataset(BaseSegDataset):\n",
" CLASSES = classes\n",
" PALETTE = palette\n",
" def __init__(self, split, **kwargs):\n",
Expand Down
4 changes: 2 additions & 2 deletions mmseg/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .chase_db1 import ChaseDB1Dataset
from .cityscapes import CityscapesDataset
from .coco_stuff import COCOStuffDataset
from .custom import CustomDataset
from .custom import BaseSegDataset
from .dark_zurich import DarkZurichDataset
from .dataset_wrappers import MultiImageMixDataset
from .drive import DRIVEDataset
Expand All @@ -22,7 +22,7 @@
from .voc import PascalVOCDataset

__all__ = [
'CustomDataset', 'CityscapesDataset', 'PascalVOCDataset', 'ADE20KDataset',
'BaseSegDataset', 'CityscapesDataset', 'PascalVOCDataset', 'ADE20KDataset',
'PascalContextDataset', 'PascalContextDataset59', 'ChaseDB1Dataset',
'DRIVEDataset', 'HRFDataset', 'STAREDataset', 'DarkZurichDataset',
'NightDrivingDataset', 'COCOStuffDataset', 'LoveDADataset',
Expand Down
4 changes: 2 additions & 2 deletions mmseg/datasets/ade.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Copyright (c) OpenMMLab. All rights reserved.
from mmseg.registry import DATASETS
from .custom import CustomDataset
from .custom import BaseSegDataset


@DATASETS.register_module()
class ADE20KDataset(CustomDataset):
class ADE20KDataset(BaseSegDataset):
"""ADE20K dataset.

In segmentation map annotation for ADE20K, 0 stands for background, which
Expand Down
4 changes: 2 additions & 2 deletions mmseg/datasets/chase_db1.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright (c) OpenMMLab. All rights reserved.

from mmseg.registry import DATASETS
from .custom import CustomDataset
from .custom import BaseSegDataset


@DATASETS.register_module()
class ChaseDB1Dataset(CustomDataset):
class ChaseDB1Dataset(BaseSegDataset):
"""Chase_db1 dataset.

In segmentation map annotation for Chase_db1, 0 stands for background,
Expand Down
4 changes: 2 additions & 2 deletions mmseg/datasets/cityscapes.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Copyright (c) OpenMMLab. All rights reserved.
from mmseg.registry import DATASETS
from .custom import CustomDataset
from .custom import BaseSegDataset


@DATASETS.register_module()
class CityscapesDataset(CustomDataset):
class CityscapesDataset(BaseSegDataset):
"""Cityscapes dataset.

The ``img_suffix`` is fixed to '_leftImg8bit.png' and ``seg_map_suffix`` is
Expand Down
4 changes: 2 additions & 2 deletions mmseg/datasets/coco_stuff.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Copyright (c) OpenMMLab. All rights reserved.
from mmseg.registry import DATASETS
from .custom import CustomDataset
from .custom import BaseSegDataset


@DATASETS.register_module()
class COCOStuffDataset(CustomDataset):
class COCOStuffDataset(BaseSegDataset):
"""COCO-Stuff dataset.

In segmentation map annotation for COCO-Stuff, Train-IDs of the 10k version
Expand Down
4 changes: 2 additions & 2 deletions mmseg/datasets/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


@DATASETS.register_module()
class CustomDataset(BaseDataset):
class BaseSegDataset(BaseDataset):
"""Custom dataset for semantic segmentation. An example of file structure
is as followed.

Expand All @@ -32,7 +32,7 @@ class CustomDataset(BaseDataset):
│ │ │ │ ├── zzz{seg_map_suffix}
│ │ │ ├── val

The img/gt_semantic_seg pair of CustomDataset should be of the same
The img/gt_semantic_seg pair of BaseSegDataset should be of the same
except suffix. A valid img/gt_semantic_seg filename pair should be like
``xxx{img_suffix}`` and ``xxx{seg_map_suffix}`` (extension is also included
in the suffix). If split is given, then ``xxx`` is specified in txt file.
Expand Down
4 changes: 2 additions & 2 deletions mmseg/datasets/drive.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright (c) OpenMMLab. All rights reserved.

from mmseg.registry import DATASETS
from .custom import CustomDataset
from .custom import BaseSegDataset


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

In segmentation map annotation for DRIVE, 0 stands for background, which is
Expand Down
4 changes: 2 additions & 2 deletions mmseg/datasets/hrf.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright (c) OpenMMLab. All rights reserved.

from mmseg.registry import DATASETS
from .custom import CustomDataset
from .custom import BaseSegDataset


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

In segmentation map annotation for HRF, 0 stands for background, which is
Expand Down
4 changes: 2 additions & 2 deletions mmseg/datasets/isaid.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Copyright (c) OpenMMLab. All rights reserved.
from mmseg.registry import DATASETS
from .custom import CustomDataset
from .custom import BaseSegDataset


@DATASETS.register_module()
class iSAIDDataset(CustomDataset):
class iSAIDDataset(BaseSegDataset):
""" iSAID: A Large-scale Dataset for Instance Segmentation in Aerial Images
In segmentation map annotation for iSAID dataset, which is included
in 16 categories. ``reduce_zero_label`` is fixed to False. The
Expand Down
4 changes: 2 additions & 2 deletions mmseg/datasets/isprs.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Copyright (c) OpenMMLab. All rights reserved.
from mmseg.registry import DATASETS
from .custom import CustomDataset
from .custom import BaseSegDataset


@DATASETS.register_module()
class ISPRSDataset(CustomDataset):
class ISPRSDataset(BaseSegDataset):
"""ISPRS dataset.

In segmentation map annotation for ISPRS, 0 is the ignore index.
Expand Down
4 changes: 2 additions & 2 deletions mmseg/datasets/loveda.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Copyright (c) OpenMMLab. All rights reserved.
from mmseg.registry import DATASETS
from .custom import CustomDataset
from .custom import BaseSegDataset


@DATASETS.register_module()
class LoveDADataset(CustomDataset):
class LoveDADataset(BaseSegDataset):
"""LoveDA dataset.

In segmentation map annotation for LoveDA, 0 is the ignore index.
Expand Down
6 changes: 3 additions & 3 deletions mmseg/datasets/pascal_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import os.path as osp

from mmseg.registry import DATASETS
from .custom import CustomDataset
from .custom import BaseSegDataset


@DATASETS.register_module()
class PascalContextDataset(CustomDataset):
class PascalContextDataset(BaseSegDataset):
"""PascalContext dataset.

In segmentation map annotation for PascalContext, 0 stands for background,
Expand Down Expand Up @@ -57,7 +57,7 @@ def __init__(self, ann_file: str, **kwargs) -> None:


@DATASETS.register_module()
class PascalContextDataset59(CustomDataset):
class PascalContextDataset59(BaseSegDataset):
"""PascalContext dataset.

In segmentation map annotation for PascalContext, 0 stands for background,
Expand Down
4 changes: 2 additions & 2 deletions mmseg/datasets/potsdam.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Copyright (c) OpenMMLab. All rights reserved.
from mmseg.registry import DATASETS
from .custom import CustomDataset
from .custom import BaseSegDataset


@DATASETS.register_module()
class PotsdamDataset(CustomDataset):
class PotsdamDataset(BaseSegDataset):
"""ISPRS Potsdam dataset.

In segmentation map annotation for Potsdam dataset, 0 is the ignore index.
Expand Down
4 changes: 2 additions & 2 deletions mmseg/datasets/stare.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Copyright (c) OpenMMLab. All rights reserved.
from mmseg.registry import DATASETS
from .custom import CustomDataset
from .custom import BaseSegDataset


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

In segmentation map annotation for STARE, 0 stands for background, which is
Expand Down
4 changes: 2 additions & 2 deletions mmseg/datasets/voc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import os.path as osp

from mmseg.registry import DATASETS
from .custom import CustomDataset
from .custom import BaseSegDataset


@DATASETS.register_module()
class PascalVOCDataset(CustomDataset):
class PascalVOCDataset(BaseSegDataset):
"""Pascal VOC dataset.

Args:
Expand Down
34 changes: 17 additions & 17 deletions tests/test_datasets/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

import pytest

from mmseg.datasets import (ADE20KDataset, CityscapesDataset, COCOStuffDataset,
CustomDataset, ISPRSDataset, LoveDADataset,
PascalVOCDataset, PotsdamDataset, iSAIDDataset)
from mmseg.registry import DATASETS
from mmseg.datasets import (ADE20KDataset, BaseSegDataset,
CityscapesDataset, COCOStuffDataset, ISPRSDataset,
LoveDADataset, PascalVOCDataset, PotsdamDataset,
iSAIDDataset)
from mmseg.utils import get_classes, get_palette


Expand Down Expand Up @@ -87,7 +87,7 @@ def test_palette():
def test_custom_dataset():

# with 'img_path' and 'seg_map_path' in data_prefix
train_dataset = CustomDataset(
train_dataset = BaseSegDataset(
data_root=osp.join(osp.dirname(__file__), '../data/pseudo_dataset'),
data_prefix=dict(
img_path='imgs/',
Expand All @@ -98,7 +98,7 @@ def test_custom_dataset():
assert len(train_dataset) == 5

# with 'img_path' and 'seg_map_path' in data_prefix and ann_file
train_dataset = CustomDataset(
train_dataset = BaseSegDataset(
data_root=osp.join(osp.dirname(__file__), '../data/pseudo_dataset'),
data_prefix=dict(
img_path='imgs/',
Expand All @@ -110,7 +110,7 @@ def test_custom_dataset():
assert len(train_dataset) == 4

# no data_root
train_dataset = CustomDataset(
train_dataset = BaseSegDataset(
data_prefix=dict(
img_path=osp.join(
osp.dirname(__file__), '../data/pseudo_dataset/imgs'),
Expand All @@ -122,7 +122,7 @@ def test_custom_dataset():

# with data_root but 'img_path' and 'seg_map_path' in data_prefix are
# abs path
train_dataset = CustomDataset(
train_dataset = BaseSegDataset(
data_root=osp.join(osp.dirname(__file__), '../data/pseudo_dataset'),
data_prefix=dict(
img_path=osp.join(
Expand All @@ -134,7 +134,7 @@ def test_custom_dataset():
assert len(train_dataset) == 5

# test_mode=True
test_dataset = CustomDataset(
test_dataset = BaseSegDataset(
data_prefix=dict(
img_path=osp.join(
osp.dirname(__file__), '../data/pseudo_dataset/imgs')),
Expand Down Expand Up @@ -245,7 +245,7 @@ def test_isaid():
@pytest.mark.parametrize('dataset, classes', [
('ADE20KDataset', ('wall', 'building')),
('CityscapesDataset', ('road', 'sidewalk')),
('CustomDataset', ('bus', 'car')),
('BaseSegDataset', ('bus', 'car')),
('PascalVOCDataset', ('aeroplane', 'bicycle')),
])
def test_custom_classes_override_default(dataset, classes):
Expand All @@ -269,7 +269,7 @@ def test_custom_classes_override_default(dataset, classes):

assert custom_dataset.metainfo['classes'] != original_classes
assert custom_dataset.metainfo['classes'] == classes
if not isinstance(custom_dataset, CustomDataset):
if not isinstance(custom_dataset, BaseSegDataset):
assert isinstance(custom_dataset.label_map, dict)

# Test setting classes as a list
Expand All @@ -282,7 +282,7 @@ def test_custom_classes_override_default(dataset, classes):

assert custom_dataset.metainfo['classes'] != original_classes
assert custom_dataset.metainfo['classes'] == list(classes)
if not isinstance(custom_dataset, CustomDataset):
if not isinstance(custom_dataset, BaseSegDataset):
assert isinstance(custom_dataset.label_map, dict)

# Test overriding not a subset
Expand All @@ -295,11 +295,11 @@ def test_custom_classes_override_default(dataset, classes):

assert custom_dataset.metainfo['classes'] != original_classes
assert custom_dataset.metainfo['classes'] == [classes[0]]
if not isinstance(custom_dataset, CustomDataset):
if not isinstance(custom_dataset, BaseSegDataset):
assert isinstance(custom_dataset.label_map, dict)

# Test default behavior
if dataset_class is CustomDataset:
if dataset_class is BaseSegDataset:
with pytest.raises(AssertionError):
custom_dataset = dataset_class(
ann_file=ann_file,
Expand All @@ -320,7 +320,7 @@ def test_custom_classes_override_default(dataset, classes):


def test_custom_dataset_random_palette_is_generated():
dataset = CustomDataset(
dataset = BaseSegDataset(
pipeline=[],
data_prefix=dict(img_path=MagicMock()),
ann_file=MagicMock(),
Expand All @@ -334,7 +334,7 @@ def test_custom_dataset_random_palette_is_generated():


def test_custom_dataset_custom_palette():
dataset = CustomDataset(
dataset = BaseSegDataset(
data_prefix=dict(img_path=MagicMock()),
ann_file=MagicMock(),
metainfo=dict(
Expand All @@ -346,7 +346,7 @@ def test_custom_dataset_custom_palette():
[200, 200, 200]])
# test custom class and palette don't match
with pytest.raises(ValueError):
dataset = CustomDataset(
dataset = BaseSegDataset(
data_prefix=dict(img_path=MagicMock()),
ann_file=MagicMock(),
metainfo=dict(classes=('bus', 'car'), palette=[[200, 200, 200]]),
Expand Down
Loading