Add mask_strength to ConditioningField.

This commit is contained in:
Ryan Dick 2024-02-20 11:05:30 -05:00
parent 43d5803927
commit 4efd0f7fa9
2 changed files with 10 additions and 1 deletions

View File

@ -24,10 +24,13 @@ class AddConditioningMaskInvocation(BaseInvocation):
"""Add a mask to an existing conditioning tensor."""
conditioning: ConditioningField = InputField(description="The conditioning tensor to add a mask to.")
image: ImageField = InputField(
mask: ImageField = InputField(
description="A mask image to add to the conditioning tensor. Only the first channel of the image is used. "
"Pixels <128 are excluded from the mask, pixels >=128 are included in the mask."
)
mask_strength: float = InputField(
description="The strength of the mask to apply to the conditioning tensor.", default=1.0
)
@staticmethod
def convert_image_to_mask(image: Image.Image) -> torch.Tensor:
@ -45,6 +48,7 @@ class AddConditioningMaskInvocation(BaseInvocation):
context.services.latents.save(mask_name, mask)
self.conditioning.mask_name = mask_name
self.conditioning.mask_strength = self.mask_strength
return ConditioningOutput(conditioning=self.conditioning)

View File

@ -433,6 +433,11 @@ class ConditioningField(BaseModel):
description="The mask associated with this conditioning tensor. Excluded regions should be set to 0, included "
"regions should be set to 1.",
)
mask_strength: float = Field(
default=1.0,
description="The strength of the mask. Only has an effect if mask_name is set. The strength is relative to "
"other masks. The default is 1.0. If set to 0.0, this mask will be ignored.",
)
@invocation_output("conditioning_output")