vgg encoder with bilinear upsampling
| 367 | return feat_out, x |
| 368 | |
| 369 | class autoencoder_vgg7(nn.Module): # no decoder |
| 370 | ''' vgg encoder with bilinear upsampling''' |
| 371 | def __init__(self): |
| 372 | super(autoencoder_vgg7, self).__init__() |
| 373 | self.encoder = models.vgg19(pretrained=True).features |
| 374 | |
| 375 | def forward(self, x, upsampleH=224, upsampleW=224): |
| 376 | feat_out = [] # we only use high level features |
| 377 | for i in range(len(self.encoder)): |
| 378 | # print("layer {} encoder layer: {}".format(i, self.encoder[i])) |
| 379 | x = self.encoder[i](x) |
| 380 | if i == 3: # ReLU-4 |
| 381 | feature = torch.mean(torch.nn.UpsamplingBilinear2d(size=(upsampleH, upsampleW))(x), dim=1) |
| 382 | feat_out.append(feature) |
| 383 | elif i == 8: # ReLU-9 |
| 384 | feature = torch.mean(torch.nn.UpsamplingBilinear2d(size=(upsampleH, upsampleW))(x), dim=1) |
| 385 | feat_out.append(feature) |
| 386 | elif i == 17: # ReLU-18 |
| 387 | feature = torch.mean(torch.nn.UpsamplingBilinear2d(size=(upsampleH, upsampleW))(x), dim=1) |
| 388 | feat_out.append(feature) |
| 389 | return feat_out, x |
| 390 | |
| 391 | # PoseNet (SE(3)) w/ mobilev2 backbone |
| 392 | class PoseNetV2(nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected