From 821a0ef42735a0a97ab82be22a4fdc67c9cfc80e Mon Sep 17 00:00:00 2001 From: Mel Massadian Date: Sun, 7 Jul 2024 20:40:18 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20MaskToImage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit also remove style debug --- nodes/conditions.py | 2 +- nodes/image_processing.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/nodes/conditions.py b/nodes/conditions.py index af86d46..7a554ee 100644 --- a/nodes/conditions.py +++ b/nodes/conditions.py @@ -177,7 +177,7 @@ class MTB_StylesLoader: with open(file, encoding="utf8") as f: parsed = csv.reader(f) for i, row in enumerate(parsed): - log.debug(f"Adding style {row[0]}") + # log.debug(f"Adding style {row[0]}") try: name, positive, negative = (row + [None] * 3)[:3] positive = positive or "" diff --git a/nodes/image_processing.py b/nodes/image_processing.py index f7467cb..bcc3830 100644 --- a/nodes/image_processing.py +++ b/nodes/image_processing.py @@ -87,13 +87,13 @@ class MTB_ColorCorrect: @staticmethod def contrast_adjustment_tensor(image, contrast): r, g, b = image.unbind(-1) - + # Using Adobe RGB luminance weights. luminance_image = 0.33 * r + 0.71 * g + 0.06 * b luminance_mean = torch.mean(luminance_image.unsqueeze(-1)) # Blend original with mean luminance using contrast factor as blend ratio. - contrasted = image * contrast + (1.0 - contrast) * luminance_mean + contrasted = image * contrast + (1.0 - contrast) * luminance_mean return torch.clamp(contrasted, 0.0, 1.0) @staticmethod @@ -485,7 +485,7 @@ class MTB_MaskToImage: FUNCTION = "render_mask" def render_mask(self, mask, color, background): - masks = tensor2np(mask)[0] + masks = tensor2np(mask) images = [] for m in masks: _mask = Image.fromarray(m).convert("L") @@ -594,7 +594,7 @@ class MTB_ColoredImage: fg_images = tensor2pil(foreground_image) - for fg_image, fg_mask in zip(fg_images, fg_masks): + for fg_image, fg_mask in zip(fg_images, fg_masks, strict=False): # Resize and crop if dimensions mismatch if fg_image.size != image.size: fg_image = self.resize_and_crop(fg_image, image.size)