MCPcopy Create free account
hub / github.com/UX-Decoder/Semantic-SAM / forward

Method forward

semantic_sam/backbone/focal.py:566–590  ·  view source on GitHub ↗

Forward function.

(self, x)

Source from the content-addressed store, hash-verified

564
565
566 def forward(self, x):
567 """Forward function."""
568 tic = time.time()
569 x = self.patch_embed(x)
570 Wh, Ww = x.size(2), x.size(3)
571
572 x = x.flatten(2).transpose(1, 2)
573 x = self.pos_drop(x)
574
575 outs = {}
576 for i in range(self.num_layers):
577 layer = self.layers[i]
578 x_out, H, W, x, Wh, Ww = layer(x, Wh, Ww)
579 if i in self.out_indices:
580 norm_layer = getattr(self, f'norm{i}')
581 x_out = norm_layer(x_out)
582
583 out = x_out.view(-1, H, W, self.num_features[i]).permute(0, 3, 1, 2).contiguous()
584 outs["res{}".format(i + 2)] = out
585
586 if len(self.out_indices) == 0:
587 outs["res5"] = x_out.view(-1, H, W, self.num_features[i]).permute(0, 3, 1, 2).contiguous()
588
589 toc = time.time()
590 return outs
591
592 def train(self, mode=True):
593 """Convert the model into training mode while keep layers freezed."""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected