Skip to content

Expose get_weight to Torch Hub #6026

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

Merged
merged 2 commits into from
May 16, 2022

Conversation

datumbox
Copy link
Contributor

@datumbox datumbox commented May 16, 2022

Partially addresses #6014

This PR makes get_weight accessible via TorchHub:

    import torch

    # Currently possible to pass string:
    model = torch.hub.load("pytorch/vision", "resnet50", weights="IMAGENET1K_V2")

    # Make it possible to get access of enum weights:
    weights = torch.hub.load("pytorch/vision", "get_weight", weights="ResNet50_Weights.IMAGENET1K_V2")
    model = torch.hub.load("pytorch/vision", "resnet50", weights=weights)

This is useful for uses who want to get access to the meta-data or the transforms.

Moreover I'm converting get_enum_from_fn to private.

Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

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

Thanks @datumbox

@datumbox datumbox merged commit 9e78871 into pytorch:main May 16, 2022
@datumbox datumbox deleted the models/_api_improvements branch May 16, 2022 14:18
@github-actions
Copy link

Hey @datumbox!

You merged this PR, but no labels were added. The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py

@datumbox datumbox linked an issue May 16, 2022 that may be closed by this pull request
6 tasks
facebook-github-bot pushed a commit that referenced this pull request May 24, 2022
Summary:
* Prefixing `_get_enum_from_fn` with underscore

* Exposing `get_weight` to Torch Hub

Reviewed By: datumbox

Differential Revision: D36413345

fbshipit-source-id: 930902a98548b72b3e66c0e1bc497757ba49804b
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.

Improve documentation for Multi-weight support
3 participants