handle NaNs better

This commit is contained in:
matt3o
2023-09-24 19:38:10 +02:00
parent 64b753ef29
commit f3bdd88f3d
2 changed files with 5 additions and 3 deletions
+1 -1
View File
@@ -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)
+4 -2
View File
@@ -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)