MCPcopy Create free account
hub / github.com/SooLab/CGFormer / window_reverse

Function window_reverse

model/backbone.py:48–62  ·  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

46
47
48def window_reverse(windows, window_size, H, W):
49 """
50 Args:
51 windows: (num_windows*B, window_size, window_size, C)
52 window_size (int): Window size
53 H (int): Height of image
54 W (int): Width of image
55
56 Returns:
57 x: (B, H, W, C)
58 """
59 B = int(windows.shape[0] / (H * W / window_size / window_size))
60 x = windows.view(B, H // window_size, W // window_size, window_size, window_size, -1)
61 x = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(B, H, W, -1)
62 return x
63
64
65class WindowAttention(nn.Module):

Callers 1

forwardMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected