From 92394ab75107a5209bb5300d24fe8a861d59c846 Mon Sep 17 00:00:00 2001 From: dunkeroni Date: Sun, 18 Feb 2024 16:29:31 -0500 Subject: [PATCH] fix(nodes): canny preprocessor uses RGBA again --- .../app/invocations/controlnet_image_processors.py | 10 +++++++++- .../app/invocations/custom_nodes/InvokeAI_DemoFusion | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) create mode 160000 invokeai/app/invocations/custom_nodes/InvokeAI_DemoFusion diff --git a/invokeai/app/invocations/controlnet_image_processors.py b/invokeai/app/invocations/controlnet_image_processors.py index 1ef5352db6..797ea62f7c 100644 --- a/invokeai/app/invocations/controlnet_image_processors.py +++ b/invokeai/app/invocations/controlnet_image_processors.py @@ -143,8 +143,12 @@ class ImageProcessorInvocation(BaseInvocation, WithMetadata, WithBoard): # superclass just passes through image without processing return image + def load_image(self, context: InvocationContext) -> Image.Image: + # allows override for any special formatting specific to the preprocessor + return context.images.get_pil(self.image.image_name, "RGB") + def invoke(self, context: InvocationContext) -> ImageOutput: - raw_image = context.images.get_pil(self.image.image_name, "RGB") + raw_image = self.load_image(context) # image type should be PIL.PngImagePlugin.PngImageFile ? processed_image = self.run_processor(raw_image) @@ -181,6 +185,10 @@ class CannyImageProcessorInvocation(ImageProcessorInvocation): default=200, ge=0, le=255, description="The high threshold of the Canny pixel gradient (0-255)" ) + def load_image(self, context: InvocationContext) -> Image.Image: + # Keep alpha channel for Canny processing to detect edges of transparent areas + return context.images.get_pil(self.image.image_name, "RGBA") + def run_processor(self, image): canny_processor = CannyDetector() processed_image = canny_processor(image, self.low_threshold, self.high_threshold) diff --git a/invokeai/app/invocations/custom_nodes/InvokeAI_DemoFusion b/invokeai/app/invocations/custom_nodes/InvokeAI_DemoFusion new file mode 160000 index 0000000000..aae207914f --- /dev/null +++ b/invokeai/app/invocations/custom_nodes/InvokeAI_DemoFusion @@ -0,0 +1 @@ +Subproject commit aae207914f08f77324691ae984fae6dabb0b8976