Skip to content

Commit 258bf73

Browse files
fix(nodes): handle zero fade size (e.g. mask blur 0)
Closes #7850
1 parent 7004fde commit 258bf73

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: invokeai/app/invocations/image.py

+6
Original file line numberDiff line numberDiff line change
@@ -1095,6 +1095,7 @@ class ExpandMaskWithFadeInvocation(BaseInvocation, WithMetadata, WithBoard):
10951095
"""Expands a mask with a fade effect. The mask uses black to indicate areas to keep from the generated image and white for areas to discard.
10961096
The mask is thresholded to create a binary mask, and then a distance transform is applied to create a fade effect.
10971097
The fade size is specified in pixels, and the mask is expanded by that amount. The result is a mask with a smooth transition from black to white.
1098+
If the fade size is 0, the mask is returned as-is.
10981099
"""
10991100

11001101
mask: ImageField = InputField(description="The mask to expand")
@@ -1104,6 +1105,11 @@ class ExpandMaskWithFadeInvocation(BaseInvocation, WithMetadata, WithBoard):
11041105
def invoke(self, context: InvocationContext) -> ImageOutput:
11051106
pil_mask = context.images.get_pil(self.mask.image_name, mode="L")
11061107

1108+
if self.fade_size_px == 0:
1109+
# If the fade size is 0, just return the mask as-is.
1110+
image_dto = context.images.save(image=pil_mask, image_category=ImageCategory.MASK)
1111+
return ImageOutput.build(image_dto)
1112+
11071113
np_mask = numpy.array(pil_mask)
11081114

11091115
# Threshold the mask to create a binary mask - 0 for black, 255 for white

0 commit comments

Comments
 (0)