π Geometric Computer Vision Library for Spatial AI
Python artificial-intelligencecomputer-visiondeep-learninghacktoberfestimage-processingmachine-learningneural-networkpythonpytorchroboticsspatial-ai
added tensor device conversion for solarize params (#624)
Manu Halvagal420b6571958f
diff --git a/kornia/enhance/adjust.py b/kornia/enhance/adjust.pyindex 767383ab5..8be6d56f7 100644--- a/kornia/enhance/adjust.py+++ b/kornia/enhance/adjust.py@@ -249,6 +249,7 @@ def _solarize(input: torch.Tensor, thresholds: Union[float, torch.Tensor] = 0.5)assert input.size(0) == len(thresholds) and len(thresholds.shape) == 1, \f"threshholds must be a 1-d vector of shape ({input.size(0)},). Got {thresholds}"# TODO: I am not happy about this line, but no easy to do batch-wise operation+ thresholds = thresholds.to(input.device).to(input.dtype)thresholds = torch.stack([x.expand(*input.shape[1:]) for x in thresholds])return torch.where(input < thresholds, input, 1.0 - input)@@ -295,8 +296,8 @@ def solarize(input: torch.Tensor, thresholds: Union[float, torch.Tensor] = 0.5,assert input.size(0) == len(additions) and len(additions.shape) == 1, \f"additions must be a 1-d vector of shape ({input.size(0)},). Got {additions}"# TODO: I am not happy about this line, but no easy to do batch-wise operation+ additions = additions.to(input.device).to(input.dtype)additions = torch.stack([x.expand(*input.shape[1:]) for x in additions])-input = input + additionsinput = input.clamp(0., 1.)