From a448c61b245bfb7a898968172485e928e39c98fd Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Fri, 28 Mar 2025 06:15:24 +1000 Subject: [PATCH 1/2] fix(nodes): handle zero fade size (e.g. mask blur 0) Closes #7850 --- invokeai/app/invocations/image.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/invokeai/app/invocations/image.py b/invokeai/app/invocations/image.py index ea6069bd7a9..7fc92199540 100644 --- a/invokeai/app/invocations/image.py +++ b/invokeai/app/invocations/image.py @@ -1095,6 +1095,7 @@ class ExpandMaskWithFadeInvocation(BaseInvocation, WithMetadata, WithBoard): """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. The mask is thresholded to create a binary mask, and then a distance transform is applied to create a fade effect. 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. + If the fade size is 0, the mask is returned as-is. """ mask: ImageField = InputField(description="The mask to expand") @@ -1104,6 +1105,11 @@ class ExpandMaskWithFadeInvocation(BaseInvocation, WithMetadata, WithBoard): def invoke(self, context: InvocationContext) -> ImageOutput: pil_mask = context.images.get_pil(self.mask.image_name, mode="L") + if self.fade_size_px == 0: + # If the fade size is 0, just return the mask as-is. + image_dto = context.images.save(image=pil_mask, image_category=ImageCategory.MASK) + return ImageOutput.build(image_dto) + np_mask = numpy.array(pil_mask) # Threshold the mask to create a binary mask - 0 for black, 255 for white From cfa3ad34eb1a204a3b15cfec5e8d52fcc31f2a40 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Fri, 28 Mar 2025 06:35:36 +1000 Subject: [PATCH 2/2] chore(ui): typegen --- invokeai/frontend/web/src/services/api/schema.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/invokeai/frontend/web/src/services/api/schema.ts b/invokeai/frontend/web/src/services/api/schema.ts index dfd1f98b030..21da55167e3 100644 --- a/invokeai/frontend/web/src/services/api/schema.ts +++ b/invokeai/frontend/web/src/services/api/schema.ts @@ -6451,6 +6451,7 @@ export type components = { * @description 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. * The mask is thresholded to create a binary mask, and then a distance transform is applied to create a fade effect. * 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. + * If the fade size is 0, the mask is returned as-is. */ ExpandMaskWithFadeInvocation: { /**