diff --git a/docs/en/guide_to_framework.md b/docs/en/guide_to_framework.md index 953aa589b3..167a65d949 100644 --- a/docs/en/guide_to_framework.md +++ b/docs/en/guide_to_framework.md @@ -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 @@ -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'), ...), @@ -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'), ...), @@ -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. diff --git a/docs/zh_cn/guide_to_framework.md b/docs/zh_cn/guide_to_framework.md index 5585b88179..df86f8634f 100644 --- a/docs/zh_cn/guide_to_framework.md +++ b/docs/zh_cn/guide_to_framework.md @@ -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 @@ -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'), ...), @@ -187,9 +187,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'), # 指定对应的元信息配置文件 metainfo=dict(from_file='configs/_base_/datasets/custom.py'), ...), @@ -197,6 +197,32 @@ val_dataloader = dict( 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),并直接使用我们提供的对应数据集实现。如果这种方式不可行,则用户需要实现自己的数据集类。