Skip to content

Commit

Permalink
[Docs] Refine dataset config tutorial (#2707)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tau-J authored Sep 19, 2023
1 parent ce8da8f commit b350985
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 14 deletions.
40 changes: 33 additions & 7 deletions docs/en/guide_to_framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ dataset_info = dict(
- `joint_weights` assigns different loss weights to different keypoints.
- `sigmas` is used to calculate the OKS score. You can read [keypoints-eval](https://cocodataset.org/#keypoints-eval) to learn more about it.

In the model config, the user needs to specify the metainfo path of the custom dataset (e.g. `$MMPOSE/configs/_base_/datasets/custom.py`) as follows:
In the model config, the user needs to specify the metainfo path of the custom dataset (e.g. `$MMPOSE/configs/_base_/datasets/{your_dataset}.py`) as follows:

```python
# dataset and dataloader settings
Expand All @@ -171,9 +171,9 @@ train_dataloader = dict(
batch_size=2,
dataset=dict(
type=dataset_type,
data_root='root/of/your/train/data',
ann_file='path/to/your/train/json',
data_prefix=dict(img='path/to/your/train/img'),
data_root='root of your train data',
ann_file='path to your json file',
data_prefix=dict(img='path to your train img'),
# specify the new dataset meta information config file
metainfo=dict(from_file='configs/_base_/datasets/custom.py'),
...),
Expand All @@ -183,9 +183,9 @@ val_dataloader = dict(
batch_size=2,
dataset=dict(
type=dataset_type,
data_root='root/of/your/val/data',
ann_file='path/to/your/val/json',
data_prefix=dict(img='path/to/your/val/img'),
data_root='root of your val data',
ann_file='path to your val json',
data_prefix=dict(img='path to your val img'),
# specify the new dataset meta information config file
metainfo=dict(from_file='configs/_base_/datasets/custom.py'),
...),
Expand All @@ -194,6 +194,32 @@ val_dataloader = dict(
test_dataloader = val_dataloader
```

More specifically speaking, if you organize your data as follows:

```shell
data
├── annotations
│ ├── train.json
│ ├── val.json
├── train
│ ├── images
│ │ ├── 000001.jpg
├── val
│ ├── images
│ │ ├── 000002.jpg
```

You need to set your config as follows:

```
dataset=dict(
...
data_root='data/',
ann_file='annotations/train.json',
data_prefix=dict(img='train/images/'),
...),
```

### Dataset

To use custom dataset in MMPose, we recommend converting the annotations into a supported format (e.g. COCO or MPII) and directly using our implementation of the corresponding dataset. If this is not applicable, you may need to implement your own dataset class.
Expand Down
40 changes: 33 additions & 7 deletions docs/zh_cn/guide_to_framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ dataset_info = dict(
- `joint_weights`:每个关键点的权重,用于损失函数计算。
- `sigma`:标准差,用于计算 OKS 分数,详细信息请参考 [keypoints-eval](https://cocodataset.org/#keypoints-eval)

在模型配置文件中,你需要为自定义数据集指定对应的元信息配置文件。假如该元信息配置文件路径为 `$MMPOSE/configs/_base_/datasets/custom.py`,指定方式如下:
在模型配置文件中,你需要为自定义数据集指定对应的元信息配置文件。假如该元信息配置文件路径为 `$MMPOSE/configs/_base_/datasets/{your_dataset}.py`,指定方式如下:

```python
# dataset and dataloader settings
Expand All @@ -176,9 +176,9 @@ train_dataloader = dict(
batch_size=2,
dataset=dict(
type=dataset_type,
data_root='root/of/your/train/data',
ann_file='path/to/your/train/json',
data_prefix=dict(img='path/to/your/train/img'),
data_root='root of your train data',
ann_file='path to your json file',
data_prefix=dict(img='path to your train img'),
# 指定对应的元信息配置文件
metainfo=dict(from_file='configs/_base_/datasets/custom.py'),
...),
Expand All @@ -187,16 +187,42 @@ val_dataloader = dict(
batch_size=2,
dataset=dict(
type=dataset_type,
data_root='root/of/your/val/data',
ann_file='path/to/your/val/json',
data_prefix=dict(img='path/to/your/val/img'),
data_root='root of your val data',
ann_file='path to your val json',
data_prefix=dict(img='path to your val img'),
# 指定对应的元信息配置文件
metainfo=dict(from_file='configs/_base_/datasets/custom.py'),
...),
)
test_dataloader = val_dataloader
```

下面是一个更加具体的例子,假设你的数据集按照以下结构进行组织:

```shell
data
├── annotations
│ ├── train.json
│ ├── val.json
├── train
│ ├── images
│ │ ├── 000001.jpg
├── val
│ ├── images
│ │ ├── 000002.jpg
```

你的数据集路径应该如下所示:

```
dataset=dict(
...
data_root='data/',
ann_file='annotations/train.json',
data_prefix=dict(img='train/images/'),
...),
```

### 数据集

在 MMPose 中使用自定义数据集时,我们推荐将数据转化为已支持的格式(如 COCO 或 MPII),并直接使用我们提供的对应数据集实现。如果这种方式不可行,则用户需要实现自己的数据集类。
Expand Down

0 comments on commit b350985

Please sign in to comment.