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

Extend TorchVision's existing model builders to support multiple weights #4611

Closed
datumbox opened this issue Oct 13, 2021 · 2 comments
Closed

Comments

@datumbox
Copy link
Contributor

datumbox commented Oct 13, 2021

🚀 The feature

Note: To track the progress of the project check out this board.

The existing model builders support only single pre-trained weights.

To specify if the pretrained weights should be loaded, we pass a boolean pretrained parameter. Example:

def resnet50(pretrained: bool = False, progress: bool = True, **kwargs: Any) -> ResNet:

Builders that require model composition (for example in Object Detection), receive an additional extra boolean parameter called pretrained_backbone which indicates if a pre-trained backbone should be loaded:

def ssd300_vgg16(
pretrained: bool = False,
progress: bool = True,
num_classes: int = 91,
pretrained_backbone: bool = True,
trainable_backbone_layers: Optional[int] = None,
**kwargs: Any,
):

The above approach is limiting and doesn't allow us to support multiple weights for the same model builder.

Motivation, pitch

The Batteries Included project, enabled us to train far more accurate models than before. In order to make the new weights available to the users, we should extend the current model builders to support multiple weights. This can be done by converting the boolean parameters to an object that contains information about the weights.

Alternatives

An alternative approach would be to modify the weight URLs in place (replace the old with new ones). Unfortunately this would break the BC guarantees of vision.

Additional context

There was an original RFC with far bigger scope that discussed Model Versioning and included a solution for multi-pretrained weights support. We've decided to separate this vision specific extension from the original RFC to cover our needs and give additional time until the model versioning problem is thoroughly investigated.

@NicolasHug
Copy link
Member

Thanks @datumbox for the write up,

do you already have an idea of what it would look like in terms of API?

@datumbox
Copy link
Contributor Author

@NicolasHug Thanks for the comment.

Yes indeed. We stripped down the original proposal to its bare bones which just combines Enums to support multiple weights and data classes to store their minimum information. All other versioning mechanisms and registration mechanisms were removed to give more time for discussions. See #4610.

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

No branches or pull requests

2 participants