Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

1.4 update

dvd427925851bc67d
diff --git a/kornia/feature/laf.py b/kornia/feature/laf.py
index cdef371a1..e2397ebb2 100644
--- a/kornia/feature/laf.py
+++ b/kornia/feature/laf.py
@@ -376,8 +376,8 @@ def generate_patch_grid_from_normalized_LAF(img: torch.Tensor,
# and extraction at arbitrary other
LAF_renorm = denormalize_laf(LAF, img)
- grid = F.affine_grid(LAF_renorm.view(B * N, 2, 3),
- [B * N, ch, PS, PS])
+ grid = F.affine_grid(LAF_renorm.view(B * N, 2, 3), # type: ignore
+ [B * N, ch, PS, PS], align_corners=True)
grid[..., :, 0] = 2.0 * grid[..., :, 0].clone() / float(w) - 1.0
grid[..., :, 1] = 2.0 * grid[..., :, 1].clone() / float(h) - 1.0
return grid
@@ -410,7 +410,8 @@ def extract_patches_simple(img: torch.Tensor,
# for loop temporarily, to be refactored
for i in range(B):
grid = generate_patch_grid_from_normalized_LAF(img[i:i + 1], nlaf[i:i + 1], PS).to(img.device)
- out.append(F.grid_sample(img[i:i + 1].expand(grid.size(0), ch, h, w), grid, padding_mode="border"))
+ out.append(F.grid_sample(img[i:i + 1].expand(grid.size(0), ch, h, w), grid, # type: ignore
+ padding_mode="border", align_corners=True))
return torch.cat(out, dim=0).view(B, N, ch, PS, PS)
@@ -454,7 +455,8 @@ def extract_patches_from_pyramid(img: torch.Tensor,
cur_img[i:i + 1],
nlaf[i:i + 1, scale_mask, :, :],
PS)
- patches = F.grid_sample(cur_img[i:i + 1].expand(grid.size(0), ch, h, w), grid, padding_mode="border")
+ patches = F.grid_sample(cur_img[i:i + 1].expand(grid.size(0), ch, h, w), grid, # type: ignore
+ padding_mode="border", align_corners=True)
out[i].masked_scatter_(scale_mask.view(-1, 1, 1, 1), patches)
cur_img = kornia.pyrdown(cur_img)
cur_pyr_level += 1
diff --git a/kornia/geometry/transform/affwarp.py b/kornia/geometry/transform/affwarp.py
index 5f4ed2177..42aa32188 100644
--- a/kornia/geometry/transform/affwarp.py
+++ b/kornia/geometry/transform/affwarp.py
@@ -240,7 +240,7 @@ def resize(input: torch.Tensor, size: Union[int, Tuple[int, int]], interpolation
else:
new_size = size
- return torch.nn.functional.interpolate(input, size=new_size, mode=interpolation)
+ return torch.nn.functional.interpolate(input, size=new_size, mode=interpolation, align_corners=True)
class Resize(nn.Module):
diff --git a/kornia/geometry/transform/pyramid.py b/kornia/geometry/transform/pyramid.py
index 7f4641088..2366a21e0 100644
--- a/kornia/geometry/transform/pyramid.py
+++ b/kornia/geometry/transform/pyramid.py
@@ -65,7 +65,8 @@ class PyrDown(nn.Module):
x_blur: torch.Tensor = filter2D(input, self.kernel, self.border_type)
# downsample.
- out: torch.Tensor = F.interpolate(x_blur, scale_factor=0.5, mode='bilinear', align_corners=False)
+ out: torch.Tensor = F.interpolate(x_blur, scale_factor=0.5, mode='bilinear',
+ align_corners=False) # type: ignore
return out