From 87ee4aebb77a731442e41b595bc8b12a6fd263c3 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Wed, 17 Sep 2025 13:37:25 -0300 Subject: [PATCH] [Apply Mask][Added] Option to process images one by one --- README.md | 1 + src/nodes/nodes_img.py | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7c98c36..299e9e2 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,7 @@ Currently we just have a few nodes used by other nodes I maintain. - `blur_size_two` (`INT`): Diameter for the fine gaussian blur - `fill_color` (`BOOLEAN`): When enabled the removed image is replaced by a color, the output is an RGB image. Otherwise the removed part becomes transparent and the output is an RGBA image. - `color` (`STRING`): A string representing a color to be used when `fill_color` is enabled. Can be an hexadecimal RGB (i.e. `#AABBCC`) or comma separated RGB components. The components can be in the [0-255] or [0-1.0] range. + - `batched` (`BOOLEAN`): Process all the images at once. Otherwise do it one at a time. - **Output:** - `image` (`IMAGE`): The image after applying the mask. - `mask` (`MASK`): The input mask diff --git a/src/nodes/nodes_img.py b/src/nodes/nodes_img.py index bd2041d..b8879ea 100644 --- a/src/nodes/nodes_img.py +++ b/src/nodes/nodes_img.py @@ -412,8 +412,17 @@ class ApplyMaskAFFCE: "masks": ("MASK",), "blur_size": BLUR_SIZE_OPT, "blur_size_two": BLUR_SIZE_TWO_OPT, - "fill_color": ("BOOLEAN", {"default": False}), + "fill_color": ("BOOLEAN", { + "default": False, + "tooltip": ("Fill the background using a color.\n" + "Returns an RGB image, otherwise an RGBA.") + }), "color": COLOR_OPT, + "batched": ("BOOLEAN", { + "default": True, + "tooltip": ("Process the images at once.\n" + "Faster, needs more memory") + }), } } @@ -427,7 +436,7 @@ class ApplyMaskAFFCE: UNIQUE_NAME = "SET_ApplyMaskAFFCE" DISPLAY_NAME = "Apply Mask using AFFCE" - def get_foreground(self, images, masks, blur_size=91, blur_size_two=7, fill_color=False, color=None): + def get_foreground(self, images, masks, blur_size=91, blur_size_two=7, fill_color=False, color=None, batched=True): out_images = apply_mask(logger, images, masks, model_management.get_torch_device(), blur_size, blur_size_two, - fill_color, color) + fill_color, color, batched) return out_images.cpu(), masks.cpu()