Add a ThresholdMask node.
This commit is contained in:
parent
0db3111b5f
commit
b2e1744a16
|
@ -341,6 +341,24 @@ class GrowMask:
|
||||||
out.append(output)
|
out.append(output)
|
||||||
return (torch.stack(out, dim=0),)
|
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 = {
|
NODE_CLASS_MAPPINGS = {
|
||||||
|
@ -355,6 +373,7 @@ NODE_CLASS_MAPPINGS = {
|
||||||
"MaskComposite": MaskComposite,
|
"MaskComposite": MaskComposite,
|
||||||
"FeatherMask": FeatherMask,
|
"FeatherMask": FeatherMask,
|
||||||
"GrowMask": GrowMask,
|
"GrowMask": GrowMask,
|
||||||
|
"ThresholdMask": ThresholdMask,
|
||||||
}
|
}
|
||||||
|
|
||||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||||
|
|
Loading…
Reference in New Issue