Skip to content

Commit

Permalink
[fbsync] Adding missing named param check on ViT (#5196)
Browse files Browse the repository at this point in the history
Reviewed By: datumbox, NicolasHug

Differential Revision: D33655255

fbshipit-source-id: a6f5fe7ddd30850236d2b82a8847a2fa1b499a9b
  • Loading branch information
Vincent Moens authored and facebook-github-bot committed Jan 19, 2022
1 parent 34a1e22 commit bd89978
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion torchvision/prototype/models/vision_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from ...models.vision_transformer import VisionTransformer, interpolate_embeddings # noqa: F401
from ._api import WeightsEnum, Weights
from ._meta import _IMAGENET_CATEGORIES
from ._utils import handle_legacy_interface
from ._utils import handle_legacy_interface, _ovewrite_named_param

__all__ = [
"VisionTransformer",
Expand Down Expand Up @@ -111,6 +111,9 @@ def _vision_transformer(
) -> VisionTransformer:
image_size = kwargs.pop("image_size", 224)

if weights is not None:
_ovewrite_named_param(kwargs, "num_classes", len(weights.meta["categories"]))

model = VisionTransformer(
image_size=image_size,
patch_size=patch_size,
Expand Down

0 comments on commit bd89978

Please sign in to comment.