From 6d890192673aba4f8f1b081e420afedc650f3fe6 Mon Sep 17 00:00:00 2001 From: matt3o Date: Sun, 1 Oct 2023 11:05:05 +0200 Subject: [PATCH] fixes weird issue of CAS and bicubic interpolation --- essentials.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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)