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

Fix vgg backbone num_features #154

Merged
merged 2 commits into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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