diff --git a/README.md b/README.md index fbe6616..50261a9 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Essential nodes that are weirdly missing from ComfyUI core. With few exceptions - Image Flip - Image Desaturate - Image Posterize -- Image Contrast Adaptive Sharpening +- Image Contrast Adaptive Sharpening ([credits](https://github.com/Jamy-L/Pytorch-Contrast-Adaptive-Sharpening)) - Mask Blur - Mask Flip - Mask Grow / Shrink (same as Mask grow but adds shrink) diff --git a/essentials.py b/essentials.py index 12da82f..6a94138 100644 --- a/essentials.py +++ b/essentials.py @@ -39,6 +39,8 @@ class AnyType(str): return False any = AnyType("*") +EPSILON = 1e-7 + class GetImageSize: @classmethod def INPUT_TYPES(s): @@ -366,7 +368,7 @@ class ImageCAS: mn = mn + mn2 # Computing local weight - inv_mx = torch.reciprocal(mx) + inv_mx = torch.reciprocal(mx + EPSILON) amp = inv_mx * torch.minimum(mn, (2 - mx)) # scaling @@ -376,7 +378,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) # what am I doing?! output = pb(output)