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

[Enhance] Enhance get_torchvision_models #1867

Merged
merged 16 commits into from
Apr 18, 2022
Merged

[Enhance] Enhance get_torchvision_models #1867

merged 16 commits into from
Apr 18, 2022

Conversation

HAOCHENYE
Copy link
Collaborator

@HAOCHENYE HAOCHENYE commented Apr 11, 2022

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

Referred to #1848, torchvision after v0.13.0 removes model_urls in all modules of torchvision.model and redesigned the way to get the model. This pr refactor get_torchvision_models to make it compatible with torchvision 0.13.0 .

Modification

  1. Save the URL of torchvision v0.12.0 to mmcv/model_zoo/torchvision_0.12.json, which will be additionally loaded into model_urls of get_torchvision_models when torchvision version > 0.13.0.
  2. If torchvision version < 0.13.0, get_torchvision_models will keep its original implementation. If torchvision version >= 0.13.0, get_torchvision_models will get the newest URLs and the URLs of torchvision v0.12.0.

BC-breaking (Optional)

No.

Use cases (Optional)

  • tochvision version < 0.13.0:
    Specifiy pretrained model in config as before.
    init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet50')

  • torchvision version >= 0.13.0:
    Get newest resnet50 checkpoint by following style
    init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet50.imagenet1k_v1')
    init_cfg=dict(type='Pretrained', checkpoint='torchvision://ResNet50_Weights.IMAGENET1K_V1') (torchvision style)
    Get old checkpoint of torchvision v0.12.0
    init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet50')

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:

  • If the modification has potential influence on downstream or other related projects, this PR should be tested with some of those projects, like MMDet or MMCls.
  • CLA has been signed and all committers have signed the CLA in this PR.

@zhouzaida zhouzaida linked an issue Apr 13, 2022 that may be closed by this pull request
@zhouzaida zhouzaida requested a review from ZwwWayne April 16, 2022 00:58
mmcv/runner/checkpoint.py Outdated Show resolved Hide resolved
mmcv/runner/checkpoint.py Outdated Show resolved Hide resolved
@ZwwWayne
Copy link
Collaborator

The PR message is not precise and clear. We should tell readers how to use old/new torchvision models through config. Please update the PR messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Loading weights from TorchVision will stop working
4 participants