Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

Set padding mode to zeros for inverse of resize aug via crop (#2054)

Miquel Martí750b34b1c7dd
diff --git a/kornia/augmentation/_2d/geometric/resize.py b/kornia/augmentation/_2d/geometric/resize.py
index ddc1f3986..eb6bb059c 100644
--- a/kornia/augmentation/_2d/geometric/resize.py
+++ b/kornia/augmentation/_2d/geometric/resize.py
@@ -85,7 +85,7 @@ class Resize(GeometricAugmentationBase2D):
raise TypeError(f'Expected the transform be a Tensor. Gotcha {type(transform)}')
return crop_by_transform_mat(
- input, transform[:, :2, :], size, flags["resample"], flags["padding_mode"], flags["align_corners"]
+ input, transform[:, :2, :], size, flags["resample"].name.lower(), "zeros", flags["align_corners"]
)
diff --git a/test/augmentation/test_augmentation.py b/test/augmentation/test_augmentation.py
index fce1e8e3b..c2c9ff844 100644
--- a/test/augmentation/test_augmentation.py
+++ b/test/augmentation/test_augmentation.py
@@ -3628,6 +3628,7 @@ class TestResize:
aug = Resize(size=(4, 5))
out = aug(img)
assert out.shape == (1, 1, 4, 5)
+ assert aug.inverse(out).shape == (1, 1, 4, 6)
class TestSmallestMaxSize: