Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

Working tests

Pau87556583e6cc
diff --git a/kornia/color/adjust.py b/kornia/color/adjust.py
index e8406a5be..b2e3aed4b 100644
--- a/kornia/color/adjust.py
+++ b/kornia/color/adjust.py
@@ -80,7 +80,7 @@ def adjust_hue(input: torch.Tensor, hue_factor: Union[float, torch.Tensor]) -> t
h, s, v = torch.chunk(x_hsv, chunks=3, dim=-3)
# transform the hue value and appl module
- divisor: float = 2*pi.item()
+ divisor: float = 2 * pi.item()
h_out: torch.Tensor = torch.fmod(h + hue_factor, divisor)
# pack back back the corrected hue
diff --git a/test/color/test_adjust.py b/test/color/test_adjust.py
index 6d62b75f3..2cf9845ce 100644
--- a/test/color/test_adjust.py
+++ b/test/color/test_adjust.py
@@ -50,11 +50,12 @@ class TestAdjustSaturation:
def test_gradcheck(self):
batch_size, channels, height, width = 2, 3, 4, 5
- img = torch.ones(batch_size, channels, height, width)
+ img = torch.rand(batch_size, channels, height, width)
img = utils.tensor_to_gradcheck_var(img) # to var
assert gradcheck(kornia.adjust_saturation, (img, 2.),
raise_exception=True)
+
class TestAdjustHue:
def test_hue_one(self):
data = torch.tensor([[[.5, .5],
@@ -118,11 +119,12 @@ class TestAdjustHue:
def test_gradcheck(self):
batch_size, channels, height, width = 2, 3, 4, 5
- img = torch.ones(batch_size, channels, height, width)
+ img = torch.rand(batch_size, channels, height, width)
img = utils.tensor_to_gradcheck_var(img) # to var
assert gradcheck(kornia.adjust_hue, (img, 2.),
raise_exception=True)
+
class TestAdjustGamma:
def test_gamma_zero(self):
data = torch.tensor([[[1., 1.],
diff --git a/test/color/test_hls.py b/test/color/test_hls.py
index bbc89cb4c..37fe07667 100644
--- a/test/color/test_hls.py
+++ b/test/color/test_hls.py
@@ -54,15 +54,15 @@ class TestRgbToHls:
# Kornia
f = kornia.color.RgbToHls()
- data = data.repeat(2, 1, 1, 1) # 2x3x2x2
+ data = data.repeat(2, 1, 1, 1) # 2x3x5x5
expected = np.expand_dims(expected, 0)
- expected = expected.repeat(2, 0) # 2x3x2x2
+ expected = expected.repeat(2, 0) # 2x3x5x5
assert_allclose(f(data), expected)
def test_gradcheck(self):
- data = torch.rand(3,5,5) # 3x2x2
+ data = torch.rand(3, 5, 5) # 3x5x5
data = utils.tensor_to_gradcheck_var(data) # to var
@@ -119,7 +119,7 @@ class TestHlsToRgb:
def test_batch_hls_to_rgb(self):
- data = torch.rand(3, 5, 5)
+ data = torch.rand(3, 5, 5) # 3x5x5
# OpenCV
data_cv = data.numpy().transpose(1, 2, 0).copy()
@@ -132,7 +132,7 @@ class TestHlsToRgb:
f = kornia.color.HlsToRgb()
data[0] = 2 * pi * data[0]
- data = data.repeat(2, 1, 1, 1) # 2x3x2x2
+ data = data.repeat(2, 1, 1, 1) # 2x3x5x5
expected = np.expand_dims(expected, 0)
expected = expected.repeat(2, 0) # 2x3x2x2
@@ -147,7 +147,7 @@ class TestHlsToRgb:
def test_gradcheck(self):
- data = torch.rand(3,5,5) # 3x2x2
+ data = torch.rand(3, 5, 5) # 3x5x5
data[0] = 2 * pi * data[0]
data = utils.tensor_to_gradcheck_var(data) # to var
diff --git a/test/color/test_hsv.py b/test/color/test_hsv.py
index a2c834c49..0aa0a9caf 100644
--- a/test/color/test_hsv.py
+++ b/test/color/test_hsv.py
@@ -42,7 +42,7 @@ class TestRgbToHsv:
def test_batch_rgb_to_hls(self):
- data = torch.rand(3, 5, 5)
+ data = torch.rand(3, 5, 5) # 3x5x5
# OpenCV
data_cv = data.numpy().transpose(1, 2, 0).copy()
@@ -54,16 +54,16 @@ class TestRgbToHsv:
# Kornia
f = kornia.color.RgbToHsv()
- data = data.repeat(2, 1, 1, 1) # 2x3x2x2
+ data = data.repeat(2, 1, 1, 1) # 2x3x5x5
expected = np.expand_dims(expected, 0)
- expected = expected.repeat(2, 0) # 2x3x2x2
+ expected = expected.repeat(2, 0) # 2x3x5x5
assert_allclose(f(data), expected)
def test_gradcheck(self):
- data = torch.rand(3,5,5) # 3x2x2
+ data = torch.rand(3, 5, 5) # 3x2x2
data = utils.tensor_to_gradcheck_var(data) # to var
@@ -94,7 +94,7 @@ class TestHsvToRgb:
def test_hsv_to_rgb(self):
- data = torch.rand(3, 5, 5)
+ data = torch.rand(3, 5, 5) # 3x5x5
# OpenCV
data_cv = data.numpy().transpose(1, 2, 0).copy()
@@ -120,7 +120,7 @@ class TestHsvToRgb:
def test_batch_hsv_to_rgb(self):
- data = torch.rand(3, 5, 5)
+ data = torch.rand(3, 5, 5) # 3x5x5
# OpenCV
data_cv = data.numpy().transpose(1, 2, 0).copy()
@@ -133,10 +133,10 @@ class TestHsvToRgb:
f = kornia.color.HsvToRgb()
data[0] = 2 * pi * data[0]
- data = data.repeat(2, 1, 1, 1) # 2x3x2x2
+ data = data.repeat(2, 1, 1, 1) # 2x3x5x5
expected = np.expand_dims(expected, 0)
- expected = expected.repeat(2, 0) # 2x3x2x2
+ expected = expected.repeat(2, 0) # 2x3x5x5
assert_allclose(f(data), expected)
@@ -148,7 +148,7 @@ class TestHsvToRgb:
def test_gradcheck(self):
- data = torch.rand(3,5,5) # 3x2x2
+ data = torch.rand(3, 5, 5) # 3x5x5
data[0] = 2 * pi * data[0]
data = utils.tensor_to_gradcheck_var(data) # to var