diff --git a/essentials.py b/essentials.py index e0c2bc2..ffa34ed 100644 --- a/essentials.py +++ b/essentials.py @@ -296,13 +296,13 @@ def min_(tensor_list): # return the element-wise min of the tensor list. x = torch.stack(tensor_list) mn = x.min(axis=0)[0] - return mn + return torch.clamp(mn, min=0) def max_(tensor_list): # return the element-wise max of the tensor list. x = torch.stack(tensor_list) mx = x.max(axis=0)[0] - return mx + return torch.clamp(mx, max=1) # From https://github.com/Jamy-L/Pytorch-Contrast-Adaptive-Sharpening/ class ImageCAS: @@ -354,7 +354,7 @@ class ImageCAS: output = ((b + d + f + h)*w + e) * div output = output.clamp(0, 1) - #output = torch.nan_to_num(output) # what am I doing?! + #output = torch.nan_to_num(output) # this seems the only way to ensure there are no NaNs output = pb(output)