Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion test/test_functional_tensor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import unittest
import random
import colorsys
import math

from PIL import Image
from PIL.Image import NEAREST, BILINEAR, BICUBIC
Expand Down Expand Up @@ -114,7 +115,13 @@ def test_rgb2hsv(self):

colorsys_img = torch.tensor(hsv, dtype=torch.float32)

max_diff = (colorsys_img - ft_hsv_img).abs().max()
ft_hsv_img_h, ft_hsv_img_sv = torch.split(ft_hsv_img, [1, 2], dim=1)
colorsys_img_h, colorsys_img_sv = torch.split(colorsys_img, [1, 2], dim=1)

max_diff_h = ((colorsys_img_h * 2 * math.pi).sin() - (ft_hsv_img_h * 2 * math.pi).sin()).abs().max()
max_diff_sv = (colorsys_img_sv - ft_hsv_img_sv).abs().max()
max_diff = max(max_diff_h, max_diff_sv)

self.assertLess(max_diff, 1e-5)

def test_adjustments(self):
Expand Down