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

Add DatasetInfo and refactor dataset base classes #901

Merged
merged 3 commits into from
Sep 7, 2021
Merged

Conversation

ly015
Copy link
Member

@ly015 ly015 commented Sep 2, 2021

Thanks for your contribution and we appreciate it a lot. The following instructions would make your pull request more healthy and more easily get feedback. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers.

Motivation

This PR is to merge the changes of #663 into master.

Modification

Please refer to the original PR for details.

BC-breaking (Optional)

1 DatasetInfo is needed to build dataset and inference model

DatasetInfo is defined in mmpose/datasets/dataset_info.py and is used to parse and hold dataset meta information (e.g. keypoint definition, skeleton). It is usually initialized from a config in configs/_base_/datasets/.

Please note that the old-fashioned usage listed below is still supported with warning information.

1.1 Build dataset

# New style
dataset_info = Dataset(dataset_info_cfg)
dataset = TopDownCOCODataset(
        ann_file='tests/data/coco/test_coco.json',
        img_prefix='tests/data/coco/',
        data_cfg=data_cfg_copy,
        pipeline=[],
        dataset_info=dataset_info,
        test_mode=True)

# Old style
dataset = TopDownCOCODataset(
        ann_file='tests/data/coco/test_coco.json',
        img_prefix='tests/data/coco/',
        data_cfg=data_cfg_copy,
        pipeline=[],
        test_mode=True)

Users won't have to worry about the difference in most cases, because it is encapsulated by high-level APIs like mmpose.apis.build_dataset.

1.2 Inference model

## New style
# test a single image, with a list of bboxes.
pose_results, _ = inference_top_down_pose_model(
        pose_model,
        image_name,
        person_result,
        format='xywh',
        dataset_info=dataset_info)
# show the results
vis_pose_result(
    pose_model, image_name, pose_results, dataset_info=dataset_info)

## Old style
# test a single image, with a list of bboxes.
pose_results, _ = inference_top_down_pose_model(
        pose_model,
        image_name,
        person_result,
        format='xywh',
        dataset='TopDownCOCODataset')
# show the results
vis_pose_result(
    pose_model, image_name, pose_results, dataset='TopDownCOCODataset') 

2 Use new base classes of datasets

Base classes for datasets are placed at mmpose/datasets/datasets/base. Please check the following comparison table for new and old class names.

New Base Class Old Base Class
Kpt2dSviewRgbImgTopDownDataset TopDownBaseDataset, HandBaseDataset, AnimalBaseDataset, FaceBaseDataset, FashionBaseDataset
Kpt2dSviewRgbImgBottomUpDataset BottomUpBaseDataset
Kpt3dSviewKpt2dDataset Body3DBaseDataset
Kpt3dSviewRgbImgTopDownDataset HandBaseDataset*

* InterHand3DDataset, which was originally based on HandBaseDataset, is based Kpt3dSviewRgbImgTopDownDataset in this PR. Other hand datasets are based on Kpt2dSviewRgbImgTopDownDataset.

3 Use pose_link_color to replace pose_limb_color

# New style
img_vis_2d = imshow_keypoints(
    img,
    [kpts],
    skeleton=skeleton,
    pose_kpt_color=[(127, 127, 127)* len(kpts)],
    pose_link_color=[(127, 127, 127)* len(skeletons)])

# New style
img_vis_2d = imshow_keypoints(
    img,
    [kpts],
    skeleton=skeleton,
    pose_kpt_color=[(127, 127, 127)* len(kpts)],
    pose_limb_color=[(127, 127, 127)* len(skeletons)])

Checklist

Before PR:

  • I have read and followed the workflow indicated in the CONTRIBUTING.md to create this PR.
  • Pre-commit or linting tools indicated in CONTRIBUTING.md are used to fix the potential lint issues.
  • Bug fixes are covered by unit tests, the case that causes the bug should be added in the unit tests.
  • New functionalities are covered by complete unit tests. If not, please add more unit test to ensure the correctness.
  • The documentation has been modified accordingly, including docstring or example tutorials.

After PR:

  • CLA has been signed and all committers have signed the CLA in this PR.

@ly015 ly015 requested review from innerlee and jin-s13 September 2, 2021 03:41
@ly015 ly015 changed the title add dataset info (#663) Add DatasetInfo and refactor dataset base classes Sep 2, 2021
* Fix import and deprecation issues in unit tests (#871)

* fix some bugs in the unit test of smpl model.

* reorganize `tests/` to solve importing issue (PEP 420)

* fix deprecation warnings in unit tests

Co-authored-by: ly015 <[email protected]>

* add benchmark regression test script with tmux (#849)

* test the simple case using tmux to run multiple benchmark regression test tasks

* modify and rename the config file and script

* Delete config_list.yaml

* modify the config and rename the filename

* Delete test_benchmark_tmux.py

* modify the script and rename the filename

* Update setup.cfg

* using mmcv.load to avoid introducing the extra dependency on yaml

* fix some typo

* refactor the config file and modify the script accordingly

* modify the config and script

* rename the config file

* Correct dataset preparation guide of WFLW (#873)

* add pr template (#875)

* add CITATION.cff and update setup.py (#876)

* Add copyright header and pre-commit hook (#872)

* Add pre-commit hook to automatically add copyright file header

* update files with copyright header

*  Limit copyright checking in the first 2 lines of a file
* Exclude configs in demo/

* set max-header-lines as 5

* rebase to master and add copyright to new files
* move benchmark_regression into .dev_scripts/benchmark

* Translate tasks/2d_body_keypoint.md (#842)

* 2rd PR remove poseval

* fix lint

* revise the CN version

Co-authored-by: ly015 <[email protected]>

* fix some bugs in the unit test of smpl model.

* * reorganiz `tests/` to solve importing issue (PEP 420)

* add dataset info

* fix lint

* * fix wrongly modified parts in previous rebase
* fix lint

* rename datasets/_base_ as datasets/base

* resolve compatibility of pose_limb_color

* Add dummy dataset base classes with old names for compatibility

* * Rewrite relative unittest based on dataset_info
* Add bc-breaking test for functions related to dataset_info
* Rename DatasetInfo.dataset_info as DatasetInfo._dataset_info
* Fix dataset_info of h36m dataset

* Handle breaking change pose_limb_color -> pose_link_color

* add unittest for old-fashioned dataset initialization without dataset_info

* resolve naming conflict in unittests

Co-authored-by: zengwang430521 <[email protected]>
Co-authored-by: ly015 <[email protected]>
@ly015 ly015 merged commit 8f005ac into master Sep 7, 2021
@innerlee innerlee deleted the dataset_refactor branch September 7, 2021 07:34
@innerlee
Copy link
Contributor

innerlee commented Sep 7, 2021

We may add a section in the doc, describing how we support datasets via config, and how to define customized datasets

This was referenced Sep 22, 2021
shuheilocale pushed a commit to shuheilocale/mmpose that referenced this pull request May 6, 2023
* add dataset info (open-mmlab#663)

* Fix import and deprecation issues in unit tests (open-mmlab#871)

* fix some bugs in the unit test of smpl model.

* reorganize `tests/` to solve importing issue (PEP 420)

* fix deprecation warnings in unit tests

Co-authored-by: ly015 <[email protected]>

* add benchmark regression test script with tmux (open-mmlab#849)

* test the simple case using tmux to run multiple benchmark regression test tasks

* modify and rename the config file and script

* Delete config_list.yaml

* modify the config and rename the filename

* Delete test_benchmark_tmux.py

* modify the script and rename the filename

* Update setup.cfg

* using mmcv.load to avoid introducing the extra dependency on yaml

* fix some typo

* refactor the config file and modify the script accordingly

* modify the config and script

* rename the config file

* Correct dataset preparation guide of WFLW (open-mmlab#873)

* add pr template (open-mmlab#875)

* add CITATION.cff and update setup.py (open-mmlab#876)

* Add copyright header and pre-commit hook (open-mmlab#872)

* Add pre-commit hook to automatically add copyright file header

* update files with copyright header

*  Limit copyright checking in the first 2 lines of a file
* Exclude configs in demo/

* set max-header-lines as 5

* rebase to master and add copyright to new files
* move benchmark_regression into .dev_scripts/benchmark

* Translate tasks/2d_body_keypoint.md (open-mmlab#842)

* 2rd PR remove poseval

* fix lint

* revise the CN version

Co-authored-by: ly015 <[email protected]>

* fix some bugs in the unit test of smpl model.

* * reorganiz `tests/` to solve importing issue (PEP 420)

* add dataset info

* fix lint

* * fix wrongly modified parts in previous rebase
* fix lint

* rename datasets/_base_ as datasets/base

* resolve compatibility of pose_limb_color

* Add dummy dataset base classes with old names for compatibility

* * Rewrite relative unittest based on dataset_info
* Add bc-breaking test for functions related to dataset_info
* Rename DatasetInfo.dataset_info as DatasetInfo._dataset_info
* Fix dataset_info of h36m dataset

* Handle breaking change pose_limb_color -> pose_link_color

* add unittest for old-fashioned dataset initialization without dataset_info

* resolve naming conflict in unittests

Co-authored-by: zengwang430521 <[email protected]>
Co-authored-by: ly015 <[email protected]>

* fix typo

* fix typo

Co-authored-by: Jas <[email protected]>
Co-authored-by: zengwang430521 <[email protected]>
HAOCHENYE added a commit to HAOCHENYE/mmpose that referenced this pull request Jun 27, 2023
…mmlab#901)

* Support get config from model-index without installing downstream repo

* Rename _get_models_from_package to _get_models_from_config_dir

* adjust priority

* Fix as comment

* Refine exception

* Replace osp.xxx with fileio.xxx

* Refine as comment

* Revert "Replace osp.xxx with fileio.xxx"

This reverts commit 6aed9b2e88f5cf98614772ddbd89ccad22fa7d2f.

* replace fileio with osp

* fix

* Fix as comment
ajgrafton pushed a commit to ajgrafton/mmpose that referenced this pull request Mar 6, 2024
* add dataset info (open-mmlab#663)

* Fix import and deprecation issues in unit tests (open-mmlab#871)

* fix some bugs in the unit test of smpl model.

* reorganize `tests/` to solve importing issue (PEP 420)

* fix deprecation warnings in unit tests

Co-authored-by: ly015 <[email protected]>

* add benchmark regression test script with tmux (open-mmlab#849)

* test the simple case using tmux to run multiple benchmark regression test tasks

* modify and rename the config file and script

* Delete config_list.yaml

* modify the config and rename the filename

* Delete test_benchmark_tmux.py

* modify the script and rename the filename

* Update setup.cfg

* using mmcv.load to avoid introducing the extra dependency on yaml

* fix some typo

* refactor the config file and modify the script accordingly

* modify the config and script

* rename the config file

* Correct dataset preparation guide of WFLW (open-mmlab#873)

* add pr template (open-mmlab#875)

* add CITATION.cff and update setup.py (open-mmlab#876)

* Add copyright header and pre-commit hook (open-mmlab#872)

* Add pre-commit hook to automatically add copyright file header

* update files with copyright header

*  Limit copyright checking in the first 2 lines of a file
* Exclude configs in demo/

* set max-header-lines as 5

* rebase to master and add copyright to new files
* move benchmark_regression into .dev_scripts/benchmark

* Translate tasks/2d_body_keypoint.md (open-mmlab#842)

* 2rd PR remove poseval

* fix lint

* revise the CN version

Co-authored-by: ly015 <[email protected]>

* fix some bugs in the unit test of smpl model.

* * reorganiz `tests/` to solve importing issue (PEP 420)

* add dataset info

* fix lint

* * fix wrongly modified parts in previous rebase
* fix lint

* rename datasets/_base_ as datasets/base

* resolve compatibility of pose_limb_color

* Add dummy dataset base classes with old names for compatibility

* * Rewrite relative unittest based on dataset_info
* Add bc-breaking test for functions related to dataset_info
* Rename DatasetInfo.dataset_info as DatasetInfo._dataset_info
* Fix dataset_info of h36m dataset

* Handle breaking change pose_limb_color -> pose_link_color

* add unittest for old-fashioned dataset initialization without dataset_info

* resolve naming conflict in unittests

Co-authored-by: zengwang430521 <[email protected]>
Co-authored-by: ly015 <[email protected]>

* fix typo

* fix typo

Co-authored-by: Jas <[email protected]>
Co-authored-by: zengwang430521 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants