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

[Refactor] add config checker #2153

Merged
merged 4 commits into from
Apr 6, 2023
Merged

Conversation

Ben-Louis
Copy link
Collaborator

Motivation

#2108 and #2126 modified the interface of neck and head. If users use the latest mmpose and old configs, there might be some conflict.

Modification

  1. add a function check_and_update_config that checks if the config is consistent with the latest mmpose. If not, the arguments will be automatically updated. In addition, this function will display the guide for updating the configs, such as
    image
    and
    image

  2. add unit test for check_and_update_config

  3. verify the test accuracy of cid_hrnet-w32_8xb20-140e_coco-512x512, td-hm_ViTPose-base-simple_8xb64-210e_coco-256x192, td-hm_pvt-s_8xb64-210e_coco-256x192

BC-breaking (Optional)

Use cases (Optional)

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 tests to ensure 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.

'guide_to_framework.html#step3-model'

logger: MMLogger = MMLogger.get_current_instance()
logger.info(total_info)
Copy link
Collaborator

Choose a reason for hiding this comment

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

In my opinion, this info should be a user warning instead of info

# The following function automatically detects outdated
# configurations and updates them accordingly, while also providing
# clear and concise information on the changes made.
neck, head = check_and_update_config(neck, head)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this function should also take the backbone cfg as input, so that it can be used as a more general check and auto-update process for the entire model, rather than just for compatibility measures with the previous PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I also have a concern that at the beginning of the training, mmengine will print the entire config and dump a config file. Will this automatically processed function affect the above content? Such automatic modification seems to cause differences between the real model structure and the output. Do you think there is any way to optimize it?

Copy link
Collaborator

Choose a reason for hiding this comment

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

When trying to inference a model with SyncBN on cpu, it will raise an error. I think we can check the device and automatically repalce SyncBN as BN in the config dict.

Copy link
Collaborator Author

@Ben-Louis Ben-Louis Apr 5, 2023

Choose a reason for hiding this comment

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

When trying to inference a model with SyncBN on cpu, it will raise an error. I think we can check the device and automatically repalce SyncBN as BN in the config dict.

SyncBN can be converted to BN by mmengine.model.revert_sync_batchnorm. The Inferencer has supported this conversion in #2152

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I also have a concern that at the beginning of the training, mmengine will print the entire config and dump a config file. Will this automatically processed function affect the above content? Such automatic modification seems to cause differences between the real model structure and the output. Do you think there is any way to optimize it?

We can modify this checker to a hook in the future, and add more functions to it.

@Tau-J Tau-J merged commit 8e26bda into open-mmlab:dev-1.x Apr 6, 2023
Tau-J added a commit that referenced this pull request Apr 6, 2023
Tau-J pushed a commit that referenced this pull request Apr 6, 2023
@Ben-Louis Ben-Louis deleted the add-config-checker branch April 26, 2023 18:00
shuheilocale pushed a commit to shuheilocale/mmpose that referenced this pull request May 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants