MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / Backbone

Class Backbone

models/aios/backbones/backbone.py:86–115  ·  view source on GitHub ↗

ResNet backbone with frozen BatchNorm.

Source from the content-addressed store, hash-verified

84
85
86class Backbone(BackboneBase):
87 """ResNet backbone with frozen BatchNorm."""
88 def __init__(
89 self,
90 name: str,
91 train_backbone: bool,
92 dilation: bool,
93 return_interm_indices: list,
94 batch_norm=FrozenBatchNorm2d,
95 ):
96 if name in ['resnet18', 'resnet34', 'resnet50', 'resnet101']:
97 # backbone = getattr(torchvision.models, name)(
98 # replace_stride_with_dilation=[False, False, dilation],
99 # pretrained=is_main_process(), norm_layer=batch_norm)
100 backbone = getattr(torchvision.models, name)(
101 replace_stride_with_dilation=[False, False, dilation],
102 pretrained=False,
103 norm_layer=batch_norm)
104 else:
105 raise NotImplementedError(
106 'Why you can get here with name {}'.format(name))
107
108 assert name not in (
109 'resnet18',
110 'resnet34'), 'Only resnet50 and resnet101 are available.'
111 assert return_interm_indices in [[0, 1, 2, 3], [1, 2, 3], [3]]
112 num_channels_all = [256, 512, 1024, 2048]
113 num_channels = num_channels_all[4 - len(return_interm_indices):]
114 super().__init__(backbone, train_backbone, num_channels,
115 return_interm_indices)
116
117
118class Joiner(nn.Sequential):

Callers 1

build_backboneFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected