Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Add a ThresholdMask node.

comfyanonymousb2e1744a164e
diff --git a/comfy_extras/nodes_mask.py b/comfy_extras/nodes_mask.py
index a7d164bf7..29589b4ab 100644
--- a/comfy_extras/nodes_mask.py
+++ b/comfy_extras/nodes_mask.py
@@ -341,6 +341,24 @@ class GrowMask:
out.append(output)
return (torch.stack(out, dim=0),)
+class ThresholdMask:
+ @classmethod
+ def INPUT_TYPES(s):
+ return {
+ "required": {
+ "mask": ("MASK",),
+ "value": ("FLOAT", {"default": 0.5, "min": 0.0, "max": 1.0, "step": 0.01}),
+ }
+ }
+
+ CATEGORY = "mask"
+
+ RETURN_TYPES = ("MASK",)
+ FUNCTION = "image_to_mask"
+
+ def image_to_mask(self, mask, value):
+ mask = (mask > value).float()
+ return (mask,)
NODE_CLASS_MAPPINGS = {
@@ -355,6 +373,7 @@ NODE_CLASS_MAPPINGS = {
"MaskComposite": MaskComposite,
"FeatherMask": FeatherMask,
"GrowMask": GrowMask,
+ "ThresholdMask": ThresholdMask,
}
NODE_DISPLAY_NAME_MAPPINGS = {