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

Function window_reverse

PATH/core/models/backbones/vit.py:115–128  ·  view source on GitHub ↗

Args: windows: (num_windows*B, window_size, window_size, C) window_size (int): Window size H (int): Height of image W (int): Width of image Returns: x: (B, H, W, C)

(windows, window_size, H, W)

Source from the content-addressed store, hash-verified

113
114
115def window_reverse(windows, window_size, H, W):
116 """
117 Args:
118 windows: (num_windows*B, window_size, window_size, C)
119 window_size (int): Window size
120 H (int): Height of image
121 W (int): Width of image
122 Returns:
123 x: (B, H, W, C)
124 """
125 B = int(windows.shape[0] / (H * W / window_size / window_size))
126 x = windows.view(B, H // window_size, W // window_size, window_size, window_size, -1)
127 x = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(B, H, W, -1)
128 return x
129
130
131def calc_rel_pos_spatial(

Callers 1

forwardMethod · 0.70

Calls 1

permuteMethod · 0.80

Tested by

no test coverage detected