Skip to content

add detail on doc explain how to make self defined class of custom dataset registed #7906

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 15 additions & 0 deletions docs/en/tutorials/customize_dataset.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,22 @@ class MyDataset(CustomDataset):

def get_ann_info(self, idx):
return self.data_infos[idx]['ann']
```
Add MyDataset to `mmdet/datasets/__init__.py`
Copy link
Collaborator

@jbwang1997 jbwang1997 May 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then, we need to import MyDataset in mmdet/datasets/__init__.py.

```python
from .my_datasets import MyDataset

__all__ = [
# ......
'OpenImagesDataset', 'OpenImagesChallengeDataset',
# add class name in the end
'MyDataset'
]
Comment on lines +282 to +289
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from .builder import DATASETS, PIPELINES, build_dataloader, build_dataset
from .cityscapes import CityscapesDataset
from .coco import CocoDataset
#......
from .my_datasets import MyDataset

__all__ = [
    # ......
    'OpenImagesDataset', 'OpenImagesChallengeDataset',
    # add class name in the end
    'MyDataset'
]

```
last step, recompile source code
```shell
pip install -r requirements/build.txt
pip install -v -e . # or "python setup.py develop"
Comment on lines +291 to +294
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recompiling is unnecessary. Because mmdet is usually installed with develop mode. All modifications take effect directly.

```

Then in the config, to use `MyDataset` you can modify the config as the following
Expand Down
17 changes: 17 additions & 0 deletions docs/zh_cn/tutorials/customize_dataset.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,23 @@ class MyDataset(CustomDataset):
return self.data_infos[idx]['ann']

```
然后在 `mmdet/datasets__init__.py` 中引入MyDataset

```python
from .my_datasets import MyDataset
__all__ = [
# 省略一部分
'OpenImagesDataset', 'OpenImagesChallengeDataset',
# 这里加类名
'MyDataset'
]

```
重新编译源码
```shell
pip install -r requirements/build.txt
pip install -v -e . # or "python setup.py develop"
```

配置文件中,可以使用 `MyDataset` 进行如下修改

Expand Down
2 changes: 2 additions & 0 deletions mmdet/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
from .wider_face import WIDERFaceDataset
from .xml_style import XMLDataset



__all__ = [
'CustomDataset', 'XMLDataset', 'CocoDataset', 'DeepFashionDataset',
'VOCDataset', 'CityscapesDataset', 'LVISDataset', 'LVISV05Dataset',
Expand Down