π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
Fix AugmentationSequential support for RandomResizedCrop (#2398)
Adam J. Stewartcc881dd9a3a6
diff --git a/kornia/augmentation/container/augment.py b/kornia/augmentation/container/augment.pyindex 8f6cab987..6dd8b18b1 100644--- a/kornia/augmentation/container/augment.py+++ b/kornia/augmentation/container/augment.py@@ -159,7 +159,7 @@ class AugmentationSequential(ImageSequential):random_apply: Union[int, bool, Tuple[int, int]] = False,random_apply_weights: Optional[List[float]] = None,transformation_matrix: str = "silence",- extra_args: Dict[DataKey, Dict[str, Any]] = {DataKey.MASK: dict(resample=Resample.NEAREST, align_corners=True)},+ extra_args: Dict[DataKey, Dict[str, Any]] = {DataKey.MASK: dict(resample=Resample.NEAREST, align_corners=None)},) -> None:super().__init__(*args,diff --git a/test/augmentation/test_container.py b/test/augmentation/test_container.pyindex 7661223a3..23c8df93f 100644--- a/test/augmentation/test_container.py+++ b/test/augmentation/test_container.py@@ -450,6 +450,18 @@ class TestAugmentationSequential:assert out_inv[3].shape == points.shapeassert_close(out_inv[3], points, atol=1e-4, rtol=1e-4)+ def test_random_resized_crop(self, device, dtype):+ size = 50+ input = torch.randn(3, 3, 100, 100, device=device, dtype=dtype)+ mask = torch.randn(3, 1, 100, 100, device=device, dtype=dtype)+ aug = K.AugmentationSequential(K.RandomResizedCrop((size, size), p=1.0), data_keys=["input", "mask"])++ reproducibility_test((input, mask), aug)++ out = aug(input, mask)+ assert out[0].shape == (3, 3, size, size)+ assert out[1].shape == (3, 1, size, size)+@pytest.mark.parametrize('bbox',[