MCPcopy Create free account
hub / github.com/DSL-Lab/StreamSplat / forward

Method forward

model/depth_anything/depth_anything_v2/dpt.py:117–150  ·  view source on GitHub ↗
(self, out_features, patch_h, patch_w)

Source from the content-addressed store, hash-verified

115 )
116
117 def forward(self, out_features, patch_h, patch_w):
118 out = []
119 for i, x in enumerate(out_features):
120 if self.use_clstoken:
121 x, cls_token = x[0], x[1]
122 readout = cls_token.unsqueeze(1).expand_as(x)
123 x = self.readout_projects[i](torch.cat((x, readout), -1))
124 else:
125 x = x[0]
126
127 x = x.permute(0, 2, 1).reshape((x.shape[0], x.shape[-1], patch_h, patch_w))
128
129 x = self.projects[i](x)
130 x = self.resize_layers[i](x)
131
132 out.append(x)
133
134 layer_1, layer_2, layer_3, layer_4 = out
135
136 layer_1_rn = self.scratch.layer1_rn(layer_1)
137 layer_2_rn = self.scratch.layer2_rn(layer_2)
138 layer_3_rn = self.scratch.layer3_rn(layer_3)
139 layer_4_rn = self.scratch.layer4_rn(layer_4)
140
141 path_4 = self.scratch.refinenet4(layer_4_rn, size=layer_3_rn.shape[2:])
142 path_3 = self.scratch.refinenet3(path_4, layer_3_rn, size=layer_2_rn.shape[2:])
143 path_2 = self.scratch.refinenet2(path_3, layer_2_rn, size=layer_1_rn.shape[2:])
144 path_1 = self.scratch.refinenet1(path_2, layer_1_rn)
145
146 out = self.scratch.output_conv1(path_1)
147 out = F.interpolate(out, (int(patch_h * 14), int(patch_w * 14)), mode="bilinear", align_corners=True)
148 out = self.scratch.output_conv2(out)
149
150 return out
151
152
153class DepthAnythingV2(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected