Merge pull request #2285 from huggingface/fix_swin_pad

Fix reversed H & W padding for swin patch merging
This commit is contained in:
Ross Wightman 2024-09-21 17:00:49 -07:00 committed by GitHub
commit 93374637c6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 3 deletions

View File

@ -435,7 +435,7 @@ class PatchMerging(nn.Module):
def forward(self, x):
B, H, W, C = x.shape
pad_values = (0, 0, 0, H % 2, 0, W % 2)
pad_values = (0, 0, 0, W % 2, 0, H % 2)
x = nn.functional.pad(x, pad_values)
_, H, W, _ = x.shape

View File

@ -439,7 +439,7 @@ class PatchMerging(nn.Module):
def forward(self, x: torch.Tensor) -> torch.Tensor:
B, H, W, C = x.shape
pad_values = (0, 0, 0, H % 2, 0, W % 2)
pad_values = (0, 0, 0, W % 2, 0, H % 2)
x = nn.functional.pad(x, pad_values)
_, H, W, _ = x.shape

View File

@ -445,7 +445,7 @@ class PatchMerging(nn.Module):
"""
B, H, W, C = x.shape
pad_values = (0, 0, 0, H % 2, 0, W % 2)
pad_values = (0, 0, 0, W % 2, 0, H % 2)
x = nn.functional.pad(x, pad_values)
_, H, W, _ = x.shape