MCPcopy Create free account
hub / github.com/ActiveVisionLab/DFNet / autoencoder_vgg7

Class autoencoder_vgg7

script/feature/model.py:369–389  ·  view source on GitHub ↗

vgg encoder with bilinear upsampling

Source from the content-addressed store, hash-verified

367 return feat_out, x
368
369class 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
392class PoseNetV2(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected