Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] Refine dataset config tutorial #2707

Merged
merged 2 commits into from
Sep 19, 2023
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
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
Loading