MCPcopy Create free account
hub / github.com/alinlab/SelfPatch / forward_features

Method forward_features

detection/backbone/vit_SelfPatch.py:283–300  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

281
282
283 def forward_features(self, x):
284 B, C, H, W = x.shape
285 H, W = H // self.patch_embed.patch_size, W // self.patch_embed.patch_size
286 x = self.prepare_tokens(x)
287
288 outs = []
289 for i, layer in enumerate(self.blocks):
290 x = layer(x)
291
292 if i in self.out_indices:
293 out = x.permute(0, 2, 1).reshape(B, -1, H, W).contiguous()
294 outs.append(out)
295
296 ops = [self.fpn1, self.fpn2, self.fpn3, self.fpn4]
297 for i in range(len(outs)):
298 outs[i] = ops[i](outs[i])
299
300 return tuple(outs)
301
302
303 def forward(self, x):

Callers 1

forwardMethod · 0.95

Calls 1

prepare_tokensMethod · 0.95

Tested by

no test coverage detected