Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Commit

Permalink
fix vgg backbone num_features (#154)
Browse files Browse the repository at this point in the history
Co-authored-by: Jirka Borovec <[email protected]>
  • Loading branch information
kaushikb11 and Borda authored Mar 3, 2021
1 parent 557cd8d commit 1b056c7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion flash/vision/backbones.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def torchvision_backbone_and_num_features(model_name: str, pretrained: bool = Tr
if model_name in MOBILENET_MODELS + VGG_MODELS:
model = model(pretrained=pretrained)
backbone = model.features
num_features = model.classifier[-1].in_features
num_features = 512 if model_name in VGG_MODELS else model.classifier[-1].in_features
return backbone, num_features

elif model_name in RESNET_MODELS:
Expand Down
4 changes: 2 additions & 2 deletions tests/vision/test_backbones.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@


@pytest.mark.parametrize(["backbone", "expected_num_features"], [("resnet34", 512), ("mobilenet_v2", 1280),
("simclr-imagenet", 2048)])
def test_fetch_fasterrcnn_backbone_and_num_features(backbone, expected_num_features):
("simclr-imagenet", 2048), ("vgg16", 512)])
def test_backbone_and_num_features(backbone, expected_num_features):

backbone_model, num_features = backbone_and_num_features(model_name=backbone, pretrained=False, fpn=False)

Expand Down

0 comments on commit 1b056c7

Please sign in to comment.