Skip to content

Commit

Permalink
Fixing bug on SSD backbone freezing. (#4591)
Browse files Browse the repository at this point in the history
# Conflicts:
#	torchvision/models/detection/ssd.py
  • Loading branch information
datumbox authored Oct 11, 2021
1 parent ccf3aa2 commit 58a60b2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions torchvision/models/detection/ssd.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def _vgg_extractor(backbone_name: str, highres: bool, progress: bool, pretrained
backbone = vgg.__dict__[backbone_name](pretrained=pretrained, progress=progress).features

# Gather the indices of maxpools. These are the locations of output blocks.
stage_indices = [i for i, b in enumerate(backbone) if isinstance(b, nn.MaxPool2d)]
stage_indices = [0] + [i for i, b in enumerate(backbone) if isinstance(b, nn.MaxPool2d)][:-1]
num_stages = len(stage_indices)

# find the index of the layer from which we wont freeze
Expand Down Expand Up @@ -569,7 +569,7 @@ def ssd300_vgg16(pretrained: bool = False, progress: bool = True, num_classes: i
warnings.warn("The size of the model is already fixed; ignoring the argument.")

trainable_backbone_layers = _validate_trainable_layers(
pretrained or pretrained_backbone, trainable_backbone_layers, 5, 5)
pretrained or pretrained_backbone, trainable_backbone_layers, 5, 4)

if pretrained:
# no need to download the backbone if pretrained is set
Expand Down

0 comments on commit 58a60b2

Please sign in to comment.