MCPcopy Create free account
hub / github.com/thygate/stable-diffusion-webui-depthmap-script / DepthNet

Class DepthNet

lib/network_auxi.py:64–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62 return x
63
64class DepthNet(nn.Module):
65 __factory = {
66 18: Resnet.resnet18,
67 34: Resnet.resnet34,
68 50: Resnet.resnet50,
69 101: Resnet.resnet101,
70 152: Resnet.resnet152
71 }
72 def __init__(self,
73 backbone='resnet',
74 depth=50,
75 upfactors=[2, 2, 2, 2]):
76 super(DepthNet, self).__init__()
77 self.backbone = backbone
78 self.depth = depth
79 self.pretrained = False
80 self.inchannels = [256, 512, 1024, 2048]
81 self.midchannels = [256, 256, 256, 512]
82 self.upfactors = upfactors
83 self.outchannels = 1
84
85 # Build model
86 if self.backbone == 'resnet':
87 if self.depth not in DepthNet.__factory:
88 raise KeyError("Unsupported depth:", self.depth)
89 self.encoder = DepthNet.__factory[depth](pretrained=self.pretrained)
90 elif self.backbone == 'resnext101_32x8d':
91 self.encoder = Resnext_torch.resnext101_32x8d(pretrained=self.pretrained)
92 else:
93 self.encoder = Resnext_torch.resnext101(pretrained=self.pretrained)
94
95 def forward(self, x):
96 x = self.encoder(x) # 1/32, 1/16, 1/8, 1/4
97 return x
98
99
100class FTB(nn.Module):

Callers 3

resnet50_stride32Function · 0.85
resnext101_stride32x8dFunction · 0.85
network_auxi.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected