π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
fixed rgb_to_hsv gradcheck
diegovd029678b0a985eb7b
diff --git a/torchgeometry/image/color.py b/torchgeometry/image/color.pyindex 2271932e1..4cb0cca2d 100644--- a/torchgeometry/image/color.py+++ b/torchgeometry/image/color.py@@ -46,7 +46,6 @@ def rgb_to_hsv(image):raise ValueError("Input size must have a shape of (*, 3, H, W). Got {}".format(image.shape))- torch.autograd.set_detect_anomaly(True)r = image[..., 0, :, :]g = image[..., 1, :, :]b = image[..., 2, :, :]@@ -57,9 +56,11 @@ def rgb_to_hsv(image):v = maxc # brightnessdeltac = maxc - minc- s = deltac.clone() / v # saturation+ s = deltac / v # saturation++ # avoid division by zero+ deltac = torch.where(deltac == 0, torch.ones_like(deltac), deltac)- deltac[deltac == 0] = 1 # avoid division by zerorc = (maxc - r) / deltacgc = (maxc - g) / deltacbc = (maxc - b) / deltac