Args: windows: (num_windows*B, window_size, window_size, C) H (int): Height of image W (int): Width of image Returns: x: (B, H, W, C)
(self, windows, H, W)
| 251 | return x |
| 252 | |
| 253 | def window_reverse(self, windows, H, W): |
| 254 | """ |
| 255 | Args: |
| 256 | windows: (num_windows*B, window_size, window_size, C) |
| 257 | H (int): Height of image |
| 258 | W (int): Width of image |
| 259 | Returns: |
| 260 | x: (B, H, W, C) |
| 261 | """ |
| 262 | window_size = self.window_size |
| 263 | B = int(windows.shape[0] / (H * W / window_size / window_size)) |
| 264 | x = windows.view(B, H // window_size, W // window_size, window_size, |
| 265 | window_size, -1) |
| 266 | x = x.permute(0, 1, 3, 2, 4, 5).contiguous().view(B, H, W, -1) |
| 267 | return x |
| 268 | |
| 269 | def window_partition(self, x): |
| 270 | """ |