MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / forward

Method forward

PATH/core/models/backbones/vit.py:510–534  ·  view source on GitHub ↗
(self, input_var)

Source from the content-addressed store, hash-verified

508 return x.permute(0, 2, 1).reshape(B, -1, Hp, Wp)
509
510 def forward(self, input_var):
511 output = {}
512 x = input_var['image']
513
514 # pre_input padding for test support
515 x = self._normalization(x)
516
517 if not self.proj_padding:
518 stride = 32
519 output["prepad_input_size"] = [x.shape[-2], x.shape[-1]] # h, w for sem_seg_postprocess
520 target_size = (torch.tensor((x.shape[-1], x.shape[-2])) + (stride - 1)).div(stride, rounding_mode="floor") * stride # w, h
521 padding_size = [ # [l,r,t,b]
522 0,
523 target_size[0] - x.shape[-1],
524 0,
525 target_size[1] - x.shape[-2],
526 ]
527 x = F.pad(x, padding_size, value=0.).contiguous()
528 output["image"] = x
529
530 # pre_input padding for test support >>> end
531
532 output['backbone_output'] = self.forward_features(x)
533 input_var.update(output)
534 return input_var
535
536
537def vit_aligned_base_patch16(pretrained=False, load_pos_embed=True, **kwargs):

Callers

nothing calls this directly

Calls 3

_normalizationMethod · 0.95
forward_featuresMethod · 0.95
updateMethod · 0.45

Tested by

no test coverage detected