Skip to content

Commit

Permalink
Add ade doc (#10504)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiexinch committed Jun 14, 2023
1 parent 429c2a4 commit e858b60
Show file tree
Hide file tree
Showing 15 changed files with 507 additions and 192 deletions.
53 changes: 53 additions & 0 deletions configs/_base_/datasets/ade20k_instance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# dataset settings
dataset_type = 'ADE20KInstanceDataset'
data_root = 'data/ADEChallengeData2016/'

# Example to use different file client
# Method 1: simply set the data root and let the file I/O module
# automatically infer from prefix (not support LMDB and Memcache yet)

# data_root = 's3://openmmlab/datasets/detection/ADEChallengeData2016/'

# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6
# backend_args = dict(
# backend='petrel',
# path_mapping=dict({
# './data/': 's3://openmmlab/datasets/detection/',
# 'data/': 's3://openmmlab/datasets/detection/'
# }))
backend_args = None

test_pipeline = [
dict(type='LoadImageFromFile', backend_args=backend_args),
dict(type='Resize', scale=(2560, 640), keep_ratio=True),
# If you don't have a gt annotation, delete the pipeline
dict(type='LoadAnnotations', with_bbox=True, with_mask=True),
dict(
type='PackDetInputs',
meta_keys=('img_id', 'img_path', 'ori_shape', 'img_shape',
'scale_factor'))
]

val_dataloader = dict(
batch_size=1,
num_workers=2,
persistent_workers=True,
drop_last=False,
sampler=dict(type='DefaultSampler', shuffle=False),
dataset=dict(
type=dataset_type,
data_root=data_root,
ann_file='ade20k_instance_val.json',
data_prefix=dict(img='images/validation'),
test_mode=True,
pipeline=test_pipeline,
backend_args=backend_args))
test_dataloader = val_dataloader

val_evaluator = dict(
type='CocoMetric',
ann_file=data_root + 'ade20k_instance_val.json',
metric=['bbox', 'segm'],
format_only=False,
backend_args=backend_args)
test_evaluator = val_evaluator
23 changes: 0 additions & 23 deletions configs/_base_/datasets/ade20k_panoptic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@

backend_args = None

train_pipeline = [
dict(type='LoadImageFromFile', backend_args=backend_args),
dict(type='LoadPanopticAnnotations', backend_args=backend_args),
# TODO: the performance of `FixScaleResize` need to check.
dict(type='FixScaleResize', scale=(2560, 640), backend_args=backend_args),
dict(type='RandomCrop', crop_size=(640, 640), crop_type='absolute'),
dict(type='RandomFlip', prob=0.5),
dict(type='PackDetInputs')
]
test_pipeline = [
dict(type='LoadImageFromFile', backend_args=backend_args),
dict(type='Resize', scale=(640, 640), keep_ratio=True),
Expand All @@ -23,20 +14,6 @@
'scale_factor'))
]

train_dataloader = dict(
batch_size=4,
num_workers=2,
persistent_workers=True,
sampler=dict(type='DefaultSampler', shuffle=True),
batch_sampler=dict(type='AspectRatioBatchSampler'),
dataset=dict(
type=dataset_type,
data_root=data_root,
ann_file='ade20k_panoptic_train.json',
data_prefix=dict(img='images/training/', seg='ade20k_panoptic_train/'),
filter_cfg=dict(filter_empty_gt=True, min_size=32),
pipeline=train_pipeline,
backend_args=backend_args))
val_dataloader = dict(
batch_size=1,
num_workers=2,
Expand Down
2 changes: 1 addition & 1 deletion configs/_base_/datasets/ade20k_semantic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Method 1: simply set the data root and let the file I/O module
# automatically infer from prefix (not support LMDB and Memcache yet)

# data_root = 's3://openmmlab/datasets/detection/coco/'
# data_root = 's3://openmmlab/datasets/detection/ADEChallengeData2016/'

# Method 2: Use `backend_args`, `file_client_args` in versions before 3.0.0rc6
# backend_args = dict(
Expand Down
2 changes: 1 addition & 1 deletion configs/_base_/datasets/refcoco+.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
text_mode='original',
pipeline=test_pipeline))

val_evaluator = dict(type='RefSegMetric', metrics=['cIoU', 'mIoU'])
val_evaluator = dict(type='RefSegMetric', iou_metrics=['cIoU', 'mIoU'])
test_evaluator = val_evaluator
2 changes: 1 addition & 1 deletion configs/_base_/datasets/refcoco.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
text_mode='original',
pipeline=test_pipeline))

val_evaluator = dict(type='RefSegMetric', metrics=['cIoU', 'mIoU'])
val_evaluator = dict(type='RefSegMetric', iou_metrics=['cIoU', 'mIoU'])
test_evaluator = val_evaluator
2 changes: 1 addition & 1 deletion configs/_base_/datasets/refcocog.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
text_mode='original',
pipeline=test_pipeline))

val_evaluator = dict(type='RefSegMetric', metrics=['cIoU', 'mIoU'])
val_evaluator = dict(type='RefSegMetric', iou_metrics=['cIoU', 'mIoU'])
test_evaluator = val_evaluator
66 changes: 66 additions & 0 deletions docs/en/user_guides/dataset_prepare.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,69 @@ data
│   │   └── refs(umd).p
| |── train2014
```

The images and annotations of [ADE20K](https://groups.csail.mit.edu/vision/datasets/ADE20K/) dataset can be download by running `tools/misc/download_dataset.py`:

```shell
python tools/misc/download_dataset.py --dataset-name ade20k_2016 --save-dir data --unzip
```

Then move the annotations to the `data/ADEChallengeData2016` directory and run the preprocess script to produce the coco format annotations:

```shell
mv data/annotations_instance data/ADEChallengeData2016/
mv data/categoryMapping.txt data/ADEChallengeData2016/
mv data/objectInfo150.txt data/ADEChallengeData2016/
python tools/dataset_converters/ade20k2coco.py data/ADEChallengeData2016 --task panoptic
python tools/dataset_converters/ade20k2coco.py data/ADEChallengeData2016 --task instance
```

The directory should be like this.

```text
data
├── ADEChallengeData2016
│   ├── ade20k_instance_train.json
│   ├── ade20k_instance_val.json
│   ├── ade20k_panoptic_train
| | ├── ADE_train_00000001.png
| | ├── ADE_train_00000002.png
| | ├── ...
│   ├── ade20k_panoptic_train.json
│   ├── ade20k_panoptic_val
| | ├── ADE_val_00000001.png
| | ├── ADE_val_00000002.png
| | ├── ...
│   ├── ade20k_panoptic_val.json
│   ├── annotations
| | ├── training
| | | ├── ADE_train_00000001.png
| | | ├── ADE_train_00000002.png
| | | ├── ...
| | ├── validation
| | | ├── ADE_val_00000001.png
| | | ├── ADE_val_00000002.png
| | | ├── ...
│   ├── annotations_instance
| | ├── training
| | | ├── ADE_train_00000001.png
| | | ├── ADE_train_00000002.png
| | | ├── ...
| | ├── validation
| | | ├── ADE_val_00000001.png
| | | ├── ADE_val_00000002.png
| | | ├── ...
│   ├── categoryMapping.txt
│   ├── images
│   | ├── training
| | | ├── ADE_train_00000001.jpg
| | | ├── ADE_train_00000002.jpg
| | | ├── ...
| | ├── validation
| | | ├── ADE_val_00000001.jpg
| | | ├── ADE_val_00000002.jpg
| | | ├── ...
│   ├── imgCatIds.json
│   ├── objectInfo150.txt
| |── sceneCategories.txt
```
6 changes: 4 additions & 2 deletions mmdet/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) OpenMMLab. All rights reserved.
from .ade20k import ADE20KPanopticDataset, ADE20KSegDataset
from .ade20k import (ADE20KInstanceDataset, ADE20KPanopticDataset,
ADE20KSegDataset)
from .base_det_dataset import BaseDetDataset
from .base_semseg_dataset import BaseSegDataset
from .base_video_dataset import BaseVideoDataset
Expand Down Expand Up @@ -38,5 +39,6 @@
'BaseVideoDataset', 'MOTChallengeDataset', 'TrackImgSampler',
'ReIDDataset', 'YouTubeVISDataset', 'TrackAspectRatioBatchSampler',
'ADE20KPanopticDataset', 'COCOCaptionDataset', 'RefCOCODataset',
'BaseSegDataset', 'ADE20KSegDataset', 'CocoSegDataset'
'BaseSegDataset', 'ADE20KSegDataset', 'CocoSegDataset',
'ADE20KInstanceDataset'
]
Loading

0 comments on commit e858b60

Please sign in to comment.