update LoveDA dataset api
parent
845098b155
commit
d26173e772
|
@ -0,0 +1,49 @@
|
|||
# dataset settings
|
||||
dataset_type = 'LoveDADataset'
|
||||
data_root = 'data/loveda'
|
||||
img_norm_cfg = dict(
|
||||
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
|
||||
crop_size = (512, 512)
|
||||
train_pipeline = [
|
||||
# dict(type='LoadImageFromFile'),
|
||||
dict(type='LoadAnnotations', reduce_zero_label=True),
|
||||
dict(type='RandomCrop', crop_size=crop_size, cat_max_ratio=0.75),
|
||||
dict(type='RandomFlip', prob=0.5),
|
||||
dict(type='Normalize', **img_norm_cfg),
|
||||
dict(type='DefaultFormatBundle'),
|
||||
dict(type='Collect', keys=['img', 'gt_semantic_seg']),
|
||||
]
|
||||
test_pipeline = [
|
||||
# dict(type='LoadImageFromFile'),
|
||||
dict(
|
||||
img_scale=(1024, 1024),
|
||||
transforms=[
|
||||
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=dataset_type,
|
||||
data_root=data_root,
|
||||
reduce_zero_label=True,
|
||||
img_dir='img_dir/train',
|
||||
ann_dir='ann_dir/train',
|
||||
pipeline=train_pipeline),
|
||||
val=dict(
|
||||
type=dataset_type,
|
||||
data_root=data_root,
|
||||
reduce_zero_label=True,
|
||||
img_dir='img_dir/val',
|
||||
ann_dir='ann_dir/val',
|
||||
pipeline=test_pipeline),
|
||||
test=dict(
|
||||
type=dataset_type,
|
||||
data_root=data_root,
|
||||
reduce_zero_label=True,
|
||||
img_dir='img_dir/test',
|
||||
ann_dir=None,
|
||||
pipeline=test_pipeline))
|
|
@ -253,3 +253,31 @@ Since we only support test models on this dataset, you may only download [the va
|
|||
### Nighttime Driving
|
||||
|
||||
Since we only support test models on this dataset, you may only download [the test set](http://data.vision.ee.ethz.ch/daid/NighttimeDriving/NighttimeDrivingTest.zip).
|
||||
|
||||
|
||||
### LoveDA
|
||||
The data could be downloaded [here](https://drive.google.com/drive/folders/1ibYV0qwn4yuuh068Rnc-w4tPi0U0c-ti?usp=sharing)
|
||||
|
||||
For LoveDA dataset, please run the following command to download and re-organize the dataset.
|
||||
|
||||
```shell
|
||||
# download
|
||||
mkdir loveda && cd loveda
|
||||
wget https://drive.google.com/drive/folders/1ibYV0qwn4yuuh068Rnc-w4tPi0U0c-ti?usp=sharing
|
||||
|
||||
# unzip
|
||||
unzip \*.zip
|
||||
|
||||
# Convert into segmentation splits
|
||||
mkdir -p img_dir/train img_dir/val img_dir/test ann_dir/train ann_dir/val
|
||||
mv Train\Rural\images_png\* img_dir\train
|
||||
mv Train\Urban\images_png\* img_dir\train
|
||||
mv Val\Rural\images_png\* img_dir\val
|
||||
mv Val\Uban\images_png\* img_dir\val
|
||||
mv Test\Rural\images_png\* img_dir\val
|
||||
mv Test\Uban\images_png\* img_dir\val
|
||||
mv Train\Rural\masks_png\* ann_dir\train
|
||||
mv Train\Uban\masks_png\* ann_dir\train
|
||||
mv Val\Rural\masks_png\* ann_dir\val
|
||||
mv Val\Uban\masks_png\* ann_dir\val
|
||||
```
|
||||
|
|
|
@ -195,3 +195,31 @@ python tools/convert_datasets/stare.py /path/to/stare-images.tar /path/to/labels
|
|||
### Nighttime Driving
|
||||
|
||||
因为我们只支持在此数据集上测试模型,所以您只需下载[测试集](http://data.vision.ee.ethz.ch/daid/NighttimeDriving/NighttimeDrivingTest.zip)。
|
||||
|
||||
|
||||
### LoveDA
|
||||
|
||||
下载[LoveDA数据集](https://drive.google.com/drive/folders/1ibYV0qwn4yuuh068Rnc-w4tPi0U0c-ti?usp=sharing)。
|
||||
|
||||
对于 LoveDA 数据集,请运行以下命令下载并组织数据集
|
||||
```shell
|
||||
# download
|
||||
mkdir loveda && cd loveda
|
||||
wget https://drive.google.com/drive/folders/1ibYV0qwn4yuuh068Rnc-w4tPi0U0c-ti?usp=sharing
|
||||
|
||||
# unzip
|
||||
unzip \*.zip
|
||||
|
||||
# Convert into segmentation splits
|
||||
mkdir -p img_dir/train img_dir/val img_dir/test ann_dir/train ann_dir/val
|
||||
mv Train/Rural/images_png/* img_dir/train
|
||||
mv Train/Urban/images_png/* img_dir/train
|
||||
mv Val/Rural/images_png/* img_dir/val
|
||||
mv Val/Urban/images_png/* img_dir/val
|
||||
mv Test/Rural/images_png/* img_dir/val
|
||||
mv Test/Urban/images_png/* img_dir/val
|
||||
mv Train/Rural/masks_png/* ann_dir/train
|
||||
mv Train/Urban/masks_png/* ann_dir/train
|
||||
mv Val/Rural/masks_png/* ann_dir/val
|
||||
mv Val/Urban/masks_png/* ann_dir/val
|
||||
```
|
||||
|
|
|
@ -13,6 +13,8 @@ from .night_driving import NightDrivingDataset
|
|||
from .pascal_context import PascalContextDataset, PascalContextDataset59
|
||||
from .stare import STAREDataset
|
||||
from .voc import PascalVOCDataset
|
||||
from .loveda import LoveDADataset
|
||||
|
||||
|
||||
__all__ = [
|
||||
'CustomDataset', 'build_dataloader', 'ConcatDataset', 'RepeatDataset',
|
||||
|
@ -20,5 +22,5 @@ __all__ = [
|
|||
'PascalVOCDataset', 'ADE20KDataset', 'PascalContextDataset',
|
||||
'PascalContextDataset59', 'ChaseDB1Dataset', 'DRIVEDataset', 'HRFDataset',
|
||||
'STAREDataset', 'DarkZurichDataset', 'NightDrivingDataset',
|
||||
'COCOStuffDataset'
|
||||
'COCOStuffDataset', 'LoveDADataset',
|
||||
]
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
from .builder import DATASETS
|
||||
from .custom import CustomDataset
|
||||
|
||||
|
||||
@DATASETS.register_module()
|
||||
class LoveDADataset(CustomDataset):
|
||||
"""LoveDA dataset.
|
||||
|
||||
In segmentation map annotation for LoveDA, 0 is the ignore index.
|
||||
``reduce_zero_label`` should be set to True.
|
||||
The ``img_suffix`` and ``seg_map_suffix`` are both fixed to '.png'.
|
||||
"""
|
||||
CLASSES = ('background', 'building', 'road', 'water', 'barren', 'forest', 'agricultural')
|
||||
|
||||
PALETTE = [[255, 255, 255], [255, 0, 0], [255, 255, 0], [0, 0, 255],
|
||||
[159, 129, 183], [0, 255, 0], [255, 195, 128]]
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super(LoveDADataset, self).__init__(
|
||||
img_suffix='.png', seg_map_suffix='.png', reduce_zero_label=True, **kwargs)
|
||||
|
|
@ -13,7 +13,7 @@ from PIL import Image
|
|||
|
||||
from mmseg.core.evaluation import get_classes, get_palette
|
||||
from mmseg.datasets import (DATASETS, ADE20KDataset, CityscapesDataset,
|
||||
ConcatDataset, CustomDataset, PascalVOCDataset,
|
||||
ConcatDataset, CustomDataset, PascalVOCDataset, LoveDADataset,
|
||||
RepeatDataset, build_dataset)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue