Fix Pixel Sort Default + Add Divide

This commit is contained in:
EllangoK
2024-08-09 13:11:03 -04:00
parent 522817d3d3
commit 049eb2b4f3
3 changed files with 16 additions and 4 deletions
+7 -1
View File
@@ -10,7 +10,7 @@ class ArithmeticBlend:
"required": {
"image1": ("IMAGE",),
"image2": ("IMAGE",),
"blend_mode": (["add", "subtract", "difference"],),
"blend_mode": (["add", "subtract", "difference", "divide"],),
},
}
@@ -26,6 +26,8 @@ class ArithmeticBlend:
blended_image = self.subtract(image1, image2)
elif blend_mode == "difference":
blended_image = self.difference(image1, image2)
elif blend_mode == "divide":
blended_image = self.divide(image1, image2)
else:
raise ValueError(f"Unsupported arithmetic blend mode: {blend_mode}")
@@ -41,6 +43,10 @@ class ArithmeticBlend:
def difference(self, img1, img2):
return torch.abs(img1 - img2)
def divide(self, img1, img2):
img2_safe = torch.where(img1 == 0, torch.tensor(1e-10), img1)
return img1 / img2_safe
NODE_CLASS_MAPPINGS = {
"ArithmeticBlend": ArithmeticBlend,
}