| 174 | |
| 175 | |
| 176 | class SimpleResNetEncoder3(nn.Module): |
| 177 | def __init__(self, pretrain=False, use_layer2=False): |
| 178 | super().__init__() |
| 179 | resnet = models.resnet34(pretrained=pretrain) |
| 180 | nets = [] |
| 181 | net_names = ['conv1', 'bn1', 'relu', 'maxpool', 'layer1'] |
| 182 | if use_layer2: |
| 183 | net_names.append('layer2') |
| 184 | for net in net_names: |
| 185 | nets.append(getattr(resnet, net)) |
| 186 | self.resnet = nn.Sequential(*nets) |
| 187 | |
| 188 | def forward(self, x): |
| 189 | x = self.resnet(x) |
| 190 | return x |
| 191 | |
| 192 | |
| 193 | from torchvision.models.detection.backbone_utils import resnet_fpn_backbone |
nothing calls this directly
no outgoing calls
no test coverage detected