π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
#2348 Fix bug in ycbcr_to_rgb function (#2610)
Yulia Maksymiukce89d4104dc7
diff --git a/kornia/color/ycbcr.py b/kornia/color/ycbcr.pyindex 4e9fe5d85..c0cb597de 100644--- a/kornia/color/ycbcr.py+++ b/kornia/color/ycbcr.py@@ -98,7 +98,7 @@ def ycbcr_to_rgb(image: Tensor) -> Tensor:r: Tensor = y + 1.403 * cr_shiftedg: Tensor = y - 0.714 * cr_shifted - 0.344 * cb_shiftedb: Tensor = y + 1.773 * cb_shifted- return torch.stack([r, g, b], -3)+ return torch.stack([r, g, b], -3).clamp(0, 1)class RgbToYcbcr(nn.Module):diff --git a/test/color/test_ycbcr.py b/test/color/test_ycbcr.pyindex db513014f..c29199829 100644--- a/test/color/test_ycbcr.py+++ b/test/color/test_ycbcr.py@@ -185,25 +185,25 @@ class TestYcbcrToRgb(BaseTester):[[[- [1.3226931, 0.5639256, 0.14902398, 1.0217545, 0.2569923],- [0.37973762, 0.64386904, 1.1992811, -0.603531, 0.4239992],- [1.0080798, 1.3131194, -0.1370286, 0.60653293, 0.3505922],- [-0.4573757, 0.6076593, 0.33508536, 0.27470887, 1.2284023],- [0.52727354, -0.1673561, 0.05404532, 1.2725366, 0.5783674],+ [1.0000, 0.5639256, 0.14902398, 1.0000, 0.2569923],+ [0.37973762, 0.64386904, 1.0000, 0.0000, 0.4239992],+ [1.0000, 1.0000, 0.0000, 0.60653293, 0.3505922],+ [0.0000, 0.6076593, 0.33508536, 0.27470887, 1.0000],+ [0.52727354, 0.0000, 0.05404532, 1.0000, 0.5783674],],[- [0.736647, -0.01305042, 0.55139434, 0.44206098, 0.4548782],- [-0.22063601, 0.98196536, 0.54739904, 0.33826917, 0.850068],- [0.72412336, 0.6222996, 0.110618, 1.0039049, 0.614918],+ [0.736647, 0.0000, 0.55139434, 0.44206098, 0.4548782],+ [0.0000, 0.98196536, 0.54739904, 0.33826917, 0.850068],+ [0.72412336, 0.6222996, 0.110618, 1.0000, 0.614918],[0.15862459, 0.0699634, 0.66296846, 0.4845066, 0.3705502],- [1.0145653, 0.46070462, 0.5654058, 0.24897486, -0.11174999],+ [1.0000, 0.46070462, 0.5654058, 0.24897486, 0.0000],],[- [1.4161384, 0.88769174, 0.4394987, -0.31889397, -0.5671302],- [0.77483994, 0.99839956, 1.6813064, 0.41622213, 1.3508832],- [0.7488585, -0.04955059, 0.01748962, 0.9683316, 0.49795526],- [0.9473541, 1.2473994, -0.3918787, 0.47037587, 1.2893858],- [1.4082898, -0.21875012, 0.6804801, 0.9795798, 0.24646705],+ [1.0000, 0.88769174, 0.4394987, 0.0000, 0.0000],+ [0.77483994, 0.99839956, 1.0000, 0.41622213, 1.0000],+ [0.7488585, 0.0000, 0.01748962, 0.9683316, 0.49795526],+ [0.9473541, 1.0000, 0.0000, 0.47037587, 1.0000],+ [1.0000, 0.0000, 0.6804801, 0.9795798, 0.24646705],],]],diff --git a/test/geometry/camera/test_pinhole.py b/test/geometry/camera/test_pinhole.pyindex da890cc8e..54b111ce8 100644--- a/test/geometry/camera/test_pinhole.py+++ b/test/geometry/camera/test_pinhole.py@@ -198,6 +198,7 @@ class TestPixel2Cam:assert_close(pixel_coords_concat, pixel_coords_input, atol=1e-4, rtol=1e-4)@pytest.mark.parametrize("batch_size", (1,))+ @pytest.mark.slowdef test_gradcheck(self, batch_size, device, dtype):H, W = 10, 20fx, fy = W, Hdiff --git a/test/nerf/test_nerf_solver.py b/test/nerf/test_nerf_solver.pyindex bf856d2dd..bdcaba8f2 100755--- a/test/nerf/test_nerf_solver.py+++ b/test/nerf/test_nerf_solver.py@@ -26,6 +26,7 @@ class TestNerfSolver:for param_before_update, param_after_update in zip(params_before_update, params_after_update))+ @pytest.mark.slowdef test_only_red_uniform_sampling(self, device, dtype):torch.manual_seed(1) # For reproducibility of random processescamera = create_one_camera(5, 9, device, dtype)