MCPcopy Create free account
hub / github.com/baegwangbin/surface_normal_uncertainty / Encoder

Class Encoder

models/baseline.py:35–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33
34# Encoder
35class Encoder(nn.Module):
36 def __init__(self):
37 super(Encoder, self).__init__()
38
39 basemodel_name = 'tf_efficientnet_b5_ap'
40 print('Loading base model ()...'.format(basemodel_name), end='')
41 basemodel = torch.hub.load('rwightman/gen-efficientnet-pytorch', basemodel_name, pretrained=True)
42 print('Done.')
43
44 # Remove last layer
45 print('Removing last two layers (global_pool & classifier).')
46 basemodel.global_pool = nn.Identity()
47 basemodel.classifier = nn.Identity()
48
49 self.original_model = basemodel
50
51 def forward(self, x):
52 features = [x]
53 for k, v in self.original_model._modules.items():
54 if (k == 'blocks'):
55 for ki, vi in v._modules.items():
56 features.append(vi(features[-1]))
57 else:
58 features.append(v(features[-1]))
59 return features
60
61
62# Decoder (no pixel-wise MLP, no uncertainty-guided sampling)

Callers 1

__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected