Commit 737966a3 authored by Kyryl Truskovskyi's avatar Kyryl Truskovskyi Committed by Francisco Massa
Browse files

Fix resnet fpn backbone for resnet18 and resnet34 (#1147)

* in_channels_stage2 from backbone.inplanes

* remove type for backward compatible
parent 75f89cf2
import unittest
import torch
from torchvision.models.detection.backbone_utils import resnet_fpn_backbone
class ResnetFPNBackboneTester(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.dtype = torch.float32
def test_resnet18_fpn_backbone(self):
device = torch.device('cpu')
x = torch.rand(1, 3, 300, 300, dtype=self.dtype, device=device)
resnet18_fpn = resnet_fpn_backbone(backbone_name='resnet18', pretrained=False)
y = resnet18_fpn(x)
assert list(y.keys()) == [0, 1, 2, 3, 'pool']
def test_resnet50_fpn_backbone(self):
device = torch.device('cpu')
x = torch.rand(1, 3, 300, 300, dtype=self.dtype, device=device)
resnet50_fpn = resnet_fpn_backbone(backbone_name='resnet50', pretrained=False)
y = resnet50_fpn(x)
assert list(y.keys()) == [0, 1, 2, 3, 'pool']
...@@ -51,7 +51,7 @@ def resnet_fpn_backbone(backbone_name, pretrained): ...@@ -51,7 +51,7 @@ def resnet_fpn_backbone(backbone_name, pretrained):
return_layers = {'layer1': 0, 'layer2': 1, 'layer3': 2, 'layer4': 3} return_layers = {'layer1': 0, 'layer2': 1, 'layer3': 2, 'layer4': 3}
in_channels_stage2 = 256 in_channels_stage2 = backbone.inplanes // 8
in_channels_list = [ in_channels_list = [
in_channels_stage2, in_channels_stage2,
in_channels_stage2 * 2, in_channels_stage2 * 2,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment