π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
fix shift_rgb stack dimension (#1930)
Nathanfb52c207a3f9
diff --git a/kornia/enhance/shift_rgb.py b/kornia/enhance/shift_rgb.pyindex e68b84385..e6088af3f 100644--- a/kornia/enhance/shift_rgb.py+++ b/kornia/enhance/shift_rgb.py@@ -14,6 +14,6 @@ def shift_rgb(image: torch.Tensor, r_shift: torch.Tensor, g_shift: torch.Tensor,shifts = [r_shift, g_shift, b_shift]- shifted = (image + torch.stack(shifts).view(-1, 3, 1, 1).to(image)).clamp_(min=0, max=1)+ shifted = (image + torch.stack(shifts, dim=1).view(-1, 3, 1, 1).to(image)).clamp_(min=0, max=1)return shifteddiff --git a/test/augmentation/test_augmentation.py b/test/augmentation/test_augmentation.pyindex 1a172a314..1f0dea41a 100644--- a/test/augmentation/test_augmentation.py+++ b/test/augmentation/test_augmentation.py@@ -3487,8 +3487,8 @@ class TestRandomRGBShift:f = RandomRGBShift(p=1.0).to(device)expected = torch.tensor([- [[[0.19625, 0.00000]], [[0.56822, 0.76822]], [[0.00000, 0.28847]]],- [[[0.00000, 0.33203]], [[0.00000, 0.60742]], [[0.33407, 0.43407]]],+ [[[0.19626, 0.00000]], [[0.00000, 0.08848]], [[0.20742, 0.50742]]],+ [[[0.46822, 0.96822]], [[0.00000, 0.43203]], [[0.33408, 0.43408]]],],device=device,dtype=dtype,@@ -3506,8 +3506,8 @@ class TestRandomRGBShift:f = RandomRGBShift(p=1.0, same_on_batch=True).to(device)expected = torch.tensor([- [[[0.19626, 0.00000]], [[0.29626, 0.49626]], [[0.66822, 0.96822]]],- [[[0.46822, 0.96822]], [[0.00000, 0.38848]], [[0.00000, 0.00000]]],+ [[[0.19626, 0.00000]], [[0.56822, 0.76822]], [[0.00000, 0.28848]]],+ [[[0.19626, 0.69626]], [[0.26822, 1.00000]], [[0.00000, 0.00000]]],],device=device,dtype=dtype,